Skip to content

Commit 7d15d1b

Browse files
authored
Merge branch 'main' into github-organization-repositories
2 parents af5cc7f + 94f71cf commit 7d15d1b

File tree

43 files changed

+1807
-531
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1807
-531
lines changed

github/data_source_github_actions_environment_secrets_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ func TestAccGithubActionsEnvironmentSecretsDataSource(t *testing.T) {
2424
}
2525
2626
resource "github_actions_environment_secret" "test" {
27-
repository = github_repository.test.name
28-
environment = github_repository_environment.test.environment
29-
secret_name = "secret_1"
30-
plaintext_value = "foo"
27+
repository = github_repository.test.name
28+
environment = github_repository_environment.test.environment
29+
secret_name = "secret_1"
30+
value = "foo"
3131
}
3232
`, repoName)
3333

github/data_source_github_actions_organization_secrets_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ func TestAccGithubActionsOrganizationSecretsDataSource(t *testing.T) {
1515

1616
config := fmt.Sprintf(`
1717
resource "github_actions_organization_secret" "test" {
18-
secret_name = "org_secret_1_%s"
19-
plaintext_value = "foo"
20-
visibility = "all" # going with all as it does not require a paid subscrption
18+
secret_name = "org_secret_1_%s"
19+
value = "foo"
20+
visibility = "all" # going with all as it does not require a paid subscrption
2121
}
2222
`, randomID)
2323

github/data_source_github_actions_secrets_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ func TestAccGithubActionsSecretsDataSource(t *testing.T) {
2020
}
2121
2222
resource "github_actions_secret" "test" {
23-
secret_name = "secret_1"
24-
repository = github_repository.test.name
25-
plaintext_value = "foo"
23+
secret_name = "secret_1"
24+
repository = github_repository.test.name
25+
value = "foo"
2626
}
2727
`, repoName)
2828

github/data_source_github_dependabot_organization_secrets_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ func TestAccGithubDependabotOrganizationSecretsDataSource(t *testing.T) {
1515

1616
config := fmt.Sprintf(`
1717
resource "github_dependabot_organization_secret" "test" {
18-
secret_name = "org_dep_secret_1_%s"
19-
plaintext_value = "foo"
20-
visibility = "private"
18+
secret_name = "org_dep_secret_1_%s"
19+
value = "foo"
20+
visibility = "private"
2121
}
2222
`, randomID)
2323

github/data_source_github_dependabot_secrets_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ func TestAccGithubDependabotSecretsDataSource(t *testing.T) {
2020
}
2121
2222
resource "github_dependabot_secret" "test" {
23-
secret_name = "dep_secret_1"
24-
repository = github_repository.test.name
25-
plaintext_value = "foo"
23+
secret_name = "dep_secret_1"
24+
repository = github_repository.test.name
25+
value = "foo"
2626
}
2727
`, repoName)
2828

github/resource_github_actions_environment_secret.go

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,22 +54,41 @@ func resourceGithubActionsEnvironmentSecret() *schema.Resource {
5454
Type: schema.TypeString,
5555
Optional: true,
5656
Computed: true,
57-
ConflictsWith: []string{"plaintext_value"},
57+
RequiredWith: []string{"value_encrypted"},
58+
ConflictsWith: []string{"value", "plaintext_value"},
5859
Description: "ID of the public key used to encrypt the secret.",
5960
},
61+
"value": {
62+
Type: schema.TypeString,
63+
Optional: true,
64+
Sensitive: true,
65+
ExactlyOneOf: []string{"value", "value_encrypted", "encrypted_value", "plaintext_value"},
66+
Description: "Plaintext value to be encrypted.",
67+
},
68+
"value_encrypted": {
69+
Type: schema.TypeString,
70+
Optional: true,
71+
Sensitive: true,
72+
ExactlyOneOf: []string{"value", "value_encrypted", "encrypted_value", "plaintext_value"},
73+
ValidateDiagFunc: validation.ToDiagFunc(validation.StringIsBase64),
74+
Description: "Value encrypted with the GitHub public key, defined by key_id, in Base64 format.",
75+
},
6076
"encrypted_value": {
6177
Type: schema.TypeString,
6278
Optional: true,
63-
ExactlyOneOf: []string{"encrypted_value", "plaintext_value"},
79+
Sensitive: true,
80+
ExactlyOneOf: []string{"value", "value_encrypted", "encrypted_value", "plaintext_value"},
6481
ValidateDiagFunc: validation.ToDiagFunc(validation.StringIsBase64),
6582
Description: "Encrypted value of the secret using the GitHub public key in Base64 format.",
83+
Deprecated: "Use value_encrypted and key_id.",
6684
},
6785
"plaintext_value": {
6886
Type: schema.TypeString,
6987
Optional: true,
7088
Sensitive: true,
71-
ExactlyOneOf: []string{"encrypted_value", "plaintext_value"},
89+
ExactlyOneOf: []string{"value", "value_encrypted", "encrypted_value", "plaintext_value"},
7290
Description: "Plaintext value of the secret to be encrypted.",
91+
Deprecated: "Use value.",
7392
},
7493
"created_at": {
7594
Type: schema.TypeString,
@@ -112,7 +131,7 @@ func resourceGithubActionsEnvironmentSecretCreate(ctx context.Context, d *schema
112131
envName := d.Get("environment").(string)
113132
secretName := d.Get("secret_name").(string)
114133
keyID := d.Get("key_id").(string)
115-
encryptedValue := d.Get("encrypted_value").(string)
134+
encryptedValue, _ := resourceKeysGetOk[string](d, "value_encrypted", "encrypted_value")
116135

117136
escapedEnvName := url.PathEscape(envName)
118137

@@ -134,7 +153,7 @@ func resourceGithubActionsEnvironmentSecretCreate(ctx context.Context, d *schema
134153
}
135154

136155
if len(encryptedValue) == 0 {
137-
plaintextValue := d.Get("plaintext_value").(string)
156+
plaintextValue, _ := resourceKeysGetOk[string](d, "value", "plaintext_value")
138157

139158
encryptedBytes, err := encryptPlaintext(plaintextValue, publicKey)
140159
if err != nil {
@@ -239,7 +258,7 @@ func resourceGithubActionsEnvironmentSecretUpdate(ctx context.Context, d *schema
239258
envName := d.Get("environment").(string)
240259
secretName := d.Get("secret_name").(string)
241260
keyID := d.Get("key_id").(string)
242-
encryptedValue := d.Get("encrypted_value").(string)
261+
encryptedValue, _ := resourceKeysGetOk[string](d, "value_encrypted", "encrypted_value")
243262

244263
escapedEnvName := url.PathEscape(envName)
245264

@@ -255,7 +274,7 @@ func resourceGithubActionsEnvironmentSecretUpdate(ctx context.Context, d *schema
255274
}
256275

257276
if len(encryptedValue) == 0 {
258-
plaintextValue := d.Get("plaintext_value").(string)
277+
plaintextValue, _ := resourceKeysGetOk[string](d, "value", "plaintext_value")
259278

260279
encryptedBytes, err := encryptPlaintext(plaintextValue, publicKey)
261280
if err != nil {

github/resource_github_actions_environment_secret_migration_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@ package github
2020
// {
2121
// testName: "migrates v0 to v1",
2222
// rawState: map[string]any{
23-
// "id": "my-repo:my-environment:MY_SECRET",
24-
// "repository": "my-repo",
25-
// "environment": "my-environment",
26-
// "secret_name": "MY_SECRET",
27-
// "value": "my-value",
23+
// "id": "my-repo:my-environment:MY_SECRET",
24+
// "repository": "my-repo",
25+
// "environment": "my-environment",
26+
// "secret_name": "MY_SECRET",
27+
// "plaintext_value": "my-value",
2828
// },
2929
// want: map[string]any{
30-
// "id": "my-repo:my-environment:MY_SECRET",
31-
// "repository": "my-repo",
32-
// "repository_id": 123456,
33-
// "environment": "my-environment",
34-
// "secret_name": "MY_SECRET",
35-
// "value": "my-value",
30+
// "id": "my-repo:my-environment:MY_SECRET",
31+
// "repository": "my-repo",
32+
// "repository_id": 123456,
33+
// "environment": "my-environment",
34+
// "secret_name": "MY_SECRET",
35+
// "plaintext_value": "my-value",
3636
// },
3737
// shouldError: false,
3838
// },

0 commit comments

Comments
 (0)