Skip to content

Commit

Permalink
ENG-10012: (v2) Deprecate rewrite_on_violation, add enable_dataset_re…
Browse files Browse the repository at this point in the history
…writes (#310)

* Rename rewrite_on_violation -> enable_dataset_rewrites

* Update docs

* Deprecate instead of removing

* Fix docs
  • Loading branch information
Yowgf authored Nov 7, 2022
1 parent 46be090 commit 8f26910
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 12 deletions.
24 changes: 20 additions & 4 deletions cyral/resource_cyral_repository_conf_analysis.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,16 @@ type UserFacingConfig struct {
EnableDataMasking bool `json:"enableDataMasking"`
LogGroups []string `json:"logGroups,omitempty"`
Redact string `json:"redact"`
RewriteOnViolation bool `json:"rewriteOnViolation"`
RewriteOnViolation bool `json:"rewriteOnViolation,omitempty"`
EnableDatasetRewrites bool `json:"enableDatasetRewrites,omitempty"`
}

func resourceRepositoryConfAnalysis() *schema.Resource {
rewriteOnViolationDeprecationMessage := "This arguments only works for " +
"control plane versions up to `v2.34.x`. Please see " +
"`enable_dataset_rewrites` for a similar option for control " +
"plane versions greater or equal to `v2.35.x`."

return &schema.Resource{
Description: "Manages Repository Analysis Configuration. This resource allows configuring both " +
"[Log Settings](https://cyral.com/docs/manage-repositories/repo-log-volume) " +
Expand Down Expand Up @@ -88,9 +94,17 @@ func resourceRepositoryConfAnalysis() *schema.Resource {
Optional: true,
},
"rewrite_on_violation": {
Description: "If set to `true` it will enable rewriting queries on violations.",
Type: schema.TypeBool,
Optional: true,
Description: "If set to `true` it will enable rewriting queries on violations.",
Type: schema.TypeBool,
Optional: true,
Deprecated: rewriteOnViolationDeprecationMessage,
ConflictsWith: []string{"enable_dataset_rewrites"},
},
"enable_dataset_rewrites": {
Description: "If set to `true` it will enable rewriting queries.",
Type: schema.TypeBool,
Optional: true,
ConflictsWith: []string{"rewrite_on_violation"},
},
"comment_annotation_groups": {
Description: "Valid values are: `identity`, `client`, `repo`, `sidecar`. The " +
Expand Down Expand Up @@ -267,6 +281,7 @@ func getConfAnalysisDataFromResource(d *schema.ResourceData) (RepositoryConfAnal
LogGroups: logGroups,
Redact: d.Get("redact").(string),
RewriteOnViolation: d.Get("rewrite_on_violation").(bool),
EnableDatasetRewrites: d.Get("enable_dataset_rewrites").(bool),
},
}, nil
}
Expand All @@ -293,4 +308,5 @@ func setConfAnalysisDataToResource(d *schema.ResourceData, resourceData Reposito
d.Set("log_groups", logGroupsSet)
d.Set("redact", resourceData.Config.Redact)
d.Set("rewrite_on_violation", resourceData.Config.RewriteOnViolation)
d.Set("enable_dataset_rewrites", resourceData.Config.EnableDatasetRewrites)
}
6 changes: 3 additions & 3 deletions cyral/resource_cyral_repository_conf_analysis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func testAccRepoConfAnalysisCheck_DefaultValues() resource.TestCheckFunc {
resource.TestCheckResourceAttr("cyral_repository_conf_analysis.test_conf_analysis",
"redact", "all"),
resource.TestCheckResourceAttr("cyral_repository_conf_analysis.test_conf_analysis",
"rewrite_on_violation", "false"),
"enable_dataset_rewrites", "false"),
)
}

Expand All @@ -136,7 +136,7 @@ func testAccRepoConfAnalysisConfig_Updated() string {
disable_pre_configured_alerts = false
block_on_violation = true
disable_filter_analysis = false
rewrite_on_violation = true
enable_dataset_rewrites = true
enable_data_masking = true
comment_annotation_groups = [
"identity"
Expand Down Expand Up @@ -166,7 +166,7 @@ func testAccRepoConfAnalysisCheck_Updated() resource.TestCheckFunc {
resource.TestCheckResourceAttr("cyral_repository_conf_analysis.test_conf_analysis",
"enable_data_masking", "true"),
resource.TestCheckResourceAttr("cyral_repository_conf_analysis.test_conf_analysis",
"rewrite_on_violation", "true"),
"enable_dataset_rewrites", "true"),
resource.TestCheckResourceAttr("cyral_repository_conf_analysis.test_conf_analysis",
"comment_annotation_groups.#", "1"),
resource.TestCheckResourceAttr("cyral_repository_conf_analysis.test_conf_analysis",
Expand Down
7 changes: 4 additions & 3 deletions docs/resources/repository_conf_analysis.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ resource "cyral_repository_conf_analysis" "all_conf_analysis_enabled" {
disable_pre_configured_alerts = false
block_on_violation = true
disable_filter_analysis = false
rewrite_on_violation = true
enable_dataset_rewrites = true
enable_data_masking = true
comment_annotation_groups = [ "identity" ]
log_groups = [ "everything" ]
Expand All @@ -35,7 +35,7 @@ resource "cyral_repository_conf_analysis" "all_conf_analysis_disabled" {
disable_pre_configured_alerts = true
block_on_violation = false
disable_filter_analysis = true
rewrite_on_violation = false
enable_dataset_rewrites = false
enable_data_masking = false
comment_annotation_groups = []
log_groups = []
Expand All @@ -58,6 +58,7 @@ resource "cyral_repository_conf_analysis" "all_conf_analysis_disabled" {
- `disable_filter_analysis` (Boolean) If set to `true` it will _disable_ filter analysis.
- `disable_pre_configured_alerts` (Boolean) If set to `true` it will _disable_ preconfigured alerts.
- `enable_data_masking` (Boolean) If set to `true` it will allow policies to force the masking of specified data fields in the results of queries. [Learn more](https://cyral.com/docs/using-cyral/masking/).
- `enable_dataset_rewrites` (Boolean) If set to `true` it will enable rewriting queries.
- `log_groups` (Set of String) Responsible for configuring the Log Settings. Valid values are documented below. The `log_groups` list support the following values:
- `everything` - Enables all the Log Settings.
- `dql` - Enables the `DQLs` setting for `all requests`.
Expand All @@ -79,7 +80,7 @@ resource "cyral_repository_conf_analysis" "all_conf_analysis_disabled" {
- `new-connections` - Log new connections.
- `closed-connections` - Log closed connections.
- `redact` (String) Valid values are: `all`, `none` and `watched`. If set to `all` it will enable the redact of all literal values, `none` will disable it, and `watched` will only redact values from tracked fields set in the Datamap.
- `rewrite_on_violation` (Boolean) If set to `true` it will enable rewriting queries on violations.
- `rewrite_on_violation` (Boolean, Deprecated) If set to `true` it will enable rewriting queries on violations.

### Read-Only

Expand Down
4 changes: 2 additions & 2 deletions examples/resources/cyral_repository_conf_analysis/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ resource "cyral_repository_conf_analysis" "all_conf_analysis_enabled" {
disable_pre_configured_alerts = false
block_on_violation = true
disable_filter_analysis = false
rewrite_on_violation = true
enable_dataset_rewrites = true
enable_data_masking = true
comment_annotation_groups = [ "identity" ]
log_groups = [ "everything" ]
Expand All @@ -21,7 +21,7 @@ resource "cyral_repository_conf_analysis" "all_conf_analysis_disabled" {
disable_pre_configured_alerts = true
block_on_violation = false
disable_filter_analysis = true
rewrite_on_violation = false
enable_dataset_rewrites = false
enable_data_masking = false
comment_annotation_groups = []
log_groups = []
Expand Down

0 comments on commit 8f26910

Please sign in to comment.