Skip to content

Commit

Permalink
[#34]: chore: folders and config refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
rustatian authored Jul 2, 2022
2 parents 74c3b90 + 0e5096c commit 628746b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ linters: # All available linters list: <https://golangci-lint.run/usage/linters/
- ineffassign # Detects when assignments to existing variables are not used
- misspell # Finds commonly misspelled English words in comments
- nakedret # Finds naked returns in functions greater than a specified function length
- nestif # Reports deeply nested if statements
- noctx # finds sending http request without context.Context
- nolintlint # Reports ill-formed or insufficient nolint directives
- prealloc # Finds slice declarations that could potentially be preallocated
Expand Down
10 changes: 7 additions & 3 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (c *Config) Validate() error { //nolint:gocognit,gocyclo
c.Roadrunner[ref] = defaultBranch
}

if (c.GitLab != nil && len(c.GitLab.Plugins) == 0) || (c.GitHub != nil && len(c.GitHub.Plugins) == 0) {
if (c.GitLab != nil && len(c.GitLab.Plugins) == 0) && (c.GitHub != nil && len(c.GitHub.Plugins) == 0) {
return errors.New("no plugins specified in the configuration")
}

Expand All @@ -74,8 +74,8 @@ func (c *Config) Validate() error { //nolint:gocognit,gocyclo
}
}

if c.GitHub.Token == nil {
c.GitHub.Token = &Token{Token: ""}
if c.GitHub.Token == nil || c.GitHub.Token.Token == "" {
return errors.New("github.token should not be empty, create a token with any permissions: https://github.com/settings/tokens")
}
}

Expand All @@ -97,6 +97,10 @@ func (c *Config) Validate() error { //nolint:gocognit,gocyclo
if c.GitLab.BaseURL == nil {
c.GitLab.BaseURL = &Endpoint{BaseURL: gitlabBaseURL}
}

if c.GitLab.Token == nil || c.GitLab.Token.Token == "" {
return errors.New("gitlab.token should not be empty, create a token with at least [api, read_api] permissions: https://gitlab.com/-/profile/personal_access_tokens")
}
}

if len(c.Log) == 0 {
Expand Down

0 comments on commit 628746b

Please sign in to comment.