Skip to content

Commit

Permalink
fix: added some validations and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
omri2001 committed Aug 4, 2024
1 parent 81b4dae commit df72152
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/configuration/environment_variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The helm chart populate them using [values.yaml](https://github.com/quickube/pip
The git token that will be used.

- GIT_URL
the git url that will be used, mostly relevant when running gitlab on-prem
the git url that will be used, only relevant when running gitlab self hosted

- GIT_ORG_NAME
The organization name.
Expand Down
2 changes: 1 addition & 1 deletion pkg/conf/git_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
type GitProviderConfig struct {
Provider string `envconfig:"GIT_PROVIDER" required:"true"`
Token string `envconfig:"GIT_TOKEN" required:"true"`
Url string `envconfig:"GIT_URL" required:"true"`
Url string `envconfig:"GIT_URL" required:"false"`
OrgName string `envconfig:"GIT_ORG_NAME" required:"true"`
OrgLevelWebhook bool `envconfig:"GIT_ORG_LEVEL_WEBHOOK" default:"false" required:"false"`
RepoList string `envconfig:"GIT_WEBHOOK_REPO_LIST" required:"false"`
Expand Down
2 changes: 2 additions & 0 deletions pkg/git_provider/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ func NewGitlabClient(cfg *conf.GlobalConfig) (Client, error) {
return nil, fmt.Errorf("failed to get organization data %s", resp.Status)
}

cfg = EnsureGitlabURL(cfg)

c := &GitlabClientImpl{
client: client,
cfg: cfg,
Expand Down
8 changes: 8 additions & 0 deletions pkg/git_provider/gitlab_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,12 @@ func FixRepoNames(c *GitlabClientImpl) error{
}
c.cfg.GitProviderConfig.RepoList = strings.Join(formattedRepos, ",")
return nil
}

func EnsureGitlabURL(c *conf.GlobalConfig) *conf.GlobalConfig{
saasGitlabUrl := "https://gitlab.com"
if c.Url == "" {
c.Url = saasGitlabUrl
}
return c
}

0 comments on commit df72152

Please sign in to comment.