-
Notifications
You must be signed in to change notification settings - Fork 386
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 to disable auto-stop for SQL Endpoints #900
Conversation
Codecov Report
@@ Coverage Diff @@
## master #900 +/- ##
=======================================
Coverage 90.95% 90.95%
=======================================
Files 110 110
Lines 9497 9499 +2
=======================================
+ Hits 8638 8640 +2
Misses 509 509
Partials 350 350
|
common/reflect_resource.go
Outdated
@@ -85,7 +85,7 @@ func StructToSchema(v interface{}, customize func(map[string]*schema.Schema) map | |||
} | |||
|
|||
func handleOptional(typeField reflect.StructField, schema *schema.Schema) { | |||
if strings.Contains(typeField.Tag.Get("json"), "omitempty") { | |||
if strings.Contains(typeField.Tag.Get("json"), "omitempty") || strings.Contains(typeField.Tag.Get("tf"), "optional") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may cause schema consistency validation errors, need to run also integration tests just to be sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you afraid that something will break, then I can get back to original fix:
m["auto_stop_mins"].Required = false
m["auto_stop_mins"].Optional = true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Required is false by default anyway.
This is literally the same annoying case as with num_workers
, where we have a lot of hacks around.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. If I remove omitempty then it’s implicitly set to Required = true during analysis of the struct… I already hit this issue :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I need to check, maybe we can simplify other places with that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there should be no struct tags for single place use
@@ -186,6 +186,8 @@ func ResourceSQLEndpoint() *schema.Resource { | |||
s := common.StructToSchema(SQLEndpoint{}, func( | |||
m map[string]*schema.Schema) map[string]*schema.Schema { | |||
m["auto_stop_mins"].Default = 120 | |||
m["auto_stop_mins"].Required = false | |||
m["auto_stop_mins"].Optional = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.Optional = true
and no omitempty
creates a schema consistency conflict.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's why it has .Required = false
this PR is of low priority, given the percentage of resource usage across all resources. |
No description provided.