Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions internal/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ type DefaultRegistry struct {
type UpdateDefaults struct {
Schedule Schedule `yaml:"schedule"`
CommitMessage CommitMessage `yaml:"commit-message"`
OpenPullRequestsLimit int `yaml:"open-pull-requests-limit"`
OpenPullRequestsLimit *int `yaml:"open-pull-requests-limit,omitempty"`
InsecureExternalCodeExecution string `yaml:"insecure-external-code-execution"`
RebaseStrategy string `yaml:"rebase-strategy"`
Cooldown Cooldown `yaml:"cooldown"`
Expand Down Expand Up @@ -109,7 +109,7 @@ type Update struct {
Schedule Schedule `yaml:"schedule,omitempty"`
Registries []string `yaml:"registries,omitempty"`
CommitMessage CommitMessage `yaml:"commit-message,omitempty"`
OpenPullRequestsLimit int `yaml:"open-pull-requests-limit,omitempty"`
OpenPullRequestsLimit *int `yaml:"open-pull-requests-limit,omitempty"`
Assignees []string `yaml:"assignees,omitempty"`
Allow []Allow `yaml:"allow,omitempty"`
Ignore []Ignore `yaml:"ignore,omitempty"`
Expand Down Expand Up @@ -576,7 +576,7 @@ func applyOverrides(update *Update, overrides UpdateDefaults) {
if overrides.CommitMessage != (CommitMessage{}) {
update.CommitMessage = overrides.CommitMessage
}
if overrides.OpenPullRequestsLimit != 0 {
if overrides.OpenPullRequestsLimit != nil {
update.OpenPullRequestsLimit = overrides.OpenPullRequestsLimit
}
if overrides.RebaseStrategy != "" {
Expand Down
5 changes: 3 additions & 2 deletions internal/pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"strings"
"testing"

"github.com/getyourguide/dependabutler/internal/pkg/util"
"gopkg.in/yaml.v3"
)

Expand Down Expand Up @@ -52,7 +53,7 @@ registries:
`,
&ToolConfig{
UpdateDefaults: UpdateDefaults{
OpenPullRequestsLimit: 10,
OpenPullRequestsLimit: util.Ptr(10),
InsecureExternalCodeExecution: "allow",
Schedule: Schedule{
Interval: "daily",
Expand Down Expand Up @@ -276,7 +277,7 @@ func TestAddManifest(t *testing.T) {
Time: "18:15",
Timezone: "Europe/Berlin",
},
OpenPullRequestsLimit: 9,
OpenPullRequestsLimit: util.Ptr(9),
},
UpdateOverrides: map[string]UpdateDefaults{
"docker": {
Expand Down
5 changes: 5 additions & 0 deletions internal/pkg/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,8 @@ func RandToken(n int) (string, error) {
}
return hex.EncodeToString(bytes), nil
}

// Ptr returns a pointer to the given value
func Ptr[T any](v T) *T {
return &v
}