Skip to content

Commit 7daaf0e

Browse files
authored
Merge branch 'main' into main
2 parents 5b248b8 + c99f24e commit 7daaf0e

File tree

122 files changed

+13313
-2544
lines changed

Some content is hidden

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

122 files changed

+13313
-2544
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
GITHUB_TEST_ORGANIZATION: 'kfcampbell-terraform-provider'
1313
steps:
1414
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
15-
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
15+
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
1616
with:
1717
go-version-file: 'go.mod'
1818
cache: true

.github/workflows/codeql.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,21 @@ jobs:
2727
- name: Checkout repository
2828
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2929

30-
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
30+
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
3131
with:
3232
go-version-file: 'go.mod'
3333
cache: true
3434

3535
# Initializes the CodeQL tools for scanning.
3636
- name: Initialize CodeQL
37-
uses: github/codeql-action/init@f09c1c0a94de965c15400f5634aa42fac8fb8f88 # v3.27.5
37+
uses: github/codeql-action/init@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3.28.0
3838
with:
3939
languages: ${{ matrix.language }}
4040

4141
- name: Autobuild
42-
uses: github/codeql-action/autobuild@f09c1c0a94de965c15400f5634aa42fac8fb8f88 # v3.27.5
42+
uses: github/codeql-action/autobuild@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3.28.0
4343

4444
- name: Perform CodeQL Analysis
45-
uses: github/codeql-action/analyze@f09c1c0a94de965c15400f5634aa42fac8fb8f88 # v3.27.5
45+
uses: github/codeql-action/analyze@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3.28.0
4646
with:
4747
category: "/language:${{matrix.language}}"

.github/workflows/dotcom-acceptance-tests-all.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
with:
2121
ref: ${{ github.event.pull_request.head.ref }}
2222
fetch-depth: 2
23-
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
23+
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
2424
with:
2525
go-version-file: 'go.mod'
2626
cache: true
@@ -38,7 +38,7 @@ jobs:
3838
with:
3939
ref: ${{ github.event.pull_request.head.ref }}
4040
fetch-depth: 2
41-
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
41+
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
4242
with:
4343
go-version-file: 'go.mod'
4444
cache: true
@@ -71,7 +71,7 @@ jobs:
7171
with:
7272
ref: ${{ github.event.pull_request.head.ref }}
7373
fetch-depth: 2
74-
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
74+
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
7575
with:
7676
go-version-file: 'go.mod'
7777
cache: true

.github/workflows/dotcom-acceptance-tests-manual.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2121
with:
2222
ref: ${{ github.event.pull_request.head.sha }}
23-
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
23+
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
2424
with:
2525
go-version-file: 'go.mod'
2626
cache: true
@@ -52,7 +52,7 @@ jobs:
5252
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
5353
with:
5454
ref: ${{ github.event.pull_request.head.sha }}
55-
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
55+
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
5656
with:
5757
go-version-file: 'go.mod'
5858
cache: true
@@ -89,7 +89,7 @@ jobs:
8989
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
9090
with:
9191
ref: ${{ github.event.pull_request.head.sha }}
92-
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
92+
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
9393
with:
9494
go-version-file: 'go.mod'
9595
cache: true

.github/workflows/dotcom-acceptance-tests.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
with:
2929
ref: ${{ github.event.pull_request.head.ref }}
3030
fetch-depth: 2
31-
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
31+
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
3232
with:
3333
go-version-file: 'go.mod'
3434
cache: true
@@ -48,7 +48,7 @@ jobs:
4848
with:
4949
ref: ${{ github.event.pull_request.head.ref }}
5050
fetch-depth: 2
51-
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
51+
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
5252
with:
5353
go-version-file: 'go.mod'
5454
cache: true

.github/workflows/ghes-acceptance-tests-all.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
with:
3333
ref: ${{ github.event.pull_request.head.ref }}
3434
fetch-depth: 2
35-
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
35+
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
3636
with:
3737
go-version-file: 'go.mod'
3838
cache: true
@@ -51,7 +51,7 @@ jobs:
5151
with:
5252
ref: ${{ github.event.pull_request.head.ref }}
5353
fetch-depth: 2
54-
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
54+
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
5555
with:
5656
go-version-file: 'go.mod'
5757
cache: true
@@ -86,7 +86,7 @@ jobs:
8686
with:
8787
ref: ${{ github.event.pull_request.head.ref }}
8888
fetch-depth: 2
89-
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
89+
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
9090
with:
9191
go-version-file: 'go.mod'
9292
cache: true

.github/workflows/ghes-acceptance-tests.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
with:
2828
ref: ${{ github.event.pull_request.head.ref }}
2929
fetch-depth: 2
30-
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
30+
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
3131
with:
3232
go-version-file: 'go.mod'
3333
cache: true
@@ -46,7 +46,7 @@ jobs:
4646
with:
4747
ref: ${{ github.event.pull_request.head.ref }}
4848
fetch-depth: 2
49-
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
49+
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
5050
with:
5151
go-version-file: 'go.mod'
5252
cache: true
@@ -67,7 +67,7 @@ jobs:
6767
with:
6868
ref: ${{ github.event.pull_request.head.ref }}
6969
fetch-depth: 2
70-
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
70+
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
7171
with:
7272
go-version-file: 'go.mod'
7373
cache: true

.github/workflows/release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
# Allow goreleaser to access older tag information.
2323
fetch-depth: 0
2424

25-
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
25+
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
2626
with:
2727
go-version-file: 'go.mod'
2828
cache: true

CONTRIBUTING.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Setting a `processId` of 0 allows a dropdown to select the process of the provid
8181

8282
0. Add a sleep call (e.g. `time.Sleep(10 * time.Second)`) in the [`func providerConfigure(p *schema.Provider) schema.ConfigureFunc`](https://github.com/integrations/terraform-provider-github/blob/cec7e175c50bb091feecdc96ba117067c35ee351/github/provider.go#L274C1-L274C64) before the immediate `return` call. This will allow time to connect the debugger while the provider is initializing, before any critical logic happens.
8383

84-
0. Build the terraform provider with debug flags enabled and copy it to the appropriate bin folder with a command like `go build -gcflags="all=-N -l" -o ~/go/bin`.
84+
0. Build the terraform provider with debug flags enabled and copy it to the appropriate bin folder with a command like `go build -gcflags="all=-N -l" -o ~/go/bin/`.
8585

8686
0. Create or edit a `dev.tfrc` that points toward the newly-built binary, and export the `TF_CLI_CONFIG_FILE` variable to point to it. Further instructions on this process may be found in the [Building the provider](#using-a-local-version-of-the-provider) section.
8787

@@ -99,7 +99,7 @@ Manual testing should be performed on each PR opened in order to validate the pr
9999
Build the provider and specify the output directory:
100100

101101
```sh
102-
$ go build -gcflags="all=-N -l" -o ~/go/bin
102+
$ go build -gcflags="all=-N -l" -o ~/go/bin/
103103
```
104104

105105
This enables verifying your locally built provider using examples available in the `examples/` directory.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Organization Security Manager Example
2+
3+
This example demonstrates creating an organization security manager team.
4+
5+
It will:
6+
- Create a team with the specified `team_name` in the specified `owner` organization
7+
- Assign the organization security manager role to the team
8+
9+
The GitHub token must have the `admin:org` scope.
10+
11+
```console
12+
export GITHUB_OWNER=my-organization
13+
export GITHUB_TOKEN=ghp_###
14+
export GITHUB_TEAM_NAME="My Security Manager Team"
15+
```
16+
17+
```console
18+
terraform apply \
19+
-var "owner=${GITHUB_OWNER}" \
20+
-var "github_token=${GITHUB_TOKEN}" \
21+
-var "team_name=${GITHUB_TEAM_NAME}"
22+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
resource "github_team" "security_managers" {
2+
name = var.team_name
3+
description = "A team of organization security managers"
4+
}
5+
6+
resource "github_organization_security_manager" "security_managers" {
7+
team_slug = github_team.security_managers.slug
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
output "github_security_managers_team" {
2+
description = "The organization security managers team"
3+
value = github_organization_security_manager.security_managers
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
provider "github" {
2+
owner = var.owner
3+
token = var.github_token
4+
}
5+
6+
terraform {
7+
required_providers {
8+
github = {
9+
source = "integrations/github"
10+
}
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
variable "github_token" {
2+
description = "GitHub access token used to configure the provider"
3+
type = string
4+
}
5+
6+
variable "owner" {
7+
description = "GitHub owner used to configure the provider"
8+
type = string
9+
}
10+
11+
variable "team_name" {
12+
description = "The name to use for the GitHub team"
13+
type = string
14+
}

github/apps.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func GenerateOAuthTokenFromApp(baseURL, appID, appInstallationID, pemData string
3131
}
3232

3333
func getInstallationAccessToken(baseURL string, jwt string, installationID string) (string, error) {
34-
if baseURL != "https://api.github.com/" {
34+
if baseURL != "https://api.github.com/" && !GHECDataResidencyMatch.MatchString(baseURL) {
3535
baseURL += "api/v3/"
3636
}
3737

github/config.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"net/http"
66
"net/url"
77
"path"
8+
"regexp"
89
"strings"
910
"time"
1011

@@ -36,6 +37,10 @@ type Owner struct {
3637
IsOrganization bool
3738
}
3839

40+
// GHECDataResidencyMatch is a regex to match a GitHub Enterprise Cloud data residency URL:
41+
// https://[hostname].ghe.com instances expect paths that behave similar to GitHub.com, not GitHub Enterprise Server.
42+
var GHECDataResidencyMatch = regexp.MustCompile(`^https:\/\/[a-zA-Z0-9.\-]*\.ghe\.com$`)
43+
3944
func RateLimitedHTTPClient(client *http.Client, writeDelay time.Duration, readDelay time.Duration, retryDelay time.Duration, parallelRequests bool, retryableErrors map[int]bool, maxRetries int) *http.Client {
4045

4146
client.Transport = NewEtagTransport(client.Transport)
@@ -80,7 +85,7 @@ func (c *Config) NewGraphQLClient(client *http.Client) (*githubv4.Client, error)
8085
return nil, err
8186
}
8287

83-
if uv4.String() != "https://api.github.com/" {
88+
if uv4.String() != "https://api.github.com/" && !GHECDataResidencyMatch.MatchString(uv4.String()) {
8489
uv4.Path = path.Join(uv4.Path, "api/graphql/")
8590
} else {
8691
uv4.Path = path.Join(uv4.Path, "graphql")
@@ -96,7 +101,7 @@ func (c *Config) NewRESTClient(client *http.Client) (*github.Client, error) {
96101
return nil, err
97102
}
98103

99-
if uv3.String() != "https://api.github.com/" {
104+
if uv3.String() != "https://api.github.com/" && !GHECDataResidencyMatch.MatchString(uv3.String()) {
100105
uv3.Path = uv3.Path + "api/v3/"
101106
}
102107

github/config_test.go

+58
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,64 @@ import (
77
"github.com/shurcooL/githubv4"
88
)
99

10+
func TestGHECDataResidencyMatch(t *testing.T) {
11+
testCases := []struct {
12+
url string
13+
matches bool
14+
description string
15+
}{
16+
{
17+
url: "https://customer.ghe.com",
18+
matches: true,
19+
description: "GHEC data residency URL with customer name",
20+
},
21+
{
22+
url: "https://customer-name.ghe.com",
23+
matches: true,
24+
description: "GHEC data residency URL with hyphenated name",
25+
},
26+
{
27+
url: "https://api.github.com",
28+
matches: false,
29+
description: "GitHub.com API URL",
30+
},
31+
{
32+
url: "https://github.com",
33+
matches: false,
34+
description: "GitHub.com URL",
35+
},
36+
{
37+
url: "https://example.com",
38+
matches: false,
39+
description: "Generic URL",
40+
},
41+
{
42+
url: "http://customer.ghe.com",
43+
matches: false,
44+
description: "Non-HTTPS GHEC URL",
45+
},
46+
{
47+
url: "https://customer.ghe.com/api/v3",
48+
matches: false,
49+
description: "GHEC URL with path",
50+
},
51+
{
52+
url: "https://ghe.com",
53+
matches: false,
54+
description: "GHEC domain without subdomain",
55+
},
56+
}
57+
58+
for _, tc := range testCases {
59+
t.Run(tc.description, func(t *testing.T) {
60+
matches := GHECDataResidencyMatch.MatchString(tc.url)
61+
if matches != tc.matches {
62+
t.Errorf("URL %q: expected match=%v, got %v", tc.url, tc.matches, matches)
63+
}
64+
})
65+
}
66+
}
67+
1068
func TestAccConfigMeta(t *testing.T) {
1169

1270
// FIXME: Skip test runs during travis lint checking

0 commit comments

Comments
 (0)