Skip to content

Commit

Permalink
overlays part 1
Browse files Browse the repository at this point in the history
  • Loading branch information
komalali committed Jun 17, 2020
1 parent 1760f3c commit 702004e
Show file tree
Hide file tree
Showing 12 changed files with 541 additions and 49 deletions.
45 changes: 26 additions & 19 deletions provider/cmd/pulumi-gen-kubernetes/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,25 +174,32 @@ func writeNodeJSClient(pkg *schema.Package, outdir, templateDir string) {
}

func writePythonClient(pkg *schema.Package, outdir string, templateDir string) {
//resources, err := pythongen.LanguageResources("pulumigen", pkg)
//if err != nil {
// panic(err)
//}
//
//templateResources := gen.TemplateResources{}
//for _, resource := range resources {
// r := gen.TemplateResource{
// Name: resource.Name,
// Package: resource.Package,
// Token: resource.Token,
// }
// templateResources.Resources = append(templateResources.Resources, r)
//}
//sort.Slice(templateResources.Resources, func(i, j int) bool {
// return templateResources.Resources[i].Token < templateResources.Resources[j].Token
//})

files, err := pythongen.GeneratePackage("pulumigen", pkg, nil)
resources, err := pythongen.LanguageResources("pulumigen", pkg)
if err != nil {
panic(err)
}

templateResources := gen.TemplateResources{}
for _, resource := range resources {
r := gen.TemplateResource{
Name: resource.Name,
Package: resource.Package,
Token: resource.Token,
}
templateResources.Resources = append(templateResources.Resources, r)
}
sort.Slice(templateResources.Resources, func(i, j int) bool {
return templateResources.Resources[i].Token < templateResources.Resources[j].Token
})

overlays := map[string][]byte{
"apiextensions/custom_resource.py": mustLoadFile(filepath.Join(templateDir, "apiextensions", "custom_resource.py")),
"helm/v2/helm.py": mustLoadFile(filepath.Join(templateDir, "helm", "v2", "helm.py")),
"helm/v3/helm.py": mustLoadFile(filepath.Join(templateDir, "helm", "v2", "helm.py")), // v3 support is currently identical to v2
// "pulumi_kubernetes/yaml.py": mustRenderTemplate(filepath.Join(templateDir, "yaml", "yaml.tmpl"), templateResources),
}

files, err := pythongen.GeneratePackage("pulumigen", pkg, overlays)
if err != nil {
panic(err)
}
Expand Down
9 changes: 0 additions & 9 deletions provider/pkg/gen/python-templates/helm/__init__.py

This file was deleted.

6 changes: 0 additions & 6 deletions provider/pkg/gen/python-templates/helm/v2/__init__.py

This file was deleted.

6 changes: 0 additions & 6 deletions provider/pkg/gen/python-templates/helm/v3/__init__.py

This file was deleted.

2 changes: 1 addition & 1 deletion sdk/python/pulumi_kubernetes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import importlib
# Make subpackages available:
__all__ = ['admissionregistration', 'apiextensions', 'apiregistration', 'apps', 'auditregistration', 'authentication', 'authorization', 'autoscaling', 'batch', 'certificates', 'coordination', 'core', 'discovery', 'events', 'extensions', 'flowcontrol', 'meta', 'networking', 'node', 'policy', 'rbac', 'scheduling', 'settings', 'storage']
__all__ = ['admissionregistration', 'apiextensions', 'apiregistration', 'apps', 'auditregistration', 'authentication', 'authorization', 'autoscaling', 'batch', 'certificates', 'coordination', 'core', 'discovery', 'events', 'extensions', 'flowcontrol', 'helm', 'meta', 'networking', 'node', 'policy', 'rbac', 'scheduling', 'settings', 'storage']
for pkg in __all__:
if pkg != 'config':
importlib.import_module(f'{__name__}.{pkg}')
Expand Down
3 changes: 3 additions & 0 deletions sdk/python/pulumi_kubernetes/apiextensions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@
for pkg in __all__:
if pkg != 'config':
importlib.import_module(f'{__name__}.{pkg}')

# Export this package's modules as members:
from .custom_resource import *
File renamed without changes.
11 changes: 6 additions & 5 deletions sdk/python/pulumi_kubernetes/helm/__init__.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# coding=utf-8
# *** WARNING: this file was generated by the Pulumi Kubernetes codegen tool. ***
# *** WARNING: this file was generated by pulumigen. ***
# *** Do not edit by hand unless you're certain you know what you are doing! ***

import importlib
# Make subpackages available:
__all__ = [
"v2",
"v3",
]
__all__ = ['v2', 'v3']
for pkg in __all__:
if pkg != 'config':
importlib.import_module(f'{__name__}.{pkg}')
2 changes: 1 addition & 1 deletion sdk/python/pulumi_kubernetes/helm/v2/__init__.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# coding=utf-8
# *** WARNING: this file was generated by the Pulumi Kubernetes codegen tool. ***
# *** WARNING: this file was generated by pulumigen. ***
# *** Do not edit by hand unless you're certain you know what you are doing! ***

# Export this package's modules as members:
Expand Down
4 changes: 2 additions & 2 deletions sdk/python/pulumi_kubernetes/helm/v3/__init__.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# coding=utf-8
# *** WARNING: this file was generated by the Pulumi Kubernetes codegen tool. ***
# *** WARNING: this file was generated by pulumigen. ***
# *** Do not edit by hand unless you're certain you know what you are doing! ***

# Export this package's modules as members:
from ..v2.helm import * # v3 support is identical to v2
from .helm import *
Loading

0 comments on commit 702004e

Please sign in to comment.