-
Notifications
You must be signed in to change notification settings - Fork 0
fix: set parent properly on configmaps, naming uniqueness #45
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 all commits
Commits
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 |
|---|---|---|
|
|
@@ -19,28 +19,33 @@ type EnvProvider interface { | |
|
|
||
| // CreateConfigMap creates a Kubernetes ConfigMap from an environment variables struct | ||
| // It automatically converts field names to environment variable format (UPPER_SNAKE_CASE) | ||
| // The optional parent parameter can be provided to set the parent resource for the ConfigMap | ||
| func CreateConfigMap[T EnvProvider]( | ||
| ctx *pulumi.Context, | ||
| name string, | ||
| namespace pulumi.StringInput, | ||
| labels pulumi.StringMap, | ||
| env T, | ||
| parent ...pulumi.Resource, | ||
| ) (*corev1.ConfigMap, error) { | ||
| // Create metadata for ConfigMap | ||
| metadata := &metav1.ObjectMetaArgs{ | ||
| Name: pulumi.String(name), | ||
| Namespace: namespace, | ||
| Labels: labels, | ||
| } | ||
|
|
||
| // Get environment variables as a map using the EnvProvider interface | ||
| data := env.GetEnvMap() | ||
|
|
||
| // Prepare options with parent if provided | ||
| var opts []pulumi.ResourceOption | ||
| if len(parent) > 0 && parent[0] != nil { | ||
| opts = append(opts, pulumi.Parent(parent[0])) | ||
| } | ||
|
|
||
| // Create and return ConfigMap | ||
| return corev1.NewConfigMap(ctx, name, &corev1.ConfigMapArgs{ | ||
| Metadata: metadata, | ||
| Data: data, | ||
| }) | ||
| Metadata: &metav1.ObjectMetaArgs{ | ||
| Namespace: namespace, | ||
| Labels: labels, | ||
| }, | ||
|
Comment on lines
+43
to
+46
|
||
| Data: data, | ||
| }, opts...) | ||
| } | ||
|
|
||
| // CreateEnvMap converts a struct to a map of environment variables | ||
|
|
@@ -212,7 +217,6 @@ func CreatePersistentVolumeClaim( | |
|
|
||
| return corev1.NewPersistentVolumeClaim(ctx, name, &corev1.PersistentVolumeClaimArgs{ | ||
| Metadata: &metav1.ObjectMetaArgs{ | ||
| Name: pulumi.String(name), | ||
| Labels: labels, | ||
| Namespace: namespace, | ||
| }, | ||
|
|
||
Oops, something went wrong.
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.
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.
The variadic parameter
parent ...pulumi.Resourceallows multiple parents to be passed, but the implementation only uses the first one. Consider using a single optional parameterparent pulumi.Resourceor*pulumi.Resourceto make the API intention clearer and prevent confusion.