forked from kubernetes-sigs/cluster-api-provider-aws
-
Notifications
You must be signed in to change notification settings - Fork 1
🌱 feat: adds new nodeadm bootstrap type #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
c38276b
ci: adds unit tests
faiq 641b157
Merge pull request #2 from nutanix-cloud-native/faiq/unit-tests-on-pr
faiq 97049ce
feat: starts bootstrapping new type with kubebuilder
faiq 7e42d77
feat: adds fields to nodeadm config
faiq 7e108ee
refactor: use a common file resolver so nodeadmconfig can use it
faiq af310a2
feat: implements nodeadm config controller
faiq 3961c8b
fix: api type issues from copy paste mistakes
faiq 955a172
test: adds reconciler tests for nodeadm
faiq c51c989
fix: runs golangci-lint
faiq 2f2e34d
fix: boundries in userdata
faiq 66a5d18
fix: kubelet logic
faiq 59fbdbc
fix: adds nodeadmconfigtemplate crd
faiq 4e1fa66
fix: nodeadm kubelet config
faiq a961548
fix: handle runtime.Rawextension properly
faiq 3b4537a
e2e: adds test for nodeadm
faiq 4f4db0c
chore: fixes up tests to no longer require TEST_ENV variable
faiq f6d79e2
fix: we don't need to set eks specific labels
faiq 3537aa5
fix: removes local store options which isn't supported by capa
faiq c434fec
fix: use prenodeadm commands name
faiq File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| package controllers | ||
|
|
||
| import ( | ||
| "context" | ||
|
|
||
| "github.com/pkg/errors" | ||
| corev1 "k8s.io/api/core/v1" | ||
| "k8s.io/apimachinery/pkg/api/errors" | ||
| apierrors "k8s.io/apimachinery/pkg/api/errors" | ||
| "k8s.io/apimachinery/pkg/types" | ||
| "sigs.k8s.io/controller-runtime/pkg/client" | ||
|
|
||
| eksbootstrapv1 "sigs.k8s.io/cluster-api-provider-aws/bootstrap/eks/api/v1beta2" | ||
| ) | ||
|
|
||
| // FileResolver provides methods to resolve files and their content from secrets. | ||
| type FileResolver struct { | ||
| Client client.Reader | ||
| } | ||
|
|
||
| // ResolveFiles resolves the content of files, fetching data from referenced secrets if needed. | ||
| func (fr *FileResolver) ResolveFiles(ctx context.Context, namespace string, files []eksbootstrapv1.File) ([]eksbootstrapv1.File, error) { | ||
| collected := make([]eksbootstrapv1.File, 0, len(files)) | ||
|
|
||
| for i := range files { | ||
| in := files[i] | ||
| if in.ContentFrom != nil { | ||
| data, err := fr.ResolveSecretFileContent(ctx, namespace, in) | ||
| if err != nil { | ||
| return nil, errors.Wrapf(err, "failed to resolve file source") | ||
| } | ||
| in.ContentFrom = nil | ||
| in.Content = string(data) | ||
| } | ||
| collected = append(collected, in) | ||
| } | ||
|
|
||
| return collected, nil | ||
| } | ||
|
|
||
| // ResolveSecretFileContent fetches the content of a file from a referenced secret. | ||
| func (fr *FileResolver) ResolveSecretFileContent(ctx context.Context, ns string, source eksbootstrapv1.File) ([]byte, error) { | ||
| secret := &corev1.Secret{} | ||
| key := types.NamespacedName{Namespace: ns, Name: source.ContentFrom.Secret.Name} | ||
| if err := fr.Client.Get(ctx, key, secret); err != nil { | ||
| if apierrors.IsNotFound(err) { | ||
| return nil, errors.Wrapf(err, "secret not found: %s", key) | ||
| } | ||
| return nil, errors.Wrapf(err, "failed to retrieve Secret %q", key) | ||
| } | ||
| data, ok := secret.Data[source.ContentFrom.Secret.Key] | ||
| if !ok { | ||
| return nil, errors.Errorf("secret references non-existent secret key: %q", source.ContentFrom.Secret.Key) | ||
| } | ||
| return data, nil | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.