Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Generate Required Fields with Pointer Types #88

Closed
ulucinar opened this issue Oct 7, 2021 · 1 comment · Fixed by #90
Closed

Generate Required Fields with Pointer Types #88

ulucinar opened this issue Oct 7, 2021 · 1 comment · Fixed by #90
Assignees
Labels
alpha bug Something isn't working

Comments

@ulucinar
Copy link
Collaborator

ulucinar commented Oct 7, 2021

What happened?

Currently in Terrajet, we generate fields that correspond to Terraform attributes with a required schema such as this one with non-pointer types. When we late initialize an instance of the enclosing type (network_profile in this example) with an optional schema, we only late-initialize the optional, hence pointer-typed fields) but not the fields that are marked as required. This is because the late-initialization library only initializes nil-pointers because zero-values of non-pointer types (e.g., an empty string) could be a valid value for that attribute, which should not be late-initialized.

How can we reproduce it?

When trying #77 with provider-tf-azure on a v1alpha1.KubernetesCluster resource, first the Kubernetes cluster is provisioned successfully but after the first observation causes a NetworkPlugin to be late-initialized without the NetworkPlugin field (a required field) being late-initialized to one of the allowed values (kubenet or azure) although the Terraform state has it properly set to kubenet.

@ulucinar ulucinar added the bug Something isn't working label Oct 7, 2021
@ulucinar
Copy link
Collaborator Author

ulucinar commented Oct 7, 2021

After discussing this issue with @muvaf, we have decided to generate required fields with pointer types also. This will have a bigger impact when compared to handling the situation per-case via Terraformed resource configurations but we do not expect any new issues when we switch from non-pointer to pointer types for required fields and if we succeed, it will provide a better development experience without the need for custom configurations. Also we cannot detect such issues at build time and if we don't attempt to address by non-pointer types, we will be hunting for these issues at runtime.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
alpha bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant