From 08d7c2f98e4cfbd421ff0c4f84eddfbeab9aef2f Mon Sep 17 00:00:00 2001 From: Justin Bailey Date: Mon, 10 Jun 2024 14:39:01 +0000 Subject: [PATCH] chore: fix typos (#676) --- CONTRIBUTING.md | 2 +- README.md | 114 +++++++++++++----- docs/overrides.md | 4 +- .../bundles/08-var-precedence/uds-config.yaml | 4 +- 4 files changed, 89 insertions(+), 35 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 517a04f4..364e87aa 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -16,7 +16,7 @@ Fundamentally, software engineering is a communication problem; we write code fo - **Write tests that give confidence**: Unless there is a technical blocker, every new feature and bug fix should be tested in the project's automated test suite. Although many of our tests are E2E, unit and integration-style tests are also welcomed. Note that unit tests can live in a `*_test.go` file alongside the source code, and E2E tests live in `src/test/e2e` -- **Prefer readability over being clever**: We have a strong preference for code readabilty in UDS CLI. Specifically, this means things like: naming variables appropriately, keeping functions to a reasonable size and avoiding complicated solutions when simple ones exist. +- **Prefer readability over being clever**: We have a strong preference for code readability in UDS CLI. Specifically, this means things like: naming variables appropriately, keeping functions to a reasonable size and avoiding complicated solutions when simple ones exist. - **User experience is paramount**: UDS CLI doesn't have a pretty UI (yet), but the core user-centered design principles that apply when building a frontend also apply to this CLI tool. First and foremost, features in UDS CLI should enhance workflows and make life easier for end users; if a feature doesn't accomplish this, it will be dropped. diff --git a/README.md b/README.md index e24ce78b..5e6742cd 100644 --- a/README.md +++ b/README.md @@ -7,37 +7,55 @@ ## Table of Contents -1. [Install](#install) -1. [Contributing](CONTRIBUTING.md) -1. [Quickstart](#quickstart) - - [Create](#bundle-create) - - [Deploy](#bundle-deploy) - - [Inspect](#bundle-inspect) - - [Publish](#bundle-publish) - - [Remove](#bundle-remove) +- [UDS-CLI](#uds-cli) + - [Table of Contents](#table-of-contents) + - [Install](#install) + - [Contributing](#contributing) + - [Quickstart](#quickstart) + - [Declarative Syntax](#declarative-syntax) + - [First-class UDS Support](#first-class-uds-support) + - [Bundle Create](#bundle-create) + - [Bundle Deploy](#bundle-deploy) + - [Specifying Packages using `--packages`](#specifying-packages-using---packages) + - [Resuming Bundle Deploys using `--resume`](#resuming-bundle-deploys-using---resume) + - [Bundle Inspect](#bundle-inspect) + - [Viewing Images in a Bundle](#viewing-images-in-a-bundle) + - [Viewing SBOMs](#viewing-sboms) + - [Bundle Publish](#bundle-publish) + - [Bundle Remove](#bundle-remove) - [Logs](#logs) -1. [Bundle Architecture and Multi-Arch Support](#bundle-architecture-and-multi-arch-support) -1. [Configuration](#configuration) -1. [Sharing Variables](#sharing-variables) -1. [Duplicate Packages and Naming](#duplicate-packages-and-naming) -1. [Zarf Integration](#zarf-integration) -1. [Bundle Overrides](docs/overrides.md) -1. [Bundle Anatomy](docs/anatomy.md) -1. [Runner](docs/runner.md) -1. [Dev Mode](#dev-mode) -1. [Scan](#scan) + - [Bundle Architecture and Multi-Arch Support](#bundle-architecture-and-multi-arch-support) + - [Architecture Validation](#architecture-validation) + - [Configuration](#configuration) + - [Sharing Variables](#sharing-variables) + - [Importing/Exporting Variables](#importingexporting-variables) + - [Sharing Variables Across Multiple Packages](#sharing-variables-across-multiple-packages) + - [Variable Precedence and Specificity](#variable-precedence-and-specificity) + - [Duplicate Packages And Naming](#duplicate-packages-and-naming) + - [Zarf Integration](#zarf-integration) + - [Dev Mode](#dev-mode) + - [Scan](#scan) + - [Usage](#usage) + - [Required Parameters](#required-parameters) + - [Optional Parameters](#optional-parameters) + - [Example Usage](#example-usage) ## Install + Recommended installation method is with Brew: + ``` brew tap defenseunicorns/tap && brew install uds ``` + UDS CLI Binaries are also included with each [Github Release](https://github.com/defenseunicorns/uds-cli/releases) ## Contributing + Build instructions and contributing docs are located in [CONTRIBUTING.md](CONTRIBUTING.md). ## Quickstart + The UDS-CLI's flagship feature is deploying multiple, independent Zarf packages. To create a `UDSBundle` of Zarf packages, create a `uds-bundle.yaml` file like so: ```yaml @@ -57,58 +75,72 @@ packages: repository: ghcr.io/defenseunicorns/uds-cli/podinfo ref: 0.0.1 ``` + The above `UDSBundle` deploys the Zarf init package and podinfo. The packages referenced in `packages` can exist either locally or in an OCI registry. See [here](src/test/packages/03-local-and-remote) for an example that deploys both local and remote Zarf packages. More `UDSBundle` examples can be found in the [src/test/bundles](src/test/bundles) folder. #### Declarative Syntax + The syntax of a `uds-bundle.yaml` is entirely declarative. As a result, the UDS CLI will not prompt users to deploy optional components in a Zarf package. If you want to deploy an optional Zarf component, it must be specified in the `optionalComponents` key of a particular `package`. #### First-class UDS Support + When running `deploy`,`inspect`,`remove`, and `pull` commands, UDS CLI contains shorthand for interacting with the Defense Unicorns org on GHCR. Specifically, unless otherwise specified, paths will automatically be expanded to the Defense Unicorns org on GHCR. For example: + - `uds deploy unicorn-bundle:v0.1.0` is equivalent to `uds deploy ghcr.io/defenseunicorns/packages/uds/bundles/unicorn-bundle:v0.1.0` The bundle matching and expansion is ordered as follows: + 1. Local with a `tar.zst` extension 2. Remote path: `oci://ghcr.io/defenseunicorns/packages/uds/bundles/` 3. Remote path: `oci://ghcr.io/defenseunicorns/packages/delivery/` 4. Remote path: `oci://ghcr.io/defenseunicorns/packages/` -That is to say, if the bundle is not local, UDS CLI will check path 2, path 3, etc for the remote bundle artifact. This behavior can be overriden by specifying the full path to the bundle artifact, for example `uds deploy ghcr.io/defenseunicorns/dev/path/dev-bundle:v0.1.0`. +That is to say, if the bundle is not local, UDS CLI will check path 2, path 3, etc for the remote bundle artifact. This behavior can be overridden by specifying the full path to the bundle artifact, for example `uds deploy ghcr.io/defenseunicorns/dev/path/dev-bundle:v0.1.0`. ### Bundle Create + Pulls the Zarf packages from the registry and bundles them into an OCI artifact. There are 2 ways to create Bundles: + 1. Inside an OCI registry: `uds create -o ghcr.io/defenseunicorns/dev` 1. Locally on your filesystem: `uds create ` -> [!NOTE] +> [!NOTE] > The `--insecure` flag is necessary when interacting with a local registry, but not from secure, remote registries such as GHCR. ### Bundle Deploy + Deploys the bundle There are 2 ways to deploy Bundles: + 1. From an OCI registry: `uds deploy ghcr.io/defenseunicorns/dev/:` 1. From your local filesystem: `uds deploy uds-bundle-.tar.zst` #### Specifying Packages using `--packages` + By default all the packages in the bundle are deployed, but you can also deploy only certain packages in the bundle by using the `--packages` flag. As an example: `uds deploy uds-bundle-.tar.zst --packages init,nginx` #### Resuming Bundle Deploys using `--resume` + By default all the packages in the bundle are deployed, regardless of if they have already been deployed, but you can also choose to only deploy packages that have not already been deployed by using the `--resume` flag As an example: `uds deploy uds-bundle-.tar.zst --resume` ### Bundle Inspect + Inspect the `uds-bundle.yaml` of a bundle + 1. From an OCI registry: `uds inspect oci://ghcr.io/defenseunicorns/dev/:` 1. From your local filesystem: `uds inspect uds-bundle-.tar.zst` #### Viewing Images in a Bundle + It is possible to derive images from a `uds-bundle.yaml`. This can be useful for situations where you need to know what images will be bundled before you actually create the bundle. This is accomplished with the `--list-images` flag. For example: `uds inspect ./uds-bundle.yaml --list-images` @@ -116,22 +148,27 @@ It is possible to derive images from a `uds-bundle.yaml`. This can be useful for This command will return a list of images derived from the bundle's packages, taking into account optional and required package components. #### Viewing SBOMs + There are 2 additional flags for the `uds inspect` command you can use to extract and view SBOMs: + - Output the SBOMs as a tar file: `uds inspect ... --sbom` - Output SBOMs into a directory as files: `uds inspect ... --sbom --extract` This functionality will use the `sboms.tar` of the underlying Zarf packages to create new a `bundle-sboms.tar` artifact containing all SBOMs from the Zarf packages in the bundle. ### Bundle Publish + Local bundles can be published to an OCI registry like so: -`uds publish .tar.zst oci:// ` +`uds publish .tar.zst oci://` As an example: `uds publish uds-bundle-example-arm64-0.0.1.tar.zst oci://ghcr.io/github_user` ### Bundle Remove + Removes the bundle There are 2 ways to remove Bundles: + 1. From an OCI registry: `uds remove oci://ghcr.io/defenseunicorns/dev/: --confirm` 1. From your local filesystem: `uds remove uds-bundle-.tar.zst --confirm` @@ -147,7 +184,9 @@ As an example: `uds remove uds-bundle-.tar.zst --packages init,nginx` The `uds logs` command can be used to view the most recent logs of a bundle operation. Note that depending on your OS temporary directory and file settings, recent logs are purged after a certain amount of time, so this command may return an error if the logs are no longer available. ## Bundle Architecture and Multi-Arch Support + There are several ways to specify the architecture of a bundle according to the following precedence: + 1. Setting `--architecture` or `-a` flag during `uds ...` operations: `uds create --architecture arm64` 2. Setting a `UDS_ARCHITECTURE` environment variable 3. Setting the `options.architecture` key in a `uds-config.yaml` @@ -158,9 +197,10 @@ This means that setting the `--architecture` flag takes precedence over all othe UDS CLI supports multi-arch bundles. This means you can push bundles with different architectures to the same remote OCI repository, at the same tag. For example, you can push both an `amd64` and `arm64` bundle to `ghcr.io//:0.0.1`. ### Architecture Validation -When deploying a local bundle, the bundle's architecture will be used for comparison against the cluster architecture to ensure compatability. If deploying a remote bundle, by default the bundle is pulled based on system architecture, which is then checked against the cluster. -> [!NOTE] +When deploying a local bundle, the bundle's architecture will be used for comparison against the cluster architecture to ensure compatibility. If deploying a remote bundle, by default the bundle is pulled based on system architecture, which is then checked against the cluster. + +> [!NOTE] > It is possible to override the bundle architecture used at validation time by using the `--architecture` / `-a` flag. If, for example, you have a multi-arch remote bundle that you want to deploy from an arm64 machine to an amd64 cluster, the validation with fail because the system arch does not match the cluster arch. However, you can pull the correct bundle version by specifying the arch with the command line architecture flag. @@ -169,7 +209,9 @@ e.g. `uds deploy -a amd64 --confirm` ## Configuration + The UDS CLI can be configured with a `uds-config.yaml` file. This file can be placed in the current working directory or specified with an environment variable called `UDS_CONFIG`. The basic structure of the `uds-config.yaml` is as follows: + ```yaml options: log_level: debug @@ -194,11 +236,15 @@ variables: - path: "/" pathType: "Prefix" ``` + The `options` key contains UDS CLI options that are not specific to a particular Zarf package. The `variables` key contains variables that are specific to a particular Zarf package. If you want to share insensitive variables across multiple Zarf packages, you can use the `shared` key, where the key is the variable name and the value is the variable value. ## Sharing Variables + ### Importing/Exporting Variables + Zarf package variables can be passed between Zarf packages: + ```yaml kind: UDSBundle metadata: @@ -225,13 +271,16 @@ Variables that you want to make available to other packages are in the `export` In the example above, the `OUTPUT` variable is created as part of a Zarf Action in the [output-var](src/test/packages/zarf/no-cluster/output-var) package, and the [receive-var](src/test/packages/zarf/no-cluster/receive-var) package expects a variable called `OUTPUT`. ### Sharing Variables Across Multiple Packages + If a Zarf variable has the same name in multiple packages and you don't want to set it multiple times via the import/export syntax, you can set an environment variable prefixed with `UDS_` and it will be applied to all the Zarf packages in a bundle. For example, if multiple packages require a `DOMAIN` variable, you could set it once with a `UDS_DOMAIN` environment variable and it would be applied to all packages. Note that this can also be done with the `shared` key in the `uds-config.yaml` file. On deploy, you can also set package variables by using the `--set` flag. If the package name isn't included in the key (example: `--set super=true`) the variable will get applied to all of the packages. If the package name is included in the key (example: `--set cool-package.super=true`) the variable will only get applied to that package. ### Variable Precedence and Specificity + In a bundle, variables can come from 4 sources. Those sources and their precedence are shown below in order of least to most specificity: + - Variables declared in a Zarf pkg - Variables `import`'ed from a bundle package's `export` - Variables configured in the `shared` key in a `uds-config.yaml` @@ -241,10 +290,10 @@ In a bundle, variables can come from 4 sources. Those sources and their preceden That is to say, variables set using the `--set` flag take precedence over all other variable sources. - ## Duplicate Packages And Naming -It is possible to deploy multiple instances of the same Zarf package in a bundle. For example, the following `uds-bundle.yaml` deploys 3 instances of the [helm-overrides](src/test/packages/helm/zarf.yaml) Zarf packags: +It is possible to deploy multiple instances of the same Zarf package in a bundle. For example, the following `uds-bundle.yaml` deploys 3 instances of the [helm-overrides](src/test/packages/helm/zarf.yaml) Zarf packages: + ```yaml kind: UDSBundle metadata: @@ -281,23 +330,26 @@ packages: ``` The naming conventions for deploying duplicate packages are as follows: + 1. The `name` field of the package in the `uds-bundle.yaml` must be unique 1. The duplicate packages must be deployed in different namespaces 1. In order to deploy duplicates of local packages, the `path` field must point to a Zarf package tarball instead of to a folder. -> [!NOTE] +> [!NOTE] > Today the duplicate packages feature is only supported for packages with Helm charts. This is because Helm charts' [namespaces can be overridden](docs/overrides.md#namespace) at deploy time. ## Zarf Integration + UDS CLI includes a vendored version of Zarf inside of its binary. To use Zarf, simply run `uds zarf `. For example, to create a Zarf package, run `uds zarf create `, or to use the [airgap tooling](https://docs.zarf.dev/docs/the-zarf-cli/cli-commands/zarf_tools) that Zarf provides, run `uds zarf tools `. ## Dev Mode -NOTE: Dev mode is a BETA feature +> [!NOTE] +> Dev mode is a BETA feature Dev mode facilitates faster dev cycles when developing and testing bundles -``` +```sh uds dev deploy | ``` @@ -316,11 +368,10 @@ The `dev deploy` command performs the following operations: ## Scan -> [!NOTE] +> [!NOTE] > Scan is an ALPHA feature. > Trivy is a prerequisite for scanning container images and filesystem for vulnerabilities. You can find more information and installation instructions at [Trivy's official documentation](https://aquasecurity.github.io/trivy). - The `scan` command is used to scan a Zarf package for vulnerabilities and generate a report. This command is currently in ALPHA. ### Usage @@ -332,16 +383,19 @@ uds scan --org --package-name --tag [options ``` ### Required Parameters + - `--org` or `-o`: Organization name (default: `defenseunicorns`) - `--package-name` or `-n`: Name of the package (e.g., `packages/uds/gitlab-runner`) - `--tag` or `-g`: Tag name (e.g., `16.10.0-uds.0-upstream`) - `--output-file` or `-f`: Output file for CSV results ### Optional Parameters + - `--docker-username` or `-u`: Docker username for registry access, accepts CSV values - `--docker-password` or `-p`: Docker password for registry access, accepts CSV values ### Example Usage + ```sh uds scan -o defenseunicorns -n packages/uds/gitlab-runner -g 16.10.0-uds.0-upstream -u docker-username -p docker-password -f gitlab-runner.csv ``` diff --git a/docs/overrides.md b/docs/overrides.md index 50cf6141..14ba629f 100644 --- a/docs/overrides.md +++ b/docs/overrides.md @@ -121,7 +121,7 @@ In this example, the `helm-overrides-package` Zarf package has a component calle ### Values Files -The `valuesFiles` in an `overrides` block are a list of `file`'s. It allows users to override multiple values in a Zarf package component's underlying Helm chart, by providing a file with those values instead of having to include them all indiviually in the `overrides` block. +The `valuesFiles` in an `overrides` block are a list of `file`'s. It allows users to override multiple values in a Zarf package component's underlying Helm chart, by providing a file with those values instead of having to include them all individually in the `overrides` block. ### Values @@ -283,7 +283,7 @@ variables: test_secret: test.cert ``` -This means when `test.cert` is evalutated it will first be appended to the config path like so `src/test/bundles/07-helm-overrides/variable-files/test.cert`. +This means when `test.cert` is evaluated it will first be appended to the config path like so `src/test/bundles/07-helm-overrides/variable-files/test.cert`. If the file path is already set to the same relative path as the config, then no merging will take place. diff --git a/src/test/bundles/08-var-precedence/uds-config.yaml b/src/test/bundles/08-var-precedence/uds-config.yaml index b8a7cd97..799ea10f 100644 --- a/src/test/bundles/08-var-precedence/uds-config.yaml +++ b/src/test/bundles/08-var-precedence/uds-config.yaml @@ -2,8 +2,8 @@ options: log_level: debug shared: - domain: burning.boats # used in helm-overrides pkg, but overriden in output-var pkg - ui_color: purple # overriden by env var + domain: burning.boats # used in helm-overrides pkg, but overridden in output-var pkg + ui_color: purple # overridden by env var variables: helm-overrides: