From 0daaf503f492a02debd0c105abd59c20f313316a Mon Sep 17 00:00:00 2001 From: Wayne Starr Date: Wed, 19 Apr 2023 11:23:22 -0500 Subject: [PATCH] Fix linting and UI version check (#1624) ## Description This cleans up the UI diff check script for local dev and a few linting issues. ## Related Issue Fixes #1614 ## Type of change - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [X] Other (security config, docs update, etc) ## Checklist before merging - [X] Test, docs, adr added or updated as needed - [X] [Contributor Guide Steps](https://github.com/defenseunicorns/zarf/blob/main/CONTRIBUTING.md#developer-workflow) followed --- .github/workflows/release.yml | 2 +- .goreleaser.yaml | 2 +- README.md | 4 ++-- hack/print-ui-diff.sh | 3 --- src/internal/packager/images/pull.go | 3 ++- src/pkg/message/message.go | 6 ++---- src/pkg/packager/deprecated/common.go | 1 + src/pkg/transform/image.go | 4 ++-- 8 files changed, 11 insertions(+), 14 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6cc11776cd..dd3ec1bbd4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,7 +9,7 @@ jobs: push-resources: runs-on: ubuntu-latest permissions: - contents: read + contents: write packages: write steps: - name: Checkout diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 54e89d2b6d..828e9ed462 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -15,7 +15,7 @@ builds: - darwin - windows ldflags: - - -s -w -X github.com/defenseunicorns/zarf/src/config.CLIVersion={{.Tag}} + - -s -w -X github.com/defenseunicorns/zarf/src/config.CLIVersion={{.Tag}} -X k8s.io/component-base/version.gitVersion=v0.0.0+zarf{{.Tag}} -X k8s.io/component-base/version.gitCommit={{.FullCommit}} -X k8s.io/component-base/version.buildDate={{.Date}} goarch: - amd64 - arm64 diff --git a/README.md b/README.md index 6e782cc7f4..facb99a82a 100644 --- a/README.md +++ b/README.md @@ -6,12 +6,12 @@ [![Zarf Documentation Status](https://api.netlify.com/api/v1/badges/fe846ae4-25fb-4274-9968-90782640ee9f/deploy-status)](https://app.netlify.com/sites/zarf-docs/deploys) [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/defenseunicorns/zarf/badge)](https://api.securityscorecards.dev/projects/github.com/defenseunicorns/zarf) +zarf logo + [![Zarf Website](https://img.shields.io/badge/web-zarf.dev-6d87c3)](https://zarf.dev/) [![Zarf Documentation](https://img.shields.io/badge/docs-docs.zarf.dev-775ba1)](https://docs.zarf.dev/) [![Zarf Slack Channel](https://img.shields.io/badge/k8s%20slack-zarf-40a3dd)](https://kubernetes.slack.com/archives/C03B6BJAUJ3) -zarf logo - Zarf eliminates the [complexity of air gap software delivery](https://www.itopstimes.com/contain/air-gap-kubernetes-considerations-for-running-cloud-native-applications-without-the-cloud/) for Kubernetes clusters and cloud-native workloads using a declarative packaging strategy to support DevSecOps in offline and semi-connected environments. ## 📦 Out of the Box Features diff --git a/hack/print-ui-diff.sh b/hack/print-ui-diff.sh index e8758612fa..1ab4616f9f 100755 --- a/hack/print-ui-diff.sh +++ b/hack/print-ui-diff.sh @@ -2,9 +2,6 @@ # Get the diff for UI related files git diff HEAD src/ui -git diff HEAD package.json -git diff HEAD package-lock.json -git diff HEAD .npmrc git diff HEAD .eslint* git diff HEAD ts* git diff HEAD prettier* diff --git a/src/internal/packager/images/pull.go b/src/internal/packager/images/pull.go index 32948059d4..49f3b6bfab 100644 --- a/src/internal/packager/images/pull.go +++ b/src/internal/packager/images/pull.go @@ -7,6 +7,7 @@ package images import ( "context" "encoding/json" + "errors" "fmt" "io" "os" @@ -63,7 +64,7 @@ func (i *ImgConfig) PullAll() error { // Create the ImagePath directory err := os.Mkdir(i.ImagesPath, 0755) - if err != nil { + if err != nil && !errors.Is(err, os.ErrExist) { return fmt.Errorf("failed to create image path %s: %w", i.ImagesPath, err) } diff --git a/src/pkg/message/message.go b/src/pkg/message/message.go index 459e6031ee..e304670f8a 100644 --- a/src/pkg/message/message.go +++ b/src/pkg/message/message.go @@ -35,9 +35,6 @@ const ( // NoProgress tracks whether spinner/progress bars show updates. var NoProgress bool -// Separator is a string of 100 spaces to provide visual separation between elements. -var Separator = strings.Repeat(" ", 100) - var logLevel = InfoLevel // Write logs to stderr and a buffer for logFile generation. @@ -45,6 +42,7 @@ var logFile *os.File var useLogFile bool +// DebugWriter represents a writer interface that writes to message.Debug type DebugWriter struct{} func (d *DebugWriter) Write(raw []byte) (int, error) { @@ -220,7 +218,7 @@ func HorizontalRule() { pterm.Println(strings.Repeat("━", 100)) } -// HorizontalRule prints a yellow horizontal rule to separate the terminal +// HorizontalNoteRule prints a yellow horizontal rule to separate the terminal func HorizontalNoteRule() { pterm.Println() pterm.FgYellow.Println(strings.Repeat("━", 100)) diff --git a/src/pkg/packager/deprecated/common.go b/src/pkg/packager/deprecated/common.go index 5e7e5ffbdb..c8d3907f7b 100644 --- a/src/pkg/packager/deprecated/common.go +++ b/src/pkg/packager/deprecated/common.go @@ -15,6 +15,7 @@ import ( "github.com/pterm/pterm" ) +// BreakingChange represents a breaking change that happened on a specified Zarf version type BreakingChange struct { version *semver.Version title string diff --git a/src/pkg/transform/image.go b/src/pkg/transform/image.go index d461c13587..53dcc5167c 100644 --- a/src/pkg/transform/image.go +++ b/src/pkg/transform/image.go @@ -35,9 +35,9 @@ func ImageTransformHost(targetHost, srcReference string) (string, error) { // If this image is specified by digest then don't add a checksum it as it will already be a specific SHA if image.Digest != "" { return fmt.Sprintf("%s/%s@%s", targetHost, image.Path, image.Digest), nil - } else { - return fmt.Sprintf("%s/%s:%s-zarf-%d", targetHost, image.Path, image.Tag, checksum), nil } + + return fmt.Sprintf("%s/%s:%s-zarf-%d", targetHost, image.Path, image.Tag, checksum), nil } // ImageTransformHostWithoutChecksum replaces the base url for an image but avoids adding a checksum of the original url (note image refs are not full URLs).