Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add app to the github app installation id #4650

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const (
GHAppKeyFlag = "gh-app-key"
GHAppKeyFileFlag = "gh-app-key-file"
GHAppSlugFlag = "gh-app-slug"
GHInstallationIDFlag = "gh-installation-id"
GHAppInstallationIDFlag = "gh-app-installation-id"
GHOrganizationFlag = "gh-org"
GHWebhookSecretFlag = "gh-webhook-secret" // nolint: gosec
GHAllowMergeableBypassApply = "gh-allow-mergeable-bypass-apply" // nolint: gosec
Expand Down Expand Up @@ -620,8 +620,8 @@ var int64Flags = map[string]int64Flag{
description: "GitHub App Id. If defined, initializes the GitHub client with app-based credentials",
defaultValue: 0,
},
GHInstallationIDFlag: {
description: "GitHub Installation Id. If defined, initializes the GitHub client with app-based credentials " +
GHAppInstallationIDFlag: {
description: "GitHub App Installation Id. If defined, initializes the GitHub client with app-based credentials " +
"using this specific GitHub Application Installation ID, otherwise it attempts to auto-detect it. " +
"Note that this value must be set if you want to have one App and multiple installations of that same " +
"application.",
Expand Down
12 changes: 6 additions & 6 deletions cmd/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ var testFlags = map[string]interface{}{
GHAppKeyFlag: "",
GHAppKeyFileFlag: "",
GHAppSlugFlag: "atlantis",
GHInstallationIDFlag: int64(0),
GHAppInstallationIDFlag: int64(0),
GHOrganizationFlag: "",
GHWebhookSecretFlag: "secret",
GiteaBaseURLFlag: "http://localhost",
Expand Down Expand Up @@ -750,16 +750,16 @@ func TestExecute_GithubApp(t *testing.T) {
func TestExecute_GithubAppWithInstallationID(t *testing.T) {
t.Log("Should pass the installation ID to the config.")
c := setup(map[string]interface{}{
GHAppKeyFlag: testdata.GithubPrivateKey,
GHAppIDFlag: "1",
GHInstallationIDFlag: "2",
RepoAllowlistFlag: "*",
GHAppKeyFlag: testdata.GithubPrivateKey,
GHAppIDFlag: "1",
GHAppInstallationIDFlag: "2",
RepoAllowlistFlag: "*",
}, t)
err := c.Execute()
Ok(t, err)

Equals(t, int64(1), passedConfig.GithubAppID)
Equals(t, int64(2), passedConfig.GithubInstallationID)
Equals(t, int64(2), passedConfig.GithubAppInstallationID)
}

func TestExecute_GiteaUser(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions runatlantis.io/docs/server-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -687,12 +687,12 @@ and set `--autoplan-modules` to `false`.
Hostname of your GitHub Enterprise installation. If using [github.com](https://github.com),
don't set. Defaults to `github.com`.

### `--gh-installation-id`
### `--gh-app-installation-id`

```bash
atlantis server --gh-installation-id="123"
atlantis server --gh-app-installation-id="123"
# or
ATLANTIS_GH_INSTALLATION_ID="123"
ATLANTIS_GH_APP_INSTALLATION_ID="123"
```

The installation ID of a specific instance of a GitHub application. Normally this value is
Expand Down
4 changes: 2 additions & 2 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ func NewServer(userConfig UserConfig, config Config) (*Server, error) {
}
githubCredentials = &vcs.GithubAppCredentials{
AppID: userConfig.GithubAppID,
InstallationID: userConfig.GithubInstallationID,
InstallationID: userConfig.GithubAppInstallationID,
Key: privateKey,
Hostname: userConfig.GithubHostname,
AppSlug: userConfig.GithubAppSlug,
Expand All @@ -249,7 +249,7 @@ func NewServer(userConfig UserConfig, config Config) (*Server, error) {
} else if userConfig.GithubAppID != 0 && userConfig.GithubAppKey != "" {
githubCredentials = &vcs.GithubAppCredentials{
AppID: userConfig.GithubAppID,
InstallationID: userConfig.GithubInstallationID,
InstallationID: userConfig.GithubAppInstallationID,
Key: []byte(userConfig.GithubAppKey),
Hostname: userConfig.GithubHostname,
AppSlug: userConfig.GithubAppSlug,
Expand Down
2 changes: 1 addition & 1 deletion server/user_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type UserConfig struct {
GithubAppKey string `mapstructure:"gh-app-key"`
GithubAppKeyFile string `mapstructure:"gh-app-key-file"`
GithubAppSlug string `mapstructure:"gh-app-slug"`
GithubInstallationID int64 `mapstructure:"gh-installation-id"`
GithubAppInstallationID int64 `mapstructure:"gh-app-installation-id"`
GithubTeamAllowlist string `mapstructure:"gh-team-allowlist"`
GiteaBaseURL string `mapstructure:"gitea-base-url"`
GiteaToken string `mapstructure:"gitea-token"`
Expand Down
Loading