fabric8-services / fabric8-jenkins-idler

OpenShift.io service to idle resp.unidle Jenkins instances
Apache License 2.0
4 stars 15 forks source link

Fix idler choosing wrong feature toggle impl #335

Closed sthaha closed 5 years ago

sthaha commented 5 years ago

Feature toggle has 2 implementations and the way it is chosen in main is based on the value of JC_FIXED_UUID environment variable. e.g.

// main.go: createFeatureToggle

if len(config.GetFixedUuids()) > 0 {
  f, err = toggles.NewFixedUUIDToggle(config.GetFixedUuids())
} else {
  f, err = toggles.NewUnleashToggle(config.GetToggleURL())
}

The recent change to idler configuration package to use viper ( 73d8f0ed6864d40905cd72747a517de59adababf ) introduced a change (regression) that resulted in GetFixedUuids returning a []string{ "" } when the variable isn't set.

This meant that idler would always choose the FixedUUID toggle instead of using the actual feature toggle service.

This patch fixes the issue by fixing GetFixedUuids to return empty slice if the env var isn't set.

Fixes #333