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

Explicit propagation for json,"..,optional" fields #268

Closed
nfx opened this issue Dec 30, 2022 · 6 comments
Closed

Explicit propagation for json,"..,optional" fields #268

nfx opened this issue Dec 30, 2022 · 6 comments

Comments

@nfx
Copy link
Contributor

nfx commented Dec 30, 2022

fix cases around optional propagation:

func isOptional(typeField reflect.StructField) bool {
	if strings.Contains(typeField.Tag.Get("json"), "omitempty") {
		return true
	}
	tfTags := strings.Split(typeField.Tag.Get("tf"), ",")
	for _, tag := range tfTags {
		if tag == "optional" {
			return true
		}
	}
	return false
}
...
                omitEmpty := isOptional(typeField)
		if omitEmpty && !fieldSchema.Optional {
			return fmt.Errorf("inconsistency: %s has omitempty, but is not optional", fieldName)
		}
@benbauer89
Copy link

Hey, I created an issue with basically the same problem: databricks/terraform-provider-databricks#1776
any chance this gets prioritized in one of the next releases?

@nfx
Copy link
Contributor Author

nfx commented Apr 3, 2023

@benbauer89 we'll pick it up once we SDK-migrate TF resource that needs it

@pietern
Copy link
Contributor

pietern commented Sep 13, 2023

@hectorcast-db Is working on support for this in #615 and more.

@mgyucht
Copy link
Contributor

mgyucht commented Oct 25, 2023

I think the Go SDK changes are complete, so we can probably close this issue? The remaining issues stem from the TF provider and should be resolved when TF starts to use ForceSendFields (hopefully in the next release).

@hectorcast-db
Copy link
Contributor

Correct. SDK changes are complete. Closing this issue.

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

No branches or pull requests

5 participants