Skip to content

Commit

Permalink
inspect_template_name changed from required to optional (GoogleCloudP…
Browse files Browse the repository at this point in the history
…latform#8036)

* inspect_template_name changed to optional from required

* changed random string func and config in test
  • Loading branch information
JayS-crest authored and ericayyliu committed Jul 26, 2023
1 parent 87d10f9 commit e670a2e
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 1 deletion.
1 change: 0 additions & 1 deletion mmv1/products/dlp/JobTrigger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ properties:
- !ruby/object:Api::Type::String
name: 'inspectTemplateName'
description: The name of the template to run when this job is triggered.
required: true
- !ruby/object:Api::Type::NestedObject
name: 'inspectConfig'
description: The core content of the template.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,50 @@ func TestAccDataLossPreventionJobTrigger_dlpJobTriggerActionsOptionalExample(t *
})
}

func TestAccDataLossPreventionJobTrigger_dlpJobTriggerInspectOptionalExample(t *testing.T) {
t.Parallel()

context := map[string]interface{}{
"project": acctest.GetTestProjectFromEnv(),
"random_suffix": RandString(t, 10),
}

VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckDataLossPreventionJobTriggerDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccDataLossPreventionJobTrigger_dlpJobTriggerInspectOptionalBasic(context),
},
{
ResourceName: "google_data_loss_prevention_job_trigger.basic",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"parent"},
},
{
Config: testAccDataLossPreventionJobTrigger_dlpJobTriggerBasic(context),
},
{
ResourceName: "google_data_loss_prevention_job_trigger.basic",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"parent"},
},
{
Config: testAccDataLossPreventionJobTrigger_dlpJobTriggerInspectOptionalBasic(context),
},
{
ResourceName: "google_data_loss_prevention_job_trigger.basic",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"parent"},
},
},
})
}

func testAccDataLossPreventionJobTrigger_dlpJobTriggerBasic(context map[string]interface{}) string {
return Nprintf(`
resource "google_data_loss_prevention_job_trigger" "basic" {
Expand Down Expand Up @@ -2271,3 +2315,39 @@ resource "google_data_loss_prevention_job_trigger" "basic" {
}
`, context)
}

func testAccDataLossPreventionJobTrigger_dlpJobTriggerInspectOptionalBasic(context map[string]interface{}) string {
return Nprintf(`
resource "google_data_loss_prevention_job_trigger" "basic" {
parent = "projects/%{project}"
description = "Starting description"
display_name = "display"
triggers {
schedule {
recurrence_period_duration = "86400s"
}
}
inspect_job {
actions {
save_findings {
output_config {
table {
project_id = "project"
dataset_id = "dataset123"
}
}
}
}
storage_config {
cloud_storage_options {
file_set {
url = "gs://mybucket/directory/"
}
}
}
}
}
`, context)
}

0 comments on commit e670a2e

Please sign in to comment.