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

Properly reference override values in Python Helm SDK #676

Merged
merged 2 commits into from
Jul 31, 2019
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
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
## 0.25.4 (Unreleased)

### Supported Kubernetes versions

- v1.15.x
- v1.14.x
- v1.13.x

### Bug fixes

- Properly reference override values in Python Helm SDK (https://github.com/pulumi/pulumi-kubernetes/pull/676).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Properly reference override values in Python Helm SDK (https://github.com/pulumi/pulumi-kubernetes/pull/676).
- Properly reference override values in Python Helm SDK (https://github.com/pulumi/pulumi-kubernetes/pull/676).


## 0.25.3 (July 29, 2019)

### Supported Kubernetes versions
Expand Down
1 change: 1 addition & 0 deletions pkg/gen/python-templates/helm/v2/helm.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ def _parse_chart(all_config: Tuple[str, Union[ChartOpts, LocalChartOpts], pulumi
vals = config.values if config.values is not None else {}
data = json.dumps(vals).encode('utf-8')
overrides.write(data)
overrides.flush()

namespace_arg = ['--namespace', config.namespace] if config.namespace else []

Expand Down
1 change: 1 addition & 0 deletions sdk/python/pulumi_kubernetes/helm/v2/helm.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ def _parse_chart(all_config: Tuple[str, Union[ChartOpts, LocalChartOpts], pulumi
vals = config.values if config.values is not None else {}
data = json.dumps(vals).encode('utf-8')
overrides.write(data)
overrides.flush()

namespace_arg = ['--namespace', config.namespace] if config.namespace else []

Expand Down
6 changes: 4 additions & 2 deletions tests/examples/python/helm/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
# limitations under the License.
from pulumi_kubernetes.helm.v2 import Chart, ChartOpts

Chart("unbound", ChartOpts("stable/unbound"))
values = {"unbound": {"image": {"pullPolicy": "Always"}}}

Chart("unbound", ChartOpts("stable/unbound", values=values))

# Deploy a duplicate chart with a different resource prefix to verify that multiple instances of the Chart
# can be managed in the same stack.
Chart("unbound", ChartOpts("stable/unbound", resource_prefix="dup"))
Chart("unbound", ChartOpts("stable/unbound", resource_prefix="dup", values=values))
35 changes: 35 additions & 0 deletions tests/examples/python/python_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,41 @@ func TestHelm(t *testing.T) {
options := baseOptions.With(integration.ProgramTestOptions{
Dir: filepath.Join(cwd, "helm"),
ExpectRefreshChanges: true, // PodDisruptionBudget status gets updated by the Deployment.
ExtraRuntimeValidation: func(t *testing.T, stackInfo integration.RuntimeValidationStackInfo) {
assert.NotNil(t, stackInfo.Deployment)
assert.Equal(t, 12, len(stackInfo.Deployment.Resources))

sort.Slice(stackInfo.Deployment.Resources, func(i, j int) bool {
ri := stackInfo.Deployment.Resources[i]
rj := stackInfo.Deployment.Resources[j]
riname, _ := openapi.Pluck(ri.Outputs, "metadata", "name")
rinamespace, _ := openapi.Pluck(ri.Outputs, "metadata", "namespace")
rjname, _ := openapi.Pluck(rj.Outputs, "metadata", "name")
rjnamespace, _ := openapi.Pluck(rj.Outputs, "metadata", "namespace")
return fmt.Sprintf("%s/%s/%s", ri.URN.Type(), rinamespace, riname) <
fmt.Sprintf("%s/%s/%s", rj.URN.Type(), rjnamespace, rjname)
})

// Verify override value was set.
unboundDepl := stackInfo.Deployment.Resources[5]
assert.Equal(t, tokens.Type("kubernetes:extensions/v1beta1:Deployment"), unboundDepl.URN.Type())
containersRaw, _ := openapi.Pluck(unboundDepl.Outputs, "spec", "template", "spec", "containers")
containers := containersRaw.([]interface{})
assert.Equal(t, 2, len(containers))
container := containers[0].(map[string]interface{})
containerName, _ := openapi.Pluck(container, "name")
assert.True(t, strings.HasPrefix(containerName.(string), "unbound"))
pullPolicy, _ := openapi.Pluck(container, "imagePullPolicy")
assert.True(t, strings.HasPrefix(pullPolicy.(string), "Always"))

// Verify the provider resource.
provRes := stackInfo.Deployment.Resources[10]
assert.True(t, providers.IsProviderType(provRes.URN.Type()))

// Verify root resource.
stackRes := stackInfo.Deployment.Resources[11]
assert.Equal(t, resource.RootStackType, stackRes.URN.Type())
},
})
integration.ProgramTest(t, &options)
}