-
Notifications
You must be signed in to change notification settings - Fork 0
🌱 Helm extension prototype #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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Per Goncalves da Silva <[email protected]>
Signed-off-by: Per Goncalves da Silva <[email protected]>
Signed-off-by: Per Goncalves da Silva <[email protected]>
Signed-off-by: yashoza19 <[email protected]>
a2c4563
to
b05a2f0
Compare
type ConfigSourceReferences struct { | ||
ConfigMapNames []string `json:"configMapNames,omitempty"` | ||
SecretNames []string `json:"secretNames,omitempty"` | ||
TextConfigs []string `json:"textConfigs,omitempty"` | ||
} |
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.
What if you did something like a discriminated union here?
I'm thinking something like:
type ConfigSourceType string
const (
ConfigSourceTypeConfigMap = "ConfigMap"
ConfigSourceTypeSecret = "Secret"
ConfigSourceTypeInline = "Inline"
)
// CEL validation here to ensure type + property correctness
type ConfigSource struct {
// +required
Type ConfigSourceType `json:"type"`
// +optional
ConfigMap *ConfigMapReference `json:"configMap,omitempty"`
...
}
Then line 149 could become:
ConfigSources []ConfigSource
I think something like this might fit better with the existing conventions of the ClusterExtension API
@@ -283,3 +201,98 @@ func createClientWithToken(cfg *rest.Config, token string) (*kubernetes.Clientse | |||
|
|||
return clientSet, nil | |||
} | |||
|
|||
// Looks for the ConfigSources by name in the install namespace and gathers values | |||
func processConfig(ctx context.Context, tokenGetter *authentication.TokenGetter, ext *ocv1alpha1.ClusterExtension, values chartutil.Values) (chartutil.Values, 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.
This function is generally pretty straightforward but I wonder if the mental model here could be simplified a bit with some logical abstractions or separate functions?
I think the discriminated union approach for the API might also make that abstraction/functional separation a bit nicer.
Maybe something like:
func processConfigSources(ctx context.Context, client *kubernetes.Clientset, configSources []ocv1alpha1.ConfigSource, values chartutil.Values) (chartutil.Values, error) {
for _, configSource := range configSources {
userSuppliedValues, err := loadValuesFromConfigSource(ctx, client, configSource)
// err check
// do something with values
}
// return loaded values
}
func loadValuesFromConfigSource(ctx context.Context, client *kubernetes.Clientset, configSource ocv1alpha1.ConfigSource) (chartutil.Values, error) {
switch configSource.Type {
case ocv1alpha1.ConfigSourceTypeConfigMap:
// Load from configmap
case ocv1alpha1.ConfigSourceTypeSecret:
// Load from secret
case ocv1alpha1.ConfigSourceTypeInline:
// Load from inline
}
}
What I put might not work as is, but hopefully gets the point across that I think some responsibility separation here might be useful for readability, maintenance, and testing.
Description
Building on the initial prototype that adds functionality to install helm charts as extensions, additional functionality has been added to allow for the specification of values in the form of config maps, secrets or plain text.
Reviewer Checklist