From f4a389514305ccb17a16d04edabd841b007de040 Mon Sep 17 00:00:00 2001 From: Austin Abro <37223396+AustinAbro321@users.noreply.github.com> Date: Wed, 20 Nov 2024 15:52:50 -0500 Subject: [PATCH 01/15] chore: unhide log-format flag (#3251) Signed-off-by: Austin Abro --- site/src/content/docs/commands/zarf.md | 1 + site/src/content/docs/commands/zarf_completion.md | 1 + site/src/content/docs/commands/zarf_completion_bash.md | 1 + site/src/content/docs/commands/zarf_completion_fish.md | 1 + .../src/content/docs/commands/zarf_completion_powershell.md | 1 + site/src/content/docs/commands/zarf_completion_zsh.md | 1 + site/src/content/docs/commands/zarf_connect.md | 1 + site/src/content/docs/commands/zarf_connect_list.md | 1 + site/src/content/docs/commands/zarf_destroy.md | 1 + site/src/content/docs/commands/zarf_dev.md | 1 + site/src/content/docs/commands/zarf_dev_deploy.md | 1 + site/src/content/docs/commands/zarf_dev_find-images.md | 1 + site/src/content/docs/commands/zarf_dev_generate-config.md | 1 + site/src/content/docs/commands/zarf_dev_generate.md | 1 + site/src/content/docs/commands/zarf_dev_lint.md | 1 + site/src/content/docs/commands/zarf_dev_patch-git.md | 1 + site/src/content/docs/commands/zarf_dev_sha256sum.md | 1 + site/src/content/docs/commands/zarf_init.md | 1 + site/src/content/docs/commands/zarf_package.md | 1 + site/src/content/docs/commands/zarf_package_create.md | 1 + site/src/content/docs/commands/zarf_package_deploy.md | 1 + site/src/content/docs/commands/zarf_package_inspect.md | 1 + site/src/content/docs/commands/zarf_package_list.md | 1 + .../content/docs/commands/zarf_package_mirror-resources.md | 1 + site/src/content/docs/commands/zarf_package_publish.md | 1 + site/src/content/docs/commands/zarf_package_pull.md | 1 + site/src/content/docs/commands/zarf_package_remove.md | 1 + site/src/content/docs/commands/zarf_tools.md | 1 + site/src/content/docs/commands/zarf_tools_archiver.md | 1 + .../content/docs/commands/zarf_tools_archiver_compress.md | 1 + .../content/docs/commands/zarf_tools_archiver_decompress.md | 1 + .../content/docs/commands/zarf_tools_archiver_version.md | 1 + site/src/content/docs/commands/zarf_tools_clear-cache.md | 1 + site/src/content/docs/commands/zarf_tools_download-init.md | 1 + site/src/content/docs/commands/zarf_tools_gen-key.md | 1 + site/src/content/docs/commands/zarf_tools_gen-pki.md | 1 + site/src/content/docs/commands/zarf_tools_get-creds.md | 1 + site/src/content/docs/commands/zarf_tools_update-creds.md | 1 + site/src/content/docs/commands/zarf_version.md | 1 + src/cmd/internal.go | 1 + src/cmd/root.go | 6 +----- 41 files changed, 41 insertions(+), 5 deletions(-) diff --git a/site/src/content/docs/commands/zarf.md b/site/src/content/docs/commands/zarf.md index 0ed3312946..2abaf2d473 100644 --- a/site/src/content/docs/commands/zarf.md +++ b/site/src/content/docs/commands/zarf.md @@ -25,6 +25,7 @@ zarf COMMAND [flags] -a, --architecture string Architecture for OCI images and Zarf packages -h, --help help for zarf --insecure-skip-tls-verify Skip checking server's certificate for validity. This flag should only be used if you have a specific reason and accept the reduced security posture. + --log-format string [alpha] Select a logging format. Defaults to 'text'. Valid options are: 'text', 'json', 'console', 'dev' -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 diff --git a/site/src/content/docs/commands/zarf_completion.md b/site/src/content/docs/commands/zarf_completion.md index 99a58b833a..dfeb5e7d08 100644 --- a/site/src/content/docs/commands/zarf_completion.md +++ b/site/src/content/docs/commands/zarf_completion.md @@ -27,6 +27,7 @@ See each sub-command's help for details on how to use the generated script. ``` -a, --architecture string Architecture for OCI images and Zarf packages --insecure-skip-tls-verify Skip checking server's certificate for validity. This flag should only be used if you have a specific reason and accept the reduced security posture. + --log-format string [alpha] Select a logging format. Defaults to 'text'. Valid options are: 'text', 'json', 'console', 'dev' -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 diff --git a/site/src/content/docs/commands/zarf_completion_bash.md b/site/src/content/docs/commands/zarf_completion_bash.md index 349bbf7e0a..01a8516499 100644 --- a/site/src/content/docs/commands/zarf_completion_bash.md +++ b/site/src/content/docs/commands/zarf_completion_bash.md @@ -50,6 +50,7 @@ zarf completion bash ``` -a, --architecture string Architecture for OCI images and Zarf packages --insecure-skip-tls-verify Skip checking server's certificate for validity. This flag should only be used if you have a specific reason and accept the reduced security posture. + --log-format string [alpha] Select a logging format. Defaults to 'text'. Valid options are: 'text', 'json', 'console', 'dev' -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 diff --git a/site/src/content/docs/commands/zarf_completion_fish.md b/site/src/content/docs/commands/zarf_completion_fish.md index de3f70b160..7b6953dece 100644 --- a/site/src/content/docs/commands/zarf_completion_fish.md +++ b/site/src/content/docs/commands/zarf_completion_fish.md @@ -41,6 +41,7 @@ zarf completion fish [flags] ``` -a, --architecture string Architecture for OCI images and Zarf packages --insecure-skip-tls-verify Skip checking server's certificate for validity. This flag should only be used if you have a specific reason and accept the reduced security posture. + --log-format string [alpha] Select a logging format. Defaults to 'text'. Valid options are: 'text', 'json', 'console', 'dev' -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 diff --git a/site/src/content/docs/commands/zarf_completion_powershell.md b/site/src/content/docs/commands/zarf_completion_powershell.md index 53add1dc9a..880f91bac3 100644 --- a/site/src/content/docs/commands/zarf_completion_powershell.md +++ b/site/src/content/docs/commands/zarf_completion_powershell.md @@ -38,6 +38,7 @@ zarf completion powershell [flags] ``` -a, --architecture string Architecture for OCI images and Zarf packages --insecure-skip-tls-verify Skip checking server's certificate for validity. This flag should only be used if you have a specific reason and accept the reduced security posture. + --log-format string [alpha] Select a logging format. Defaults to 'text'. Valid options are: 'text', 'json', 'console', 'dev' -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 diff --git a/site/src/content/docs/commands/zarf_completion_zsh.md b/site/src/content/docs/commands/zarf_completion_zsh.md index 94bdf43f4d..2806b879c5 100644 --- a/site/src/content/docs/commands/zarf_completion_zsh.md +++ b/site/src/content/docs/commands/zarf_completion_zsh.md @@ -52,6 +52,7 @@ zarf completion zsh [flags] ``` -a, --architecture string Architecture for OCI images and Zarf packages --insecure-skip-tls-verify Skip checking server's certificate for validity. This flag should only be used if you have a specific reason and accept the reduced security posture. + --log-format string [alpha] Select a logging format. Defaults to 'text'. Valid options are: 'text', 'json', 'console', 'dev' -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 diff --git a/site/src/content/docs/commands/zarf_connect.md b/site/src/content/docs/commands/zarf_connect.md index 1b504873ab..d4ee6637b1 100644 --- a/site/src/content/docs/commands/zarf_connect.md +++ b/site/src/content/docs/commands/zarf_connect.md @@ -41,6 +41,7 @@ zarf connect { REGISTRY | GIT | connect-name } [flags] ``` -a, --architecture string Architecture for OCI images and Zarf packages --insecure-skip-tls-verify Skip checking server's certificate for validity. This flag should only be used if you have a specific reason and accept the reduced security posture. + --log-format string [alpha] Select a logging format. Defaults to 'text'. Valid options are: 'text', 'json', 'console', 'dev' -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 diff --git a/site/src/content/docs/commands/zarf_connect_list.md b/site/src/content/docs/commands/zarf_connect_list.md index 8829b812e0..51cece492e 100644 --- a/site/src/content/docs/commands/zarf_connect_list.md +++ b/site/src/content/docs/commands/zarf_connect_list.md @@ -25,6 +25,7 @@ zarf connect list [flags] ``` -a, --architecture string Architecture for OCI images and Zarf packages --insecure-skip-tls-verify Skip checking server's certificate for validity. This flag should only be used if you have a specific reason and accept the reduced security posture. + --log-format string [alpha] Select a logging format. Defaults to 'text'. Valid options are: 'text', 'json', 'console', 'dev' -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 diff --git a/site/src/content/docs/commands/zarf_destroy.md b/site/src/content/docs/commands/zarf_destroy.md index 64608f4e58..5515c30c58 100644 --- a/site/src/content/docs/commands/zarf_destroy.md +++ b/site/src/content/docs/commands/zarf_destroy.md @@ -37,6 +37,7 @@ zarf destroy --confirm [flags] ``` -a, --architecture string Architecture for OCI images and Zarf packages --insecure-skip-tls-verify Skip checking server's certificate for validity. This flag should only be used if you have a specific reason and accept the reduced security posture. + --log-format string [alpha] Select a logging format. Defaults to 'text'. Valid options are: 'text', 'json', 'console', 'dev' -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 diff --git a/site/src/content/docs/commands/zarf_dev.md b/site/src/content/docs/commands/zarf_dev.md index 0dd4d1e4f1..2669e39b67 100644 --- a/site/src/content/docs/commands/zarf_dev.md +++ b/site/src/content/docs/commands/zarf_dev.md @@ -21,6 +21,7 @@ Commands useful for developing packages ``` -a, --architecture string Architecture for OCI images and Zarf packages --insecure-skip-tls-verify Skip checking server's certificate for validity. This flag should only be used if you have a specific reason and accept the reduced security posture. + --log-format string [alpha] Select a logging format. Defaults to 'text'. Valid options are: 'text', 'json', 'console', 'dev' -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 diff --git a/site/src/content/docs/commands/zarf_dev_deploy.md b/site/src/content/docs/commands/zarf_dev_deploy.md index b08c142478..e0e1842db7 100644 --- a/site/src/content/docs/commands/zarf_dev_deploy.md +++ b/site/src/content/docs/commands/zarf_dev_deploy.md @@ -38,6 +38,7 @@ zarf dev deploy [flags] ``` -a, --architecture string Architecture for OCI images and Zarf packages --insecure-skip-tls-verify Skip checking server's certificate for validity. This flag should only be used if you have a specific reason and accept the reduced security posture. + --log-format string [alpha] Select a logging format. Defaults to 'text'. Valid options are: 'text', 'json', 'console', 'dev' -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 diff --git a/site/src/content/docs/commands/zarf_dev_find-images.md b/site/src/content/docs/commands/zarf_dev_find-images.md index a5f94578ee..7c1eb61b39 100644 --- a/site/src/content/docs/commands/zarf_dev_find-images.md +++ b/site/src/content/docs/commands/zarf_dev_find-images.md @@ -39,6 +39,7 @@ zarf dev find-images [ PACKAGE ] [flags] ``` -a, --architecture string Architecture for OCI images and Zarf packages --insecure-skip-tls-verify Skip checking server's certificate for validity. This flag should only be used if you have a specific reason and accept the reduced security posture. + --log-format string [alpha] Select a logging format. Defaults to 'text'. Valid options are: 'text', 'json', 'console', 'dev' -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 diff --git a/site/src/content/docs/commands/zarf_dev_generate-config.md b/site/src/content/docs/commands/zarf_dev_generate-config.md index cb5040f133..86878db2b9 100644 --- a/site/src/content/docs/commands/zarf_dev_generate-config.md +++ b/site/src/content/docs/commands/zarf_dev_generate-config.md @@ -34,6 +34,7 @@ zarf dev generate-config [ FILENAME ] [flags] ``` -a, --architecture string Architecture for OCI images and Zarf packages --insecure-skip-tls-verify Skip checking server's certificate for validity. This flag should only be used if you have a specific reason and accept the reduced security posture. + --log-format string [alpha] Select a logging format. Defaults to 'text'. Valid options are: 'text', 'json', 'console', 'dev' -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 diff --git a/site/src/content/docs/commands/zarf_dev_generate.md b/site/src/content/docs/commands/zarf_dev_generate.md index 58ffc1102f..6f82e67995 100644 --- a/site/src/content/docs/commands/zarf_dev_generate.md +++ b/site/src/content/docs/commands/zarf_dev_generate.md @@ -36,6 +36,7 @@ zarf dev generate podinfo --url https://github.com/stefanprodan/podinfo.git --ve ``` -a, --architecture string Architecture for OCI images and Zarf packages --insecure-skip-tls-verify Skip checking server's certificate for validity. This flag should only be used if you have a specific reason and accept the reduced security posture. + --log-format string [alpha] Select a logging format. Defaults to 'text'. Valid options are: 'text', 'json', 'console', 'dev' -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 diff --git a/site/src/content/docs/commands/zarf_dev_lint.md b/site/src/content/docs/commands/zarf_dev_lint.md index 57827ee0ed..753362c5ef 100644 --- a/site/src/content/docs/commands/zarf_dev_lint.md +++ b/site/src/content/docs/commands/zarf_dev_lint.md @@ -31,6 +31,7 @@ zarf dev lint [ DIRECTORY ] [flags] ``` -a, --architecture string Architecture for OCI images and Zarf packages --insecure-skip-tls-verify Skip checking server's certificate for validity. This flag should only be used if you have a specific reason and accept the reduced security posture. + --log-format string [alpha] Select a logging format. Defaults to 'text'. Valid options are: 'text', 'json', 'console', 'dev' -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 diff --git a/site/src/content/docs/commands/zarf_dev_patch-git.md b/site/src/content/docs/commands/zarf_dev_patch-git.md index 4a3b2553d0..f4de661dab 100644 --- a/site/src/content/docs/commands/zarf_dev_patch-git.md +++ b/site/src/content/docs/commands/zarf_dev_patch-git.md @@ -27,6 +27,7 @@ zarf dev patch-git HOST FILE [flags] ``` -a, --architecture string Architecture for OCI images and Zarf packages --insecure-skip-tls-verify Skip checking server's certificate for validity. This flag should only be used if you have a specific reason and accept the reduced security posture. + --log-format string [alpha] Select a logging format. Defaults to 'text'. Valid options are: 'text', 'json', 'console', 'dev' -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 diff --git a/site/src/content/docs/commands/zarf_dev_sha256sum.md b/site/src/content/docs/commands/zarf_dev_sha256sum.md index 91419a9665..41b1d3f77e 100644 --- a/site/src/content/docs/commands/zarf_dev_sha256sum.md +++ b/site/src/content/docs/commands/zarf_dev_sha256sum.md @@ -26,6 +26,7 @@ zarf dev sha256sum { FILE | URL } [flags] ``` -a, --architecture string Architecture for OCI images and Zarf packages --insecure-skip-tls-verify Skip checking server's certificate for validity. This flag should only be used if you have a specific reason and accept the reduced security posture. + --log-format string [alpha] Select a logging format. Defaults to 'text'. Valid options are: 'text', 'json', 'console', 'dev' -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 diff --git a/site/src/content/docs/commands/zarf_init.md b/site/src/content/docs/commands/zarf_init.md index 0f14453100..7a448e9281 100644 --- a/site/src/content/docs/commands/zarf_init.md +++ b/site/src/content/docs/commands/zarf_init.md @@ -86,6 +86,7 @@ $ zarf init --artifact-push-password={PASSWORD} --artifact-push-username={USERNA ``` -a, --architecture string Architecture for OCI images and Zarf packages --insecure-skip-tls-verify Skip checking server's certificate for validity. This flag should only be used if you have a specific reason and accept the reduced security posture. + --log-format string [alpha] Select a logging format. Defaults to 'text'. Valid options are: 'text', 'json', 'console', 'dev' -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 diff --git a/site/src/content/docs/commands/zarf_package.md b/site/src/content/docs/commands/zarf_package.md index a8d1244e58..37ba5dfdf9 100644 --- a/site/src/content/docs/commands/zarf_package.md +++ b/site/src/content/docs/commands/zarf_package.md @@ -23,6 +23,7 @@ Zarf package commands for creating, deploying, and inspecting packages ``` -a, --architecture string Architecture for OCI images and Zarf packages --insecure-skip-tls-verify Skip checking server's certificate for validity. This flag should only be used if you have a specific reason and accept the reduced security posture. + --log-format string [alpha] Select a logging format. Defaults to 'text'. Valid options are: 'text', 'json', 'console', 'dev' -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 diff --git a/site/src/content/docs/commands/zarf_package_create.md b/site/src/content/docs/commands/zarf_package_create.md index b3ef73bb78..7fe3f104ae 100644 --- a/site/src/content/docs/commands/zarf_package_create.md +++ b/site/src/content/docs/commands/zarf_package_create.md @@ -44,6 +44,7 @@ zarf package create [ DIRECTORY ] [flags] ``` -a, --architecture string Architecture for OCI images and Zarf packages --insecure-skip-tls-verify Skip checking server's certificate for validity. This flag should only be used if you have a specific reason and accept the reduced security posture. + --log-format string [alpha] Select a logging format. Defaults to 'text'. Valid options are: 'text', 'json', 'console', 'dev' -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 diff --git a/site/src/content/docs/commands/zarf_package_deploy.md b/site/src/content/docs/commands/zarf_package_deploy.md index 4ebbe054c6..c423cad9ce 100644 --- a/site/src/content/docs/commands/zarf_package_deploy.md +++ b/site/src/content/docs/commands/zarf_package_deploy.md @@ -39,6 +39,7 @@ zarf package deploy [ PACKAGE_SOURCE ] [flags] -a, --architecture string Architecture for OCI images and Zarf packages --insecure-skip-tls-verify Skip checking server's certificate for validity. This flag should only be used if you have a specific reason and accept the reduced security posture. -k, --key string Path to public key file for validating signed packages + --log-format string [alpha] Select a logging format. Defaults to 'text'. Valid options are: 'text', 'json', 'console', 'dev' -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 diff --git a/site/src/content/docs/commands/zarf_package_inspect.md b/site/src/content/docs/commands/zarf_package_inspect.md index 8881bbe248..833011a813 100644 --- a/site/src/content/docs/commands/zarf_package_inspect.md +++ b/site/src/content/docs/commands/zarf_package_inspect.md @@ -34,6 +34,7 @@ zarf package inspect [ PACKAGE_SOURCE ] [flags] -a, --architecture string Architecture for OCI images and Zarf packages --insecure-skip-tls-verify Skip checking server's certificate for validity. This flag should only be used if you have a specific reason and accept the reduced security posture. -k, --key string Path to public key file for validating signed packages + --log-format string [alpha] Select a logging format. Defaults to 'text'. Valid options are: 'text', 'json', 'console', 'dev' -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 diff --git a/site/src/content/docs/commands/zarf_package_list.md b/site/src/content/docs/commands/zarf_package_list.md index 4fddd0dd13..233335dac3 100644 --- a/site/src/content/docs/commands/zarf_package_list.md +++ b/site/src/content/docs/commands/zarf_package_list.md @@ -26,6 +26,7 @@ zarf package list [flags] -a, --architecture string Architecture for OCI images and Zarf packages --insecure-skip-tls-verify Skip checking server's certificate for validity. This flag should only be used if you have a specific reason and accept the reduced security posture. -k, --key string Path to public key file for validating signed packages + --log-format string [alpha] Select a logging format. Defaults to 'text'. Valid options are: 'text', 'json', 'console', 'dev' -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 diff --git a/site/src/content/docs/commands/zarf_package_mirror-resources.md b/site/src/content/docs/commands/zarf_package_mirror-resources.md index 20a60964ab..659a1b7bd9 100644 --- a/site/src/content/docs/commands/zarf_package_mirror-resources.md +++ b/site/src/content/docs/commands/zarf_package_mirror-resources.md @@ -67,6 +67,7 @@ $ zarf package mirror-resources \ -a, --architecture string Architecture for OCI images and Zarf packages --insecure-skip-tls-verify Skip checking server's certificate for validity. This flag should only be used if you have a specific reason and accept the reduced security posture. -k, --key string Path to public key file for validating signed packages + --log-format string [alpha] Select a logging format. Defaults to 'text'. Valid options are: 'text', 'json', 'console', 'dev' -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 diff --git a/site/src/content/docs/commands/zarf_package_publish.md b/site/src/content/docs/commands/zarf_package_publish.md index 310e4481c5..0ebfdb3516 100644 --- a/site/src/content/docs/commands/zarf_package_publish.md +++ b/site/src/content/docs/commands/zarf_package_publish.md @@ -41,6 +41,7 @@ $ zarf package publish ./path/to/dir oci://my-registry.com/my-namespace -a, --architecture string Architecture for OCI images and Zarf packages --insecure-skip-tls-verify Skip checking server's certificate for validity. This flag should only be used if you have a specific reason and accept the reduced security posture. -k, --key string Path to public key file for validating signed packages + --log-format string [alpha] Select a logging format. Defaults to 'text'. Valid options are: 'text', 'json', 'console', 'dev' -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 diff --git a/site/src/content/docs/commands/zarf_package_pull.md b/site/src/content/docs/commands/zarf_package_pull.md index 81bee3464c..1b87e49a33 100644 --- a/site/src/content/docs/commands/zarf_package_pull.md +++ b/site/src/content/docs/commands/zarf_package_pull.md @@ -42,6 +42,7 @@ $ zarf package pull oci://ghcr.io/defenseunicorns/packages/dos-games:1.0.0 -a sk -a, --architecture string Architecture for OCI images and Zarf packages --insecure-skip-tls-verify Skip checking server's certificate for validity. This flag should only be used if you have a specific reason and accept the reduced security posture. -k, --key string Path to public key file for validating signed packages + --log-format string [alpha] Select a logging format. Defaults to 'text'. Valid options are: 'text', 'json', 'console', 'dev' -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 diff --git a/site/src/content/docs/commands/zarf_package_remove.md b/site/src/content/docs/commands/zarf_package_remove.md index edebd01408..104484e18c 100644 --- a/site/src/content/docs/commands/zarf_package_remove.md +++ b/site/src/content/docs/commands/zarf_package_remove.md @@ -29,6 +29,7 @@ zarf package remove { PACKAGE_SOURCE | PACKAGE_NAME } --confirm [flags] -a, --architecture string Architecture for OCI images and Zarf packages --insecure-skip-tls-verify Skip checking server's certificate for validity. This flag should only be used if you have a specific reason and accept the reduced security posture. -k, --key string Path to public key file for validating signed packages + --log-format string [alpha] Select a logging format. Defaults to 'text'. Valid options are: 'text', 'json', 'console', 'dev' -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 diff --git a/site/src/content/docs/commands/zarf_tools.md b/site/src/content/docs/commands/zarf_tools.md index 51e9e472d1..e770789a98 100644 --- a/site/src/content/docs/commands/zarf_tools.md +++ b/site/src/content/docs/commands/zarf_tools.md @@ -21,6 +21,7 @@ Collection of additional tools to make airgap easier ``` -a, --architecture string Architecture for OCI images and Zarf packages --insecure-skip-tls-verify Skip checking server's certificate for validity. This flag should only be used if you have a specific reason and accept the reduced security posture. + --log-format string [alpha] Select a logging format. Defaults to 'text'. Valid options are: 'text', 'json', 'console', 'dev' -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 diff --git a/site/src/content/docs/commands/zarf_tools_archiver.md b/site/src/content/docs/commands/zarf_tools_archiver.md index edd7615755..9a17c3d5a2 100644 --- a/site/src/content/docs/commands/zarf_tools_archiver.md +++ b/site/src/content/docs/commands/zarf_tools_archiver.md @@ -21,6 +21,7 @@ Compresses/Decompresses generic archives, including Zarf packages ``` -a, --architecture string Architecture for OCI images and Zarf packages --insecure-skip-tls-verify Skip checking server's certificate for validity. This flag should only be used if you have a specific reason and accept the reduced security posture. + --log-format string [alpha] Select a logging format. Defaults to 'text'. Valid options are: 'text', 'json', 'console', 'dev' -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 diff --git a/site/src/content/docs/commands/zarf_tools_archiver_compress.md b/site/src/content/docs/commands/zarf_tools_archiver_compress.md index de2cc0518a..9de8388512 100644 --- a/site/src/content/docs/commands/zarf_tools_archiver_compress.md +++ b/site/src/content/docs/commands/zarf_tools_archiver_compress.md @@ -25,6 +25,7 @@ zarf tools archiver compress SOURCES ARCHIVE [flags] ``` -a, --architecture string Architecture for OCI images and Zarf packages --insecure-skip-tls-verify Skip checking server's certificate for validity. This flag should only be used if you have a specific reason and accept the reduced security posture. + --log-format string [alpha] Select a logging format. Defaults to 'text'. Valid options are: 'text', 'json', 'console', 'dev' -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 diff --git a/site/src/content/docs/commands/zarf_tools_archiver_decompress.md b/site/src/content/docs/commands/zarf_tools_archiver_decompress.md index ead2ce66ac..05f0687f61 100644 --- a/site/src/content/docs/commands/zarf_tools_archiver_decompress.md +++ b/site/src/content/docs/commands/zarf_tools_archiver_decompress.md @@ -26,6 +26,7 @@ zarf tools archiver decompress ARCHIVE DESTINATION [flags] ``` -a, --architecture string Architecture for OCI images and Zarf packages --insecure-skip-tls-verify Skip checking server's certificate for validity. This flag should only be used if you have a specific reason and accept the reduced security posture. + --log-format string [alpha] Select a logging format. Defaults to 'text'. Valid options are: 'text', 'json', 'console', 'dev' -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 diff --git a/site/src/content/docs/commands/zarf_tools_archiver_version.md b/site/src/content/docs/commands/zarf_tools_archiver_version.md index 169ece563b..86f490e7b3 100644 --- a/site/src/content/docs/commands/zarf_tools_archiver_version.md +++ b/site/src/content/docs/commands/zarf_tools_archiver_version.md @@ -25,6 +25,7 @@ zarf tools archiver version [flags] ``` -a, --architecture string Architecture for OCI images and Zarf packages --insecure-skip-tls-verify Skip checking server's certificate for validity. This flag should only be used if you have a specific reason and accept the reduced security posture. + --log-format string [alpha] Select a logging format. Defaults to 'text'. Valid options are: 'text', 'json', 'console', 'dev' -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 diff --git a/site/src/content/docs/commands/zarf_tools_clear-cache.md b/site/src/content/docs/commands/zarf_tools_clear-cache.md index c2e7f8d94e..3e41fba093 100644 --- a/site/src/content/docs/commands/zarf_tools_clear-cache.md +++ b/site/src/content/docs/commands/zarf_tools_clear-cache.md @@ -26,6 +26,7 @@ zarf tools clear-cache [flags] ``` -a, --architecture string Architecture for OCI images and Zarf packages --insecure-skip-tls-verify Skip checking server's certificate for validity. This flag should only be used if you have a specific reason and accept the reduced security posture. + --log-format string [alpha] Select a logging format. Defaults to 'text'. Valid options are: 'text', 'json', 'console', 'dev' -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 diff --git a/site/src/content/docs/commands/zarf_tools_download-init.md b/site/src/content/docs/commands/zarf_tools_download-init.md index 723c4d3d83..b6a616a80e 100644 --- a/site/src/content/docs/commands/zarf_tools_download-init.md +++ b/site/src/content/docs/commands/zarf_tools_download-init.md @@ -26,6 +26,7 @@ zarf tools download-init [flags] ``` -a, --architecture string Architecture for OCI images and Zarf packages --insecure-skip-tls-verify Skip checking server's certificate for validity. This flag should only be used if you have a specific reason and accept the reduced security posture. + --log-format string [alpha] Select a logging format. Defaults to 'text'. Valid options are: 'text', 'json', 'console', 'dev' -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 diff --git a/site/src/content/docs/commands/zarf_tools_gen-key.md b/site/src/content/docs/commands/zarf_tools_gen-key.md index 421f4029ad..93805806a7 100644 --- a/site/src/content/docs/commands/zarf_tools_gen-key.md +++ b/site/src/content/docs/commands/zarf_tools_gen-key.md @@ -25,6 +25,7 @@ zarf tools gen-key [flags] ``` -a, --architecture string Architecture for OCI images and Zarf packages --insecure-skip-tls-verify Skip checking server's certificate for validity. This flag should only be used if you have a specific reason and accept the reduced security posture. + --log-format string [alpha] Select a logging format. Defaults to 'text'. Valid options are: 'text', 'json', 'console', 'dev' -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 diff --git a/site/src/content/docs/commands/zarf_tools_gen-pki.md b/site/src/content/docs/commands/zarf_tools_gen-pki.md index 641fe08402..cdba8d052b 100644 --- a/site/src/content/docs/commands/zarf_tools_gen-pki.md +++ b/site/src/content/docs/commands/zarf_tools_gen-pki.md @@ -26,6 +26,7 @@ zarf tools gen-pki HOST [flags] ``` -a, --architecture string Architecture for OCI images and Zarf packages --insecure-skip-tls-verify Skip checking server's certificate for validity. This flag should only be used if you have a specific reason and accept the reduced security posture. + --log-format string [alpha] Select a logging format. Defaults to 'text'. Valid options are: 'text', 'json', 'console', 'dev' -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 diff --git a/site/src/content/docs/commands/zarf_tools_get-creds.md b/site/src/content/docs/commands/zarf_tools_get-creds.md index 8d8511ffb3..89b6b4c21f 100644 --- a/site/src/content/docs/commands/zarf_tools_get-creds.md +++ b/site/src/content/docs/commands/zarf_tools_get-creds.md @@ -45,6 +45,7 @@ $ zarf tools get-creds artifact ``` -a, --architecture string Architecture for OCI images and Zarf packages --insecure-skip-tls-verify Skip checking server's certificate for validity. This flag should only be used if you have a specific reason and accept the reduced security posture. + --log-format string [alpha] Select a logging format. Defaults to 'text'. Valid options are: 'text', 'json', 'console', 'dev' -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 diff --git a/site/src/content/docs/commands/zarf_tools_update-creds.md b/site/src/content/docs/commands/zarf_tools_update-creds.md index 6ff620ea1a..50c3b0e037 100644 --- a/site/src/content/docs/commands/zarf_tools_update-creds.md +++ b/site/src/content/docs/commands/zarf_tools_update-creds.md @@ -74,6 +74,7 @@ $ zarf tools update-creds artifact --artifact-push-username={USERNAME} --artifac ``` -a, --architecture string Architecture for OCI images and Zarf packages --insecure-skip-tls-verify Skip checking server's certificate for validity. This flag should only be used if you have a specific reason and accept the reduced security posture. + --log-format string [alpha] Select a logging format. Defaults to 'text'. Valid options are: 'text', 'json', 'console', 'dev' -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 diff --git a/site/src/content/docs/commands/zarf_version.md b/site/src/content/docs/commands/zarf_version.md index ab3859c1ec..8448928de4 100644 --- a/site/src/content/docs/commands/zarf_version.md +++ b/site/src/content/docs/commands/zarf_version.md @@ -30,6 +30,7 @@ zarf version [flags] ``` -a, --architecture string Architecture for OCI images and Zarf packages --insecure-skip-tls-verify Skip checking server's certificate for validity. This flag should only be used if you have a specific reason and accept the reduced security posture. + --log-format string [alpha] Select a logging format. Defaults to 'text'. Valid options are: 'text', 'json', 'console', 'dev' -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 diff --git a/src/cmd/internal.go b/src/cmd/internal.go index b3bc2c4592..685248e149 100644 --- a/src/cmd/internal.go +++ b/src/cmd/internal.go @@ -85,6 +85,7 @@ var genCLIDocs = &cobra.Command{ // If the command is a vendored command, add a dummy flag to hide root flags from the docs if common.CheckVendorOnlyFromPath(toolCmd) { addHiddenDummyFlag(toolCmd, "log-level") + addHiddenDummyFlag(toolCmd, "log-format") addHiddenDummyFlag(toolCmd, "architecture") addHiddenDummyFlag(toolCmd, "no-log-file") addHiddenDummyFlag(toolCmd, "no-progress") diff --git a/src/cmd/root.go b/src/cmd/root.go index 6fb0b5f9fb..922a015126 100644 --- a/src/cmd/root.go +++ b/src/cmd/root.go @@ -164,7 +164,7 @@ func init() { // Logs rootCmd.PersistentFlags().StringVarP(&LogLevelCLI, "log-level", "l", v.GetString(common.VLogLevel), lang.RootCmdFlagLogLevel) - rootCmd.PersistentFlags().StringVar(&LogFormat, "log-format", v.GetString(common.VLogFormat), "Select a logging format. Defaults to 'text'. Valid options are: 'text', 'json'") + rootCmd.PersistentFlags().StringVar(&LogFormat, "log-format", v.GetString(common.VLogFormat), "[alpha] Select a logging format. Defaults to 'text'. Valid options are: 'text', 'json', 'console', 'dev'") rootCmd.PersistentFlags().BoolVar(&SkipLogFile, "no-log-file", v.GetBool(common.VNoLogFile), lang.RootCmdFlagSkipLogFile) rootCmd.PersistentFlags().BoolVar(&message.NoProgress, "no-progress", v.GetBool(common.VNoProgress), lang.RootCmdFlagNoProgress) rootCmd.PersistentFlags().BoolVar(&NoColor, "no-color", v.GetBool(common.VNoColor), lang.RootCmdFlagNoColor) @@ -178,10 +178,6 @@ func init() { rootCmd.PersistentFlags().MarkDeprecated("insecure", "please use --plain-http, --insecure-skip-tls-verify, or --skip-signature-validation instead.") rootCmd.PersistentFlags().BoolVar(&config.CommonOptions.PlainHTTP, "plain-http", v.GetBool(common.VPlainHTTP), lang.RootCmdFlagPlainHTTP) rootCmd.PersistentFlags().BoolVar(&config.CommonOptions.InsecureSkipTLSVerify, "insecure-skip-tls-verify", v.GetBool(common.VInsecureSkipTLSVerify), lang.RootCmdFlagInsecureSkipTLSVerify) - - // HACK(mkcp): This is a workaround for us testing that help output matches to the byte. Undo this and update tests - // before release. - rootCmd.PersistentFlags().MarkHidden("log-format") } // setup Logger handles creating a logger and setting it as the global default. From 7bf60721ac5ba35f64e665630dbabb9cf6c5688c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 21 Nov 2024 10:44:17 +0100 Subject: [PATCH 02/15] chore(deps): bump actions/dependency-review-action from 4.4.0 to 4.5.0 (#3258) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/dependency-review.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index 08131eb4d0..7e352206f0 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -12,4 +12,4 @@ jobs: - name: Checkout uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Dependency Review - uses: actions/dependency-review-action@4081bf99e2866ebe428fc0477b69eb4fcda7220a # v4.4.0 + uses: actions/dependency-review-action@3b139cfc5fae8b618d3eae3675e383bb1769c019 # v4.5.0 From 56907721752167dfb7c93ef7f03000dcc92adc78 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 21 Nov 2024 09:44:56 +0000 Subject: [PATCH 03/15] chore(deps): bump codecov/codecov-action from 5.0.2 to 5.0.7 (#3257) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/test-unit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-unit.yml b/.github/workflows/test-unit.yml index 6b1981ae15..878c81f400 100644 --- a/.github/workflows/test-unit.yml +++ b/.github/workflows/test-unit.yml @@ -49,6 +49,6 @@ jobs: run: make test-unit - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@5c47607acb93fed5485fdbf7232e8a31425f672a # v5.0.2 + uses: codecov/codecov-action@015f24e6818733317a2da2edd6290ab26238649a # v5.0.7 with: token: ${{ secrets.CODECOV_TOKEN }} From bc2e806f5eaf874a9f20e588d950f6e8190b7e09 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 21 Nov 2024 10:45:25 +0100 Subject: [PATCH 04/15] chore(deps): bump github/codeql-action from 3.27.4 to 3.27.5 (#3256) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/scan-codeql.yml | 4 ++-- .github/workflows/scorecard.yaml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/scan-codeql.yml b/.github/workflows/scan-codeql.yml index d05c476a52..5c34ef14f3 100644 --- a/.github/workflows/scan-codeql.yml +++ b/.github/workflows/scan-codeql.yml @@ -45,7 +45,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@ea9e4e37992a54ee68a9622e985e60c8e8f12d9f # v3.27.4 + uses: github/codeql-action/init@f09c1c0a94de965c15400f5634aa42fac8fb8f88 # v3.27.5 with: languages: ${{ matrix.language }} config-file: ./.github/codeql.yaml @@ -54,6 +54,6 @@ jobs: run: make build-cli-linux-amd - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@ea9e4e37992a54ee68a9622e985e60c8e8f12d9f # v3.27.4 + uses: github/codeql-action/analyze@f09c1c0a94de965c15400f5634aa42fac8fb8f88 # v3.27.5 with: category: "/language:${{matrix.language}}" diff --git a/.github/workflows/scorecard.yaml b/.github/workflows/scorecard.yaml index e753a99620..d782b29edf 100644 --- a/.github/workflows/scorecard.yaml +++ b/.github/workflows/scorecard.yaml @@ -44,6 +44,6 @@ jobs: # Upload the results to GitHub's code scanning dashboard. - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@ea9e4e37992a54ee68a9622e985e60c8e8f12d9f # v3.27.4 + uses: github/codeql-action/upload-sarif@f09c1c0a94de965c15400f5634aa42fac8fb8f88 # v3.27.5 with: sarif_file: results.sarif From 234dbf2933c67702510fd15ee11a5e51c37d08f4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 21 Nov 2024 10:47:44 +0100 Subject: [PATCH 05/15] chore(deps): bump github.com/mikefarah/yq/v4 from 4.44.3 to 4.44.5 (#3247) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 6 +++--- go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 09222998df..2ff45ec79e 100644 --- a/go.mod +++ b/go.mod @@ -396,7 +396,7 @@ require ( github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect github.com/microsoft/go-rustaudit v0.0.0-20220730194248-4b17361d90a5 // indirect github.com/miekg/pkcs11 v1.1.1 // indirect - github.com/mikefarah/yq/v4 v4.44.3 + github.com/mikefarah/yq/v4 v4.44.5 github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect @@ -437,7 +437,7 @@ require ( github.com/pborman/indent v1.2.1 // indirect github.com/pborman/uuid v1.2.1 // indirect github.com/pelletier/go-toml v1.9.5 // indirect - github.com/pelletier/go-toml/v2 v2.2.2 // indirect + github.com/pelletier/go-toml/v2 v2.2.3 // indirect github.com/peterbourgon/diskv v2.0.1+incompatible // indirect github.com/pierrec/lz4/v4 v4.1.21 // indirect github.com/pjbgf/sha1cd v0.3.0 // indirect @@ -524,7 +524,7 @@ require ( go.uber.org/zap v1.27.0 // indirect golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa // indirect golang.org/x/mod v0.21.0 // indirect - golang.org/x/net v0.30.0 // indirect + golang.org/x/net v0.31.0 // indirect golang.org/x/oauth2 v0.23.0 // indirect golang.org/x/sys v0.27.0 // indirect golang.org/x/text v0.20.0 // indirect diff --git a/go.sum b/go.sum index 0d3acb94a2..b422325daf 100644 --- a/go.sum +++ b/go.sum @@ -1283,8 +1283,8 @@ github.com/miekg/dns v1.1.58/go.mod h1:Ypv+3b/KadlvW9vJfXOTf300O4UqaHFzFCuHz+rPk github.com/miekg/pkcs11 v1.0.3-0.20190429190417-a667d056470f/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs= github.com/miekg/pkcs11 v1.1.1 h1:Ugu9pdy6vAYku5DEpVWVFPYnzV+bxB+iRdbuFSu7TvU= github.com/miekg/pkcs11 v1.1.1/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs= -github.com/mikefarah/yq/v4 v4.44.3 h1:3zxHntH67maSHr6ynCjM44htw7LZNINmTzYn3tM2t+I= -github.com/mikefarah/yq/v4 v4.44.3/go.mod h1:1pm9sJoyZLDql3OqgklvRCkD0XIIHMZV38jKZgAuxwY= +github.com/mikefarah/yq/v4 v4.44.5 h1:/Xm1dM1BfyDJMg+yIpnl2AgpmLFQg3Lcm/kuyYgHEXE= +github.com/mikefarah/yq/v4 v4.44.5/go.mod h1:rpn3xGVz+2pDuLJTlCvzatCwTmmUeHcm7MbkbtHdvkc= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI= github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= @@ -1414,8 +1414,8 @@ github.com/pborman/uuid v1.2.1/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtP github.com/pelletier/go-toml v1.9.4/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= -github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= -github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= +github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M= +github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc= github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+vxiaj6gdUUzhl4XmI= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= github.com/petergtz/pegomock v2.9.0+incompatible h1:BKfb5XfkJfehe5T+O1xD4Zm26Sb9dnRj7tHxLYwUPiI= @@ -1930,8 +1930,8 @@ golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= -golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= -golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= +golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo= +golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= From c916af81f36b5c41225c5ca77f388c3ae60265e7 Mon Sep 17 00:00:00 2001 From: schristoff <28318173+schristoff@users.noreply.github.com> Date: Thu, 21 Nov 2024 10:00:15 +0000 Subject: [PATCH 06/15] chore: add ADOPTERS.md (#3225) Signed-off-by: schristoff <28318173+schristoff@users.noreply.github.com> --- ADOPTERS.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 ADOPTERS.md diff --git a/ADOPTERS.md b/ADOPTERS.md new file mode 100644 index 0000000000..524a55b89c --- /dev/null +++ b/ADOPTERS.md @@ -0,0 +1,22 @@ +# Zarf Adopters + +We want to know if you use Zarf! Project priorities and funding are based on adoption. +So if you are using Zarf, add yourself to this page by making a pull request. + +#### [Defense Unicorns](https://defenseunicorns.com/) +Status: Production +Country: United States 🇺🇸 +Usage: Unicorn Delivery Service (UDS) leverages Zarf to streamline deployments in +disconnected or restricted environments, delivering a fully deployable, +self-contained platform for mission applications—with all dependencies +and configuration included. + + + +#### [Radius Methods](https://radiusmethod.com/) +Status: Production +Country: United States 🇺🇸 +Usage: +* Supporting Army and Air Force Software Factories +* Delivering SocketZero and Landmine Products to Air-Gapped Networks +* Multi-Node k3s Package for High Availability \ No newline at end of file From 2b43c918c920005d4ff1d33463ce93cd851c124d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 21 Nov 2024 12:06:03 +0100 Subject: [PATCH 07/15] chore(deps): bump github.com/golang-jwt/jwt/v4 from 4.5.0 to 4.5.1 (#3263) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 2ff45ec79e..0a67812d77 100644 --- a/go.mod +++ b/go.mod @@ -315,7 +315,7 @@ require ( github.com/gobwas/glob v0.2.3 // indirect github.com/goccy/go-json v0.10.3 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/golang-jwt/jwt/v4 v4.5.1 // indirect github.com/golang-jwt/jwt/v5 v5.2.1 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.4 // indirect diff --git a/go.sum b/go.sum index b422325daf..8d27a86f64 100644 --- a/go.sum +++ b/go.sum @@ -873,8 +873,9 @@ github.com/golang-cz/devslog v0.0.11 h1:v4Yb9o0ZpuZ/D8ZrtVw1f9q5XrjnkxwHF1XmWwO8 github.com/golang-cz/devslog v0.0.11/go.mod h1:bSe5bm0A7Nyfqtijf1OMNgVJHlWEuVSXnkuASiE1vV8= github.com/golang-jwt/jwt/v4 v4.0.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= github.com/golang-jwt/jwt/v4 v4.2.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= -github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/golang-jwt/jwt/v4 v4.5.1 h1:JdqV9zKUdtaa9gdPlywC3aeoEsR681PlKC+4F5gQgeo= +github.com/golang-jwt/jwt/v4 v4.5.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= From fdb17a4c5054652a071becfe3ae8b64b040d74a7 Mon Sep 17 00:00:00 2001 From: Philip Laine Date: Thu, 21 Nov 2024 14:41:08 +0100 Subject: [PATCH 08/15] Update Go to 1.23.3 (#3260) Signed-off-by: Philip Laine --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 0a67812d77..7bc6aa920d 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/zarf-dev/zarf -go 1.22.8 +go 1.23.3 // TODO (@AABRO): Pending merge into github.com/gojsonschema/gojsonschema (https://github.com/gojsonschema/gojsonschema/pull/5) replace github.com/xeipuuv/gojsonschema => github.com/defenseunicorns/gojsonschema v0.0.0-20231116163348-e00f069122d6 From 2e66463bc990d10b55c6c215f895533154a0c1a2 Mon Sep 17 00:00:00 2001 From: Austin Abro <37223396+AustinAbro321@users.noreply.github.com> Date: Thu, 21 Nov 2024 08:55:01 -0500 Subject: [PATCH 09/15] chore: separate schema generation (#2886) Signed-off-by: Austin Abro --- Makefile | 2 +- hack/create-zarf-schema.sh | 21 ------ hack/schema/README.md | 8 +++ hack/schema/create-zarf-schema.sh | 28 ++++++++ hack/schema/go.mod | 42 +++++++++++ hack/schema/go.sum | 111 ++++++++++++++++++++++++++++++ hack/schema/main.go | 50 ++++++++++++++ src/cmd/internal.go | 67 ------------------ 8 files changed, 240 insertions(+), 89 deletions(-) delete mode 100755 hack/create-zarf-schema.sh create mode 100644 hack/schema/README.md create mode 100755 hack/schema/create-zarf-schema.sh create mode 100644 hack/schema/go.mod create mode 100644 hack/schema/go.sum create mode 100644 hack/schema/main.go diff --git a/Makefile b/Makefile index 9c3ac5ea18..20f33d0394 100644 --- a/Makefile +++ b/Makefile @@ -102,7 +102,7 @@ build-cli: build-cli-linux-amd build-cli-linux-arm build-cli-mac-intel build-cli docs-and-schema: ## Generate the Zarf Documentation and Schema ZARF_CONFIG=hack/empty-config.toml go run main.go internal gen-cli-docs - ZARF_CONFIG=hack/empty-config.toml hack/create-zarf-schema.sh + hack/schema/create-zarf-schema.sh init-package-with-agent: build build-local-agent-image init-package diff --git a/hack/create-zarf-schema.sh b/hack/create-zarf-schema.sh deleted file mode 100755 index 91fa767bf5..0000000000 --- a/hack/create-zarf-schema.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -# Create the json schema for the zarf.yaml -go run main.go internal gen-config-schema > zarf.schema.json - -# Adds pattern properties to all definitions to allow for yaml extensions -jq ' - def addPatternProperties: - . + - if has("properties") then - {"patternProperties": {"^x-": {}}} - else - {} - end; - - walk(if type == "object" then addPatternProperties else . end) -' zarf.schema.json > temp_zarf.schema.json - -mv temp_zarf.schema.json zarf.schema.json diff --git a/hack/schema/README.md b/hack/schema/README.md new file mode 100644 index 0000000000..8336ae049e --- /dev/null +++ b/hack/schema/README.md @@ -0,0 +1,8 @@ +# schema generation + +This go project generates the JSON schema for zarf.yaml files. + +## Usage +This code should be called with `./create-zarf-schema.sh` which will generate all of the schemas, add yaml extension, and move the schema files to their proper place in the repo. + +Alternatively run `go run main.go` to print the json schema to the stdout. diff --git a/hack/schema/create-zarf-schema.sh b/hack/schema/create-zarf-schema.sh new file mode 100755 index 0000000000..7e55703a8f --- /dev/null +++ b/hack/schema/create-zarf-schema.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +set -euo pipefail + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +add_yaml_extensions() { + local src=$1 + local dst=$2 + + jq ' + def addPatternProperties: + . + + if has("properties") then + {"patternProperties": {"^x-": {}}} + else + {} + end; + + walk(if type == "object" then addPatternProperties else . end) + ' "$src" > "$dst" +} + +go run "$SCRIPT_DIR/main.go" > "zarf_package_v1alpha1.schema.json" + +add_yaml_extensions "zarf_package_v1alpha1.schema.json" "$SCRIPT_DIR/../../zarf.schema.json" + +rm zarf_package_v1alpha1.schema.json diff --git a/hack/schema/go.mod b/hack/schema/go.mod new file mode 100644 index 0000000000..e85cd3bfeb --- /dev/null +++ b/hack/schema/go.mod @@ -0,0 +1,42 @@ +module github.com/zarf-dev/zarf/hack/schema + +go 1.22.8 + +toolchain go1.23.2 + +replace github.com/zarf-dev/zarf => ../.. + +require ( + github.com/invopop/jsonschema v0.12.0 + github.com/zarf-dev/zarf v0.38.2 +) + +require ( + github.com/bahlo/generic-list-go v0.2.0 // indirect + github.com/buger/jsonparser v1.1.1 // indirect + github.com/defenseunicorns/pkg/helpers/v2 v2.0.1 // indirect + github.com/fxamacker/cbor/v2 v2.7.0 // indirect + github.com/go-logr/logr v1.4.2 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/google/gofuzz v1.2.0 // indirect + github.com/json-iterator/go v1.1.12 // indirect + github.com/mailru/easyjson v0.7.7 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/otiai10/copy v1.14.0 // indirect + github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect + github.com/x448/float16 v0.8.4 // indirect + golang.org/x/net v0.30.0 // indirect + golang.org/x/sync v0.9.0 // indirect + golang.org/x/sys v0.27.0 // indirect + golang.org/x/text v0.19.0 // indirect + gopkg.in/inf.v0 v0.9.1 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect + k8s.io/apimachinery v0.31.2 // indirect + k8s.io/klog/v2 v2.130.1 // indirect + k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // indirect + oras.land/oras-go/v2 v2.5.0 // indirect + sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect +) diff --git a/hack/schema/go.sum b/hack/schema/go.sum new file mode 100644 index 0000000000..df5ea8840b --- /dev/null +++ b/hack/schema/go.sum @@ -0,0 +1,111 @@ +github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk= +github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg= +github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs= +github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/defenseunicorns/pkg/helpers/v2 v2.0.1 h1:j08rz9vhyD9Bs+yKiyQMY2tSSejXRMxTqEObZ5M1Wbk= +github.com/defenseunicorns/pkg/helpers/v2 v2.0.1/go.mod h1:u1PAqOICZyiGIVA2v28g55bQH1GiAt0Bc4U9/rnWQvQ= +github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E= +github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ= +github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= +github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/invopop/jsonschema v0.12.0 h1:6ovsNSuvn9wEQVOyc72aycBMVQFKz7cPdMJn10CvzRI= +github.com/invopop/jsonschema v0.12.0/go.mod h1:ffZ5Km5SWWRAIN6wbDXItl95euhFz2uON45H2qjYt+0= +github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= +github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/otiai10/copy v1.14.0 h1:dCI/t1iTdYGtkvCuBG2BgR6KZa83PTclw4U5n2wAllU= +github.com/otiai10/copy v1.14.0/go.mod h1:ECfuL02W+/FkTWZWgQqXPWZgW9oeKCSQ5qVfSc4qc4w= +github.com/otiai10/mint v1.5.1 h1:XaPLeE+9vGbuyEHem1JNk3bYc7KKqyI/na0/mLd/Kks= +github.com/otiai10/mint v1.5.1/go.mod h1:MJm72SBthJjz8qhefc4z1PYEieWmy8Bku7CjcAqyUSM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc= +github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw= +github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= +github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= +golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ= +golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s= +golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= +golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= +gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +k8s.io/apimachinery v0.31.2 h1:i4vUt2hPK56W6mlT7Ry+AO8eEsyxMD1U44NR22CLTYw= +k8s.io/apimachinery v0.31.2/go.mod h1:rsPdaZJfTfLsNJSQzNHQvYoTmxhoOEofxtOsF3rtsMo= +k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= +k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= +k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 h1:pUdcCO1Lk/tbT5ztQWOBi5HBgbBP1J8+AsQnQCKsi8A= +k8s.io/utils v0.0.0-20240711033017-18e509b52bc8/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +oras.land/oras-go/v2 v2.5.0 h1:o8Me9kLY74Vp5uw07QXPiitjsw7qNXi8Twd+19Zf02c= +oras.land/oras-go/v2 v2.5.0/go.mod h1:z4eisnLP530vwIOUOJeBIj0aGI0L1C3d53atvCBqZHg= +sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= +sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= +sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4= +sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08= +sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= +sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/hack/schema/main.go b/hack/schema/main.go new file mode 100644 index 0000000000..0f3b3575a2 --- /dev/null +++ b/hack/schema/main.go @@ -0,0 +1,50 @@ +package main + +import ( + "encoding/json" + "errors" + "fmt" + "os" + "path/filepath" + "runtime" + + "github.com/invopop/jsonschema" + "github.com/zarf-dev/zarf/src/api/v1alpha1" +) + +func genSchema() (string, error) { + reflector := jsonschema.Reflector(jsonschema.Reflector{ExpandedStruct: true}) + + // AddGoComments breaks if called with a absolute path, so we move to the directory of the go executable + // then use a relative path to the package + _, filename, _, ok := runtime.Caller(1) + if !ok { + return "", errors.New("unable to get the current filename") + } + goExecDir := filepath.Dir(filename) + if err := os.Chdir(goExecDir); err != nil { + return "", err + } + + typePackagePath := filepath.Join("..", "..", "src", "api", "v1alpha1") + + if err := reflector.AddGoComments("github.com/zarf-dev/zarf/hack/schema", typePackagePath); err != nil { + return "", err + } + + schema := reflector.Reflect(&v1alpha1.ZarfPackage{}) + output, err := json.MarshalIndent(schema, "", " ") + if err != nil { + return "", fmt.Errorf("unable to generate the Zarf config schema: %w", err) + } + return string(output), nil +} + +func main() { + schema, err := genSchema() + if err != nil { + fmt.Println(err) + os.Exit(1) + } + fmt.Println(schema) +} diff --git a/src/cmd/internal.go b/src/cmd/internal.go index 685248e149..ec68557f7c 100644 --- a/src/cmd/internal.go +++ b/src/cmd/internal.go @@ -6,26 +6,21 @@ package cmd import ( "context" - "encoding/json" - "errors" "fmt" "os" "path/filepath" "strings" "github.com/defenseunicorns/pkg/helpers/v2" - "github.com/invopop/jsonschema" "github.com/spf13/cobra" "github.com/spf13/cobra/doc" "github.com/spf13/pflag" - "github.com/zarf-dev/zarf/src/api/v1alpha1" "github.com/zarf-dev/zarf/src/cmd/common" "github.com/zarf-dev/zarf/src/config/lang" "github.com/zarf-dev/zarf/src/internal/agent" "github.com/zarf-dev/zarf/src/internal/gitea" "github.com/zarf-dev/zarf/src/pkg/cluster" "github.com/zarf-dev/zarf/src/pkg/message" - "github.com/zarf-dev/zarf/src/types" ) var ( @@ -167,66 +162,6 @@ tableOfContents: false }, } -func addGoComments(reflector *jsonschema.Reflector) error { - addCommentErr := errors.New("this command must be called from the root of the Zarf repo") - - typePackagePath := filepath.Join("src", "api", "v1alpha1") - if err := reflector.AddGoComments("github.com/zarf-dev/zarf", typePackagePath); err != nil { - return fmt.Errorf("%w: %w", addCommentErr, err) - } - varPackagePath := filepath.Join("src", "pkg", "variables") - if err := reflector.AddGoComments("github.com/zarf-dev/zarf", varPackagePath); err != nil { - return fmt.Errorf("%w: %w", addCommentErr, err) - } - return nil -} - -var genConfigSchemaCmd = &cobra.Command{ - Use: "gen-config-schema", - Aliases: []string{"gc"}, - Short: lang.CmdInternalConfigSchemaShort, - RunE: func(_ *cobra.Command, _ []string) error { - reflector := jsonschema.Reflector(jsonschema.Reflector{ExpandedStruct: true}) - if err := addGoComments(&reflector); err != nil { - return err - } - - schema := reflector.Reflect(&v1alpha1.ZarfPackage{}) - output, err := json.MarshalIndent(schema, "", " ") - if err != nil { - return fmt.Errorf("unable to generate the Zarf config schema: %w", err) - } - fmt.Print(string(output) + "\n") - return nil - }, -} - -type zarfTypes struct { - DeployedPackage types.DeployedPackage - ZarfPackage v1alpha1.ZarfPackage - ZarfState types.ZarfState -} - -var genTypesSchemaCmd = &cobra.Command{ - Use: "gen-types-schema", - Aliases: []string{"gt"}, - Short: lang.CmdInternalTypesSchemaShort, - RunE: func(_ *cobra.Command, _ []string) error { - reflector := jsonschema.Reflector(jsonschema.Reflector{ExpandedStruct: true}) - if err := addGoComments(&reflector); err != nil { - return err - } - - schema := reflector.Reflect(&zarfTypes{}) - output, err := json.MarshalIndent(schema, "", " ") - if err != nil { - return fmt.Errorf("unable to generate the JSON schema for the Zarf types DeployedPackage, ZarfPackage, and ZarfState: %w", err) - } - fmt.Print(string(output) + "\n") - return nil - }, -} - var createReadOnlyGiteaUser = &cobra.Command{ Use: "create-read-only-gitea-user", Short: lang.CmdInternalCreateReadOnlyGiteaUserShort, @@ -374,8 +309,6 @@ func init() { internalCmd.AddCommand(agentCmd) internalCmd.AddCommand(httpProxyCmd) internalCmd.AddCommand(genCLIDocs) - internalCmd.AddCommand(genConfigSchemaCmd) - internalCmd.AddCommand(genTypesSchemaCmd) internalCmd.AddCommand(createReadOnlyGiteaUser) internalCmd.AddCommand(createPackageRegistryToken) internalCmd.AddCommand(updateGiteaPVC) From a4898df6f250ff4c1df8034b7931c75a00d2bbb6 Mon Sep 17 00:00:00 2001 From: Allen Conlon Date: Thu, 21 Nov 2024 09:46:17 -0500 Subject: [PATCH 10/15] fix: maintain agent mutate even when already mutated (#3166) Signed-off-by: Allen Conlon --- src/internal/agent/hooks/flux-helmrepo.go | 48 +++++--- .../agent/hooks/flux-helmrepo_test.go | 85 ++++++++++++-- src/internal/agent/hooks/flux-ocirepo.go | 79 +++++++------ src/internal/agent/hooks/flux-ocirepo_test.go | 105 ++++++++++++++---- 4 files changed, 240 insertions(+), 77 deletions(-) diff --git a/src/internal/agent/hooks/flux-helmrepo.go b/src/internal/agent/hooks/flux-helmrepo.go index 067ae0c890..f5557db19b 100644 --- a/src/internal/agent/hooks/flux-helmrepo.go +++ b/src/internal/agent/hooks/flux-helmrepo.go @@ -37,6 +37,7 @@ func NewHelmRepositoryMutationHook(ctx context.Context, cluster *cluster.Cluster // mutateHelmRepo mutates the repository url to point to the repository URL defined in the ZarfState. func mutateHelmRepo(ctx context.Context, r *v1.AdmissionRequest, cluster *cluster.Cluster) (*operations.Result, error) { l := logger.From(ctx) + src := &flux.HelmRepository{} if err := json.Unmarshal(r.Object.Raw, &src); err != nil { return nil, fmt.Errorf(lang.ErrUnmarshal, err) @@ -48,13 +49,6 @@ func mutateHelmRepo(ctx context.Context, r *v1.AdmissionRequest, cluster *cluste return &operations.Result{Allowed: true}, nil } - if src.Labels != nil && src.Labels["zarf-agent"] == "patched" { - return &operations.Result{ - Allowed: true, - PatchOps: nil, - }, nil - } - zarfState, err := cluster.LoadZarfState(ctx) if err != nil { return nil, err @@ -70,21 +64,45 @@ func mutateHelmRepo(ctx context.Context, r *v1.AdmissionRequest, cluster *cluste "name", src.Name, "registry", registryAddress) - patchedSrc, err := transform.ImageTransformHost(registryAddress, src.Spec.URL) - if err != nil { - return nil, fmt.Errorf("unable to transform the HelmRepo URL: %w", err) + patchedURL := src.Spec.URL + + var ( + isPatched bool + + isCreate = r.Operation == v1.Create + isUpdate = r.Operation == v1.Update + ) + + // Check if this is an update operation and the hostname is different from what we have in the zarfState + // NOTE: We mutate on updates IF AND ONLY IF the hostname in the request is different than the hostname in the zarfState + // NOTE: We are checking if the hostname is different before because we do not want to potentially mutate a URL that has already been mutated. + if isUpdate { + zarfStateAddress := helpers.OCIURLPrefix + registryAddress + isPatched, err = helpers.DoHostnamesMatch(zarfStateAddress, src.Spec.URL) + if err != nil { + return nil, fmt.Errorf(lang.AgentErrHostnameMatch, err) + } } - patchedRefInfo, err := transform.ParseImageRef(patchedSrc) - if err != nil { - return nil, fmt.Errorf("unable to parse the HelmRepo URL: %w", err) + // Mutate the helm repo URL if necessary + if isCreate || (isUpdate && !isPatched) { + patchedSrc, err := transform.ImageTransformHost(registryAddress, src.Spec.URL) + if err != nil { + return nil, fmt.Errorf("unable to transform the HelmRepo URL: %w", err) + } + + patchedRefInfo, err := transform.ParseImageRef(patchedSrc) + if err != nil { + return nil, fmt.Errorf("unable to parse the HelmRepo URL: %w", err) + } + patchedURL = helpers.OCIURLPrefix + patchedRefInfo.Name } - patchedURL := helpers.OCIURLPrefix + patchedRefInfo.Name l.Debug("mutating the Flux HelmRepository URL to the Zarf URL", "original", src.Spec.URL, "mutated", patchedURL) - patches := populateHelmRepoPatchOperations(patchedURL, zarfState.RegistryInfo.IsInternal()) + var patches []operations.PatchOperation + patches = populateHelmRepoPatchOperations(patchedURL, zarfState.RegistryInfo.IsInternal()) patches = append(patches, getLabelPatch(src.Labels)) return &operations.Result{ diff --git a/src/internal/agent/hooks/flux-helmrepo_test.go b/src/internal/agent/hooks/flux-helmrepo_test.go index d56d7e29a5..b5c861331f 100644 --- a/src/internal/agent/hooks/flux-helmrepo_test.go +++ b/src/internal/agent/hooks/flux-helmrepo_test.go @@ -68,22 +68,36 @@ func TestFluxHelmMutationWebhook(t *testing.T) { code: http.StatusInternalServerError, }, { - name: "should not mutate when agent patched", - admissionReq: createFluxHelmRepoAdmissionRequest(t, v1.Update, &flux.HelmRepository{ + name: "should be mutated with no internal service registry", + admissionReq: createFluxHelmRepoAdmissionRequest(t, v1.Create, &flux.HelmRepository{ ObjectMeta: metav1.ObjectMeta{ - Name: "already-patched", - Labels: map[string]string{ - "zarf-agent": "patched", - }, + Name: "mutate-this", }, Spec: flux.HelmRepositorySpec{ + URL: "oci://ghcr.io/stefanprodan/charts", Type: "oci", }, }), + patch: []operations.PatchOperation{ + operations.ReplacePatchOperation( + "/spec/url", + "oci://127.0.0.1:31999/stefanprodan/charts", + ), + operations.AddPatchOperation( + "/spec/secretRef", + fluxmeta.LocalObjectReference{Name: config.ZarfImagePullSecretName}, + ), + operations.ReplacePatchOperation( + "/metadata/labels", + map[string]string{ + "zarf-agent": "patched", + }, + ), + }, code: http.StatusOK, }, { - name: "should be mutated with no internal service registry", + name: "should be mutated with internal service registry", admissionReq: createFluxHelmRepoAdmissionRequest(t, v1.Create, &flux.HelmRepository{ ObjectMeta: metav1.ObjectMeta{ Name: "mutate-this", @@ -93,6 +107,55 @@ func TestFluxHelmMutationWebhook(t *testing.T) { Type: "oci", }, }), + patch: []operations.PatchOperation{ + operations.ReplacePatchOperation( + "/spec/url", + "oci://10.11.12.13:5000/stefanprodan/charts", + ), + operations.AddPatchOperation( + "/spec/secretRef", + fluxmeta.LocalObjectReference{Name: config.ZarfImagePullSecretName}, + ), + operations.ReplacePatchOperation( + "/metadata/labels", + map[string]string{ + "zarf-agent": "patched", + }, + ), + }, + svc: &corev1.Service{ + TypeMeta: metav1.TypeMeta{ + APIVersion: corev1.SchemeGroupVersion.String(), + Kind: "Service", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: "zarf-docker-registry", + Namespace: "zarf", + }, + Spec: corev1.ServiceSpec{ + Type: corev1.ServiceTypeNodePort, + Ports: []corev1.ServicePort{ + { + NodePort: int32(31999), + Port: 5000, + }, + }, + ClusterIP: "10.11.12.13", + }, + }, + code: http.StatusOK, + }, + { + name: "should not mutate URL if it has the same hostname as Zarf state", + admissionReq: createFluxHelmRepoAdmissionRequest(t, v1.Update, &flux.HelmRepository{ + ObjectMeta: metav1.ObjectMeta{ + Name: "no-mutate-this", + }, + Spec: flux.HelmRepositorySpec{ + URL: "oci://127.0.0.1:31999/stefanprodan/charts", + Type: "oci", + }, + }), patch: []operations.PatchOperation{ operations.ReplacePatchOperation( "/spec/url", @@ -112,13 +175,13 @@ func TestFluxHelmMutationWebhook(t *testing.T) { code: http.StatusOK, }, { - name: "should be mutated with internal service registry", - admissionReq: createFluxHelmRepoAdmissionRequest(t, v1.Create, &flux.HelmRepository{ + name: "should not mutate URL if it has the same hostname as Zarf state internal repo", + admissionReq: createFluxHelmRepoAdmissionRequest(t, v1.Update, &flux.HelmRepository{ ObjectMeta: metav1.ObjectMeta{ - Name: "mutate-this", + Name: "no-mutate-this", }, Spec: flux.HelmRepositorySpec{ - URL: "oci://ghcr.io/stefanprodan/charts", + URL: "oci://10.11.12.13:5000/stefanprodan/charts", Type: "oci", }, }), diff --git a/src/internal/agent/hooks/flux-ocirepo.go b/src/internal/agent/hooks/flux-ocirepo.go index 39cd139aaf..3024705ddc 100644 --- a/src/internal/agent/hooks/flux-ocirepo.go +++ b/src/internal/agent/hooks/flux-ocirepo.go @@ -36,6 +36,14 @@ func NewOCIRepositoryMutationHook(ctx context.Context, cluster *cluster.Cluster) // mutateOCIRepo mutates the oci repository url to point to the repository URL defined in the ZarfState. func mutateOCIRepo(ctx context.Context, r *v1.AdmissionRequest, cluster *cluster.Cluster) (*operations.Result, error) { l := logger.From(ctx) + var ( + patches []operations.PatchOperation + isPatched bool + + isCreate = r.Operation == v1.Create + isUpdate = r.Operation == v1.Update + ) + src := &flux.OCIRepository{} if err := json.Unmarshal(r.Object.Raw, &src); err != nil { return nil, fmt.Errorf(lang.ErrUnmarshal, err) @@ -45,19 +53,12 @@ func mutateOCIRepo(ctx context.Context, r *v1.AdmissionRequest, cluster *cluster src.Spec.Reference = &flux.OCIRepositoryRef{} } - // If we have a semver we want to continue since we wil still have the upstream tag + // If we have a semver we want to continue since we will still have the upstream tag // but should warn that we can't guarantee there won't be collisions if src.Spec.Reference.SemVer != "" { l.Warn("Detected a semver OCI ref, continuing but will be unable to guarantee against collisions if multiple OCI artifacts with the same name are brought in from different registries", "ref", src.Spec.Reference.SemVer) } - if src.Labels != nil && src.Labels["zarf-agent"] == "patched" { - return &operations.Result{ - Allowed: true, - PatchOps: []operations.PatchOperation{}, - }, nil - } - zarfState, err := cluster.LoadZarfState(ctx) if err != nil { return nil, err @@ -74,37 +75,51 @@ func mutateOCIRepo(ctx context.Context, r *v1.AdmissionRequest, cluster *cluster "name", src.Name, "registry", registryAddress) - ref := src.Spec.URL - if src.Spec.Reference.Digest != "" { - ref = fmt.Sprintf("%s@%s", ref, src.Spec.Reference.Digest) - } else if src.Spec.Reference.Tag != "" { - ref = fmt.Sprintf("%s:%s", ref, src.Spec.Reference.Tag) - } - - patchedSrc, err := transform.ImageTransformHost(registryAddress, ref) - if err != nil { - return nil, fmt.Errorf("unable to transform the OCIRepo URL: %w", err) - } - - patchedRefInfo, err := transform.ParseImageRef(patchedSrc) - if err != nil { - return nil, fmt.Errorf("unable to parse the transformed OCIRepo URL: %w", err) - } + patchedURL := src.Spec.URL patchedRef := src.Spec.Reference - patchedURL := helpers.OCIURLPrefix + patchedRefInfo.Name + // Check if this is an update operation and the hostname is different from what we have in the zarfState + // NOTE: We mutate on updates IF AND ONLY IF the hostname in the request is different than the hostname in the zarfState + // NOTE: We are checking if the hostname is different before because we do not want to potentially mutate a URL that has already been mutated. + if isUpdate { + zarfStateAddress := helpers.OCIURLPrefix + registryAddress + isPatched, err = helpers.DoHostnamesMatch(zarfStateAddress, src.Spec.URL) + if err != nil { + return nil, fmt.Errorf(lang.AgentErrHostnameMatch, err) + } + } - if patchedRefInfo.Digest != "" { - patchedRef.Digest = patchedRefInfo.Digest - } else if patchedRefInfo.Tag != "" { - patchedRef.Tag = patchedRefInfo.Tag + // Mutate the oci repo URL if necessary + if isCreate || (isUpdate && !isPatched) { + if src.Spec.Reference.Digest != "" { + patchedURL = fmt.Sprintf("%s@%s", patchedURL, src.Spec.Reference.Digest) + } else if src.Spec.Reference.Tag != "" { + patchedURL = fmt.Sprintf("%s:%s", patchedURL, src.Spec.Reference.Tag) + } + + patchedSrc, err := transform.ImageTransformHost(registryAddress, patchedURL) + if err != nil { + return nil, fmt.Errorf("unable to transform the OCIRepo URL: %w", err) + } + + patchedRefInfo, err := transform.ParseImageRef(patchedSrc) + if err != nil { + return nil, fmt.Errorf("unable to parse the transformed OCIRepo URL: %w", err) + } + + patchedURL = helpers.OCIURLPrefix + patchedRefInfo.Name + + if patchedRefInfo.Digest != "" { + patchedRef.Digest = patchedRefInfo.Digest + } else if patchedRefInfo.Tag != "" { + patchedRef.Tag = patchedRefInfo.Tag + } } l.Debug("mutating the Flux OCIRepository URL to the Zarf URL", "original", src.Spec.URL, "mutated", patchedURL) - - patches := populateOCIRepoPatchOperations(patchedURL, zarfState.RegistryInfo.IsInternal(), patchedRef) - + patches = populateOCIRepoPatchOperations(patchedURL, zarfState.RegistryInfo.IsInternal(), patchedRef) patches = append(patches, getLabelPatch(src.Labels)) + return &operations.Result{ Allowed: true, PatchOps: patches, diff --git a/src/internal/agent/hooks/flux-ocirepo_test.go b/src/internal/agent/hooks/flux-ocirepo_test.go index b15fd73d3c..a7d5447e51 100644 --- a/src/internal/agent/hooks/flux-ocirepo_test.go +++ b/src/internal/agent/hooks/flux-ocirepo_test.go @@ -38,25 +38,6 @@ func TestFluxOCIMutationWebhook(t *testing.T) { t.Parallel() tests := []admissionTest{ - { - name: "should not mutate when agent patched", - admissionReq: createFluxOCIRepoAdmissionRequest(t, v1.Update, &flux.OCIRepository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "already-patched", - Labels: map[string]string{ - "zarf-agent": "patched", - }, - }, - Spec: flux.OCIRepositorySpec{ - URL: "oci://ghcr.io/stefanprodan/manifests/podinfo", - Reference: &flux.OCIRepositoryRef{ - Tag: "6.4.0", - }, - }, - }), - patch: nil, - code: http.StatusOK, - }, { name: "bad oci url", admissionReq: createFluxOCIRepoAdmissionRequest(t, v1.Update, &flux.OCIRepository{ @@ -187,6 +168,92 @@ func TestFluxOCIMutationWebhook(t *testing.T) { }, code: http.StatusOK, }, + { + name: "should not mutate URL if it has the same hostname as Zarf state", + admissionReq: createFluxOCIRepoAdmissionRequest(t, v1.Update, &flux.OCIRepository{ + ObjectMeta: metav1.ObjectMeta{ + Name: "mutate-this", + }, + Spec: flux.OCIRepositorySpec{ + URL: "oci://127.0.0.1:31999/stefanprodan/manifests/podinfo", + Reference: &flux.OCIRepositoryRef{ + Tag: "6.4.0-zarf-2823281104", + }, + }, + }), + patch: []operations.PatchOperation{ + operations.ReplacePatchOperation( + "/spec/url", + "oci://127.0.0.1:31999/stefanprodan/manifests/podinfo", + ), + operations.AddPatchOperation( + "/spec/secretRef", + fluxmeta.LocalObjectReference{Name: config.ZarfImagePullSecretName}, + ), + operations.ReplacePatchOperation( + "/spec/ref/tag", + "6.4.0-zarf-2823281104", + ), + operations.ReplacePatchOperation( + "/metadata/labels", + map[string]string{ + "zarf-agent": "patched", + }, + ), + }, + code: http.StatusOK, + }, + { + name: "should not mutate URL if it has the same hostname as Zarf state internal repo", + admissionReq: createFluxOCIRepoAdmissionRequest(t, v1.Update, &flux.OCIRepository{ + ObjectMeta: metav1.ObjectMeta{ + Name: "mutate-this", + }, + Spec: flux.OCIRepositorySpec{ + URL: "oci://10.11.12.13:5000/stefanprodan/charts", + Reference: &flux.OCIRepositoryRef{ + Digest: "sha256:6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b", + }, + }, + }), + patch: []operations.PatchOperation{ + operations.ReplacePatchOperation( + "/spec/url", + "oci://10.11.12.13:5000/stefanprodan/charts", + ), + operations.AddPatchOperation( + "/spec/secretRef", + fluxmeta.LocalObjectReference{Name: config.ZarfImagePullSecretName}, + ), + operations.ReplacePatchOperation( + "/metadata/labels", + map[string]string{ + "zarf-agent": "patched", + }, + ), + }, + svc: &corev1.Service{ + TypeMeta: metav1.TypeMeta{ + APIVersion: corev1.SchemeGroupVersion.String(), + Kind: "Service", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: "zarf-docker-registry", + Namespace: "zarf", + }, + Spec: corev1.ServiceSpec{ + Type: corev1.ServiceTypeNodePort, + Ports: []corev1.ServicePort{ + { + NodePort: int32(31999), + Port: 5000, + }, + }, + ClusterIP: "10.11.12.13", + }, + }, + code: http.StatusOK, + }, } ctx := context.Background() From 85601fc075a391c77822ec3c998ec494dbb3d881 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 21 Nov 2024 16:45:28 +0100 Subject: [PATCH 11/15] chore(deps): bump github.com/anchore/stereoscope from 0.0.6-0.20241101185849-cbd43fb4e5d3 to 0.0.9 (#3264) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 6 +++--- go.sum | 23 ++++++----------------- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/go.mod b/go.mod index 7bc6aa920d..61ae2d141a 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/Masterminds/semver/v3 v3.3.0 github.com/agnivade/levenshtein v1.2.0 github.com/anchore/clio v0.0.0-20241015191535-f538a9016e10 - github.com/anchore/stereoscope v0.0.6-0.20241101185849-cbd43fb4e5d3 + github.com/anchore/stereoscope v0.0.9 github.com/anchore/syft v1.16.0 github.com/avast/retry-go/v4 v4.6.0 github.com/defenseunicorns/pkg/helpers/v2 v2.0.1 @@ -165,7 +165,7 @@ require ( github.com/Microsoft/go-winio v0.6.2 // indirect github.com/Microsoft/hcsshim v0.11.7 // indirect github.com/OneOfOne/xxhash v1.2.8 // indirect - github.com/ProtonMail/go-crypto v1.0.0 // indirect + github.com/ProtonMail/go-crypto v1.1.2 // indirect github.com/ThalesIgnite/crypto11 v1.2.5 // indirect github.com/a8m/envsubst v1.4.2 // indirect github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect @@ -481,7 +481,7 @@ require ( github.com/spf13/cast v1.7.0 // indirect github.com/spiffe/go-spiffe/v2 v2.3.0 // indirect github.com/subosito/gotenv v1.6.0 // indirect - github.com/sylabs/sif/v2 v2.19.2 // indirect + github.com/sylabs/sif/v2 v2.20.0 // indirect github.com/sylabs/squashfs v1.0.0 // indirect github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect github.com/tchap/go-patricia/v2 v2.3.1 // indirect diff --git a/go.sum b/go.sum index 8d27a86f64..6b62ebd255 100644 --- a/go.sum +++ b/go.sum @@ -305,8 +305,8 @@ github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2/go.mod h1:HBCaDe github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/OneOfOne/xxhash v1.2.8 h1:31czK/TI9sNkxIKfaUfGlU47BAxQ0ztGgd9vPyqimf8= github.com/OneOfOne/xxhash v1.2.8/go.mod h1:eZbhyaAYD41SGSSsnmcpxVoRiQ/MPUTjUdIIOT9Um7Q= -github.com/ProtonMail/go-crypto v1.0.0 h1:LRuvITjQWX+WIfr930YHG2HNfjR1uOfyf5vE0kC2U78= -github.com/ProtonMail/go-crypto v1.0.0/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= +github.com/ProtonMail/go-crypto v1.1.2 h1:A7JbD57ThNqh7XjmHE+PXpQ3Dqt3BrSAC0AL0Go3KS0= +github.com/ProtonMail/go-crypto v1.1.2/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE= github.com/ThalesIgnite/crypto11 v1.2.5 h1:1IiIIEqYmBvUYFeMnHqRft4bwf/O36jryEUpY+9ef8E= github.com/ThalesIgnite/crypto11 v1.2.5/go.mod h1:ILDKtnCKiQ7zRoNxcp36Y1ZR8LBPmR2E23+wTQe/MlE= github.com/a8m/envsubst v1.4.2 h1:4yWIHXOLEJHQEFd4UjrWDrYeYlV7ncFWJOCBRLOZHQg= @@ -395,8 +395,8 @@ github.com/anchore/grype v0.77.0 h1:HoTdZ67INrEpEiSKL713zY+j77HxoEAcsMPIZDZ4yP4= github.com/anchore/grype v0.77.0/go.mod h1:k6QLcebOqPm+90y8mMesOJM6A6DYQllOic6Tmz507sc= github.com/anchore/packageurl-go v0.1.1-0.20241018175412-5c22e6360c4f h1:dAQPIrQ3a5PBqZeZ+B9NGZsGmodk4NO9OjDIsQmQyQM= github.com/anchore/packageurl-go v0.1.1-0.20241018175412-5c22e6360c4f/go.mod h1:KoYIv7tdP5+CC9VGkeZV4/vGCKsY55VvoG+5dadg4YI= -github.com/anchore/stereoscope v0.0.6-0.20241101185849-cbd43fb4e5d3 h1:T1LMkKwzSg1s8+xylq51xroPoo83Nt3zQPvdRRDB9Bw= -github.com/anchore/stereoscope v0.0.6-0.20241101185849-cbd43fb4e5d3/go.mod h1:jgLIzIwEkfMhjhKmuzaSEeU2/vFCqlO3XTrSeSLfOaM= +github.com/anchore/stereoscope v0.0.9 h1:rLhYWe/CXhDq/UCUWQ3U5xtpGk4RFnssKaM0bHhs5us= +github.com/anchore/stereoscope v0.0.9/go.mod h1:c2oGDU0R+llJObsatBSenjYPV1raKhMq9GEqe8J56EI= github.com/anchore/syft v1.16.0 h1:iHPqE2q7gmvRDdmh5/897ycRbetfmLwor17/YBNVQNw= github.com/anchore/syft v1.16.0/go.mod h1:x8JNItb+Dj3xwG1tRfyCbJj9Xl/vlcBfXz7q3M2GmjA= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= @@ -510,7 +510,6 @@ github.com/buildkite/interpolate v0.1.3 h1:OFEhqji1rNTRg0u9DsSodg63sjJQEb1uWbENq github.com/buildkite/interpolate v0.1.3/go.mod h1:UNVe6A+UfiBNKbhAySrBbZFZFxQ+DXr9nWen6WVt/A8= github.com/buildkite/roko v1.2.0 h1:hbNURz//dQqNl6Eo9awjQOVOZwSDJ8VEbBDxSfT9rGQ= github.com/buildkite/roko v1.2.0/go.mod h1:23R9e6nHxgedznkwwfmqZ6+0VJZJZ2Sg/uVcp2cP46I= -github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/bytecodealliance/wasmtime-go/v3 v3.0.2 h1:3uZCA/BLTIu+DqCfguByNMJa2HVHpXvjfy0Dy7g6fuA= github.com/bytecodealliance/wasmtime-go/v3 v3.0.2/go.mod h1:RnUjnIXxEJcL6BgCvNyzCCRzZcxCgsZCi+RNlvYor5Q= github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= @@ -550,7 +549,6 @@ github.com/clbanning/mxj/v2 v2.5.5/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn github.com/clbanning/mxj/v2 v2.7.0 h1:WA/La7UGCanFe5NpHF0Q3DNtnCsVoxbPKuyBNHWRyME= github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= github.com/cloudflare/circl v1.3.8 h1:j+V8jJt09PoeMFIu2uh5JUyEaIHTXVOHslFoLNAKqwI= github.com/cloudflare/circl v1.3.8/go.mod h1:PDRU+oXvdD7KCtgKxW95M5Z8BpSCJXQORiZFnBQS5QU= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= @@ -1637,8 +1635,8 @@ github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8 github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= -github.com/sylabs/sif/v2 v2.19.2 h1:KKcUKnbnT69rN1WWHRYoAVKFpqnXpNJ36kmQLpp86Uc= -github.com/sylabs/sif/v2 v2.19.2/go.mod h1:nhX6D/CJntHDWspNLXLe+yct0cd5lm8HJ7VIW6hgKrw= +github.com/sylabs/sif/v2 v2.20.0 h1:RfDHEltUrchZbp/XGcWaw3nRSbufoNWqvwmf91/Q2gI= +github.com/sylabs/sif/v2 v2.20.0/go.mod h1:z6dq3B7QXK0pD71n15kAapven+gE+PZAIPOewBTNDpU= github.com/sylabs/squashfs v1.0.0 h1:xAyMS21ogglkuR5HaY55PCfqY3H32ma9GkasTYo28Zg= github.com/sylabs/squashfs v1.0.0/go.mod h1:rhWzvgefq1X+R+LZdts10hfMsTg3g74OfGunW8tvg/4= github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs= @@ -1816,9 +1814,7 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= -golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I= golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= @@ -1925,9 +1921,7 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= -golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= @@ -2074,8 +2068,6 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -2090,9 +2082,7 @@ golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9sn golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.9.0/go.mod h1:M6DEAAIenWoTxdKrOltXcmDY3rSplQUkrvaDU5FcQyo= golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= @@ -2110,7 +2100,6 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= From 7aa3224cc75dc5ace059fe0897cc4ee307a11f77 Mon Sep 17 00:00:00 2001 From: Philip Laine Date: Thu, 21 Nov 2024 17:35:01 +0100 Subject: [PATCH 12/15] Set Helm max history to limit secret creation (#3249) Signed-off-by: Philip Laine --- src/internal/packager/helm/chart.go | 6 +++++ src/test/e2e/25_helm_test.go | 26 ++++++++++++++++--- .../25-helm-release-history/chart/Chart.yaml | 5 ++++ .../chart/templates/configmap.yaml | 6 +++++ .../25-helm-release-history/zarf.yaml | 12 +++++++++ 5 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 src/test/packages/25-helm-release-history/chart/Chart.yaml create mode 100644 src/test/packages/25-helm-release-history/chart/templates/configmap.yaml create mode 100644 src/test/packages/25-helm-release-history/zarf.yaml diff --git a/src/internal/packager/helm/chart.go b/src/internal/packager/helm/chart.go index ac79a0fc1d..59454057bf 100644 --- a/src/internal/packager/helm/chart.go +++ b/src/internal/packager/helm/chart.go @@ -34,6 +34,9 @@ import ( "github.com/zarf-dev/zarf/src/types" ) +// Use same default as Helm CLI does. +const maxHelmHistory = 10 + // InstallOrUpgradeChart performs a helm install of the given chart. func (h *Helm) InstallOrUpgradeChart(ctx context.Context) (types.ConnectStrings, string, error) { l := logger.From(ctx) @@ -349,6 +352,8 @@ func (h *Helm) upgradeChart(ctx context.Context, lastRelease *release.Release, p // Post-processing our manifests to apply vars and run zarf helm logic in cluster client.PostRenderer = postRender + client.MaxHistory = maxHelmHistory + loadedChart, chartValues, err := h.loadChartData() if err != nil { return nil, fmt.Errorf("unable to load chart data: %w", err) @@ -365,6 +370,7 @@ func (h *Helm) rollbackChart(name string, version int) error { client.Wait = true client.Timeout = h.timeout client.Version = version + client.MaxHistory = maxHelmHistory return client.Run(name) } diff --git a/src/test/e2e/25_helm_test.go b/src/test/e2e/25_helm_test.go index 421b62ed0a..a741c000ac 100644 --- a/src/test/e2e/25_helm_test.go +++ b/src/test/e2e/25_helm_test.go @@ -8,18 +8,37 @@ import ( "fmt" "os/exec" "path/filepath" + "strings" "testing" "github.com/stretchr/testify/require" ) -var helmChartsPkg string +func TestHelmReleaseHistory(t *testing.T) { + outputPath := t.TempDir() + localTgzChartPath := filepath.Join("src", "test", "packages", "25-helm-release-history") + _, _, err := e2e.Zarf(t, "package", "create", localTgzChartPath, "-o", outputPath, "--confirm") + require.NoError(t, err) + + packagePath := filepath.Join(outputPath, fmt.Sprintf("zarf-package-helm-release-history-%s-0.0.1.tar.zst", e2e.Arch)) + for range 20 { + _, _, err = e2e.Zarf(t, "package", "deploy", packagePath, "--confirm") + require.NoError(t, err) + } + + stdout, err := exec.Command("helm", "history", "-n", "helm-release-history", "chart").Output() + require.NoError(t, err) + out := strings.TrimSpace(string(stdout)) + count := len(strings.Split(string(out), "\n")) + require.Equal(t, 11, count) + + _, _, err = e2e.Zarf(t, "package", "remove", packagePath, "--confirm") + require.NoError(t, err) +} func TestHelm(t *testing.T) { t.Log("E2E: Helm chart") - helmChartsPkg = filepath.Join("build", fmt.Sprintf("zarf-package-helm-charts-%s-0.0.1.tar.zst", e2e.Arch)) - testHelmUninstallRollback(t) testHelmAdoption(t) @@ -74,6 +93,7 @@ func testHelmChartsExample(t *testing.T) { require.NoError(t, err, stdOut, stdErr) // Deploy the example package. + helmChartsPkg := filepath.Join("build", fmt.Sprintf("zarf-package-helm-charts-%s-0.0.1.tar.zst", e2e.Arch)) stdOut, stdErr, err = e2e.Zarf(t, "package", "deploy", helmChartsPkg, "--confirm") require.NoError(t, err, stdOut, stdErr) require.Contains(t, string(stdErr), "registryOverrides", "registry overrides was not saved to build data") diff --git a/src/test/packages/25-helm-release-history/chart/Chart.yaml b/src/test/packages/25-helm-release-history/chart/Chart.yaml new file mode 100644 index 0000000000..d74e703bb8 --- /dev/null +++ b/src/test/packages/25-helm-release-history/chart/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v2 +name: chart +description: A Helm chart for Kubernetes +type: application +version: 0.1.0 diff --git a/src/test/packages/25-helm-release-history/chart/templates/configmap.yaml b/src/test/packages/25-helm-release-history/chart/templates/configmap.yaml new file mode 100644 index 0000000000..153ef97f50 --- /dev/null +++ b/src/test/packages/25-helm-release-history/chart/templates/configmap.yaml @@ -0,0 +1,6 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: test +data: + foo: bar diff --git a/src/test/packages/25-helm-release-history/zarf.yaml b/src/test/packages/25-helm-release-history/zarf.yaml new file mode 100644 index 0000000000..07df74d18c --- /dev/null +++ b/src/test/packages/25-helm-release-history/zarf.yaml @@ -0,0 +1,12 @@ +kind: ZarfPackageConfig +metadata: + name: helm-release-history + version: 0.0.1 +components: + - name: helm-release-history + required: true + charts: + - name: chart + namespace: helm-release-history + version: v0.1.0 + localPath: chart From a7334b80944ba1d82f3a2ec4dbb4b9e18de54c59 Mon Sep 17 00:00:00 2001 From: Kit Patella Date: Thu, 21 Nov 2024 09:05:14 -0800 Subject: [PATCH 13/15] feat: add logger to packager.Publish (#3259) Signed-off-by: Kit Patella --- src/pkg/packager/publish.go | 11 +++++++++++ src/test/e2e/50_oci_publish_deploy_test.go | 1 - 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/pkg/packager/publish.go b/src/pkg/packager/publish.go index 34c54bd546..34e56b2a9d 100644 --- a/src/pkg/packager/publish.go +++ b/src/pkg/packager/publish.go @@ -9,6 +9,7 @@ import ( "fmt" "os" "strings" + "time" "github.com/defenseunicorns/pkg/helpers/v2" "github.com/defenseunicorns/pkg/oci" @@ -17,6 +18,7 @@ import ( "github.com/zarf-dev/zarf/src/api/v1alpha1" "github.com/zarf-dev/zarf/src/config" "github.com/zarf-dev/zarf/src/pkg/layout" + "github.com/zarf-dev/zarf/src/pkg/logger" "github.com/zarf-dev/zarf/src/pkg/message" "github.com/zarf-dev/zarf/src/pkg/packager/creator" "github.com/zarf-dev/zarf/src/pkg/packager/filters" @@ -27,6 +29,10 @@ import ( // Publish publishes the package to a registry func (p *Packager) Publish(ctx context.Context) (err error) { + l := logger.From(ctx) + start := time.Now() + l.Debug("start publish") + _, isOCISource := p.source.(*sources.OCISource) if isOCISource && p.cfg.PublishOpts.SigningKeyPath == "" { // oci --> oci is a special case, where we will use oci.CopyPackage so that we can transfer the package @@ -123,5 +129,10 @@ func (p *Packager) Publish(ctx context.Context) (err error) { return err } } + l.Info("packaged successfully published", + "name", p.cfg.Pkg.Metadata.Name, + "ref", ref, + "duration", time.Since(start), + ) return nil } diff --git a/src/test/e2e/50_oci_publish_deploy_test.go b/src/test/e2e/50_oci_publish_deploy_test.go index 4c2e250551..921c127deb 100644 --- a/src/test/e2e/50_oci_publish_deploy_test.go +++ b/src/test/e2e/50_oci_publish_deploy_test.go @@ -48,7 +48,6 @@ func (suite *PublishDeploySuiteTestSuite) Test_0_Publish() { ref := suite.Reference.String() stdOut, stdErr, err := e2e.Zarf(suite.T(), "package", "publish", example, "oci://"+ref, "--plain-http") suite.NoError(err, stdOut, stdErr) - suite.Contains(stdErr, "Published "+ref) // Pull the package via OCI. stdOut, stdErr, err = e2e.Zarf(suite.T(), "package", "pull", "oci://"+ref+"/helm-charts:0.0.1", "--plain-http") From 0a62ec82b86cd0924a0e8da300df085d8051d8da Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 21 Nov 2024 17:31:21 +0000 Subject: [PATCH 14/15] chore(deps): bump github.com/derailed/k9s from 0.32.5 to 0.32.7 (#3262) Signed-off-by: dependabot[bot] Signed-off-by: Philip Laine Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 20 +++++----- go.sum | 40 +++++++++---------- .../docs/commands/zarf_tools_monitor.md | 2 +- 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/go.mod b/go.mod index 61ae2d141a..44cb6fda5f 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/avast/retry-go/v4 v4.6.0 github.com/defenseunicorns/pkg/helpers/v2 v2.0.1 github.com/defenseunicorns/pkg/oci v1.0.2 - github.com/derailed/k9s v0.32.5 + github.com/derailed/k9s v0.32.7 github.com/distribution/distribution/v3 v3.0.0-beta.1 github.com/distribution/reference v0.6.0 github.com/fairwindsops/pluto/v5 v5.20.3 @@ -184,12 +184,12 @@ require ( github.com/alibabacloud-go/tea-xml v1.1.3 // indirect github.com/aliyun/credentials-go v1.3.2 // indirect github.com/anchore/bubbly v0.0.0-20231115134915-def0aba654a9 // indirect - github.com/anchore/fangs v0.0.0-20241014201141-b6e4b3469f10 // indirect + github.com/anchore/fangs v0.0.0-20241014225144-4e1713cafd77 // indirect github.com/anchore/go-logger v0.0.0-20230725134548-c21dafa1ec5a // indirect github.com/anchore/go-macholibre v0.0.0-20220308212642-53e6d0aaf6fb // indirect github.com/anchore/go-struct-converter v0.0.0-20221118182256-c68fdcfa2092 // indirect github.com/anchore/go-version v1.2.2-0.20210903204242-51efa5b487c4 // indirect - github.com/anchore/grype v0.77.0 // indirect + github.com/anchore/grype v0.84.0 // indirect github.com/anchore/packageurl-go v0.1.1-0.20241018175412-5c22e6360c4f // indirect github.com/andybalholm/brotli v1.1.0 // indirect github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect @@ -258,7 +258,7 @@ require ( github.com/deitch/magic v0.0.0-20230404182410-1ff89d7342da // indirect github.com/derailed/popeye v0.11.3 // indirect github.com/derailed/tcell/v2 v2.3.1-rc.3 // indirect - github.com/derailed/tview v0.8.3 // indirect + github.com/derailed/tview v0.8.5 // indirect github.com/digitorus/pkcs7 v0.0.0-20230818184609-3a137a874352 // indirect github.com/digitorus/timestamp v0.0.0-20231217203849-220c5c2851b7 // indirect github.com/dimchansky/utfbom v1.1.1 // indirect @@ -287,12 +287,12 @@ require ( github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/fvbommel/sortorder v1.1.0 // indirect github.com/gabriel-vasile/mimetype v1.4.6 // indirect - github.com/gdamore/encoding v1.0.0 // indirect + github.com/gdamore/encoding v1.0.1 // indirect github.com/github/go-spdx/v2 v2.3.2 // indirect github.com/glebarez/go-sqlite v1.21.2 // indirect github.com/glebarez/sqlite v1.11.0 // indirect github.com/go-chi/chi v4.1.2+incompatible // indirect - github.com/go-errors/errors v1.4.2 // indirect + github.com/go-errors/errors v1.5.1 // indirect github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect github.com/go-git/go-billy/v5 v5.6.0 github.com/go-gorp/gorp/v3 v3.1.0 // indirect @@ -341,7 +341,7 @@ require ( github.com/hako/durafmt v0.0.0-20210608085754-5c1018a4e16b // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect - github.com/hashicorp/go-getter v1.7.5 // indirect + github.com/hashicorp/go-getter v1.7.6 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hashicorp/go-retryablehttp v0.7.7 // indirect github.com/hashicorp/go-rootcerts v1.0.2 // indirect @@ -452,7 +452,7 @@ require ( github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect github.com/rivo/uniseg v0.4.7 // indirect - github.com/rs/zerolog v1.32.0 // indirect + github.com/rs/zerolog v1.33.0 // indirect github.com/rubenv/sql-migrate v1.7.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/ryanuber/go-glob v1.0.0 // indirect @@ -542,9 +542,9 @@ require ( gopkg.in/warnings.v0 v0.1.2 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - gorm.io/gorm v1.25.9 // indirect + gorm.io/gorm v1.25.12 // indirect k8s.io/apiextensions-apiserver v0.31.1 // indirect - k8s.io/apiserver v0.31.1 // indirect + k8s.io/apiserver v0.31.2 // indirect k8s.io/cli-runtime v0.31.2 // indirect k8s.io/component-helpers v0.31.2 // indirect k8s.io/kube-openapi v0.0.0-20240816214639-573285566f34 // indirect diff --git a/go.sum b/go.sum index 6b62ebd255..bf63ff2816 100644 --- a/go.sum +++ b/go.sum @@ -377,8 +377,8 @@ github.com/anchore/bubbly v0.0.0-20231115134915-def0aba654a9 h1:p0ZIe0htYOX284Y4 github.com/anchore/bubbly v0.0.0-20231115134915-def0aba654a9/go.mod h1:3ZsFB9tzW3vl4gEiUeuSOMDnwroWxIxJelOOHUp8dSw= github.com/anchore/clio v0.0.0-20241015191535-f538a9016e10 h1:3xmanFdoQEH0REvPA+gLm3Km0/981F4z2a/7ADTlv8k= github.com/anchore/clio v0.0.0-20241015191535-f538a9016e10/go.mod h1:h6Ly2hlKjQoPtI3rA8oB5afSmB/XimhcY55xbuW4Dwo= -github.com/anchore/fangs v0.0.0-20241014201141-b6e4b3469f10 h1:w+HibE+e/heP6ysADh7sWxg5LhYdVqrpB1A4Hmgjyx8= -github.com/anchore/fangs v0.0.0-20241014201141-b6e4b3469f10/go.mod h1:s0L1//Sxn6Rq0Dcxx+dmT/RRmD9HhsaJjJkPUJHLJLM= +github.com/anchore/fangs v0.0.0-20241014225144-4e1713cafd77 h1:h7+GCqazHVS5GDJYYS6wjjglYi8xFnVWMdSUukoImTM= +github.com/anchore/fangs v0.0.0-20241014225144-4e1713cafd77/go.mod h1:qbev5czQeyDO74fPNThiEKYkgt0mx1axb+5wQcxDPFY= github.com/anchore/go-collections v0.0.0-20240216171411-9321230ce537 h1:GjNGuwK5jWjJMyVppBjYS54eOiiSNv4Ba869k4wh72Q= github.com/anchore/go-collections v0.0.0-20240216171411-9321230ce537/go.mod h1:1aiktV46ATCkuVg0O573ZrH56BUawTECPETbZyBcqT8= github.com/anchore/go-logger v0.0.0-20230725134548-c21dafa1ec5a h1:nJ2G8zWKASyVClGVgG7sfM5mwoZlZ2zYpIzN2OhjWkw= @@ -391,8 +391,8 @@ github.com/anchore/go-testutils v0.0.0-20200925183923-d5f45b0d3c04 h1:VzprUTpc0v github.com/anchore/go-testutils v0.0.0-20200925183923-d5f45b0d3c04/go.mod h1:6dK64g27Qi1qGQZ67gFmBFvEHScy0/C8qhQhNe5B5pQ= github.com/anchore/go-version v1.2.2-0.20210903204242-51efa5b487c4 h1:rmZG77uXgE+o2gozGEBoUMpX27lsku+xrMwlmBZJtbg= github.com/anchore/go-version v1.2.2-0.20210903204242-51efa5b487c4/go.mod h1:Bkc+JYWjMCF8OyZ340IMSIi2Ebf3uwByOk6ho4wne1E= -github.com/anchore/grype v0.77.0 h1:HoTdZ67INrEpEiSKL713zY+j77HxoEAcsMPIZDZ4yP4= -github.com/anchore/grype v0.77.0/go.mod h1:k6QLcebOqPm+90y8mMesOJM6A6DYQllOic6Tmz507sc= +github.com/anchore/grype v0.84.0 h1:3BwhY+ctiNBmdGd53R36xw5ndC7WhSSKEc0fqaAErw0= +github.com/anchore/grype v0.84.0/go.mod h1:CQQGcLEJBaQ8b5x3ut3T4WoO0KHnjKMFHrh5J6c4Fh4= github.com/anchore/packageurl-go v0.1.1-0.20241018175412-5c22e6360c4f h1:dAQPIrQ3a5PBqZeZ+B9NGZsGmodk4NO9OjDIsQmQyQM= github.com/anchore/packageurl-go v0.1.1-0.20241018175412-5c22e6360c4f/go.mod h1:KoYIv7tdP5+CC9VGkeZV4/vGCKsY55VvoG+5dadg4YI= github.com/anchore/stereoscope v0.0.9 h1:rLhYWe/CXhDq/UCUWQ3U5xtpGk4RFnssKaM0bHhs5us= @@ -627,14 +627,14 @@ github.com/deitch/magic v0.0.0-20230404182410-1ff89d7342da h1:ZOjWpVsFZ06eIhnh4m github.com/deitch/magic v0.0.0-20230404182410-1ff89d7342da/go.mod h1:B3tI9iGHi4imdLi4Asdha1Sc6feLMTfPLXh9IUYmysk= github.com/depcheck-test/depcheck-test v0.0.0-20220607135614-199033aaa936 h1:foGzavPWwtoyBvjWyKJYDYsyzy+23iBV7NKTwdk+LRY= github.com/depcheck-test/depcheck-test v0.0.0-20220607135614-199033aaa936/go.mod h1:ttKPnOepYt4LLzD+loXQ1rT6EmpyIYHro7TAJuIIlHo= -github.com/derailed/k9s v0.32.5 h1:M/mHb115orpiPAPOMmOnf1YMMnfXCFmqGM8+cFGLzRY= -github.com/derailed/k9s v0.32.5/go.mod h1:/rckZ2nRvD/hcDxfvADKG9/E5uLOVSBXLqA+E/ConQk= +github.com/derailed/k9s v0.32.7 h1:9FnpBv4OhvQgmI2E0uso0GihL0xKArGEEb4oPCV8NVs= +github.com/derailed/k9s v0.32.7/go.mod h1:d2xT8Q32eHOncw0F/aEZ/n3fQVMfxuYG1vWApnWqFzc= github.com/derailed/popeye v0.11.3 h1:gQUp6zuSIRDBdyLS1Ln0nFs8FbQ+KGE+iQxe0w4Ug8M= github.com/derailed/popeye v0.11.3/go.mod h1:HygqX7A8BwidorJjJUnWDZ5AvbxHIU7uRwXgOtn9GwY= github.com/derailed/tcell/v2 v2.3.1-rc.3 h1:9s1fmyRcSPRlwr/C9tcpJKCujbrtmPpST6dcMUD2piY= github.com/derailed/tcell/v2 v2.3.1-rc.3/go.mod h1:nf68BEL8fjmXQHJT3xZjoZFs2uXOzyJcNAQqGUEMrFY= -github.com/derailed/tview v0.8.3 h1:jhN7LW7pfCWf7Z6VC5Dpi/1usavOBZxz2mY90//TMsU= -github.com/derailed/tview v0.8.3/go.mod h1:q+odnnhO6QDPpBT+0dqaWj+X+uoJ6MJehXj9shgP+Cw= +github.com/derailed/tview v0.8.5 h1:pogM/OnWlgDo6j4zyzdiIXh7E7+eT7D4CPfBnyaETug= +github.com/derailed/tview v0.8.5/go.mod h1:q+odnnhO6QDPpBT+0dqaWj+X+uoJ6MJehXj9shgP+Cw= github.com/dgraph-io/badger/v3 v3.2103.5 h1:ylPa6qzbjYRQMU6jokoj4wzcaweHylt//CH0AKt0akg= github.com/dgraph-io/badger/v3 v3.2103.5/go.mod h1:4MPiseMeDQ3FNCYwRbbcBOGJLf5jsE0PPFzRiKjtcdw= github.com/dgraph-io/ristretto v0.1.1 h1:6CWw5tJNgpegArSHpNHJKldNeq03FQCwYvfMVWajOK8= @@ -756,8 +756,8 @@ github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ= github.com/gabriel-vasile/mimetype v1.4.6 h1:3+PzJTKLkvgjeTbts6msPJt4DixhT4YtFNf1gtGe3zc= github.com/gabriel-vasile/mimetype v1.4.6/go.mod h1:JX1qVKqZd40hUPpAfiNTe0Sne7hdfKSbOqqmkq8GCXc= -github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko= -github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg= +github.com/gdamore/encoding v1.0.1 h1:YzKZckdBL6jVt2Gc+5p82qhrGiqMdG/eNs6Wy0u3Uhw= +github.com/gdamore/encoding v1.0.1/go.mod h1:0Z0cMFinngz9kS1QfMjCP8TY7em3bZYeeklsSDPivEo= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/github/go-spdx/v2 v2.3.2 h1:IfdyNHTqzs4zAJjXdVQfRnxt1XMfycXoHBE2Vsm1bjs= github.com/github/go-spdx/v2 v2.3.2/go.mod h1:2ZxKsOhvBp+OYBDlsGnUMcchLeo2mrpEBn2L1C+U3IQ= @@ -775,8 +775,8 @@ github.com/gliderlabs/ssh v0.3.7 h1:iV3Bqi942d9huXnzEF2Mt+CY9gLu8DNM4Obd+8bODRE= github.com/gliderlabs/ssh v0.3.7/go.mod h1:zpHEXBstFnQYtGnB8k8kQLol82umzn/2/snG7alWVD8= github.com/go-chi/chi v4.1.2+incompatible h1:fGFk2Gmi/YKXk0OmGfBh0WgmN3XB8lVnEyNz34tQRec= github.com/go-chi/chi v4.1.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= -github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= -github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= +github.com/go-errors/errors v1.5.1 h1:ZwEMSLRCapFLflTpT7NKaAc7ukJ8ZPEjzlxt8rPN8bk= +github.com/go-errors/errors v1.5.1/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= github.com/go-git/go-billy/v5 v5.6.0 h1:w2hPNtoehvJIxR00Vb4xX94qHQi/ApZfX+nBE2Cjio8= @@ -1046,8 +1046,8 @@ github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtng github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= -github.com/hashicorp/go-getter v1.7.5 h1:dT58k9hQ/vbxNMwoI5+xFYAJuv6152UNvdHokfI5wE4= -github.com/hashicorp/go-getter v1.7.5/go.mod h1:W7TalhMmbPmsSMdNjD0ZskARur/9GJ17cfHTRtXV744= +github.com/hashicorp/go-getter v1.7.6 h1:5jHuM+aH373XNtXl9TNTUH5Qd69Trve11tHIrB+6yj4= +github.com/hashicorp/go-getter v1.7.6/go.mod h1:W7TalhMmbPmsSMdNjD0ZskARur/9GJ17cfHTRtXV744= github.com/hashicorp/go-hclog v0.12.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= github.com/hashicorp/go-hclog v1.0.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k= @@ -1501,8 +1501,8 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.32.0 h1:keLypqrlIjaFsbmJOBdB/qvyF8KEtCWHwobLp5l/mQ0= -github.com/rs/zerolog v1.32.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= +github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8= +github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= github.com/rubenv/sql-migrate v1.7.0 h1:HtQq1xyTN2ISmQDggnh0c9U3JlP8apWh8YO2jzlXpTI= github.com/rubenv/sql-migrate v1.7.0/go.mod h1:S4wtDEG1CKn+0ShpTtzWhFpHHI5PvCUtiGI+C+Z2THE= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= @@ -2446,8 +2446,8 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gorm.io/gorm v1.25.9 h1:wct0gxZIELDk8+ZqF/MVnHLkA1rvYlBWUMv2EdsK1g8= -gorm.io/gorm v1.25.9/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8= +gorm.io/gorm v1.25.12 h1:I0u8i2hWQItBq1WfE0o2+WuL9+8L21K9e2HHSTE/0f8= +gorm.io/gorm v1.25.12/go.mod h1:xh7N7RHfYlNc5EmcI/El95gXusucDrQnHXe0+CgWcLQ= gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU= gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU= helm.sh/helm/v3 v3.16.3 h1:kb8bSxMeRJ+knsK/ovvlaVPfdis0X3/ZhYCSFRP+YmY= @@ -2465,8 +2465,8 @@ k8s.io/apiextensions-apiserver v0.31.1 h1:L+hwULvXx+nvTYX/MKM3kKMZyei+UiSXQWciX/ k8s.io/apiextensions-apiserver v0.31.1/go.mod h1:tWMPR3sgW+jsl2xm9v7lAyRF1rYEK71i9G5dRtkknoQ= k8s.io/apimachinery v0.31.2 h1:i4vUt2hPK56W6mlT7Ry+AO8eEsyxMD1U44NR22CLTYw= k8s.io/apimachinery v0.31.2/go.mod h1:rsPdaZJfTfLsNJSQzNHQvYoTmxhoOEofxtOsF3rtsMo= -k8s.io/apiserver v0.31.1 h1:Sars5ejQDCRBY5f7R3QFHdqN3s61nhkpaX8/k1iEw1c= -k8s.io/apiserver v0.31.1/go.mod h1:lzDhpeToamVZJmmFlaLwdYZwd7zB+WYRYIboqA1kGxM= +k8s.io/apiserver v0.31.2 h1:VUzOEUGRCDi6kX1OyQ801m4A7AUPglpsmGvdsekmcI4= +k8s.io/apiserver v0.31.2/go.mod h1:o3nKZR7lPlJqkU5I3Ove+Zx3JuoFjQobGX1Gctw6XuE= k8s.io/cli-runtime v0.31.2 h1:7FQt4C4Xnqx8V1GJqymInK0FFsoC+fAZtbLqgXYVOLQ= k8s.io/cli-runtime v0.31.2/go.mod h1:XROyicf+G7rQ6FQJMbeDV9jqxzkWXTYD6Uxd15noe0Q= k8s.io/client-go v0.31.2 h1:Y2F4dxU5d3AQj+ybwSMqQnpZH9F30//1ObxOKlTI9yc= diff --git a/site/src/content/docs/commands/zarf_tools_monitor.md b/site/src/content/docs/commands/zarf_tools_monitor.md index 3303fde13b..5e035458d7 100644 --- a/site/src/content/docs/commands/zarf_tools_monitor.md +++ b/site/src/content/docs/commands/zarf_tools_monitor.md @@ -32,7 +32,7 @@ zarf tools monitor [flags] --insecure-skip-tls-verify If true, the server's caCertFile will not be checked for validity --kubeconfig string Path to the kubeconfig file to use for CLI requests --logFile string Specify the log file - -l, --logLevel string Specify a log level (info, warn, debug, trace, error) + -l, --logLevel string Specify a log level (error, warn, info, debug, trace) --logoless Turn K9s logo off -n, --namespace string If present, the namespace scope for this CLI request --readonly Sets readOnly mode by overriding readOnly configuration setting From 837f2caad21adb7024e8f4cd27c3689de85571c0 Mon Sep 17 00:00:00 2001 From: Austin Abro <37223396+AustinAbro321@users.noreply.github.com> Date: Thu, 21 Nov 2024 12:31:26 -0500 Subject: [PATCH 15/15] feat: introduce slog for zarf tools (#3212) Signed-off-by: Austin Abro --- src/cmd/root.go | 1 + src/cmd/tools/crane.go | 97 +++++++++++++---------------- src/cmd/tools/helm.go | 2 + src/cmd/tools/kubectl.go | 2 + src/cmd/tools/zarf.go | 92 +++++++++++++++++++++++++-- src/config/lang/english.go | 4 -- src/internal/packager/helm/chart.go | 2 + src/pkg/cluster/secrets.go | 5 ++ 8 files changed, 143 insertions(+), 62 deletions(-) diff --git a/src/cmd/root.go b/src/cmd/root.go index 922a015126..5acfc9c278 100644 --- a/src/cmd/root.go +++ b/src/cmd/root.go @@ -95,6 +95,7 @@ func preRun(cmd *cobra.Command, _ []string) error { var disableMessage bool if LogFormat != "" { disableMessage = true + skipLogFile = true ctx := logger.WithLoggingEnabled(ctx, true) cmd.SetContext(ctx) } diff --git a/src/cmd/tools/crane.go b/src/cmd/tools/crane.go index dd76955339..972a81bffc 100644 --- a/src/cmd/tools/crane.go +++ b/src/cmd/tools/crane.go @@ -5,6 +5,7 @@ package tools import ( + "context" "errors" "fmt" "os" @@ -20,7 +21,7 @@ import ( "github.com/zarf-dev/zarf/src/config/lang" "github.com/zarf-dev/zarf/src/internal/packager/images" "github.com/zarf-dev/zarf/src/pkg/cluster" - "github.com/zarf-dev/zarf/src/pkg/message" + "github.com/zarf-dev/zarf/src/pkg/logger" "github.com/zarf-dev/zarf/src/pkg/transform" "github.com/zarf-dev/zarf/src/types" ) @@ -39,6 +40,11 @@ func init() { Aliases: []string{"r", "crane"}, Short: lang.CmdToolsRegistryShort, PersistentPreRunE: func(cmd *cobra.Command, _ []string) error { + // TODO (@austinabro321) once the code in cmd is simplified, we should change this to respect + // the log-format flag + l := logger.Default() + ctx := logger.WithContext(cmd.Context(), l) + cmd.SetContext(ctx) // The crane options loading here comes from the rootCmd of crane craneOptions = append(craneOptions, crane.WithContext(cmd.Context())) // TODO(jonjohnsonjr): crane.Verbose option? @@ -51,7 +57,6 @@ func init() { if ndlayers { craneOptions = append(craneOptions, crane.WithNondistributable()) } - var err error var v1Platform *v1.Platform if platform != "all" { @@ -111,19 +116,19 @@ func zarfCraneCatalog(cranePlatformOptions *[]crane.Option) *cobra.Command { originalCatalogFn := craneCatalog.RunE craneCatalog.RunE = func(cmd *cobra.Command, args []string) error { + ctx := cmd.Context() + l := logger.From(cmd.Context()) if len(args) > 0 { return originalCatalogFn(cmd, args) } - message.Note(lang.CmdToolsRegistryZarfState) + l.Info("retrieving registry information from Zarf state") c, err := cluster.NewCluster() if err != nil { return err } - ctx := cmd.Context() - zarfState, err := c.LoadZarfState(ctx) if err != nil { return err @@ -139,7 +144,6 @@ func zarfCraneCatalog(cranePlatformOptions *[]crane.Option) *cobra.Command { *cranePlatformOptions = append(*cranePlatformOptions, authOption) if tunnel != nil { - message.Notef(lang.CmdToolsRegistryTunnel, registryEndpoint, zarfState.RegistryInfo.Address) defer tunnel.Close() return tunnel.Wrap(func() error { return originalCatalogFn(cmd, []string{registryEndpoint}) }) } @@ -160,6 +164,8 @@ func zarfCraneInternalWrapper(commandToWrap func(*[]crane.Option) *cobra.Command originalListFn := wrappedCommand.RunE wrappedCommand.RunE = func(cmd *cobra.Command, args []string) error { + ctx := cmd.Context() + l := logger.From(ctx) if len(args) < imageNameArgumentIndex+1 { return errors.New("not have enough arguments specified for this command") } @@ -170,13 +176,11 @@ func zarfCraneInternalWrapper(commandToWrap func(*[]crane.Option) *cobra.Command return originalListFn(cmd, args) } - message.Note(lang.CmdToolsRegistryZarfState) - - ctx := cmd.Context() + l.Info("retrieving registry information from Zarf state") zarfState, err := c.LoadZarfState(ctx) if err != nil { - message.Warnf("could not get Zarf state from Kubernetes cluster, continuing without state information %s", err.Error()) + l.Warn("could not get Zarf state from Kubernetes cluster, continuing without state information", "error", err.Error()) return originalListFn(cmd, args) } @@ -195,7 +199,7 @@ func zarfCraneInternalWrapper(commandToWrap func(*[]crane.Option) *cobra.Command *cranePlatformOptions = append(*cranePlatformOptions, authOption) if tunnel != nil { - message.Notef(lang.CmdToolsRegistryTunnel, tunnel.Endpoint(), zarfState.RegistryInfo.Address) + l.Info("opening a tunnel to the Zarf registry", "local-endpoint", tunnel.Endpoint(), "cluster-address", zarfState.RegistryInfo.Address) defer tunnel.Close() @@ -219,6 +223,7 @@ func pruneImages(cmd *cobra.Command, _ []string) error { } ctx := cmd.Context() + l := logger.From(ctx) zarfState, err := c.LoadZarfState(ctx) if err != nil { @@ -237,19 +242,19 @@ func pruneImages(cmd *cobra.Command, _ []string) error { } if tunnel != nil { - message.Notef(lang.CmdToolsRegistryTunnel, registryEndpoint, zarfState.RegistryInfo.Address) + l.Info("opening a tunnel to the Zarf registry", "local-endpoint", tunnel.Endpoint(), "cluster-address", zarfState.RegistryInfo.Address) defer tunnel.Close() - return tunnel.Wrap(func() error { return doPruneImagesForPackages(zarfState, zarfPackages, registryEndpoint) }) + return tunnel.Wrap(func() error { return doPruneImagesForPackages(ctx, zarfState, zarfPackages, registryEndpoint) }) } - return doPruneImagesForPackages(zarfState, zarfPackages, registryEndpoint) + return doPruneImagesForPackages(ctx, zarfState, zarfPackages, registryEndpoint) } -func doPruneImagesForPackages(zarfState *types.ZarfState, zarfPackages []types.DeployedPackage, registryEndpoint string) error { +func doPruneImagesForPackages(ctx context.Context, zarfState *types.ZarfState, zarfPackages []types.DeployedPackage, registryEndpoint string) error { + l := logger.From(ctx) authOption := images.WithPushAuth(zarfState.RegistryInfo) - spinner := message.NewProgressSpinner(lang.CmdToolsRegistryPruneLookup) - defer spinner.Stop() + l.Info("finding images to prune") // Determine which image digests are currently used by Zarf packages pkgImages := map[string]bool{} @@ -278,8 +283,6 @@ func doPruneImagesForPackages(zarfState *types.ZarfState, zarfPackages []types.D } } - spinner.Updatef(lang.CmdToolsRegistryPruneCatalog) - // Find which images and tags are in the registry currently imageCatalog, err := crane.Catalog(registryEndpoint, authOption) if err != nil { @@ -302,8 +305,6 @@ func doPruneImagesForPackages(zarfState *types.ZarfState, zarfPackages []types.D } } - spinner.Updatef(lang.CmdToolsRegistryPruneCalculate) - // Figure out which images are in the registry but not needed by packages imageDigestsToPrune := map[string]bool{} for digestRef, digest := range referenceToDigest { @@ -317,44 +318,36 @@ func doPruneImagesForPackages(zarfState *types.ZarfState, zarfPackages []types.D } } - spinner.Success() + if len(imageDigestsToPrune) == 0 { + l.Info("there are no images to prune") + return nil + } - if len(imageDigestsToPrune) > 0 { - message.Note(lang.CmdToolsRegistryPruneImageList) + l.Info("the following image digests will be pruned from the registry:") + for digestRef := range imageDigestsToPrune { + l.Info(digestRef) + } - for digestRef := range imageDigestsToPrune { - message.Info(digestRef) + confirm := config.CommonOptions.Confirm + if !confirm { + prompt := &survey.Confirm{ + Message: "continue with image prune?", } - - confirm := config.CommonOptions.Confirm - - if confirm { - message.Note(lang.CmdConfirmProvided) - } else { - prompt := &survey.Confirm{ - Message: lang.CmdConfirmContinue, - } - if err := survey.AskOne(prompt, &confirm); err != nil { - return fmt.Errorf("confirm selection canceled: %w", err) - } + if err := survey.AskOne(prompt, &confirm); err != nil { + return fmt.Errorf("confirm selection canceled: %w", err) } - if confirm { - spinner := message.NewProgressSpinner(lang.CmdToolsRegistryPruneDelete) - defer spinner.Stop() + } + if confirm { + l.Info("pruning images") - // Delete the digest references that are to be pruned - for digestRef := range imageDigestsToPrune { - err = crane.Delete(digestRef, authOption) - if err != nil { - return err - } + // Delete the digest references that are to be pruned + for digestRef := range imageDigestsToPrune { + err = crane.Delete(digestRef, authOption) + if err != nil { + return err } - - spinner.Success() + l.Debug("image pruned", "name", digestRef) } - } else { - message.Note(lang.CmdToolsRegistryPruneNoImages) } - return nil } diff --git a/src/cmd/tools/helm.go b/src/cmd/tools/helm.go index 9f367b694e..b6c08e316c 100644 --- a/src/cmd/tools/helm.go +++ b/src/cmd/tools/helm.go @@ -7,6 +7,7 @@ package tools import ( "os" + "github.com/zarf-dev/zarf/src/pkg/logger" "github.com/zarf-dev/zarf/src/pkg/message" "github.com/zarf-dev/zarf/src/cmd/tools/helm" @@ -29,6 +30,7 @@ func init() { helmCmd, err := helm.NewRootCmd(actionConfig, os.Stdout, helmArgs) if err != nil { message.Debug("Failed to initialize helm command", "error", err) + logger.Default().Debug("failed to initialize helm command", "error", err) } helmCmd.Short = lang.CmdToolsHelmShort helmCmd.Long = lang.CmdToolsHelmLong diff --git a/src/cmd/tools/kubectl.go b/src/cmd/tools/kubectl.go index bccabe89f1..4054a4e3e6 100644 --- a/src/cmd/tools/kubectl.go +++ b/src/cmd/tools/kubectl.go @@ -10,6 +10,7 @@ import ( "github.com/spf13/cobra" "github.com/zarf-dev/zarf/src/cmd/common" "github.com/zarf-dev/zarf/src/config/lang" + "github.com/zarf-dev/zarf/src/pkg/logger" "github.com/zarf-dev/zarf/src/pkg/message" kubeCLI "k8s.io/component-base/cli" kubeCmd "k8s.io/kubectl/pkg/cmd" @@ -33,6 +34,7 @@ func init() { if err := kubeCLI.RunNoErrOutput(kubectlCmd); err != nil { // @todo(jeff-mccoy) - Kubectl gets mad about being a subcommand. message.Debug(err) + logger.Default().Debug(err.Error()) } } diff --git a/src/cmd/tools/zarf.go b/src/cmd/tools/zarf.go index d33af49cdf..3f967a8510 100644 --- a/src/cmd/tools/zarf.go +++ b/src/cmd/tools/zarf.go @@ -10,6 +10,7 @@ import ( "fmt" "os" "slices" + "strings" "github.com/AlecAivazis/survey/v2" "github.com/sigstore/cosign/v2/pkg/cosign" @@ -24,6 +25,7 @@ import ( "github.com/zarf-dev/zarf/src/internal/packager/helm" "github.com/zarf-dev/zarf/src/internal/packager/template" "github.com/zarf-dev/zarf/src/pkg/cluster" + "github.com/zarf-dev/zarf/src/pkg/logger" "github.com/zarf-dev/zarf/src/pkg/message" "github.com/zarf-dev/zarf/src/pkg/packager/sources" "github.com/zarf-dev/zarf/src/pkg/pki" @@ -35,6 +37,15 @@ var subAltNames []string var outputDirectory string var updateCredsInitOpts types.ZarfInitOptions +const ( + registryKey = "registry" + registryReadKey = "registry-readonly" + gitKey = "git" + gitReadKey = "git-readonly" + artifactKey = "artifact" + agentKey = "agent" +) + var deprecatedGetGitCredsCmd = &cobra.Command{ Use: "get-git-password", Hidden: true, @@ -74,6 +85,8 @@ var getCredsCmd = &cobra.Command{ if len(args) > 0 { // If a component name is provided, only show that component's credentials + // Printing both the pterm output and slogger for now + printComponentCredential(ctx, state, args[0]) message.PrintComponentCredential(state, args[0]) } else { message.PrintCredentialTable(state, nil) @@ -101,6 +114,7 @@ var updateCredsCmd = &cobra.Command{ } ctx := cmd.Context() + l := logger.From(ctx) timeoutCtx, cancel := context.WithTimeout(ctx, cluster.DefaultTimeout) defer cancel() @@ -122,13 +136,13 @@ var updateCredsCmd = &cobra.Command{ return fmt.Errorf("unable to update Zarf credentials: %w", err) } + // Printing both the pterm output and slogger for now message.PrintCredentialUpdates(oldState, newState, args) + printCredentialUpdates(ctx, oldState, newState, args) confirm := config.CommonOptions.Confirm - if confirm { - message.Note(lang.CmdToolsUpdateCredsConfirmProvided) - } else { + if !confirm { prompt := &survey.Confirm{ Message: lang.CmdToolsUpdateCredsConfirmContinue, } @@ -180,6 +194,7 @@ var updateCredsCmd = &cobra.Command{ if err != nil { // Warn if we couldn't actually update the registry (it might not be installed and we should try to continue) message.Warnf(lang.CmdToolsUpdateCredsUnableUpdateRegistry, err.Error()) + l.Warn("unable to update Zarf Registry values", "error", err.Error()) } } if slices.Contains(args, message.GitKey) && newState.GitServer.IsInternal() && internalGitServerExists { @@ -193,6 +208,7 @@ var updateCredsCmd = &cobra.Command{ if err != nil { // Warn if we couldn't actually update the agent (it might not be installed and we should try to continue) message.Warnf(lang.CmdToolsUpdateCredsUnableUpdateAgent, err.Error()) + l.Warn("unable to update Zarf Agent TLS secrets", "error", err.Error()) } } } @@ -200,16 +216,76 @@ var updateCredsCmd = &cobra.Command{ }, } +func printComponentCredential(ctx context.Context, state *types.ZarfState, componentName string) { + // TODO (@austinabro321) when we move over to the new logger, we can should add fmt.Println calls + // to this function as they will be removed from message.PrintComponentCredential + l := logger.From(ctx) + switch strings.ToLower(componentName) { + case gitKey: + l.Info("Git server push password", "username", state.GitServer.PushUsername) + case gitReadKey: + l.Info("Git server (read-only) password", "username", state.GitServer.PullUsername) + case artifactKey: + l.Info("artifact server token", "username", state.ArtifactServer.PushUsername) + case registryKey: + l.Info("image registry password", "username", state.RegistryInfo.PushUsername) + case registryReadKey: + l.Info("image registry (read-only) password", "username", state.RegistryInfo.PullUsername) + default: + l.Warn("unknown component", "component", componentName) + } +} + +func printCredentialUpdates(ctx context.Context, oldState *types.ZarfState, newState *types.ZarfState, services []string) { + // Pause the logfile's output to avoid credentials being printed to the log file + l := logger.From(ctx) + l.Info("--- printing credential updates. Sensitive values will be redacted ---") + for _, service := range services { + switch service { + case registryKey: + oR := oldState.RegistryInfo + nR := newState.RegistryInfo + l.Info("registry URL address", "existing", oR.Address, "replacement", nR.Address) + l.Info("registry push username", "existing", oR.PushUsername, "replacement", nR.PushUsername) + l.Info("registry push password", "changed", !(oR.PushPassword == nR.PushPassword)) + l.Info("registry pull username", "existing", oR.PullUsername, "replacement", nR.PullUsername) + l.Info("registry pull password", "changed", !(oR.PullPassword == nR.PullPassword)) + case gitKey: + oG := oldState.GitServer + nG := newState.GitServer + l.Info("Git server URL address", "existing", oG.Address, "replacement", nG.Address) + l.Info("Git server push username", "existing", oG.PushUsername, "replacement", nG.PushUsername) + l.Info("Git server push password", "changed", !(oG.PushPassword == nG.PushPassword)) + l.Info("Git server pull username", "existing", oG.PullUsername, "replacement", nG.PullUsername) + l.Info("Git server pull password", "changed", !(oG.PullPassword == nG.PullPassword)) + case artifactKey: + oA := oldState.ArtifactServer + nA := newState.ArtifactServer + l.Info("artifact server URL address", "existing", oA.Address, "replacement", nA.Address) + l.Info("artifact server push username", "existing", oA.PushUsername, "replacement", nA.PushUsername) + l.Info("artifact server push token", "changed", !(oA.PushToken == nA.PushToken)) + case agentKey: + oT := oldState.AgentTLS + nT := newState.AgentTLS + l.Info("agent certificate authority", "changed", !(string(oT.CA) == string(nT.CA))) + l.Info("agent public certificate", "changed", !(string(oT.Cert) == string(nT.Cert))) + l.Info("agent private key", "changed", !(string(oT.Key) == string(nT.Key))) + } + } +} + var clearCacheCmd = &cobra.Command{ Use: "clear-cache", Aliases: []string{"c"}, Short: lang.CmdToolsClearCacheShort, - RunE: func(_ *cobra.Command, _ []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { + l := logger.From(cmd.Context()) cachePath, err := config.GetAbsCachePath() if err != nil { return err } message.Notef(lang.CmdToolsClearCacheDir, cachePath) + l.Info("clearing cache", "path", cachePath) if err := os.RemoveAll(cachePath); err != nil { return fmt.Errorf("unable to clear the cache directory %s: %w", cachePath, err) } @@ -242,7 +318,7 @@ var generatePKICmd = &cobra.Command{ Aliases: []string{"pki"}, Short: lang.CmdToolsGenPkiShort, Args: cobra.ExactArgs(1), - RunE: func(_ *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, args []string) error { pki, err := pki.GeneratePKI(args[0], subAltNames...) if err != nil { return err @@ -257,6 +333,7 @@ var generatePKICmd = &cobra.Command{ return err } message.Successf(lang.CmdToolsGenPkiSuccess, args[0]) + logger.From(cmd.Context()).Info("successfully created a chain of trust", "host", args[0]) return nil }, } @@ -265,7 +342,7 @@ var generateKeyCmd = &cobra.Command{ Use: "gen-key", Aliases: []string{"key"}, Short: lang.CmdToolsGenKeyShort, - RunE: func(_ *cobra.Command, _ []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { // Utility function to prompt the user for the password to the private key passwordFunc := func(bool) ([]byte, error) { // perform the first prompt @@ -329,6 +406,9 @@ var generateKeyCmd = &cobra.Command{ } message.Successf(lang.CmdToolsGenKeySuccess, prvKeyFileName, pubKeyFileName) + logger.From(cmd.Context()).Info("Successfully generated key pair", + "private-key-path", prvKeyExistsErr, + "public-key-path", pubKeyFileName) return nil }, } diff --git a/src/config/lang/english.go b/src/config/lang/english.go index d8c0f7694e..2d848a6c1a 100644 --- a/src/config/lang/english.go +++ b/src/config/lang/english.go @@ -36,10 +36,6 @@ const ( // Zarf CLI commands. const ( - // common command language - CmdConfirmProvided = "Confirm flag specified, continuing without prompting." - CmdConfirmContinue = "Continue with these changes?" - // root zarf command RootCmdShort = "DevSecOps for Airgap" RootCmdLong = "Zarf eliminates the complexity of air gap software delivery for Kubernetes clusters and cloud native workloads\n" + diff --git a/src/internal/packager/helm/chart.go b/src/internal/packager/helm/chart.go index 59454057bf..e000045650 100644 --- a/src/internal/packager/helm/chart.go +++ b/src/internal/packager/helm/chart.go @@ -242,6 +242,8 @@ func (h *Helm) RemoveChart(ctx context.Context, namespace string, name string, s func (h *Helm) UpdateReleaseValues(ctx context.Context, updatedValues map[string]interface{}) error { spinner := message.NewProgressSpinner("Updating values for helm release %s", h.chart.ReleaseName) defer spinner.Stop() + l := logger.From(ctx) + l.Debug("updating values for helm release", "name", h.chart.ReleaseName) err := h.createActionConfig(ctx, h.chart.Namespace, spinner) if err != nil { diff --git a/src/pkg/cluster/secrets.go b/src/pkg/cluster/secrets.go index aa49d00c9e..5cfaf30880 100644 --- a/src/pkg/cluster/secrets.go +++ b/src/pkg/cluster/secrets.go @@ -16,6 +16,7 @@ import ( v1ac "k8s.io/client-go/applyconfigurations/core/v1" "github.com/zarf-dev/zarf/src/config" + "github.com/zarf-dev/zarf/src/pkg/logger" "github.com/zarf-dev/zarf/src/pkg/message" "github.com/zarf-dev/zarf/src/types" ) @@ -93,6 +94,7 @@ func (c *Cluster) GenerateGitPullCreds(namespace, name string, gitServerInfo typ // UpdateZarfManagedImageSecrets updates all Zarf-managed image secrets in all namespaces based on state func (c *Cluster) UpdateZarfManagedImageSecrets(ctx context.Context, state *types.ZarfState) error { + l := logger.From(ctx) spinner := message.NewProgressSpinner("Updating existing Zarf-managed image secrets") defer spinner.Stop() @@ -117,6 +119,7 @@ func (c *Cluster) UpdateZarfManagedImageSecrets(ctx context.Context, state *type if err != nil { return err } + l.Info("applying Zarf managed registry secret for namespace", "name", namespace.Name) spinner.Updatef("Updating existing Zarf-managed image secret for namespace: '%s'", namespace.Name) _, err = c.Clientset.CoreV1().Secrets(*newRegistrySecret.Namespace).Apply(ctx, newRegistrySecret, metav1.ApplyOptions{Force: true, FieldManager: FieldManagerName}) if err != nil { @@ -132,6 +135,7 @@ func (c *Cluster) UpdateZarfManagedImageSecrets(ctx context.Context, state *type func (c *Cluster) UpdateZarfManagedGitSecrets(ctx context.Context, state *types.ZarfState) error { spinner := message.NewProgressSpinner("Updating existing Zarf-managed git secrets") defer spinner.Stop() + l := logger.From(ctx) namespaceList, err := c.Clientset.CoreV1().Namespaces().List(ctx, metav1.ListOptions{}) if err != nil { @@ -151,6 +155,7 @@ func (c *Cluster) UpdateZarfManagedGitSecrets(ctx context.Context, state *types. } newGitSecret := c.GenerateGitPullCreds(namespace.Name, config.ZarfGitServerSecretName, state.GitServer) spinner.Updatef("Updating existing Zarf-managed git secret for namespace: %s", namespace.Name) + l.Info("applying Zarf managed git secret for namespace", "name", namespace.Name) _, err = c.Clientset.CoreV1().Secrets(*newGitSecret.Namespace).Apply(ctx, newGitSecret, metav1.ApplyOptions{Force: true, FieldManager: FieldManagerName}) if err != nil { return err