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

Add Patch resources to all SDKs #2043

Merged
merged 16 commits into from
Jul 12, 2022
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
## Unreleased

- Implement Server-Side Apply mode (https://github.com/pulumi/pulumi-kubernetes/pull/2029)
- Add Patch resources to all SDKs (https://github.com/pulumi/pulumi-kubernetes/pull/2043)
- Add awaiter for service-account-token secret (https://github.com/pulumi/pulumi-kubernetes/pull/2048)
- All Java packages changed to be more intuitive, unfortunately this is a breaking change for Java version (https://github.com/pulumi/pulumi-kubernetes/pull/2055)
- Add Java packages overrides to schema (https://github.com/pulumi/pulumi-kubernetes/pull/2055)

## 3.19.4 (June 21, 2022)

Expand Down
65 changes: 42 additions & 23 deletions provider/cmd/pulumi-gen-kubernetes/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ func writeNodeJSClient(pkg *schema.Package, outdir, templateDir string) {
if resource.Package == "" {
continue
}
if strings.HasSuffix(resource.Name, "Patch") {
continue
}
tr := gen.TemplateResource{
Name: resource.Name,
Package: resource.Package,
Expand Down Expand Up @@ -212,11 +215,12 @@ func writeNodeJSClient(pkg *schema.Package, outdir, templateDir string) {
templateResources.Packages = packages.SortedValues()

overlays := map[string][]byte{
"apiextensions/customResource.ts": mustLoadFile(filepath.Join(templateDir, "apiextensions", "customResource.ts")),
"helm/v2/helm.ts": mustLoadFile(filepath.Join(templateDir, "helm", "v2", "helm.ts")),
"helm/v3/helm.ts": mustLoadFile(filepath.Join(templateDir, "helm", "v3", "helm.ts")),
"kustomize/kustomize.ts": mustLoadFile(filepath.Join(templateDir, "kustomize", "kustomize.ts")),
"yaml/yaml.ts": mustRenderTemplate(filepath.Join(templateDir, "yaml", "yaml.tmpl"), templateResources),
"apiextensions/customResource.ts": mustLoadFile(filepath.Join(templateDir, "apiextensions", "customResource.ts")),
"apiextensions/customResourcePatch.ts": mustLoadFile(filepath.Join(templateDir, "apiextensions", "customResourcePatch.ts")),
"helm/v2/helm.ts": mustLoadFile(filepath.Join(templateDir, "helm", "v2", "helm.ts")),
"helm/v3/helm.ts": mustLoadFile(filepath.Join(templateDir, "helm", "v3", "helm.ts")),
"kustomize/kustomize.ts": mustLoadFile(filepath.Join(templateDir, "kustomize", "kustomize.ts")),
"yaml/yaml.ts": mustRenderTemplate(filepath.Join(templateDir, "yaml", "yaml.tmpl"), templateResources),
}
files, err := nodejsgen.GeneratePackage("pulumigen", pkg, overlays)
if err != nil {
Expand All @@ -241,6 +245,9 @@ func writePythonClient(pkg *schema.Package, outdir string, templateDir string) {
if resourcesToFilterFromTemplate.Has(tok) {
continue
}
if strings.HasSuffix(resource.Name, "Patch") {
continue
}
r := gen.TemplateResource{
Name: resource.Name,
Package: resource.Package,
Expand All @@ -253,11 +260,12 @@ func writePythonClient(pkg *schema.Package, outdir string, templateDir string) {
})

overlays := map[string][]byte{
"apiextensions/CustomResource.py": mustLoadFile(filepath.Join(templateDir, "apiextensions", "CustomResource.py")),
"helm/v2/helm.py": mustLoadFile(filepath.Join(templateDir, "helm", "v2", "helm.py")),
"helm/v3/helm.py": mustLoadFile(filepath.Join(templateDir, "helm", "v3", "helm.py")),
"kustomize/kustomize.py": mustLoadFile(filepath.Join(templateDir, "kustomize", "kustomize.py")),
"yaml/yaml.py": mustRenderTemplate(filepath.Join(templateDir, "yaml", "yaml.tmpl"), templateResources),
"apiextensions/CustomResource.py": mustLoadFile(filepath.Join(templateDir, "apiextensions", "CustomResource.py")),
"apiextensions/CustomResourcePatch.py": mustLoadFile(filepath.Join(templateDir, "apiextensions", "CustomResourcePatch.py")),
"helm/v2/helm.py": mustLoadFile(filepath.Join(templateDir, "helm", "v2", "helm.py")),
"helm/v3/helm.py": mustLoadFile(filepath.Join(templateDir, "helm", "v3", "helm.py")),
"kustomize/kustomize.py": mustLoadFile(filepath.Join(templateDir, "kustomize", "kustomize.py")),
"yaml/yaml.py": mustRenderTemplate(filepath.Join(templateDir, "yaml", "yaml.tmpl"), templateResources),
}

files, err := pythongen.GeneratePackage("pulumigen", pkg, overlays)
Expand All @@ -279,6 +287,9 @@ func writeDotnetClient(pkg *schema.Package, outdir, templateDir string) {
if resourcesToFilterFromTemplate.Has(tok) {
continue
}
if strings.HasSuffix(resource.Name, "Patch") {
continue
}
r := gen.TemplateResource{
Name: resource.Name,
Package: resource.Package,
Expand All @@ -290,19 +301,20 @@ func writeDotnetClient(pkg *schema.Package, outdir, templateDir string) {
return templateResources.Resources[i].Token < templateResources.Resources[j].Token
})
overlays := map[string][]byte{
"ApiExtensions/CustomResource.cs": mustLoadFile(filepath.Join(templateDir, "apiextensions", "CustomResource.cs")),
"Helm/ChartBase.cs": mustLoadFile(filepath.Join(templateDir, "helm", "ChartBase.cs")),
"Helm/Unwraps.cs": mustLoadFile(filepath.Join(templateDir, "helm", "Unwraps.cs")),
"Helm/V2/Chart.cs": mustLoadFile(filepath.Join(templateDir, "helm", "v2", "Chart.cs")),
"Helm/V3/Chart.cs": mustLoadFile(filepath.Join(templateDir, "helm", "v3", "Chart.cs")),
"Helm/V3/Invokes.cs": mustLoadFile(filepath.Join(templateDir, "helm", "v3", "Invokes.cs")),
"Kustomize/Directory.cs": mustLoadFile(filepath.Join(templateDir, "kustomize", "Directory.cs")),
"Kustomize/Invokes.cs": mustLoadFile(filepath.Join(templateDir, "kustomize", "Invokes.cs")),
"Yaml/ConfigFile.cs": mustLoadFile(filepath.Join(templateDir, "yaml", "ConfigFile.cs")),
"Yaml/ConfigGroup.cs": mustLoadFile(filepath.Join(templateDir, "yaml", "ConfigGroup.cs")),
"Yaml/Invokes.cs": mustLoadFile(filepath.Join(templateDir, "yaml", "Invokes.cs")),
"Yaml/TransformationAction.cs": mustLoadFile(filepath.Join(templateDir, "yaml", "TransformationAction.cs")),
"Yaml/Yaml.cs": mustRenderTemplate(filepath.Join(templateDir, "yaml", "yaml.tmpl"), templateResources),
"ApiExtensions/CustomResource.cs": mustLoadFile(filepath.Join(templateDir, "apiextensions", "CustomResource.cs")),
"ApiExtensions/CustomResourcePatch.cs": mustLoadFile(filepath.Join(templateDir, "apiextensions", "CustomResourcePatch.cs")),
"Helm/ChartBase.cs": mustLoadFile(filepath.Join(templateDir, "helm", "ChartBase.cs")),
"Helm/Unwraps.cs": mustLoadFile(filepath.Join(templateDir, "helm", "Unwraps.cs")),
"Helm/V2/Chart.cs": mustLoadFile(filepath.Join(templateDir, "helm", "v2", "Chart.cs")),
"Helm/V3/Chart.cs": mustLoadFile(filepath.Join(templateDir, "helm", "v3", "Chart.cs")),
"Helm/V3/Invokes.cs": mustLoadFile(filepath.Join(templateDir, "helm", "v3", "Invokes.cs")),
"Kustomize/Directory.cs": mustLoadFile(filepath.Join(templateDir, "kustomize", "Directory.cs")),
"Kustomize/Invokes.cs": mustLoadFile(filepath.Join(templateDir, "kustomize", "Invokes.cs")),
"Yaml/ConfigFile.cs": mustLoadFile(filepath.Join(templateDir, "yaml", "ConfigFile.cs")),
"Yaml/ConfigGroup.cs": mustLoadFile(filepath.Join(templateDir, "yaml", "ConfigGroup.cs")),
"Yaml/Invokes.cs": mustLoadFile(filepath.Join(templateDir, "yaml", "Invokes.cs")),
"Yaml/TransformationAction.cs": mustLoadFile(filepath.Join(templateDir, "yaml", "TransformationAction.cs")),
"Yaml/Yaml.cs": mustRenderTemplate(filepath.Join(templateDir, "yaml", "yaml.tmpl"), templateResources),
}

files, err := dotnetgen.GeneratePackage("pulumigen", pkg, overlays)
Expand Down Expand Up @@ -360,6 +372,9 @@ func writeGoClient(pkg *schema.Package, outdir string, templateDir string) {
if resourcesToFilterFromTemplate.Has(tok) {
continue
}
if strings.HasSuffix(resource.Name, "Patch") {
continue
}
r := gen.TemplateResource{
Alias: resource.Alias,
Name: resource.Name,
Expand All @@ -374,6 +389,7 @@ func writeGoClient(pkg *schema.Package, outdir string, templateDir string) {

files["kubernetes/customPulumiTypes.go"] = mustLoadGoFile(filepath.Join(templateDir, "customPulumiTypes.go"))
files["kubernetes/apiextensions/customResource.go"] = mustLoadGoFile(filepath.Join(templateDir, "apiextensions", "customResource.go"))
files["kubernetes/apiextensions/customResourcePatch.go"] = mustLoadGoFile(filepath.Join(templateDir, "apiextensions", "customResourcePatch.go"))
files["kubernetes/helm/v2/chart.go"] = mustLoadGoFile(filepath.Join(templateDir, "helm", "v2", "chart.go"))
files["kubernetes/helm/v2/pulumiTypes.go"] = mustLoadGoFile(filepath.Join(templateDir, "helm", "v2", "pulumiTypes.go"))
files["kubernetes/helm/v3/chart.go"] = mustLoadGoFile(filepath.Join(templateDir, "helm", "v3", "chart.go"))
Expand Down Expand Up @@ -441,6 +457,9 @@ func genK8sResourceTypes(pkg *schema.Package) {
if resource.IsOverlay {
continue
}
if strings.HasSuffix(kind, "Patch") {
continue
}

groupVersions.Add(groupVersion)
kinds.Add(kind)
Expand Down
Loading