Skip to content

Commit

Permalink
making branches optional
Browse files Browse the repository at this point in the history
  • Loading branch information
s1moe2 committed May 29, 2020
1 parent e2a9463 commit acf9159
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
.idea
.bin
.bin
test.sh
11 changes: 4 additions & 7 deletions cmd/envgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,25 +129,22 @@ func (g *Generator) loadConfig(filepath string) error {

g.conf = *config

g.branchSuffix, err = g.findBranchSuffix()
if err != nil {
return fmt.Errorf("missing branch suffix")
}
g.branchSuffix = g.findBranchSuffix()

return nil
}

// findBranchSuffix determines the branch suffix to use, depending on the current CI branch
func (g *Generator) findBranchSuffix() (string, error) {
func (g *Generator) findBranchSuffix() string {
branch := getEnv(g.conf.BranchVarName, "", g.conf.BranchVarDefault)

for _, b := range g.conf.Branches {
if b.Name == branch {
return b.Suffix, nil
return b.Suffix
}
}

return "", fmt.Errorf("could not find branch suffix")
return ""
}

// getEnv looks up for a loaded environment variable.
Expand Down

0 comments on commit acf9159

Please sign in to comment.