terraform-provider-nsxt icon indicating copy to clipboard operation
terraform-provider-nsxt copied to clipboard

[WIP] Skip attribute processing when no values is assigned in schema

Open ksamoray opened this issue 1 year ago • 8 comments

When a value is not assigned to the schema for some attribute, using d.Get("attr_name").(type) will return a zero or a null string.

That would break when this value is not allowed by NSX and usually we protect against this with an if statement which would assign this attribute a value only when it's set in the schema. With required attributes that cannot happen as NSX will check that a value is assigned prior to the Create() call.

ksamoray avatar Jul 01 '24 14:07 ksamoray

/test-all

ksamoray avatar Jul 01 '24 14:07 ksamoray

/test-all

ksamoray avatar Jul 01 '24 15:07 ksamoray

/test-all

ksamoray avatar Jul 01 '24 15:07 ksamoray

/test-all

ksamoray avatar Jul 02 '24 08:07 ksamoray

We need to be able to set empty value as in some cases, this is the way to nullify value on update. We have OmitIfEmpty boolean flag to control this behavior

annakhm avatar Jul 02 '24 16:07 annakhm

@annakhm Isn't it better to nullify by default and set when needed?

ksamoray avatar Jul 02 '24 16:07 ksamoray

@annakhm Isn't it better to nullify by default and set when needed?

There is a difference between empty value (translates to field name with empty value in API call) and nil value (field name is not mentioned in the request). The latter is sometimes ignored with NSX Patch behavior (which is correct behavior, since attributes that are not specified should not be touched with Patch. In those cases, explicit empty value is needed to remove assigned value.

annakhm avatar Jul 02 '24 21:07 annakhm

/test-all

ksamoray avatar Jul 03 '24 12:07 ksamoray