Skip to content

Commit 622a6ec

Browse files
Merge branch 'integrations:main' into repository-page-visibility
2 parents cd7bb22 + 15fff78 commit 622a6ec

72 files changed

Lines changed: 3139 additions & 1803 deletions

File tree

Some content is hidden

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

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
cache: true
4242

4343
- name: Install Syft
44-
uses: anchore/sbom-action/download-syft@a930d0ac434e3182448fe678398ba5713717112a # v0.21.0
44+
uses: anchore/sbom-action/download-syft@0b82b0b1a22399a1c542d4d656f70cd903571b5c # v0.21.1
4545

4646
- name: Install Cosign
4747
uses: sigstore/cosign-installer@faadad0cce49287aee09b3a48701e75088a2c6ad # v4.0.0

CONTRIBUTING.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@ If a full debugger is desired, VSCode may be used. In order to do so,
7878

7979
```json
8080
{
81-
"name": "Attach to Process",
82-
"type": "go",
83-
"request": "attach",
84-
"mode": "local",
85-
"processId": 0,
81+
"name": "Attach to Process",
82+
"type": "go",
83+
"request": "attach",
84+
"mode": "local",
85+
"processId": 0,
8686
}
8787
```
8888

@@ -165,7 +165,7 @@ export GITHUB_TOKEN=
165165
# Configure user level values
166166
export GH_TEST_USER_REPOSITORY=
167167

168-
# Configure for the org under test
168+
# Configure values for the organization under test
169169
export GH_TEST_ORG_USER=
170170
export GH_TEST_ORG_SECRET_NAME=
171171
export GH_TEST_ORG_REPOSITORY=
@@ -177,6 +177,9 @@ export GH_TEST_EXTERNAL_USER=
177177
export GH_TEST_EXTERNAL_USER_TOKEN=
178178
export GH_TEST_EXTERNAL_USER2=
179179

180+
# Configure values for the enterprise under test
181+
export GH_TEST_ENTERPRISE_EMU_GROUP_ID=
182+
180183
# Configure test options
181184
export GH_TEST_ADVANCED_SECURITY=
182185
```

github/acc_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ type testAccConfig struct {
6868
testExternalUserToken string
6969
testExternalUser2 string
7070

71+
// Enterprise test configuration
72+
testEnterpriseEMUGroupId int
73+
7174
// Test options
7275
testAdvancedSecurity bool
7376
}
@@ -149,6 +152,11 @@ func TestMain(m *testing.M) {
149152
fmt.Println("GITHUB_ENTERPRISE_SLUG environment variable not set")
150153
os.Exit(1)
151154
}
155+
156+
i, err := strconv.Atoi(os.Getenv("GH_TEST_ENTERPRISE_EMU_GROUP_ID"))
157+
if err == nil {
158+
config.testEnterpriseEMUGroupId = i
159+
}
152160
}
153161

154162
i, err := strconv.Atoi(os.Getenv("GH_TEST_ORG_APP_INSTALLATION_ID"))

github/data_source_github_actions_environment_public_key.go

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ import (
44
"context"
55
"net/url"
66

7+
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
78
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
89
)
910

1011
func dataSourceGithubActionsEnvironmentPublicKey() *schema.Resource {
1112
return &schema.Resource{
12-
Read: dataSourceGithubActionsEnvironmentPublicKeyRead,
13+
ReadContext: dataSourceGithubActionsEnvironmentPublicKeyRead,
1314

1415
Schema: map[string]*schema.Schema{
1516
"repository": {
@@ -32,33 +33,29 @@ func dataSourceGithubActionsEnvironmentPublicKey() *schema.Resource {
3233
}
3334
}
3435

35-
func dataSourceGithubActionsEnvironmentPublicKeyRead(d *schema.ResourceData, meta any) error {
36-
ctx := context.Background()
36+
func dataSourceGithubActionsEnvironmentPublicKeyRead(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
3737
client := meta.(*Owner).v3client
3838
owner := meta.(*Owner).name
3939
repository := d.Get("repository").(string)
4040

4141
envName := d.Get("environment").(string)
42-
escapedEnvName := url.PathEscape(envName)
4342

4443
repo, _, err := client.Repositories.Get(ctx, owner, repository)
4544
if err != nil {
46-
return err
45+
return diag.FromErr(err)
4746
}
4847

49-
publicKey, _, err := client.Actions.GetEnvPublicKey(ctx, int(repo.GetID()), escapedEnvName)
48+
publicKey, _, err := client.Actions.GetEnvPublicKey(ctx, int(repo.GetID()), url.PathEscape(envName))
5049
if err != nil {
51-
return err
50+
return diag.FromErr(err)
5251
}
5352

5453
d.SetId(publicKey.GetKeyID())
55-
err = d.Set("key_id", publicKey.GetKeyID())
56-
if err != nil {
57-
return err
54+
if err := d.Set("key_id", publicKey.GetKeyID()); err != nil {
55+
return diag.FromErr(err)
5856
}
59-
err = d.Set("key", publicKey.GetKey())
60-
if err != nil {
61-
return err
57+
if err := d.Set("key", publicKey.GetKey()); err != nil {
58+
return diag.FromErr(err)
6259
}
6360

6461
return nil

github/data_source_github_actions_environment_secrets.go

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ package github
22

33
import (
44
"context"
5-
"fmt"
65
"net/url"
76

87
"github.com/google/go-github/v81/github"
98

9+
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
1010
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1111
)
1212

1313
func dataSourceGithubActionsEnvironmentSecrets() *schema.Resource {
1414
return &schema.Resource{
15-
Read: dataSourceGithubActionsEnvironmentSecretsRead,
15+
ReadContext: dataSourceGithubActionsEnvironmentSecretsRead,
1616

1717
Schema: map[string]*schema.Schema{
1818
"full_name": {
@@ -55,20 +55,18 @@ func dataSourceGithubActionsEnvironmentSecrets() *schema.Resource {
5555
}
5656
}
5757

58-
func dataSourceGithubActionsEnvironmentSecretsRead(d *schema.ResourceData, meta any) error {
59-
ctx := context.Background()
58+
func dataSourceGithubActionsEnvironmentSecretsRead(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
6059
client := meta.(*Owner).v3client
6160
owner := meta.(*Owner).name
6261
var repoName string
6362

6463
envName := d.Get("environment").(string)
65-
escapedEnvName := url.PathEscape(envName)
6664

6765
if fullName, ok := d.GetOk("full_name"); ok {
6866
var err error
6967
owner, repoName, err = splitRepoFullName(fullName.(string))
7068
if err != nil {
71-
return err
69+
return diag.FromErr(err)
7270
}
7371
}
7472

@@ -77,23 +75,23 @@ func dataSourceGithubActionsEnvironmentSecretsRead(d *schema.ResourceData, meta
7775
}
7876

7977
if repoName == "" {
80-
return fmt.Errorf("one of %q or %q has to be provided", "full_name", "name")
78+
return diag.Errorf("one of %q or %q has to be provided", "full_name", "name")
8179
}
8280

8381
repo, _, err := client.Repositories.Get(ctx, owner, repoName)
8482
if err != nil {
85-
return err
83+
return diag.FromErr(err)
8684
}
8785

8886
options := github.ListOptions{
89-
PerPage: 100,
87+
PerPage: maxPerPage,
9088
}
9189

9290
var all_secrets []map[string]string
9391
for {
94-
secrets, resp, err := client.Actions.ListEnvSecrets(ctx, int(repo.GetID()), escapedEnvName, &options)
92+
secrets, resp, err := client.Actions.ListEnvSecrets(ctx, int(repo.GetID()), url.PathEscape(envName), &options)
9593
if err != nil {
96-
return err
94+
return diag.FromErr(err)
9795
}
9896
for _, secret := range secrets.Secrets {
9997
new_secret := map[string]string{
@@ -109,8 +107,15 @@ func dataSourceGithubActionsEnvironmentSecretsRead(d *schema.ResourceData, meta
109107
options.Page = resp.NextPage
110108
}
111109

112-
d.SetId(buildTwoPartID(repoName, envName))
113-
_ = d.Set("secrets", all_secrets)
110+
if id, err := buildID(repoName, escapeIDPart(envName)); err != nil {
111+
return diag.FromErr(err)
112+
} else {
113+
d.SetId(id)
114+
}
115+
116+
if err := d.Set("secrets", all_secrets); err != nil {
117+
return diag.FromErr(err)
118+
}
114119

115120
return nil
116121
}

github/data_source_github_actions_environment_secrets_test.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,18 @@ func TestAccGithubActionsEnvironmentSecretsDataSource(t *testing.T) {
1515

1616
config := fmt.Sprintf(`
1717
resource "github_repository" "test" {
18-
name = "%s"
19-
auto_init = true
18+
name = "%s"
2019
}
2120
2221
resource "github_repository_environment" "test" {
23-
repository = github_repository.test.name
24-
environment = "environment / test"
22+
repository = github_repository.test.name
23+
environment = "environment / test"
2524
}
2625
2726
resource "github_actions_environment_secret" "test" {
28-
secret_name = "secret_1"
29-
environment = github_repository_environment.test.environment
30-
repository = github_repository.test.name
27+
repository = github_repository.test.name
28+
environment = github_repository_environment.test.environment
29+
secret_name = "secret_1"
3130
plaintext_value = "foo"
3231
}
3332
`, repoName)

github/data_source_github_actions_environment_variables.go

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ package github
22

33
import (
44
"context"
5-
"fmt"
65
"net/url"
76

87
"github.com/google/go-github/v81/github"
98

9+
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
1010
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1111
)
1212

1313
func dataSourceGithubActionsEnvironmentVariables() *schema.Resource {
1414
return &schema.Resource{
15-
Read: dataSourceGithubActionsEnvironmentVariablesRead,
15+
ReadContext: dataSourceGithubActionsEnvironmentVariablesRead,
1616

1717
Schema: map[string]*schema.Schema{
1818
"full_name": {
@@ -59,20 +59,18 @@ func dataSourceGithubActionsEnvironmentVariables() *schema.Resource {
5959
}
6060
}
6161

62-
func dataSourceGithubActionsEnvironmentVariablesRead(d *schema.ResourceData, meta any) error {
63-
ctx := context.Background()
62+
func dataSourceGithubActionsEnvironmentVariablesRead(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
6463
client := meta.(*Owner).v3client
6564
owner := meta.(*Owner).name
6665
var repoName string
6766

6867
envName := d.Get("environment").(string)
69-
escapedEnvName := url.PathEscape(envName)
7068

7169
if fullName, ok := d.GetOk("full_name"); ok {
7270
var err error
7371
owner, repoName, err = splitRepoFullName(fullName.(string))
7472
if err != nil {
75-
return err
73+
return diag.FromErr(err)
7674
}
7775
}
7876

@@ -81,18 +79,18 @@ func dataSourceGithubActionsEnvironmentVariablesRead(d *schema.ResourceData, met
8179
}
8280

8381
if repoName == "" {
84-
return fmt.Errorf("one of %q or %q has to be provided", "full_name", "name")
82+
return diag.Errorf("one of %q or %q has to be provided", "full_name", "name")
8583
}
8684

8785
options := github.ListOptions{
88-
PerPage: 100,
86+
PerPage: maxPerPage,
8987
}
9088

9189
var all_variables []map[string]string
9290
for {
93-
variables, resp, err := client.Actions.ListEnvVariables(ctx, owner, repoName, escapedEnvName, &options)
91+
variables, resp, err := client.Actions.ListEnvVariables(ctx, owner, repoName, url.PathEscape(envName), &options)
9492
if err != nil {
95-
return err
93+
return diag.FromErr(err)
9694
}
9795
for _, variable := range variables.Variables {
9896
new_variable := map[string]string{
@@ -109,8 +107,15 @@ func dataSourceGithubActionsEnvironmentVariablesRead(d *schema.ResourceData, met
109107
options.Page = resp.NextPage
110108
}
111109

112-
d.SetId(buildTwoPartID(repoName, envName))
113-
_ = d.Set("variables", all_variables)
110+
if id, err := buildID(repoName, escapeIDPart(envName)); err != nil {
111+
return diag.FromErr(err)
112+
} else {
113+
d.SetId(id)
114+
}
115+
116+
if err := d.Set("variables", all_variables); err != nil {
117+
return diag.FromErr(err)
118+
}
114119

115120
return nil
116121
}

0 commit comments

Comments
 (0)