mirror of
https://github.com/fleetdm/fleet
synced 2026-05-22 16:39:01 +00:00
Rename the builtin label constant
This commit is contained in:
parent
7964a81828
commit
8a0f87ef3d
7 changed files with 45 additions and 19 deletions
|
|
@ -178,8 +178,8 @@ func TestApplyTeamSpecs(t *testing.T) {
|
|||
}
|
||||
|
||||
ds.LabelIDsByNameFunc = func(ctx context.Context, labels []string) (map[string]uint, error) {
|
||||
require.ElementsMatch(t, labels, []string{fleet.BuiltinMacOS14PlusLabelName})
|
||||
return map[string]uint{fleet.BuiltinMacOS14PlusLabelName: 1}, nil
|
||||
require.ElementsMatch(t, labels, []string{fleet.BuiltinLabelMacOS14Plus})
|
||||
return map[string]uint{fleet.BuiltinLabelMacOS14Plus: 1}, nil
|
||||
}
|
||||
|
||||
ds.SetOrUpdateMDMAppleDeclarationFunc = func(ctx context.Context, declaration *fleet.MDMAppleDeclaration) (*fleet.MDMAppleDeclaration, error) {
|
||||
|
|
@ -585,8 +585,8 @@ func TestApplyAppConfig(t *testing.T) {
|
|||
}
|
||||
|
||||
ds.LabelIDsByNameFunc = func(ctx context.Context, labels []string) (map[string]uint, error) {
|
||||
require.ElementsMatch(t, labels, []string{fleet.BuiltinMacOS14PlusLabelName})
|
||||
return map[string]uint{fleet.BuiltinMacOS14PlusLabelName: 1}, nil
|
||||
require.ElementsMatch(t, labels, []string{fleet.BuiltinLabelMacOS14Plus})
|
||||
return map[string]uint{fleet.BuiltinLabelMacOS14Plus: 1}, nil
|
||||
}
|
||||
|
||||
ds.SetOrUpdateMDMAppleDeclarationFunc = func(ctx context.Context, declaration *fleet.MDMAppleDeclaration) (*fleet.MDMAppleDeclaration, error) {
|
||||
|
|
@ -1170,8 +1170,8 @@ func TestApplyAsGitOps(t *testing.T) {
|
|||
return nil
|
||||
}
|
||||
ds.LabelIDsByNameFunc = func(ctx context.Context, labels []string) (map[string]uint, error) {
|
||||
require.ElementsMatch(t, labels, []string{fleet.BuiltinMacOS14PlusLabelName})
|
||||
return map[string]uint{fleet.BuiltinMacOS14PlusLabelName: 1}, nil
|
||||
require.ElementsMatch(t, labels, []string{fleet.BuiltinLabelMacOS14Plus})
|
||||
return map[string]uint{fleet.BuiltinLabelMacOS14Plus: 1}, nil
|
||||
}
|
||||
ds.SetOrUpdateMDMAppleDeclarationFunc = func(ctx context.Context, declaration *fleet.MDMAppleDeclaration) (*fleet.MDMAppleDeclaration, error) {
|
||||
declaration.DeclarationUUID = uuid.NewString()
|
||||
|
|
|
|||
|
|
@ -2221,8 +2221,8 @@ func TestGetTeamsYAMLAndApply(t *testing.T) {
|
|||
return nil
|
||||
}
|
||||
ds.LabelIDsByNameFunc = func(ctx context.Context, labels []string) (map[string]uint, error) {
|
||||
require.ElementsMatch(t, labels, []string{fleet.BuiltinMacOS14PlusLabelName})
|
||||
return map[string]uint{fleet.BuiltinMacOS14PlusLabelName: 1}, nil
|
||||
require.ElementsMatch(t, labels, []string{fleet.BuiltinLabelMacOS14Plus})
|
||||
return map[string]uint{fleet.BuiltinLabelMacOS14Plus: 1}, nil
|
||||
}
|
||||
ds.SetOrUpdateMDMAppleDeclarationFunc = func(ctx context.Context, declaration *fleet.MDMAppleDeclaration) (*fleet.MDMAppleDeclaration, error) {
|
||||
declaration.DeclarationUUID = uuid.NewString()
|
||||
|
|
|
|||
|
|
@ -176,8 +176,8 @@ func TestBasicTeamGitOps(t *testing.T) {
|
|||
return team, nil
|
||||
}
|
||||
ds.LabelIDsByNameFunc = func(ctx context.Context, labels []string) (map[string]uint, error) {
|
||||
require.ElementsMatch(t, labels, []string{fleet.BuiltinMacOS14PlusLabelName})
|
||||
return map[string]uint{fleet.BuiltinMacOS14PlusLabelName: 1}, nil
|
||||
require.ElementsMatch(t, labels, []string{fleet.BuiltinLabelMacOS14Plus})
|
||||
return map[string]uint{fleet.BuiltinLabelMacOS14Plus: 1}, nil
|
||||
}
|
||||
ds.SetOrUpdateMDMAppleDeclarationFunc = func(ctx context.Context, declaration *fleet.MDMAppleDeclaration) (*fleet.MDMAppleDeclaration, error) {
|
||||
declaration.DeclarationUUID = uuid.NewString()
|
||||
|
|
@ -434,8 +434,8 @@ func TestFullTeamGitOps(t *testing.T) {
|
|||
return job, nil
|
||||
}
|
||||
ds.LabelIDsByNameFunc = func(ctx context.Context, labels []string) (map[string]uint, error) {
|
||||
require.ElementsMatch(t, labels, []string{fleet.BuiltinMacOS14PlusLabelName})
|
||||
return map[string]uint{fleet.BuiltinMacOS14PlusLabelName: 1}, nil
|
||||
require.ElementsMatch(t, labels, []string{fleet.BuiltinLabelMacOS14Plus})
|
||||
return map[string]uint{fleet.BuiltinLabelMacOS14Plus: 1}, nil
|
||||
}
|
||||
ds.SetOrUpdateMDMAppleDeclarationFunc = func(ctx context.Context, declaration *fleet.MDMAppleDeclaration) (*fleet.MDMAppleDeclaration, error) {
|
||||
declaration.DeclarationUUID = uuid.NewString()
|
||||
|
|
|
|||
|
|
@ -1092,12 +1092,12 @@ func (svc *Service) mdmAppleEditedMacOSUpdates(ctx context.Context, teamID *uint
|
|||
|
||||
// associate the profile with the built-in label that ensures the host is on
|
||||
// macOS 14+ to receive that profile
|
||||
lblIDs, err := svc.ds.LabelIDsByName(ctx, []string{fleet.BuiltinMacOS14PlusLabelName})
|
||||
lblIDs, err := svc.ds.LabelIDsByName(ctx, []string{fleet.BuiltinLabelMacOS14Plus})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
d.Labels = []fleet.ConfigurationProfileLabel{
|
||||
{LabelName: fleet.BuiltinMacOS14PlusLabelName, LabelID: lblIDs[fleet.BuiltinMacOS14PlusLabelName]},
|
||||
{LabelName: fleet.BuiltinLabelMacOS14Plus, LabelID: lblIDs[fleet.BuiltinLabelMacOS14Plus]},
|
||||
}
|
||||
|
||||
decl, err := svc.ds.SetOrUpdateMDMAppleDeclaration(ctx, d)
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ func TestGetOrCreatePreassignTeam(t *testing.T) {
|
|||
}
|
||||
ds.LabelIDsByNameFunc = func(ctx context.Context, names []string) (map[string]uint, error) {
|
||||
require.Len(t, names, 1)
|
||||
require.ElementsMatch(t, names, []string{fleet.BuiltinMacOS14PlusLabelName})
|
||||
require.ElementsMatch(t, names, []string{fleet.BuiltinLabelMacOS14Plus})
|
||||
return map[string]uint{names[0]: 1}, nil
|
||||
}
|
||||
ds.SetOrUpdateMDMAppleDeclarationFunc = func(ctx context.Context, declaration *fleet.MDMAppleDeclaration) (*fleet.MDMAppleDeclaration, error) {
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ func Up_20240403104633(tx *sql.Tx) error {
|
|||
ts := time.Date(2024, 4, 3, 0, 0, 0, 0, time.UTC)
|
||||
_, err := tx.Exec(
|
||||
stmt,
|
||||
fleet.BuiltinMacOS14PlusLabelName,
|
||||
fleet.BuiltinLabelMacOS14Plus,
|
||||
"macOS hosts with version 14 and above",
|
||||
`select 1 from os_version where platform = 'darwin' and major >= 14;`,
|
||||
"darwin",
|
||||
|
|
@ -49,7 +49,7 @@ func Up_20240403104633(tx *sql.Tx) error {
|
|||
// across built-in and regular. (I don't think we've done anything
|
||||
// special before, but this seems a bit nicer/clearer as to why the
|
||||
// migration may have failed and how to fix it)
|
||||
return fmt.Errorf("a label with the name %q already exists, please rename it before applying this migration: %w", fleet.BuiltinMacOS14PlusLabelName, err)
|
||||
return fmt.Errorf("a label with the name %q already exists, please rename it before applying this migration: %w", fleet.BuiltinLabelMacOS14Plus, err)
|
||||
}
|
||||
}
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -111,8 +111,6 @@ func (l Label) AuthzType() string {
|
|||
|
||||
const (
|
||||
LabelKind = "label"
|
||||
|
||||
BuiltinMacOS14PlusLabelName = "macOS 14+ (Sonoma+)"
|
||||
)
|
||||
|
||||
type LabelQueryExecution struct {
|
||||
|
|
@ -133,3 +131,31 @@ type LabelSpec struct {
|
|||
LabelMembershipType LabelMembershipType `json:"label_membership_type" db:"label_membership_type"`
|
||||
Hosts []string `json:"hosts,omitempty"`
|
||||
}
|
||||
|
||||
const (
|
||||
BuiltinLabelNameAllHosts = "All Hosts"
|
||||
BuiltinLabelNameMacOS = "macOS"
|
||||
BuiltinLabelNameUbuntuLinux = "Ubuntu Linux"
|
||||
BuiltinLabelNameCentOSLinux = "CentOS Linux"
|
||||
BuiltinLabelNameWindows = "MS Windows"
|
||||
BuiltinLabelNameRedHatLinux = "Red Hat Linux"
|
||||
BuiltinLabelNameAllLinux = "All Linux"
|
||||
BuiltinLabelNameChrome = "chrome"
|
||||
BuiltinLabelMacOS14Plus = "macOS 14+ (Sonoma+)"
|
||||
)
|
||||
|
||||
// ReservedLabelNames returns a map of label name strings
|
||||
// that are reserved by Fleet.
|
||||
func ReservedLabelNames() map[string]struct{} {
|
||||
return map[string]struct{}{
|
||||
BuiltinLabelNameAllHosts: {},
|
||||
BuiltinLabelNameMacOS: {},
|
||||
BuiltinLabelNameUbuntuLinux: {},
|
||||
BuiltinLabelNameCentOSLinux: {},
|
||||
BuiltinLabelNameWindows: {},
|
||||
BuiltinLabelNameRedHatLinux: {},
|
||||
BuiltinLabelNameAllLinux: {},
|
||||
BuiltinLabelNameChrome: {},
|
||||
BuiltinLabelMacOS14Plus: {},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue