-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from mineiros-io/integration
integration: add support to manage secrets
- Loading branch information
Showing
9 changed files
with
164 additions
and
2 deletions.
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
# CREATE A REPOSITORY WITH A SECRET | ||
# This example will create a repository with a secret and some basic settings. | ||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
# --------------------------------------------------------------------------------------------------------------------- | ||
# TEST | ||
# We are creating a repository with a single secret while specifying only the minimum required variables | ||
# --------------------------------------------------------------------------------------------------------------------- | ||
|
||
module "repository" { | ||
source = "../.." | ||
|
||
name = var.name | ||
|
||
plaintext_secrets = { | ||
(var.secret_name) = var.secret_text | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
output "repository" { | ||
description = "All outputs of the created repository." | ||
value = module.repository | ||
} | ||
|
||
output "repository_name" { | ||
description = "The full name of the created repository." | ||
value = module.repository.full_name | ||
} | ||
|
||
output "secret_name" { | ||
description = "The name of the secret." | ||
value = module.repository.secrets[0] | ||
} |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# --------------------------------------------------------------------------------------------------------------------- | ||
# ENVIRONMENT VARIABLES | ||
# Define these secrets as environment variables. | ||
# --------------------------------------------------------------------------------------------------------------------- | ||
|
||
# GITHUB_ORGANIZATION | ||
# GITHUB_TOKEN | ||
|
||
# --------------------------------------------------------------------------------------------------------------------- | ||
# REQUIRED VARIABLES | ||
# These variables must be set when using this module. | ||
# --------------------------------------------------------------------------------------------------------------------- | ||
|
||
# --------------------------------------------------------------------------------------------------------------------- | ||
# OPTIONAL VARIABLES | ||
# These variables have defaults, but may be overridden. | ||
# --------------------------------------------------------------------------------------------------------------------- | ||
|
||
variable "name" { | ||
description = "The name of the created repository." | ||
type = string | ||
default = "test-public-repository-with-secrets" | ||
} | ||
|
||
variable "secret_name" { | ||
description = "The name of the secret." | ||
type = string | ||
default = "MYSECRET" | ||
} | ||
|
||
variable "secret_text" { | ||
description = "Secret value in plain text." | ||
type = string | ||
default = "42" | ||
} |
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package test | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/gruntwork-io/terratest/modules/random" | ||
"github.com/gruntwork-io/terratest/modules/terraform" | ||
) | ||
|
||
func TestGithubPublicRepositoryWithSecret(t *testing.T) { | ||
t.Parallel() | ||
|
||
// Set the name for the repository this test should create | ||
expectedRepositoryName := fmt.Sprintf("test-public-repository-with-secret-%s", random.UniqueId()) | ||
|
||
// Set config settings for the secret this test should create | ||
expectedSecretName := "MYSECRET" | ||
expectedSecretValue := "42" | ||
|
||
terraformOptions := &terraform.Options{ | ||
// The path to where your Terraform code is located | ||
TerraformDir: "public-repository-with-secret", | ||
Upgrade: true, | ||
Vars: map[string]interface{}{ | ||
"name": expectedRepositoryName, | ||
"secret_name": expectedSecretName, | ||
"secret_text": expectedSecretValue, | ||
}, | ||
} | ||
|
||
// At the end of the test, run `terraform destroy` to clean up any resources that were created | ||
defer terraform.Destroy(t, terraformOptions) | ||
|
||
// This will run `terraform init` and `terraform apply` and fail the test if there are any errors | ||
terraform.InitAndApply(t, terraformOptions) | ||
|
||
} |
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