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

Allow 0 value in vcd_nsxt_alb_edgegateway_service_engine_group.reserved_virtual_services field #924

Merged
merged 5 commits into from Nov 15, 2022

Conversation

Didainius
Copy link
Collaborator

@Didainius Didainius commented Oct 26, 2022

Closes #923

Resource vcd_nsxt_alb_edgegateway_service_engine_group field reserved_virtual_services hit a problem where it cannot differentiate between 0 and empty value. The reason for it is that Terraform SDK has a limitation for schema.TypeInt value. (more about it).

The way to overcome it is to use schema.TypeString instead of schema.TypeInt. This works because Terraform does not put explicit differences between int and string in HCL. In the code we convert Int <-> string to match this field. Users would not even notice this change directly, because Terraform has weak typing and you can supply int value to a TypeString field (wihout quotes).

To avoid setting some arbitrary string value, there is a schema validator ValidateFunc: IsIntAndAtLeast(0).

Testing acceptance, binary and upgrade tests with tag alb passed

…String

Signed-off-by: Dainius Serplis <dserplis@vmware.com>
Signed-off-by: Dainius Serplis <dserplis@vmware.com>
Signed-off-by: Dainius Serplis <dserplis@vmware.com>
@Didainius Didainius marked this pull request as ready for review October 27, 2022 07:39
Signed-off-by: Dainius Serplis <dserplis@vmware.com>
@Didainius
Copy link
Collaborator Author

Confirmation it works for user - #923 (comment)

Copy link
Collaborator

@adambarreiro adambarreiro left a comment

Choose a reason for hiding this comment

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

Approved! I think it's a correct workaround. Recently I faced a similar nuance with TypeBool, as nil and false are indistinguishable when reading unset Computed attributes.

Copy link
Collaborator

@lvirbalas lvirbalas left a comment

Choose a reason for hiding this comment

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

Nice fix!

Signed-off-by: Dainius Serplis <dserplis@vmware.com>
@Didainius Didainius merged commit 9c1e0b7 into vmware:main Nov 15, 2022
@Didainius Didainius deleted the alb-fix-923 branch November 15, 2022 07:50
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.

error creating vcd_nsxt_alb_edgegateway_service_engine_group with 0 reserved_virtual_services
4 participants