Skip to content

Commit

Permalink
[CircleCI] Add configurable number of builds to settings (#1025)
Browse files Browse the repository at this point in the history
* Add configurable build number to settings

* Review feedback: number of builds
  • Loading branch information
David Bouchare authored Nov 22, 2020
1 parent acfafb0 commit aae1cf5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions modules/circleci/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@ const (
type Settings struct {
common *cfg.Common

apiKey string `help:"Your CircleCI API token."`
apiKey string `help:"Your CircleCI API token."`
numberOfBuilds int `help:"The number of build, 10 by default"`
}

func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {

settings := Settings{
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),

apiKey: ymlConfig.UString("apiKey", ymlConfig.UString("apikey", os.Getenv("WTF_CIRCLE_API_KEY"))),
apiKey: ymlConfig.UString("apiKey", ymlConfig.UString("apikey", os.Getenv("WTF_CIRCLE_API_KEY"))),
numberOfBuilds: ymlConfig.UInt("numberOfBuilds", 10),
}

cfg.ModuleSecret(name, globalConfig, &settings.apiKey).Load()
Expand Down
2 changes: 1 addition & 1 deletion modules/circleci/widget.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (widget *Widget) content() (string, string, bool) {
str = err.Error()
} else {
for idx, build := range builds {
if idx > 10 {
if idx > widget.settings.numberOfBuilds {
break
}

Expand Down

0 comments on commit aae1cf5

Please sign in to comment.