Skip to content
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

Ensure PULUMI_KUBERNETES_MANAGED_BY_LABEL doesn't cause diffs on updates #1508

Merged
merged 1 commit into from
Mar 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## HEAD (Unreleased)

- Ensure using `PULUMI_KUBERNETES_MANAGED_BY_LABEL` doesn't cause diffs on further stack updates (https://github.com/pulumi/pulumi-kubernetes/pull/1508)

## 2.8.3 (March 17, 2021)

- Fix bug where rendering manifests results in files being overwritten by subsequent resources with the same kind and name, but different namespace (https://github.com/pulumi/pulumi-kubernetes/pull/1429)
Expand Down
10 changes: 8 additions & 2 deletions provider/pkg/metadata/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,19 @@ func TrySetManagedByLabel(obj *unstructured.Unstructured) (bool, error) {
return TrySetLabel(obj, managedByLabel, managedBy)
}

// HasManagedByLabel returns true if the object has the `app.kubernetes.io/managed-by` label set to `pulumi`,
// or is a computed value.
// HasManagedByLabel returns true if the object has the `app.kubernetes.io/managed-by` label set to the value
// of `PULUMI_KUBERNETES_MANAGED_BY_LABEL` EnvVar, `pulumi`, or is a computed value.
func HasManagedByLabel(obj *unstructured.Unstructured) bool {
val := GetLabel(obj, managedByLabel)
if isComputedValue(val) {
return true
}
// now we should check to see if the user has specified a label via EnvVar
// we should also check to see if that value is the same as what is in the metadata
labelVal, exists := os.LookupEnv("PULUMI_KUBERNETES_MANAGED_BY_LABEL")
if exists {
return labelVal == val.(string)
}
str, ok := val.(string)
return ok && str == "pulumi"
}