Skip to content

Commit

Permalink
matcher: disable updaters creates empty updater sets
Browse files Browse the repository at this point in the history
Setting disable_updaters to true in the config should result in an empty
updaters sets list

Fixes quay#1273

Signed-off-by: Paul Aldridge <paulaldridge@uk.ibm.com>
  • Loading branch information
paulaldridge committed Jun 8, 2021
1 parent 45538e0 commit b41994d
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
3 changes: 3 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ func Validate(conf *Config) error {
if conf.HTTPListenAddr == "" {
conf.HTTPListenAddr = DefaultAddress
}
if conf.Matcher.DisableUpdaters {
conf.Updaters.Sets = []string{}
}
switch strings.ToLower(conf.Mode) {
case ComboMode:
if err := conf.Indexer.Validate(true); err != nil {
Expand Down
63 changes: 63 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,69 @@ func Test_Config_Validate_Failure(t *testing.T) {
}
}

func Test_Config_Disable_Updaters(t *testing.T) {
var table = []struct {
name string
conf config.Config
expect bool
}{
{
name: "ComboMode, disable updaters",
conf: config.Config{
Mode: config.ComboMode,
HTTPListenAddr: "localhost:8080",
Indexer: config.Indexer{
ConnString: "example@example/db",
},
Notifier: config.Notifier{
ConnString: "example@example/db",
},
Matcher: config.Matcher{
ConnString: "example@example/db",
IndexerAddr: "example@example/db",
DisableUpdaters: true,
},
Updaters: config.Updaters{
Sets: []string{
"alpine",
"aws",
},
},
},
},
{
name: "MatcherMode, disable updaters",
conf: config.Config{
Mode: config.MatcherMode,
HTTPListenAddr: "localhost:8080",
Matcher: config.Matcher{
ConnString: "example@example/db",
IndexerAddr: "example@example/db",
DisableUpdaters: true,
},
Updaters: config.Updaters{
Sets: []string{
"alpine",
"aws",
},
},
},
},
}

for _, tab := range table {
t.Run(tab.name, func(t *testing.T) {
err := config.Validate(&tab.conf)
if err != nil {
log.Fatalf("expected no errors but got: %s", err)
}
if len(tab.conf.Updaters.Sets) != 0 {
log.Fatalf("expected updaters sets to be empty but was: %s", tab.conf.Updaters.Sets)
}
})
}
}

func TestAuthUnmarshal(t *testing.T) {
t.Run("PSK", func(t *testing.T) {
type testcase struct {
Expand Down

0 comments on commit b41994d

Please sign in to comment.