-
Notifications
You must be signed in to change notification settings - Fork 3
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
ENG-12292: Add: SQL Server settings (version field) #438
Conversation
…s has one attribute: version. This is mandatory for listeners that are multiplexed.
…ngs and tls mode
…cific version (parent element is optional though). Added computed to the two optional elements "override repo client tls settings" and "tls mode" since these are populated by API if not provided.
…mode in listener data source
@@ -8,8 +8,9 @@ import ( | |||
"github.com/google/uuid" | |||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | |||
|
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.
nit: could you please delete this blank line so that all 3rd party imports are in the same block?
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.
fixed
ProxyModeKey = "proxy_mode" | ||
DynamoDbSettingsKey = "dynamodb_settings" | ||
SQLServerSettingsKey = "sqlserver_settings" | ||
VersionKey = "version" |
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.
How about (for clarity)?
VersionKey = "version" | |
SQLServerVersionKey = "version" |
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 took your suggestion. Thanks
) | ||
|
||
func tlsModes() []string { |
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.
bring this change in later (since it's not being planned for implementation right now)?
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.
thank you, leftover from refactor. Missed this one.
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.
Please add some tests to cover the ConflictsWith
controls.
…alidation. Updated setupSidecarListenerConfig method to support constructing faulty configurations (switch -> multiple if statements)
Addressed by d0576c6 |
dbVersion, charSet := "null", "null" | ||
if listener.MySQLSettings.CharacterSet != "" { | ||
charSet = fmt.Sprintf(`"%s"`, listener.MySQLSettings.CharacterSet) | ||
} | ||
if listener.MySQLSettings.DbVersion != "" { | ||
dbVersion = fmt.Sprintf(`"%s"`, listener.MySQLSettings.DbVersion) | ||
} | ||
settings = fmt.Sprintf( | ||
settings += fmt.Sprintf( |
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.
+
doesn't actually look required here, but shouldn't hurt to keep either.
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 is actually intentional in order to create an invalid configuration (conflicting settings)
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.
changes looks good to me, regarding what the API expects.
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.
Changes look good @gengdahlCyral, please consider my comment below regarding the ConflictsWith validation before we merge the PR, thanks
@@ -352,7 +378,7 @@ func getSidecarListenerSchema() map[string]*schema.Schema { | |||
Optional: true, | |||
// Notice the MaxItems: 1 here. This ensures that the user can only specify one this block. | |||
MaxItems: 1, | |||
ConflictsWith: []string{MySQLSettingsKey, DynamoDbSettingsKey}, | |||
ConflictsWith: []string{MySQLSettingsKey, DynamoDbSettingsKey, SQLServerSettingsKey}, |
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.
Should we also update the ConflictsWith
in DynamoDbSettingsKey
?
ConflictsWith: []string{S3SettingsKey, MySQLSettingsKey, SQLServerSettingsKey}
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, sorry. Fixed
"Note: If the query returns a four part version number, only the first three parts " + | ||
"should be used. Example: 16.0.1000.6 -> 16.0.1000", | ||
Type: schema.TypeString, | ||
Optional: false, |
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: false, |
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.
In API Sqlserver settings is optional, if provided though, it has to carry the version so I believe we want to align with that here.
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.
Sure, my intention here is just to point out that there's no need to specify Optional: false
- it can be omitted from the schema declaration, especially because we are already defining Required: 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.
ah, sorry I didn't get that at first :) Want me to remove and push or leave it be?
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.
@gengdahlCyral thats just a nit, so up to you! Let me know once we can merge the PR and I can help with that, changes look good to me.
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, I removed this line, it's a bit confusing to have optional and required mixed (and not really valid when I read the docs).
Feel free to merge. @VictorGFM
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Note! Crud
v5.9.0
has the API additions for which this TF PR is targeted.Description of the change
The background to the changes made in the Cyral Terraform Provider is the updated listener API
{{baseUrl}}/sidecars/:sidecarID/listeners
.This API has been extended with a complex attribute (similar to the mysql settings attribute):
The SQL server settings is applicable for listeners associated with SQL server repo type only, and is only relevant for listeners that are multiplexed.
Version is the version the sidecar will advertise in PRELOGIN MESSAGE to the client connecting.
Short description of changes in this PR:
This PR introduces changes to the Makefile, cyral/data_source_cyral_sidecar_listener.go,
In the Makefile, an up-deps target has been added to update module and test dependencies to the latest minor and patch levels.
In cyral/data_source_cyral_sidecar_listener.go, SQL Server settings have been added to the SidecarListener struct. This includes a new SQLServerSettings struct, methods to convert to and from interface representations, and relevant constants.
In cyral/resource_cyral_sidecar_listener.go, the SidecarListener struct has been expanded to include SQL Server settings similar to other data repository settings. Additionally, SQL Server settings methods for interface conversion have been added. The schema definition for SQL Server settings has also been included in the getSidecarListenerSchema function.
In cyral/resource_cyral_sidecar_listener_test.go, a test step has been added to cover SQL Server settings.
Documentation files (docs/data-sources/sidecar_listener.md and docs/resources/sidecar_listener.md) have been generated from updated code.
Type of change
Checklists
Development
Code review
Testing
Using Helm CP running updated crud