Skip to content

Commit

Permalink
fix: add app to the github app installation id
Browse files Browse the repository at this point in the history
fixes #4579
  • Loading branch information
bdellegrazie committed Jun 12, 2024
1 parent d7ae1a5 commit 3214a72
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
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

0 comments on commit 3214a72

Please sign in to comment.