Ignore teams files for non-premium gitops users. (#23194)

#21715

This fix is needed for https://github.com/fleetdm/fleet-gitops CI to run
successfully against a non-premium Fleet server.
That CI test will cover this change.

# Checklist for submitter
- [x] Manual QA for all new/changed functionality
This commit is contained in:
Victor Lyuboslavsky 2024-10-25 09:11:43 -05:00 committed by GitHub
parent 3636fe2f79
commit 62fdfb68c1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -86,8 +86,13 @@ func gitopsCommand() *cli.Command {
noTeamControls spec.Controls
noTeamPresent bool
)
isPremium := appConfig.License.IsPremium()
for _, flFilename := range flFilenames.Value() {
if filepath.Base(flFilename) == "no-team.yml" {
if !isPremium {
// Message is printed in the next flFilenames loop to avoid printing it multiple times
break
}
baseDir := filepath.Dir(flFilename)
config, err := spec.GitOpsFromFile(flFilename, baseDir, appConfig, func(format string, a ...interface{}) {})
if err != nil {
@ -148,13 +153,16 @@ func gitopsCommand() *cli.Command {
if !config.Controls.Set() {
config.Controls = noTeamControls
}
} else if !isPremium {
logf("[!] skipping team config %s since teams are only supported for premium Fleet users\n", flFilename)
continue
}
// Special handling for tokens is required because they link to teams (by
// name.) Because teams can be created/deleted during the same gitops run, we
// grab some information to help us determine allowed/restricted actions and
// when to perform the associations.
if isGlobalConfig && totalFilenames > 1 && !(totalFilenames == 2 && noTeamPresent) {
if isGlobalConfig && totalFilenames > 1 && !(totalFilenames == 2 && noTeamPresent) && isPremium {
abmTeams, hasMissingABMTeam, usesLegacyABMConfig, err = checkABMTeamAssignments(config, fleetClient)
if err != nil {
return err