forked from argoproj/argo-cd
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
integrate feature manager for report from v2 or v1
- Loading branch information
1 parent
8ad5be8
commit 7646ec7
Showing
7 changed files
with
72 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package reporter | ||
|
||
import ( | ||
settings_util "github.com/argoproj/argo-cd/v2/util/settings" | ||
log "github.com/sirupsen/logrus" | ||
"time" | ||
) | ||
|
||
type FeatureManager struct { | ||
settingsMgr *settings_util.SettingsManager | ||
shouldRun bool | ||
} | ||
|
||
func NewFeatureManager(settingsMgr *settings_util.SettingsManager) *FeatureManager { | ||
return &FeatureManager{settingsMgr: settingsMgr} | ||
} | ||
|
||
func (f *FeatureManager) setShouldRun() { | ||
reporterVersion, err := f.settingsMgr.GetCodefreshReporterVersion() | ||
if err != nil { | ||
log.Warnf("Failed to get reporter version: %v", err) | ||
f.shouldRun = false | ||
return | ||
} | ||
f.shouldRun = reporterVersion == string(settings_util.CodefreshV2ReporterVersion) | ||
} | ||
|
||
func (f *FeatureManager) Watch() { | ||
f.setShouldRun() | ||
tick := time.Tick(5 * time.Second) | ||
for { | ||
select { | ||
case <-tick: | ||
{ | ||
f.setShouldRun() | ||
} | ||
} | ||
} | ||
} | ||
|
||
func (f *FeatureManager) ShouldReporterRun() bool { | ||
return f.shouldRun | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters