-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
* fix: fix gcr limit_by_labels field
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,22 +9,40 @@ terraform { | |
provider "lacework" {} | ||
|
||
resource "lacework_integration_gcr" "example" { | ||
name = "GRC Example" | ||
name = var.integration_name | ||
registry_domain = "gcr.io" | ||
non_os_package_support = true | ||
credentials { | ||
client_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" | ||
private_key_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" | ||
client_email = "[email protected]" | ||
private_key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" | ||
client_id = var.client_id | ||
private_key_id = var.private_key_id | ||
client_email = var.client_email | ||
private_key = var.private_key | ||
} | ||
|
||
limit_num_imgs = 10 | ||
limit_by_tags = ["dev*", "*test"] | ||
limit_by_repositories = ["my-repo", "other-repo"] | ||
|
||
limit_by_labels = { | ||
key1 = "label1" | ||
key2 = "label2" | ||
foo = "bar" | ||
} | ||
} | ||
|
||
variable "integration_name" { | ||
type = string | ||
default = "Google Container Registry Example" | ||
} | ||
variable "client_id" { | ||
type = string | ||
} | ||
variable "client_email" { | ||
type = string | ||
} | ||
variable "private_key_id" { | ||
type = string | ||
} | ||
variable "private_key" { | ||
type = string | ||
sensitive = true | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package integration | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/gruntwork-io/terratest/modules/terraform" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
// TestIntegrationGCRCreate applies integration terraform: | ||
// => '../examples/resource_lacework_integration_gcr' | ||
// | ||
// It uses the go-sdk to verify the created integration, | ||
// applies an update with new integration name and destroys it | ||
func TestIntegrationGCRCreate(t *testing.T) { | ||
gcreds, err := googleLoadDefaultCredentials() | ||
if assert.Nil(t, err, "this test requires you to set GOOGLE_CREDENTIALS environment variable") { | ||
terraformOptions := terraform.WithDefaultRetryableErrors(t, &terraform.Options{ | ||
TerraformDir: "../examples/resource_lacework_integration_gcr", | ||
Vars: map[string]interface{}{ | ||
"client_id": gcreds.ClientID, | ||
"client_email": gcreds.ClientEmail, | ||
"private_key_id": gcreds.PrivateKeyID, | ||
}, | ||
EnvVars: map[string]string{ | ||
"TF_VAR_private_key": gcreds.PrivateKey, | ||
"LW_API_TOKEN": LwApiToken, | ||
}, | ||
}) | ||
defer terraform.Destroy(t, terraformOptions) | ||
|
||
// Create new Google Container Registry | ||
create := terraform.InitAndApplyAndIdempotent(t, terraformOptions) | ||
createData := GetContainerRegisteryGcr(create) | ||
assert.Equal(t, "Google Container Registry Example", createData.Data.Name) | ||
assert.Equal(t, []map[string]string{{"foo": "bar"}}, createData.Data.Data.LimitByLabel) | ||
|
||
// Update Google Container Registry | ||
terraformOptions.Vars["integration_name"] = "Google Container Registry Updated" | ||
|
||
update := terraform.ApplyAndIdempotent(t, terraformOptions) | ||
updateData := GetContainerRegistryIntegration(update) | ||
assert.Equal(t, "Google Container Registry Updated", updateData.Name) | ||
assert.Equal(t, []map[string]string{{"foo": "bar"}}, createData.Data.Data.LimitByLabel) | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.