-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
azurerm_mssql_virtual_machine: fix tests and persistent diff, use relative expiry for service principal password #10125
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6218a10
mssql: fix test, use relative expiry for service principal password
manicminer 577e180
mssql: fix persistent diff with azurerm_mssql_virtual_machine.storage…
manicminer 72286c4
mssql: drop capacity arg for result slice
manicminer 8acdb6d
mssql_virtual_machine: always track an empty string for storage_confi…
manicminer 79d87e5
mssql_virtual_machine: set all storage_configuration attributes, but …
manicminer File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -486,15 +486,33 @@ func flattenSqlVirtualMachineStorageConfigurationSettings(input *sqlvirtualmachi | |
return []interface{}{} | ||
} | ||
|
||
return []interface{}{ | ||
map[string]interface{}{ | ||
"disk_type": string(input.DiskConfigurationType), | ||
"storage_workload_type": storageWorkloadType, | ||
"data_settings": flattenSqlVirtualMachineStorageSettings(input.SQLDataSettings), | ||
"log_settings": flattenSqlVirtualMachineStorageSettings(input.SQLLogSettings), | ||
"temp_db_settings": flattenSqlVirtualMachineStorageSettings(input.SQLTempDbSettings), | ||
}, | ||
output := make(map[string]interface{}) | ||
|
||
if v := string(input.DiskConfigurationType); v != "" { | ||
output["disk_type"] = v | ||
} | ||
|
||
if storageWorkloadType != "" { | ||
output["storage_workload_type"] = storageWorkloadType | ||
} | ||
|
||
if v := flattenSqlVirtualMachineStorageSettings(input.SQLDataSettings); len(v) > 0 { | ||
output["data_settings"] = v | ||
} | ||
|
||
if v := flattenSqlVirtualMachineStorageSettings(input.SQLLogSettings); len(v) > 0 { | ||
output["log_settings"] = v | ||
} | ||
|
||
if v := flattenSqlVirtualMachineStorageSettings(input.SQLTempDbSettings); len(v) > 0 { | ||
output["temp_db_settings"] = v | ||
} | ||
|
||
if len(output) == 0 { | ||
return []interface{}{} | ||
} | ||
|
||
return []interface{}{output} | ||
} | ||
|
||
func expandSqlVirtualMachineDataStorageSettings(input []interface{}) *sqlvirtualmachine.SQLStorageSettings { | ||
|
@@ -510,10 +528,10 @@ func expandSqlVirtualMachineDataStorageSettings(input []interface{}) *sqlvirtual | |
} | ||
|
||
func expandSqlVirtualMachineStorageSettingsLuns(input []interface{}) *[]int32 { | ||
expandedLuns := make([]int32, len(input)) | ||
expandedLuns := make([]int32, 0, len(input)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure we need the capacity arg here since we're ranging over There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK cool, yeah it works without it too. |
||
for i := range input { | ||
if input[i] != nil { | ||
expandedLuns[i] = int32(input[i].(int)) | ||
expandedLuns = append(expandedLuns, int32(input[i].(int))) | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 possibly wants setting as an empty string so there's always a value?
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.
Unfortunately the problem is that Terraform shows state drift if the containing list has any elements when there are none in the config. It looks like the API has started returning an array having zero values instead of omitting it from the response, which is why I've made it try and detect that. Is there is a better way to avoid state drift in such circumstances?
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.
agreed we should track an empty string in the state in all cases - but if the nested object is returned as an empty object (e.g. all fields are empty) then we'd need to do conditionally return an empty object rather than the nested object - and presumably raise an API bug for 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.
@tombuildsstuff Yep an empty object is exactly what's being returned. I'll raise an API bug today and adjust the logic so that an empty string is saved if the other attributes are present and non-zero.
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.
given this affects the entire block - presuming we're using intermediate variables, we should be able to conditionally check the set and conditionally return the nested object, e.g.:
(we've a few instances of this of late)
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.
Cool, makes sense. Have adjusted it to always set all attributes [in the block], but return an empty slice if they all have zero values.