-
Notifications
You must be signed in to change notification settings - Fork 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
Support user-supplied bootstrap configuration #66
Conversation
func (r *CK8sConfigReconciler) resolveSecretFileContent(ctx context.Context, ns string, source bootstrapv1.File) ([]byte, error) { | ||
func (r *CK8sConfigReconciler) resolveSecretFileContent(ctx context.Context, ns string, source bootstrapv1.FileSource) ([]byte, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the parameter type from File to FileSource because 1. We do not use any of the fields from the File type, except ContentFrom. 2. This makes the function reusable for any other types that have a FileSource (and therefore reference a secret), but are not an explicit abstraction of a File.
userSuppliedBootstrapConfig, err := r.resolveUserBootstrapConfig(ctx, scope.Config) | ||
if err != nil { | ||
conditions.MarkFalse(scope.Config, bootstrapv1.DataSecretAvailableCondition, bootstrapv1.DataSecretGenerationFailedReason, clusterv1.ConditionSeverityWarning, err.Error()) | ||
return ctrl.Result{}, err | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolveUserBootstrapConfig returns an empty string if there is no user-supplied configuration, we check this later in common.go.
pkg/cloudinit/common.go
Outdated
var configFileContents string | ||
switch { | ||
case data.BootstrapConfig != "": | ||
// User-supplied bootstrap configuration from CK8sConfig object. | ||
configFileContents = data.BootstrapConfig | ||
default: | ||
configFileContents = data.ConfigFileContents | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
user-supplied bootstrap configuration has precedence over our ConfigFileContents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, added some comments
851c053
to
102cf8e
Compare
e3c9386
to
bffa5e4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Implements first-party support for supplying a bootstrap configuration (before this, it was done by overriding install.sh and adding a file under extraFiles).
The BootstrapConfig type re-uses the existing FileSource type so that a secret reference can be used to seed the configuration just like we have for files, (e.g. contentFrom).