Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: default-required feature flag #2211

Open
wants to merge 147 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 67 commits
Commits
Show all changes
147 commits
Select commit Hold shift + click to select a range
b27ed3b
required --> optional transition
Noxsios Jan 2, 2024
c93fabd
docs and scheme
Noxsios Jan 2, 2024
7fe7919
migrate
Noxsios Jan 2, 2024
d3d2d9b
docs and scheme
Noxsios Jan 2, 2024
0e17d52
unit tests
Noxsios Jan 2, 2024
3eb3a0c
cleaner override logic
Noxsios Jan 2, 2024
5e6056f
fix zarf-seed-registry optional status
Noxsios Jan 2, 2024
2a98254
fix example
Noxsios Jan 2, 2024
7b13799
fix tests + examples
Noxsios Jan 2, 2024
2ffd606
initial migration code
Noxsios Jan 2, 2024
d1d7258
add warning to migrate
Noxsios Jan 2, 2024
d05c515
cleanup
Noxsios Jan 2, 2024
36bfdf4
cleanup
Noxsios Jan 2, 2024
59e769f
fix example
Noxsios Jan 2, 2024
e88fa82
fix migrations overwriting mutations
Noxsios Jan 2, 2024
0246af6
upgrade flake
Noxsios Jan 3, 2024
acac49d
revert upgrade package required
Noxsios Jan 3, 2024
ac50291
init adr 23
Noxsios Jan 3, 2024
b3988ee
Merge branch 'main' into required-components
Noxsios Jan 3, 2024
adeebc3
seasonal migrations
Noxsios Jan 3, 2024
4d7de02
upgrade workflow and override and validate fixes
Noxsios Jan 3, 2024
37c9f28
tweaks
Noxsios Jan 3, 2024
5121822
tweaks
Noxsios Jan 3, 2024
829eecc
dev migrate
Noxsios Jan 4, 2024
0179509
docs and schema
Noxsios Jan 4, 2024
7ab1b8b
lets get silly with it
Noxsios Jan 4, 2024
f7b77b4
docs and schema
Noxsios Jan 4, 2024
755f7ce
logic
Noxsios Jan 4, 2024
a52c056
move some stuff out of packger and into interactive
Noxsios Jan 4, 2024
2e4ac72
fix clear logic
Noxsios Jan 5, 2024
e3a74f2
re-org
Noxsios Jan 5, 2024
f05fd16
lets go the distance
Noxsios Jan 5, 2024
18f9a29
docs and schema
Noxsios Jan 5, 2024
c948451
a little cleaner error
Noxsios Jan 5, 2024
9f787c7
resolve convos
Noxsios Jan 6, 2024
e257ce8
Merge branch 'main' into required-components
Noxsios Jan 8, 2024
b45eaed
cleanup
Noxsios Jan 9, 2024
ab03c58
cli stuffs
Noxsios Jan 9, 2024
c4ffd81
docs and schema
Noxsios Jan 9, 2024
b91fcf4
handle differences in filtering OCI based upon operation
Noxsios Jan 9, 2024
2c70de7
rename symbol
Noxsios Jan 9, 2024
7900e4f
Merge branch 'main' into required-components
Noxsios Jan 9, 2024
519d220
Merge branch 'main' into required-components
Noxsios Jan 11, 2024
0e698fc
my new insanity
Noxsios Jan 11, 2024
a758a27
spdx
Noxsios Jan 11, 2024
c254463
lint
Noxsios Jan 11, 2024
5bcf902
filter manager
Noxsios Jan 12, 2024
1dd33c8
move unit tests
Noxsios Jan 12, 2024
e612765
fix deploy
Noxsios Jan 14, 2024
4037da6
smarter
Noxsios Jan 14, 2024
f82b0f3
tweaks
Noxsios Jan 16, 2024
28dbfc9
dev migrate cli autocomplete
Noxsios Jan 16, 2024
0db5904
handle unset cli version
Noxsios Jan 16, 2024
826bb09
docs and schema
Noxsios Jan 16, 2024
3a2dc36
fix dev migrate --run --run
Noxsios Jan 16, 2024
44fe5ec
fix dev deploy version
Noxsios Jan 20, 2024
1129035
Merge branch 'main' into required-components
Noxsios Jan 20, 2024
78bdb71
fix upgrade test, little ugly
Noxsios Jan 21, 2024
e5965c4
rename string
Noxsios Jan 22, 2024
96664d4
Merge branch 'main' into required-components
Noxsios Jan 22, 2024
6fa3e2c
Merge branch 'main' into required-components
Noxsios Jan 28, 2024
1ad2e58
slighly different filter based on isInteractive
Noxsios Jan 28, 2024
c9ba849
fix component choice
Noxsios Jan 28, 2024
b4adcbe
remove usage of required
Noxsios Jan 28, 2024
985114d
Merge branch 'main' into required-components
Noxsios Jan 29, 2024
44367a6
optional agrees w/ required if required is set and optional dne
Noxsios Jan 30, 2024
a92602a
changes from review
Noxsios Feb 2, 2024
db974ce
cleanup
Noxsios Feb 5, 2024
e14b48e
utils fn
Noxsios Feb 5, 2024
cd3a266
feedback
Noxsios Feb 5, 2024
8f0fb19
update adr
Noxsios Feb 5, 2024
e19e3c5
changes from review
Noxsios Feb 5, 2024
1bc07c8
Merge branch 'main' into required-components
Noxsios Feb 6, 2024
6e6472c
revert
Noxsios Feb 6, 2024
cc99d8d
simpler filter logic
Noxsios Feb 6, 2024
b8e4996
migrate manifest-with-symlink
Noxsios Feb 6, 2024
4df3415
Merge branch 'main' into required-components
Noxsios Feb 7, 2024
e766cba
Merge branch 'main' into required-components
Noxsios Feb 8, 2024
a059543
feedback
Noxsios Feb 9, 2024
7cf2339
feedback
Noxsios Feb 9, 2024
7cca728
Merge branch 'main' into required-components
Noxsios Feb 9, 2024
41b9d29
comments
Noxsios Feb 9, 2024
a2cf0e5
Merge branch 'main' into required-components
Noxsios Feb 17, 2024
a7d9ccb
unit testing filters
Noxsios Feb 18, 2024
d3e342c
comments
Noxsios Feb 18, 2024
693b794
move stuff to a better spot
Noxsios Feb 18, 2024
3bc3f97
remove multi from eks distro
Noxsios Feb 18, 2024
fe8c233
md
Noxsios Feb 18, 2024
2e823b7
more unit tests
Noxsios Feb 19, 2024
57b0bd8
rename
Noxsios Feb 19, 2024
f61a836
fix unit tests
Noxsios Feb 19, 2024
6a16db9
Merge branch 'main' into required-components
Noxsios Feb 21, 2024
8a0a33f
Merge branch 'main' into required-components
Noxsios Mar 25, 2024
8873032
fix compile errors
Noxsios Mar 25, 2024
78cd6d7
Merge branch 'main' into required-components
Noxsios Mar 26, 2024
0cbd06f
fix unit tests
Noxsios Mar 27, 2024
e166cba
Merge branch 'main' into required-components
Noxsios Mar 28, 2024
2a66b29
feature flag
Noxsios Apr 2, 2024
2433771
feature flag
Noxsios Apr 2, 2024
bfc150a
docs and schema
Noxsios Apr 2, 2024
0f8fa6d
restore examples and packages
Noxsios Apr 2, 2024
e521098
restore upgrade test
Noxsios Apr 2, 2024
8d2b5ba
restore test packages
Noxsios Apr 2, 2024
9b25338
restore test packages
Noxsios Apr 2, 2024
cc2d72a
ok, i might be a little crazy
Noxsios Apr 3, 2024
7f17d63
docs and schema
Noxsios Apr 3, 2024
6bd2941
don't format and don't mutate, use stdout
Noxsios Apr 3, 2024
2701990
cleanup
Noxsios Apr 3, 2024
16d6bcf
ux
Noxsios Apr 4, 2024
cdd4f9e
update ADR
Noxsios Apr 4, 2024
116f33b
Merge branch 'main' into required-components
Noxsios Apr 4, 2024
1f5a719
cleanup
Noxsios Apr 4, 2024
c310870
cleanup
Noxsios Apr 4, 2024
d91590b
cleanup
Noxsios Apr 5, 2024
1e2404d
rename from beta features to just features
Noxsios Apr 9, 2024
d4841d1
docs and schema
Noxsios Apr 9, 2024
14786e2
docs and schema
Noxsios Apr 9, 2024
b882fe7
validate changes broken into separate PR
Noxsios Apr 9, 2024
baf3368
use Run instead of RunE for consistency
Noxsios Apr 9, 2024
d492e17
re-update validate
Noxsios Apr 9, 2024
7d7b3f8
revert
Noxsios Apr 9, 2024
298d250
Merge branch 'main' into required-components
Noxsios Apr 10, 2024
9af072b
docs and schema
Noxsios Apr 10, 2024
ff3110b
Merge branch 'main' into required-components
Noxsios Apr 25, 2024
2916c45
docs and schema
Noxsios Apr 25, 2024
2e3e175
Merge branch 'main' into required-components
Noxsios Apr 25, 2024
bdf02e7
Merge branch 'main' into required-components
Noxsios Apr 26, 2024
b6789e8
move group deprecation from migration to read
Noxsios Apr 29, 2024
be2f2d8
update ADR
Noxsios Apr 29, 2024
7e4531c
Merge branch 'main' into required-components
Noxsios Apr 29, 2024
3d33cd4
better use of generics and composition
Noxsios May 1, 2024
31d213d
Merge branch 'main' into required-components
Noxsios May 3, 2024
ade37ca
Merge branch 'main' into required-components
Noxsios May 6, 2024
aefb2c2
Merge branch 'main' into required-components
Noxsios May 7, 2024
8a342dc
Merge branch 'main' into required-components
Noxsios May 7, 2024
0c15945
Merge branch 'main' into required-components
Noxsios May 9, 2024
9519392
restore docs due to non-breaking
Noxsios May 10, 2024
2375770
breaking change, will need to discuss
Noxsios May 10, 2024
e23d898
Merge branch 'main' into required-components
Noxsios May 14, 2024
be6d51d
cleanup
Noxsios May 14, 2024
bab6b53
Merge branch 'main' into required-components
Noxsios May 15, 2024
0e1ef9b
rm validate
Noxsios May 15, 2024
f12b143
Merge branch 'main' into required-components
Noxsios May 16, 2024
e395d04
Merge branch 'main' into required-components
Noxsios May 21, 2024
ece00d1
revert behavior
Noxsios May 21, 2024
7cc9973
Merge branch 'main' into required-components
Noxsios May 22, 2024
0368956
rebase
May 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions .github/workflows/test-upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:

- name: Initialize the cluster with the release version
# NOTE: "PATH=$PATH" preserves the default user $PATH. This is needed to maintain the version of zarf installed
# in a previous step. This test run will the current release to create a K3s cluster.
# in a previous step. This test run will use the current release to create a K3s cluster.
run: |
sudo env "PATH=$PATH" CI=true zarf init --components k3s,git-server,logging --nodeport 31337 --confirm

Expand All @@ -79,10 +79,10 @@ jobs:

- name: Create and deploy the upgrade test packages
# NOTE: "PATH=$PATH" preserves the default user $PATH. This is needed to maintain the version of zarf installed
# in a previous step. This test run will the current release to create a K3s cluster.
# in a previous step. This test run will use the current release to create a K3s cluster.
run: |
zarf package create src/test/upgrade --set PODINFO_VERSION=6.3.3 --confirm
sudo env "PATH=$PATH" CI=true zarf package deploy zarf-package-test-upgrade-package-amd64-6.3.3.tar.zst --confirm
zarf package create src/test/upgrade/pre-0.33 --set PODINFO_VERSION=6.3.3 --confirm
sudo env "PATH=$PATH" CI=true zarf package deploy zarf-package-test-upgrade-package-amd64-6.3.3.tar.zst --components="test-upgrade-package" --confirm
sudo env "PATH=$PATH" CI=true zarf tools kubectl describe deployments -n=podinfo-upgrade
sudo env "PATH=$PATH" CI=true zarf tools kubectl describe pods -n=podinfo-upgrade

Expand All @@ -105,12 +105,10 @@ jobs:

- name: Run the upgrade tests
# NOTE: "PATH=$PATH" preserves the default user $PATH. This is needed to maintain the version of zarf installed
# in a previous step. This test run will the current release to create a K3s cluster.
# in a previous step. This test run will use the current release to create a K3s cluster.
run: |
sudo env "PATH=$PATH" CI=true zarf tools kubectl describe nodes

zarf package create src/test/upgrade --set PODINFO_VERSION=6.3.4 --confirm
Noxsios marked this conversation as resolved.
Show resolved Hide resolved

sudo env "PATH=$PATH" CI=true make test-upgrade ARCH=amd64

- name: Save logs
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ else
endif
endif

CLI_VERSION ?= $(if $(shell git describe --tags),$(shell git describe --tags),"UnknownVersion")
CLI_VERSION ?= $(if $(shell git describe --tags),$(shell git describe --tags),"unset-development-only")
BUILD_ARGS := -s -w -X github.com/defenseunicorns/zarf/src/config.CLIVersion=$(CLI_VERSION)
K8S_MODULES_VER=$(subst ., ,$(subst v,,$(shell go list -f '{{.Version}}' -m k8s.io/client-go)))
K8S_MODULES_MAJOR_VER=$(shell echo $$(($(firstword $(K8S_MODULES_VER)) + 1)))
Expand Down Expand Up @@ -193,12 +193,13 @@ test-upgrade: ## Run the Zarf CLI E2E tests for an external registry and cluster
@test -s $(ZARF_BIN) || $(MAKE) build-cli
[ -n "$(shell zarf version)" ] || (echo "Zarf must be installed prior to the upgrade test" && exit 1)
[ -n "$(shell zarf package list 2>&1 | grep test-upgrade-package)" ] || (echo "Zarf must be initialized and have the 6.3.3 upgrade-test package installed prior to the upgrade test" && exit 1)
@test -s "zarf-package-test-upgrade-package-amd64-6.3.4.tar.zst" || zarf package create src/test/upgrade/ --set PODINFO_VERSION=6.3.4 --confirm
@test -s ./zarf-package-test-upgrade-package-$(ARCH)-6.3.4.tar.zst || zarf package create src/test/upgrade/pre-0.33 --set PODINFO_VERSION=6.3.4 --confirm
cd src/test/upgrade && go test -failfast -v -timeout 30m

.PHONY: test-unit
test-unit: ## Run unit tests
cd src/pkg && go test ./... -failfast -v -timeout 30m
cd src/types && go test ./... -failfast -v -timeout 30m
cd src/internal && go test ./... -failfast -v timeout 30m
cd src/extensions/bigbang && go test ./. -failfast -v timeout 30m

Expand Down
1 change: 0 additions & 1 deletion adr/0017-zarf-bundle.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Currently there is no official way to enable the deployment, publishing, pulling

```yaml
- name: init
required: true
files:
- source: zarf-init-amd64-v0.27.0.tar.zst
target: zarf-init-amd64-v0.27.0.tar.zst
Expand Down
39 changes: 39 additions & 0 deletions adr/0023-required-optional.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# 23. Required -> Optional

Date: 2024-01-02

## Status

Pending
Noxsios marked this conversation as resolved.
Show resolved Hide resolved

## Context

> Feature request: <https://github.com/defenseunicorns/zarf/issues/2059>

Currently, all Zarf components default to being optional due to the `required` key being _optional_ in the yaml. This leads to package authors needing to ensure that they annotate this key for each component, and since nothing in the current validations prompts them about this they may be confused about the "all things are optional" default state.

When Zarf was first created, we didn't really know how it would evolve and this key was introduced in those very early days. At this point it would be better to require all components by default--especially with the introduction of composability and the OCI skeleton work, there is plenty of flexibility in the API to compose bespoke packages assembled from other packages.

A few ways to handle this:

1. Simply force the `required` key to be a non-optional, so that package authors would be forced to specify it for each component, thereby removing any ambiguity--but also force one more key for every single component ever created 🫠

2. Deprecate `required` and introduce an optional `optional` key, which would default to _false_.

3. Do something more significant like combine various condition-based things such as `only`, `optional` (instead of `required`), or `default`.

## Decision

> The change that we're proposing or have agreed to implement.

Option 2: deprecate `required` and introduce an optional `optional` key, which defaults to _false_.

Components are now **required** by default, instead of **optional**.

## Consequences

`zarf package create` will fail if any usage of `required` is detected in the `zarf.yaml`, resulting in some thrash for package creators.
Noxsios marked this conversation as resolved.
Show resolved Hide resolved

Packages created w/ Zarf v0.33.0+ will have their implicit _required_ logic flipped from previous versions (implicit `required: false` --> implicit `optional: false`).

A `required-to-optional` migration.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
version: "1.4.2"
components:
- name: longhorn-environment-check
required: true
files:
- source: https://raw.githubusercontent.com/longhorn/longhorn/v1.4.2/scripts/environment_check.sh
target: environment_check.sh
Expand All @@ -78,7 +77,6 @@
chmod +x ./environment_check.sh
./environment_check.sh
- name: longhorn
required: true
description: "Deploy Longhorn into a Kubernetes cluster. https://longhorn.io"
actions:
# Set the delete confirmation flag for Longhorn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@

components:
- name: helm-oci-chart
required: true
charts:
- name: podinfo
version: 6.3.3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@

components:
- name: helm-oci-chart
required: true
charts:
- name: podinfo
version: 6.3.3
Expand Down
1 change: 1 addition & 0 deletions docs/2-the-zarf-cli/100-cli-commands/zarf_dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Commands useful for developing packages
* [zarf dev find-images](zarf_dev_find-images.md) - Evaluates components in a Zarf file to identify images specified in their helm charts and manifests
* [zarf dev generate-config](zarf_dev_generate-config.md) - Generates a config file for Zarf
* [zarf dev lint](zarf_dev_lint.md) - Lints the given package for valid schema and recommended practices
* [zarf dev migrate](zarf_dev_migrate.md) - [beta] Migrates the zarf.yaml in a given directory to the latest version of the zarf.yaml format
* [zarf dev patch-git](zarf_dev_patch-git.md) - Converts all .git URLs to the specified Zarf HOST and with the Zarf URL pattern in a given FILE. NOTE:
This should only be used for manifests that are not mutated by the Zarf Agent Mutating Webhook.
* [zarf dev sha256sum](zarf_dev_sha256sum.md) - Generates a SHA256SUM for the given file
38 changes: 38 additions & 0 deletions docs/2-the-zarf-cli/100-cli-commands/zarf_dev_migrate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# zarf dev migrate
<!-- Auto-generated by hack/gen-cli-docs.sh -->

[beta] Migrates the zarf.yaml in a given directory to the latest version of the zarf.yaml format

## Synopsis

[beta] Migrates the zarf.yaml in a given directory to the latest version of the zarf.yaml format.

This command modifies the original zarf.yaml file, performs a best effort attempt to preserve comments, and will format the contents in an opinionated manner.

```
zarf dev migrate [flags]
```

## Options

```
-h, --help help for migrate
--run stringArray migrations to run (default: all, available: scripts-to-actions, pluralize-set-variable, required-to-optional)
```

## Options inherited from parent commands

```
-a, --architecture string Architecture for OCI images and Zarf packages
--insecure Allow access to insecure registries and disable other recommended security enforcements such as package checksum and signature validation. This flag should only be used if you have a specific reason and accept the reduced security posture.
-l, --log-level string Log level when running Zarf. Valid options are: warn, info, debug, trace (default "info")
--no-color Disable colors in output
--no-log-file Disable log file creation
--no-progress Disable fancy UI progress bars, spinners, logos, etc
--tmpdir string Specify the temporary directory to use for intermediate files
--zarf-cache string Specify the location of the Zarf cache directory (default "~/.zarf-cache")
```

## SEE ALSO

* [zarf dev](zarf_dev.md) - Commands useful for developing packages
Loading
Loading