Skip to content

Commit

Permalink
fix(azure): allow host to be specified in user_config for on premise …
Browse files Browse the repository at this point in the history
…installation (#1860)

* add .devcontainer to .gitignore

* allow AzureDevOps host to be specified in the user_config

* fix spacing issues

* gofmt

* fixes to cmd and update to approach

Co-authored-by: atlantisbot <lkysow+atlantis@gmail.com>
  • Loading branch information
dandcg and atlantisbot authored Oct 17, 2021
1 parent 515df4e commit 571f91f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ helm/test-values.yaml
*.swp
golangci-lint
atlantis
.devcontainer
9 changes: 9 additions & 0 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const (
ADWebhookUserFlag = "azuredevops-webhook-user"
ADTokenFlag = "azuredevops-token" // nolint: gosec
ADUserFlag = "azuredevops-user"
ADHostnameFlag = "azuredevops-hostname"
AllowForkPRsFlag = "allow-fork-prs"
AllowRepoConfigFlag = "allow-repo-config"
AtlantisURLFlag = "atlantis-url"
Expand Down Expand Up @@ -106,6 +107,7 @@ const (
// NOTE: Must manually set these as defaults in the setDefaults function.
DefaultADBasicUser = ""
DefaultADBasicPassword = ""
DefaultADHostname = "dev.azure.com"
DefaultAutoplanFileList = "**/*.tf,**/*.tfvars,**/*.tfvars.json,**/terragrunt.hcl"
DefaultCheckoutStrategy = "branch"
DefaultBitbucketBaseURL = bitbucketcloud.BaseURL
Expand Down Expand Up @@ -139,6 +141,10 @@ var stringFlags = map[string]stringFlag{
description: "Azure DevOps basic HTTP authentication username for inbound webhooks.",
defaultValue: "",
},
ADHostnameFlag: {
description: "Azure DevOps hostname to support cloud and self hosted instances.",
defaultValue: "dev.azure.com",
},
AtlantisURLFlag: {
description: "URL that Atlantis can be reached at. Defaults to http://$(hostname):$port where $port is from --" + PortFlag + ". Supports a base path ex. https://example.com/basepath.",
},
Expand Down Expand Up @@ -589,6 +595,9 @@ func (s *ServerCmd) run() error {
}

func (s *ServerCmd) setDefaults(c *server.UserConfig) {
if c.AzureDevOpsHostname == "" {
c.AzureDevOpsHostname = DefaultADHostname
}
if c.AutoplanFileList == "" {
c.AutoplanFileList = DefaultAutoplanFileList
}
Expand Down
3 changes: 2 additions & 1 deletion server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,9 @@ func NewServer(userConfig UserConfig, config Config) (*Server, error) {
}
if userConfig.AzureDevopsUser != "" {
supportedVCSHosts = append(supportedVCSHosts, models.AzureDevops)

var err error
azuredevopsClient, err = vcs.NewAzureDevopsClient("dev.azure.com", userConfig.AzureDevopsUser, userConfig.AzureDevopsToken)
azuredevopsClient, err = vcs.NewAzureDevopsClient(userConfig.AzureDevOpsHostname, userConfig.AzureDevopsUser, userConfig.AzureDevopsToken)
if err != nil {
return nil, err
}
Expand Down
1 change: 1 addition & 0 deletions server/user_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type UserConfig struct {
AzureDevopsUser string `mapstructure:"azuredevops-user"`
AzureDevopsWebhookPassword string `mapstructure:"azuredevops-webhook-password"`
AzureDevopsWebhookUser string `mapstructure:"azuredevops-webhook-user"`
AzureDevOpsHostname string `mapstructure:"azuredevops-hostname"`
BitbucketBaseURL string `mapstructure:"bitbucket-base-url"`
BitbucketToken string `mapstructure:"bitbucket-token"`
BitbucketUser string `mapstructure:"bitbucket-user"`
Expand Down

0 comments on commit 571f91f

Please sign in to comment.