Skip to content

Commit

Permalink
fix: include namespace in renderedYaml filename (#1429)
Browse files Browse the repository at this point in the history
This fixes a problem when resources have the same name/kind, but live in different namespaces. This caused the first file written to be overwritten by the later resources.
  • Loading branch information
rawkode committed Feb 26, 2021
1 parent e30d9d7 commit be90a25
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## HEAD (Unreleased)

- 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)

## 2.8.2 (February 23, 2021)

- Postpone the removal of admissionregistration/v1beta1, which has been retargeted at 1.22 (https://github.com/pulumi/pulumi-kubernetes/pull/1474)
Expand Down
7 changes: 6 additions & 1 deletion provider/pkg/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -2764,7 +2764,12 @@ func renderPathForResource(resource *unstructured.Unstructured, yamlDirectory st
crdDirectory := filepath.Join(yamlDirectory, "0-crd")
manifestDirectory := filepath.Join(yamlDirectory, "1-manifest")

fileName := fmt.Sprintf("%s-%s.yaml", strings.ToLower(resource.GetKind()), resource.GetName())
namespace := "default"
if "" != resource.GetNamespace() {
namespace = resource.GetNamespace()
}

fileName := fmt.Sprintf("%s-%s-%s.yaml", strings.ToLower(resource.GetKind()), namespace, resource.GetName())
filepath.Join(yamlDirectory, fileName)

var path string
Expand Down

0 comments on commit be90a25

Please sign in to comment.