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

Update terraform kubernetes provider dependency to 1.6.2 and adapt code #11

Merged
merged 1 commit into from
Apr 27, 2019

Conversation

pdecat
Copy link
Contributor

@pdecat pdecat commented Apr 26, 2019

This PR updates terraform kubernetes provider dependency to 1.6.2.

Code needed an adaptation as, the mode and default_mode attributes of volume source blocks are now mandatorily a string representation of an octal value with a leading zero, cf.:

-https://github.com/terraform-providers/terraform-provider-kubernetes/blame/v1.6.2/CHANGELOG.md#L16

@pdecat
Copy link
Contributor Author

pdecat commented Apr 26, 2019

Without the code adaptation, tests fail:

# go test
4:44PM Warn | excluding attribute - not found in Terraform schema           attr=kubernetes_pod.spec.toleration field=Pod.Spec.Tolerations name=node_exporter_7fth_7 type=kubernetes_pod
4:44PM Warn | excluding attribute - not found in Terraform schema           attr=kubernetes_pod.spec.toleration field=Pod.Spec.Tolerations name=node_exporter_7fth_7 type=kubernetes_pod
4:44PM Warn | excluding attribute - not found in Terraform schema           attr=kubernetes_pod.spec.toleration field=Pod.Spec.Tolerations name=node_exporter_7fth_7 type=kubernetes_pod
4:44PM Warn | excluding attribute - not found in Terraform schema           attr=kubernetes_pod.spec.toleration field=Pod.Spec.Tolerations name=node_exporter_7fth_7 type=kubernetes_pod
--- FAIL: TestWriteObject (0.44s)
    --- FAIL: TestWriteObject/deployment (0.16s)
        hcl_writer_test.go:133: Validation Error: 0> spec.0.template.0.spec.0.volume.0.config_map.0.default_mode: value 420 should start with '0' (octal numeral)
    --- FAIL: TestWriteObject/podNodeExporter (0.09s)
        hcl_writer_test.go:133: Validation Error: 0> spec.0.volume.0.secret.0.default_mode: value 420 should start with '0' (octal numeral)
FAIL
exit status 1
FAIL    github.com/sl1pm4t/k2tf 0.491s

@@ -472,6 +474,13 @@ func (w *ObjectWalker) convertCtyValue(val interface{}) cty.Value {
case int:
return cty.NumberIntVal(int64(val.(int)))
case int32:
// On volume source blocks, the mode and default_mode attributes are now mandatorily a string representation of an octal value with a leading zero
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did not find any similar exceptions, this looks like the first case such a conversion is mandated.
While somewhat hacky, this seemed to me the most adequate place to implement this right now.
This may not scale well if others are needed in the future.

Copy link
Owner

Choose a reason for hiding this comment

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

Yes, time will tell if there are going to be a lot of these special cases. For now I think this is as good a place as any.

@@ -472,6 +474,13 @@ func (w *ObjectWalker) convertCtyValue(val interface{}) cty.Value {
case int:
return cty.NumberIntVal(int64(val.(int)))
case int32:
// On volume source blocks, the mode and default_mode attributes are now mandatorily a string representation of an octal value with a leading zero
Copy link
Owner

Choose a reason for hiding this comment

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

Yes, time will tell if there are going to be a lot of these special cases. For now I think this is as good a place as any.

@sl1pm4t
Copy link
Owner

sl1pm4t commented Apr 27, 2019

Thanks @pdecat

@sl1pm4t sl1pm4t merged commit b462b45 into sl1pm4t:master Apr 27, 2019
@pdecat pdecat deleted the update-terraform-kubernetes-1.6.2 branch April 27, 2019 23:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants