Skip to content

Commit

Permalink
Merge branch 'main' into improve-eks
Browse files Browse the repository at this point in the history
  • Loading branch information
AustinAbro321 authored Jul 25, 2024
2 parents 6bfd9e2 + a93d65a commit c2d06b9
Show file tree
Hide file tree
Showing 126 changed files with 1,352 additions and 1,345 deletions.
1 change: 1 addition & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ linters:
- goimports
- nolintlint
- testifylint
- whitespace
linters-settings:
govet:
enable-all: true
Expand Down
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/AlecAivazis/survey/v2 v2.3.7
github.com/Masterminds/semver/v3 v3.2.1
github.com/agnivade/levenshtein v1.1.1
github.com/anchore/clio v0.0.0-20240408173007-3c4abf89e72f
github.com/anchore/clio v0.0.0-20240705045624-ac88e09ad9d0
github.com/anchore/stereoscope v0.0.1
github.com/anchore/syft v0.100.0
github.com/defenseunicorns/pkg/helpers/v2 v2.0.1
Expand Down Expand Up @@ -40,14 +40,14 @@ require (
github.com/sigstore/sigstore/pkg/signature/kms/azure v1.8.1
github.com/sigstore/sigstore/pkg/signature/kms/gcp v1.8.1
github.com/sigstore/sigstore/pkg/signature/kms/hashivault v1.8.1
github.com/spf13/cobra v1.8.0
github.com/spf13/cobra v1.8.1
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.18.2
github.com/stretchr/testify v1.9.0
github.com/xeipuuv/gojsonschema v1.2.0
golang.org/x/crypto v0.24.0
golang.org/x/sync v0.7.0
golang.org/x/term v0.21.0
golang.org/x/term v0.22.0
helm.sh/helm/v3 v3.14.2
k8s.io/api v0.30.0
k8s.io/apimachinery v0.30.0
Expand Down Expand Up @@ -132,7 +132,7 @@ require (
github.com/alibabacloud-go/tea-xml v1.1.3 // indirect
github.com/aliyun/credentials-go v1.3.1 // indirect
github.com/anchore/bubbly v0.0.0-20231115134915-def0aba654a9 // indirect
github.com/anchore/fangs v0.0.0-20231201140849-5075d28d6d8b // indirect
github.com/anchore/fangs v0.0.0-20240508143433-f016b099950f // 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
Expand Down Expand Up @@ -199,7 +199,7 @@ require (
github.com/containerd/ttrpc v1.2.2 // indirect
github.com/containerd/typeurl/v2 v2.1.1 // indirect
github.com/coreos/go-oidc/v3 v3.9.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
github.com/cyberphone/json-canonicalization v0.0.0-20231011164504-785e29786b46 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
Expand Down Expand Up @@ -483,7 +483,7 @@ require (
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/oauth2 v0.21.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
Expand Down
24 changes: 12 additions & 12 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -372,10 +372,10 @@ github.com/aliyun/credentials-go v1.3.1 h1:uq/0v7kWrxmoLGpqjx7vtQ/s03f0zR//0br/x
github.com/aliyun/credentials-go v1.3.1/go.mod h1:8jKYhQuDawt8x2+fusqa1Y6mPxemTsBEN04dgcAcYz0=
github.com/anchore/bubbly v0.0.0-20231115134915-def0aba654a9 h1:p0ZIe0htYOX284Y4axJaGBvXHU0VCCzLN5Wf5XbKStU=
github.com/anchore/bubbly v0.0.0-20231115134915-def0aba654a9/go.mod h1:3ZsFB9tzW3vl4gEiUeuSOMDnwroWxIxJelOOHUp8dSw=
github.com/anchore/clio v0.0.0-20240408173007-3c4abf89e72f h1:2xJPf4KWzxFDwZK/yax+h8QHP2Gnn4fgXUCCeizhbyU=
github.com/anchore/clio v0.0.0-20240408173007-3c4abf89e72f/go.mod h1:1k7cwq2CeVH9dgAl0X/JBBfJ4y/E8h2R9KqByDkrCA4=
github.com/anchore/fangs v0.0.0-20231201140849-5075d28d6d8b h1:L/djgY7ZbZ/38+wUtdkk398W3PIBJLkt1N8nU/7e47A=
github.com/anchore/fangs v0.0.0-20231201140849-5075d28d6d8b/go.mod h1:TLcE0RE5+8oIx2/NPWem/dq1DeaMoC+fPEH7hoSzPLo=
github.com/anchore/clio v0.0.0-20240705045624-ac88e09ad9d0 h1:rtO6Bcc5KX1i6Ndj4pFcFUkE5PaiKv0J4hKSlmbEIXQ=
github.com/anchore/clio v0.0.0-20240705045624-ac88e09ad9d0/go.mod h1:U3M+opzBUkSBUIRUXsQj6ZgrX9i7Nn0YLn4CjmhKMNI=
github.com/anchore/fangs v0.0.0-20240508143433-f016b099950f h1:NOhzafCyNYFi88qxkBFjMzQo4dRa1vDhBzx+0Uovx8Q=
github.com/anchore/fangs v0.0.0-20240508143433-f016b099950f/go.mod h1:sVpRS2yNCw6tLVpvA1QSDVWTJVpCuAm8JNZgn4Sjz/k=
github.com/anchore/go-logger v0.0.0-20230725134548-c21dafa1ec5a h1:nJ2G8zWKASyVClGVgG7sfM5mwoZlZ2zYpIzN2OhjWkw=
github.com/anchore/go-logger v0.0.0-20230725134548-c21dafa1ec5a/go.mod h1:ubLFmlsv8/DFUQrZwY5syT5/8Er3ugSr4rDFwHsE3hg=
github.com/anchore/go-macholibre v0.0.0-20220308212642-53e6d0aaf6fb h1:iDMnx6LIjtjZ46C0akqveX83WFzhpTD3eqOthawb5vU=
Expand Down Expand Up @@ -578,8 +578,8 @@ github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/cpuguy83/go-md2man/v2 v2.0.3 h1:qMCsGGgs+MAzDFyp9LpAe1Lqy/fY/qCovCm0qnXZOBM=
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4=
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.17/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
github.com/creack/pty v1.1.21 h1:1/QdRyBaHHJP61QkWMXlOIBfsgdDeeKfK8SYVUWJKf0=
github.com/creack/pty v1.1.21/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
Expand Down Expand Up @@ -1584,8 +1584,8 @@ github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkU
github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0=
github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
github.com/spf13/cobra v1.3.0/go.mod h1:BrRVncBjOJa/eUcVVm9CE+oC6as8k+VYr4NY7WCi9V4=
github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y=
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
Expand Down Expand Up @@ -2067,8 +2067,8 @@ golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
Expand All @@ -2082,8 +2082,8 @@ 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.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
golang.org/x/term v0.21.0 h1:WVXCp+/EBEHOj53Rvu+7KiT/iElMrO8ACK16SMZ3jaA=
golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0=
golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk=
golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

"github.com/zarf-dev/zarf/src/cmd"
"github.com/zarf-dev/zarf/src/config"
"github.com/zarf-dev/zarf/src/pkg/packager/lint"
"github.com/zarf-dev/zarf/src/pkg/lint"
)

//go:embed cosign.pub
Expand Down
2 changes: 1 addition & 1 deletion site/public/tutorials/package_create_wordpress.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
<b style="color:#ffffff;"> </b><b style="color:#55ffff;">sensitive</b>:<b style="color:#ffffff;"> true</b>
<b style="color:#ffffff;"></b>-<b style="color:#55ffff;"> name</b>:<b style="color:#ff55ff;"> WORDPRESS_EMAIL</b>
<b style="color:#ff55ff;"> </b><b style="color:#55ffff;">description</b>:<b style="color:#ff55ff;"> The email that is used for the WordPress admin account</b>
<b style="color:#ff55ff;"> </b><b style="color:#55ffff;">default</b>:<b style="color:#ff55ff;"> hello@defenseunicorns.com</b>
<b style="color:#ff55ff;"> </b><b style="color:#55ffff;">default</b>:<b style="color:#ff55ff;"> hello@zarf-dev.com</b>
<b style="color:#ff55ff;"> </b><b style="color:#55ffff;">prompt</b>:<b style="color:#ffffff;"> true</b>
<b style="color:#ffffff;"></b>-<b style="color:#55ffff;"> name</b>:<b style="color:#ff55ff;"> WORDPRESS_FIRST_NAME</b>
<b style="color:#ff55ff;"> </b><b style="color:#55ffff;">description</b>:<b style="color:#ff55ff;"> The first name that is used for the WordPress admin account</b>
Expand Down
2 changes: 1 addition & 1 deletion site/src/content/docs/ref/deploy.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ $ zarf connect [service name]

:::note

You can also specify a package locally, or via oci such as `zarf package deploy oci://defenseunicorns/dos-games:1.0.0-$(uname -m) --key=https://zarf.dev/cosign.pub`
You can also specify a package locally, or via oci such as `zarf package deploy oci://defenseunicorns/dos-games:1.0.0 --key=https://zarf.dev/cosign.pub`

:::

Expand Down
2 changes: 1 addition & 1 deletion site/src/content/docs/ref/deployment-ui.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The Zarf Deployment Web UI can easily be downloaded from the [Zarf UI Github Pro

Follow these steps to get started using the Web UI

1. Step one: [Download the Zarf UI](https://github.com/defenseunicorns/zarf-ui/releases/latest) version that matches your system (i.e. `zarf-ui_v0.1.0-Darwin_arm64`)
1. Step one: [Download the Zarf UI](https://github.com/zarf-dev/zarf-ui/releases/latest) version that matches your system (i.e. `zarf-ui_v0.1.0-Darwin_arm64`)
2. Step two: (if applicable) Mark the file as executable with `chmod +x zarf-ui_v0.1.0-Darwin_arm64`
3. Step three: Run the binary with `./zarf-ui_v0.1.0-Darwin_arm64` or by double clicking the file in your file browser

Expand Down
2 changes: 1 addition & 1 deletion site/src/content/docs/roadmap.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: Roadmap

## Issue Tracking

The issue board for Zarf is hosted on a [GitHub Project Board](https://github.com/orgs/defenseunicorns/projects/1) that tracks the issues the Zarf team is working along with future work we are prioritizing.
The issue board for Zarf is hosted on a [GitHub Project Board](https://github.com/orgs/zarf-dev/projects/1) that tracks the issues the Zarf team is working along with future work we are prioritizing.

If you would like to add bug reports or feature requests, please [add an issue](https://github.com/zarf-dev/zarf/issues) to the GitHub repository under the appropriate template. If you have a more general question about a feature, feel free to ask the team in the [Zarf Kubernetes Slack Channel](https://kubernetes.slack.com/archives/C03B6BJAUJ3).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Before beginning this tutorial you will need the following:

## Deploying the Arcade

1. The `dos-games` package is easily deployable via `oci://` by running `zarf package deploy oci://defenseunicorns/dos-games:1.0.0-$(uname -m) --key=https://zarf.dev/cosign.pub`.
1. The `dos-games` package is easily deployable via `oci://` by running `zarf package deploy oci://defenseunicorns/dos-games:1.0.0 --key=https://zarf.dev/cosign.pub`.

:::tip

Expand Down
50 changes: 21 additions & 29 deletions src/cmd/common/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,38 @@
package common

import (
"errors"
"fmt"
"io"
"os"
"time"

"github.com/pterm/pterm"
"github.com/zarf-dev/zarf/src/config"
"github.com/zarf-dev/zarf/src/config/lang"

"github.com/zarf-dev/zarf/src/pkg/message"
)

// LogLevelCLI holds the log level as input from a command
var LogLevelCLI string

// SetupCLI sets up the CLI logging, interrupt functions, and more
func SetupCLI() {
match := map[string]message.LogLevel{
"warn": message.WarnLevel,
"info": message.InfoLevel,
"debug": message.DebugLevel,
"trace": message.TraceLevel,
}

if config.NoColor {
// SetupCLI sets up the CLI logging
func SetupCLI(logLevel string, skipLogFile, noColor bool) error {
if noColor {
message.DisableColor()
}

printViperConfigUsed()

// No log level set, so use the default
if LogLevelCLI != "" {
if lvl, ok := match[LogLevelCLI]; ok {
message.SetLogLevel(lvl)
message.Debug("Log level set to " + LogLevelCLI)
} else {
message.Warn(lang.RootCmdErrInvalidLogLevel)
if logLevel != "" {
match := map[string]message.LogLevel{
"warn": message.WarnLevel,
"info": message.InfoLevel,
"debug": message.DebugLevel,
"trace": message.TraceLevel,
}
lvl, ok := match[logLevel]
if !ok {
return errors.New("invalid log level, valid options are warn, info, debug, and trace")
}
message.SetLogLevel(lvl)
message.Debug("Log level set to " + logLevel)
}

// Disable progress bars for CI envs
Expand All @@ -50,21 +45,18 @@ func SetupCLI() {
message.NoProgress = true
}

if !config.SkipLogFile {
if !skipLogFile {
ts := time.Now().Format("2006-01-02-15-04-05")

f, err := os.CreateTemp("", fmt.Sprintf("zarf-%s-*.log", ts))
if err != nil {
message.WarnErr(err, "Error creating a log file in a temporary directory")
return
return fmt.Errorf("could not create a log file in a the temporary directory: %w", err)
}
logFile, err := message.UseLogFile(f)
if err != nil {
message.WarnErr(err, "Error saving a log file to a temporary directory")
return
return fmt.Errorf("could not save a log file to the temporary directory: %w", err)
}

pterm.SetDefaultOutput(io.MultiWriter(os.Stderr, logFile))
message.Notef("Saving log file to %s", f.Name())
}
return nil
}
8 changes: 5 additions & 3 deletions src/cmd/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/zarf-dev/zarf/src/cmd/common"
"github.com/zarf-dev/zarf/src/config"
"github.com/zarf-dev/zarf/src/config/lang"
"github.com/zarf-dev/zarf/src/pkg/lint"
"github.com/zarf-dev/zarf/src/pkg/message"
"github.com/zarf-dev/zarf/src/pkg/packager"
"github.com/zarf-dev/zarf/src/pkg/transform"
Expand Down Expand Up @@ -142,7 +143,7 @@ var devSha256SumCmd = &cobra.Command{
Aliases: []string{"s"},
Short: lang.CmdDevSha256sumShort,
Args: cobra.ExactArgs(1),
RunE: func(_ *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) error {
hashErr := errors.New("unable to compute the SHA256SUM hash")

fileName := args[0]
Expand All @@ -169,7 +170,7 @@ var devSha256SumCmd = &cobra.Command{
}

downloadPath := filepath.Join(tmp, fileBase)
err = utils.DownloadToFile(fileName, downloadPath, "")
err = utils.DownloadToFile(cmd.Context(), fileName, downloadPath, "")
if err != nil {
return errors.Join(hashErr, err)
}
Expand Down Expand Up @@ -269,6 +270,7 @@ var devLintCmd = &cobra.Command{
Short: lang.CmdDevLintShort,
Long: lang.CmdDevLintLong,
RunE: func(cmd *cobra.Command, args []string) error {
config.CommonOptions.Confirm = true
pkgConfig.CreateOpts.BaseDir = common.SetBaseDirectory(args)
v := common.GetViper()
pkgConfig.CreateOpts.SetVariables = helpers.TransformAndMergeMap(
Expand All @@ -280,7 +282,7 @@ var devLintCmd = &cobra.Command{
}
defer pkgClient.ClearTempPaths()

return pkgClient.Lint(cmd.Context())
return lint.Validate(cmd.Context(), pkgConfig.CreateOpts)
},
}

Expand Down
41 changes: 32 additions & 9 deletions src/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,43 @@ import (
var (
// Default global config for the packager
pkgConfig = types.PackagerConfig{}
// LogLevelCLI holds the log level as input from a command
LogLevelCLI string
// SkipLogFile is a flag to skip logging to a file
SkipLogFile bool
// NoColor is a flag to disable colors in output
NoColor bool
)

var rootCmd = &cobra.Command{
Use: "zarf COMMAND",
PersistentPreRun: func(cmd *cobra.Command, _ []string) {
// Skip for vendor-only commands
PersistentPreRunE: func(cmd *cobra.Command, _ []string) error {
// Skip for vendor only commands
if common.CheckVendorOnlyFromPath(cmd) {
return
return nil
}
// Don't log the help command

skipLogFile := SkipLogFile

// Dont write tool commands to file.
comps := strings.Split(cmd.CommandPath(), " ")
if len(comps) > 1 && comps[1] == "tools" {
skipLogFile = true
}
if len(comps) > 1 && comps[1] == "version" {
skipLogFile = true
}

// Dont write help command to file.
if cmd.Parent() == nil {
config.SkipLogFile = true
skipLogFile = true
}

err := common.SetupCLI(LogLevelCLI, skipLogFile, NoColor)
if err != nil {
return err
}
common.SetupCLI()
return nil
},
Short: lang.RootCmdShort,
Long: lang.RootCmdLong,
Expand Down Expand Up @@ -89,11 +112,11 @@ func init() {

v := common.InitViper()

rootCmd.PersistentFlags().StringVarP(&common.LogLevelCLI, "log-level", "l", v.GetString(common.VLogLevel), lang.RootCmdFlagLogLevel)
rootCmd.PersistentFlags().StringVarP(&LogLevelCLI, "log-level", "l", v.GetString(common.VLogLevel), lang.RootCmdFlagLogLevel)
rootCmd.PersistentFlags().StringVarP(&config.CLIArch, "architecture", "a", v.GetString(common.VArchitecture), lang.RootCmdFlagArch)
rootCmd.PersistentFlags().BoolVar(&config.SkipLogFile, "no-log-file", v.GetBool(common.VNoLogFile), lang.RootCmdFlagSkipLogFile)
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(&config.NoColor, "no-color", v.GetBool(common.VNoColor), lang.RootCmdFlagNoColor)
rootCmd.PersistentFlags().BoolVar(&NoColor, "no-color", v.GetBool(common.VNoColor), lang.RootCmdFlagNoColor)
rootCmd.PersistentFlags().StringVar(&config.CommonOptions.CachePath, "zarf-cache", v.GetString(common.VZarfCache), lang.RootCmdFlagCachePath)
rootCmd.PersistentFlags().StringVar(&config.CommonOptions.TempDirectory, "tmpdir", v.GetString(common.VTmpDir), lang.RootCmdFlagTempDir)
rootCmd.PersistentFlags().BoolVar(&config.CommonOptions.Insecure, "insecure", v.GetBool(common.VInsecure), lang.RootCmdFlagInsecure)
Expand Down
15 changes: 2 additions & 13 deletions src/cmd/tools/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,14 @@ import (
"fmt"

"github.com/spf13/cobra"
"github.com/zarf-dev/zarf/src/cmd/common"
"github.com/zarf-dev/zarf/src/config"

"github.com/zarf-dev/zarf/src/config/lang"
)

var toolsCmd = &cobra.Command{
Use: "tools",
Aliases: []string{"t"},
PersistentPreRun: func(cmd *cobra.Command, _ []string) {
config.SkipLogFile = true

// Skip for vendor-only commands
if common.CheckVendorOnlyFromPath(cmd) {
return
}

common.SetupCLI()
},
Short: lang.CmdToolsShort,
Short: lang.CmdToolsShort,
}

// Include adds the tools command to the root command.
Expand Down
Loading

0 comments on commit c2d06b9

Please sign in to comment.