fleet/cmd/fleetctl/testdata/gitops
Scott Gress 2a18f56655
Manage labels in GitOps (#27038)
For #24473 

# Checklist for submitter

<!-- Note that API documentation changes are now addressed by the
product design team. -->

- [ ] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/Committing-Changes.md#changes-files)
for more information.

## Details

This PR adds the ability to manage labels via GitOps. Usage is as
follows:

* If a top-level `labels:` key is provided in the global YAML file
provided to GitOps, then any labels in this list will be created (if
using a new name) or updated (if using an existing name).
* If no top-level `labels:` key is provided, no changes will be made to
labels. This allows backwards-compatibility; customers won't blow away
all of their labels if they don't immediately use `labels:` in their
YAML

Additionally, some new validation has been added so that label usage is
checked prior to application. This means that when the gitops command is
run, it will verify that any labels referenced elsewhere in the YAML
(e.g. by software installers or mdm profiles) exist, and will bail with
an error message if they don't.

## Testing

**Test label deletion**
1. Add some labels via the UI
2. Run `fleetctl gitops --dry-run` with a default.yml file _without_
`labels:` in it, and verify that it doesn't say it will update or delete
any labels
2. Run `fleetctl gitops` with a default.yml file _without_ `labels:` in
it, and verify that it doesn't modify or remove your labels
4. Run `fleetctl gitops --dry-run` with a default.yml file with
`labels:` in it and nothing underneath, and verify that it says that it
will delete your labels
4. Run `fleetctl gitops` with a default.yml file with `labels:` in it
and nothing underneath, and verify that it removes all your labels

**Test label create/update**
1. Add a label "foo" via the UI
2. Run `fleetctl gitops --dry-run` with a default.yml file with two
`labels:` in it, one named "foo" and one named "bar". Verify that the
output says that one label will be created and one will be updated.
2. Run `fleetctl gitops` with a default.yml file with two `labels:` in
it, one named "foo" and one named "bar". Verify that the two labels now
exist in the UI with the configuration you specified.

**Test label usage**
1. Add a label "foo" in the UI.
1. Run `fleetctl gitops --dry-run` with a default.yml file _without_
`labels:` in it, where a software installer or mdm profile uses the
"foo" label via `labels_include_any`. Verify that the output doesn't
complain about unknown labels.
1. Run `fleetctl gitops --dry-run` with a default.yml file _with_
`labels:` in it with nothing underneath, and a software installer or mdm
profile uses the "foo" label via `labels_include_any`. Verify that the
output complains about unknown label "foo"
1. Run `fleetctl gitops --dry-run` with a default.yml file _with_
`labels:` in it with a "foo" label defined underneath, and a software
installer or mdm profile uses the "foo" label via `labels_include_any`.
Verify that the output doesn't complain about unknown labels.
2025-03-19 16:35:11 -05:00
..
lib Adding secret support to profiles via gitops. (#24675) 2024-12-13 15:41:23 -06:00
subdir Add VPP install automation in GitOps (#25400) 2025-01-14 12:52:39 -06:00
global_config_no_paths.yml Manage labels in GitOps (#27038) 2025-03-19 16:35:11 -05:00
global_config_no_paths_no_controls.yml SE: add CLI automated tests for fleetctl gitops (#23125) 2024-10-23 16:57:56 -04:00
global_config_no_paths_no_labels.yml Manage labels in GitOps (#27038) 2025-03-19 16:35:11 -05:00
global_config_windows_migration_false_false.yml Windows MDM Migration: API, CLI and activities (#24141) 2024-11-26 11:52:56 -05:00
global_config_windows_migration_false_true.yml Windows MDM Migration: API, CLI and activities (#24141) 2024-11-26 11:52:56 -05:00
global_config_windows_migration_true_false.yml Windows MDM Migration: API, CLI and activities (#24141) 2024-11-26 11:52:56 -05:00
global_config_windows_migration_true_true.yml Windows MDM Migration: API, CLI and activities (#24141) 2024-11-26 11:52:56 -05:00
global_integration.yml Adding secret support to profiles via gitops. (#24675) 2024-12-13 15:41:23 -06:00
global_macos_custom_settings_valid_deprecated.yml no team software gitops (#20847) 2024-08-05 14:39:10 -03:00
global_macos_windows_custom_settings_valid.yml no team software gitops (#20847) 2024-08-05 14:39:10 -03:00
global_windows_custom_settings_invalid_label_mix.yml no team software gitops (#20847) 2024-08-05 14:39:10 -03:00
global_windows_custom_settings_invalid_label_mix_2.yml Profile Labels Include Any CLI (#23434) 2024-11-05 15:13:44 -05:00
global_windows_custom_settings_unknown_label.yml no team software gitops (#20847) 2024-08-05 14:39:10 -03:00
no_team_setup_software_invalid_script.yml SE: add CLI automated tests for fleetctl gitops (#23125) 2024-10-23 16:57:56 -04:00
no_team_setup_software_invalid_software_package.yml SE: add CLI automated tests for fleetctl gitops (#23125) 2024-10-23 16:57:56 -04:00
no_team_setup_software_invalid_vpp_app.yml SE: add CLI automated tests for fleetctl gitops (#23125) 2024-10-23 16:57:56 -04:00
no_team_setup_software_valid.yml Bugfix and SE: support VPP apps and (install during setup of VPP apps) in gitops for no-team (#23160) 2024-10-28 10:35:57 -04:00
no_team_software_installer_install_not_found.yml Add policies for "No team" (#21972) 2024-09-12 14:23:25 -03:00
no_team_software_installer_invalid_both_include_exclude.yml SSVL: implement gitops support for labels include/exclude on software packages (#24663) 2024-12-17 14:28:17 -05:00
no_team_software_installer_invalid_self_service_value.yml Add policies for "No team" (#21972) 2024-09-12 14:23:25 -03:00
no_team_software_installer_invalid_unknown_label.yml SSVL: implement gitops support for labels include/exclude on software packages (#24663) 2024-12-17 14:28:17 -05:00
no_team_software_installer_no_url.yml Add policies for "No team" (#21972) 2024-09-12 14:23:25 -03:00
no_team_software_installer_not_found.yml Add policies for "No team" (#21972) 2024-09-12 14:23:25 -03:00
no_team_software_installer_post_install_not_found.yml Add policies for "No team" (#21972) 2024-09-12 14:23:25 -03:00
no_team_software_installer_pre_condition_multiple_queries.yml Add policies for "No team" (#21972) 2024-09-12 14:23:25 -03:00
no_team_software_installer_pre_condition_not_found.yml Add policies for "No team" (#21972) 2024-09-12 14:23:25 -03:00
no_team_software_installer_subdir.yml Fix path resolution for installer queries and scripts to always be relative to where the query file or script is referenced (#23502) 2024-11-07 11:22:08 -06:00
no_team_software_installer_too_large.yml Add policies for "No team" (#21972) 2024-09-12 14:23:25 -03:00
no_team_software_installer_uninstall_not_found.yml Fix breaking changes tests (#22054) 2024-09-12 16:33:44 -03:00
no_team_software_installer_unsupported.yml Add policies for "No team" (#21972) 2024-09-12 14:23:25 -03:00
no_team_software_installer_valid.yml Added GitOps support for uninstall script. (#21969) 2024-09-12 13:25:40 -05:00
no_team_software_installer_valid_exclude.yml SSVL: implement gitops support for labels include/exclude on software packages (#24663) 2024-12-17 14:28:17 -05:00
no_team_software_installer_valid_include.yml SSVL: implement gitops support for labels include/exclude on software packages (#24663) 2024-12-17 14:28:17 -05:00
team_config_no_paths.yml Added GitOps support for uninstall script. (#21969) 2024-09-12 13:25:40 -05:00
team_config_webhook.yml Allow setting failing policy webhook for team via GitOps (#25715) 2025-01-30 11:21:43 -06:00
team_macos_custom_settings_valid_deprecated.yml CP Exclude Labels: CLI changes (#19990) 2024-06-25 16:06:56 -04:00
team_macos_windows_custom_settings_invalid_labels_mix.yml CP Exclude Labels: CLI changes (#19990) 2024-06-25 16:06:56 -04:00
team_macos_windows_custom_settings_invalid_labels_mix_2.yml Profile Labels Include Any CLI (#23434) 2024-11-05 15:13:44 -05:00
team_macos_windows_custom_settings_unknown_label.yml CP Exclude Labels: CLI changes (#19990) 2024-06-25 16:06:56 -04:00
team_macos_windows_custom_settings_valid.yml CP Exclude Labels: CLI changes (#19990) 2024-06-25 16:06:56 -04:00
team_setup_software_invalid_script.yml SE: add CLI automated tests for fleetctl gitops (#23125) 2024-10-23 16:57:56 -04:00
team_setup_software_invalid_software_package.yml SE: add CLI automated tests for fleetctl gitops (#23125) 2024-10-23 16:57:56 -04:00
team_setup_software_invalid_vpp_app.yml SE: add CLI automated tests for fleetctl gitops (#23125) 2024-10-23 16:57:56 -04:00
team_setup_software_valid.yml SE: add CLI automated tests for fleetctl gitops (#23125) 2024-10-23 16:57:56 -04:00
team_software_installer_install_not_found.yml VPP GitOps Config (#20238) 2024-07-10 14:53:03 -04:00
team_software_installer_invalid_both_include_exclude.yml SSVL: implement gitops support for labels include/exclude on software packages (#24663) 2024-12-17 14:28:17 -05:00
team_software_installer_invalid_self_service_value.yml VPP GitOps Config (#20238) 2024-07-10 14:53:03 -04:00
team_software_installer_invalid_unknown_label.yml SSVL: implement gitops support for labels include/exclude on software packages (#24663) 2024-12-17 14:28:17 -05:00
team_software_installer_no_url.yml VPP GitOps Config (#20238) 2024-07-10 14:53:03 -04:00
team_software_installer_not_found.yml VPP GitOps Config (#20238) 2024-07-10 14:53:03 -04:00
team_software_installer_post_install_not_found.yml VPP GitOps Config (#20238) 2024-07-10 14:53:03 -04:00
team_software_installer_pre_condition_multiple_queries.yml VPP GitOps Config (#20238) 2024-07-10 14:53:03 -04:00
team_software_installer_pre_condition_multiple_queries_apply.yml Use gitops format for software installer query (#20891) 2024-08-01 14:36:40 -04:00
team_software_installer_pre_condition_not_found.yml VPP GitOps Config (#20238) 2024-07-10 14:53:03 -04:00
team_software_installer_subdir.yml Fix path resolution for installer queries and scripts to always be relative to where the query file or script is referenced (#23502) 2024-11-07 11:22:08 -06:00
team_software_installer_too_large.yml VPP GitOps Config (#20238) 2024-07-10 14:53:03 -04:00
team_software_installer_uninstall_not_found.yml Added GitOps support for uninstall script. (#21969) 2024-09-12 13:25:40 -05:00
team_software_installer_unsupported.yml VPP GitOps Config (#20238) 2024-07-10 14:53:03 -04:00
team_software_installer_valid.yml Added GitOps support for uninstall script. (#21969) 2024-09-12 13:25:40 -05:00
team_software_installer_valid_apply.yml Use gitops format for software installer query (#20891) 2024-08-01 14:36:40 -04:00
team_software_installer_valid_env_query.yml Use gitops format for software installer query (#20891) 2024-08-01 14:36:40 -04:00
team_software_installer_valid_exclude.yml SSVL: implement gitops support for labels include/exclude on software packages (#24663) 2024-12-17 14:28:17 -05:00
team_software_installer_valid_include.yml SSVL: implement gitops support for labels include/exclude on software packages (#24663) 2024-12-17 14:28:17 -05:00
team_vpp_empty_adamid.yml Ensure empty gitops AdamIDs return an error to the user (#21087) 2024-08-06 12:00:56 -04:00
team_vpp_incorrect_type.yml Clearer type error for software VPP app IDs (#21760) 2024-09-09 15:26:21 -04:00
team_vpp_invalid_app.yml VPP Batch API (#20351) 2024-07-22 13:19:19 -04:00
team_vpp_invalid_app_labels_both.yml Add labels and editing for VPP apps (#25979) 2025-02-03 11:16:21 -06:00
team_vpp_invalid_app_labels_exclude_any.yml Add labels and editing for VPP apps (#25979) 2025-02-03 11:16:21 -06:00
team_vpp_invalid_app_labels_include_any.yml Add labels and editing for VPP apps (#25979) 2025-02-03 11:16:21 -06:00
team_vpp_valid_app.yml VPP Batch API (#20351) 2024-07-22 13:19:19 -04:00
team_vpp_valid_app_labels_exclude_any.yml Add labels and editing for VPP apps (#25979) 2025-02-03 11:16:21 -06:00
team_vpp_valid_app_labels_include_any.yml Add labels and editing for VPP apps (#25979) 2025-02-03 11:16:21 -06:00
team_vpp_valid_app_self_service.yml SSVPP Backend and CLI (#21132) 2024-08-14 10:25:32 -04:00
team_vpp_valid_empty.yml VPP Batch API (#20351) 2024-07-22 13:19:19 -04:00