Skip to content

Commit

Permalink
Merge branch 'main' into make_sure_documentation_flags_are_up_to_date
Browse files Browse the repository at this point in the history
  • Loading branch information
X-Guardian authored Nov 5, 2024
2 parents 2e87ffa + 240b6b1 commit c3a3f12
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4

- name: markdown-lint
uses: DavidAnson/markdownlint-cli2-action@b4c9feab76d8025d1e83c653fa3990936df0e6c8 # v16
uses: DavidAnson/markdownlint-cli2-action@db43aef879112c3119a410d69f66701e0d530809 # v17
with:
config: .markdownlint.yaml
globs: 'runatlantis.io/**/*.md'
Expand Down Expand Up @@ -96,6 +96,7 @@ jobs:
-e 'https://github.com/runatlantis/helm-charts#customization' \
-e 'https://github.com/sethvargo/atlantis-on-gke/blob/master/terraform/tls.tf#L64-L84' \
-e 'https://confluence.atlassian.com/*' \
--header 'User-Agent: Muffet' \
--header 'Accept-Encoding:deflate, gzip' \
--buffer-size 8192 \
http://localhost:8080/
Expand Down
1 change: 1 addition & 0 deletions runatlantis.io/docs/provider-credentials.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ provider "aws" {
```

Atlantis runs `terraform` with the following variables:

| `-var` Argument | Description |
|--------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------|
| `atlantis_user=lkysow` | The VCS username of who is running the plan command. |
Expand Down
23 changes: 21 additions & 2 deletions server/events/event_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"encoding/json"
"fmt"
"net/url"
"os"
"path"
"strings"

Expand Down Expand Up @@ -357,6 +358,7 @@ type EventParsing interface {
type EventParser struct {
GithubUser string
GithubToken string
GithubTokenFile string
GitlabUser string
GitlabToken string
GiteaUser string
Expand All @@ -372,7 +374,15 @@ type EventParser struct {
func (e *EventParser) ParseAPIPlanRequest(vcsHostType models.VCSHostType, repoFullName string, cloneURL string) (models.Repo, error) {
switch vcsHostType {
case models.Github:
return models.NewRepo(vcsHostType, repoFullName, cloneURL, e.GithubUser, e.GithubToken)
token := e.GithubToken
if e.GithubTokenFile != "" {
content, err := os.ReadFile(e.GithubTokenFile)
if err != nil {
return models.Repo{}, fmt.Errorf("failed reading github token file: %w", err)
}
token = string(content)
}
return models.NewRepo(vcsHostType, repoFullName, cloneURL, e.GithubUser, token)
case models.Gitea:
return models.NewRepo(vcsHostType, repoFullName, cloneURL, e.GiteaUser, e.GiteaToken)
case models.Gitlab:
Expand Down Expand Up @@ -626,7 +636,16 @@ func (e *EventParser) ParseGithubPull(logger logging.SimpleLogging, pull *github
// returns a repo into the Atlantis model.
// See EventParsing for return value docs.
func (e *EventParser) ParseGithubRepo(ghRepo *github.Repository) (models.Repo, error) {
return models.NewRepo(models.Github, ghRepo.GetFullName(), ghRepo.GetCloneURL(), e.GithubUser, e.GithubToken)
token := e.GithubToken
if e.GithubTokenFile != "" {
content, err := os.ReadFile(e.GithubTokenFile)
if err != nil {
return models.Repo{}, fmt.Errorf("failed reading github token file: %w", err)
}
token = string(content)
}

return models.NewRepo(models.Github, ghRepo.GetFullName(), ghRepo.GetCloneURL(), e.GithubUser, token)
}

// ParseGiteaRepo parses the response from the Gitea API endpoint that
Expand Down
1 change: 1 addition & 0 deletions server/events/event_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
var parser = events.EventParser{
GithubUser: "github-user",
GithubToken: "github-token",
GithubTokenFile: "",
GitlabUser: "gitlab-user",
GitlabToken: "gitlab-token",
AllowDraftPRs: false,
Expand Down
1 change: 1 addition & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,7 @@ func NewServer(userConfig UserConfig, config Config) (*Server, error) {
eventParser := &events.EventParser{
GithubUser: userConfig.GithubUser,
GithubToken: userConfig.GithubToken,
GithubTokenFile: userConfig.GithubTokenFile,
GitlabUser: userConfig.GitlabUser,
GitlabToken: userConfig.GitlabToken,
GiteaUser: userConfig.GiteaUser,
Expand Down

0 comments on commit c3a3f12

Please sign in to comment.