diff --git a/.golangci.yaml b/.golangci.yaml index ab7cc77904..37d811f119 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -14,6 +14,7 @@ linters: - goimports - nolintlint - testifylint + - whitespace linters-settings: govet: enable-all: true diff --git a/src/cmd/tools/yq.go b/src/cmd/tools/yq.go index 85d72ab767..41839f568b 100644 --- a/src/cmd/tools/yq.go +++ b/src/cmd/tools/yq.go @@ -10,7 +10,6 @@ import ( ) func init() { - yqCmd := yq.New() yqCmd.Example = lang.CmdToolsYqExample yqCmd.Use = "yq" diff --git a/src/extensions/bigbang/flux.go b/src/extensions/bigbang/flux.go index d67097f26c..91680970e9 100644 --- a/src/extensions/bigbang/flux.go +++ b/src/extensions/bigbang/flux.go @@ -120,7 +120,6 @@ func readFluxImages(localPath string) (images []string, err error) { for _, container := range pod.Containers { images = append(images, container.Image) } - } } diff --git a/src/internal/agent/hooks/flux-gitrepo.go b/src/internal/agent/hooks/flux-gitrepo.go index 079ee6a8e0..38a5aedadb 100644 --- a/src/internal/agent/hooks/flux-gitrepo.go +++ b/src/internal/agent/hooks/flux-gitrepo.go @@ -38,7 +38,6 @@ func NewGitRepositoryMutationHook(ctx context.Context, cluster *cluster.Cluster) // mutateGitRepoCreate mutates the git repository url to point to the repository URL defined in the ZarfState. func mutateGitRepo(ctx context.Context, r *v1.AdmissionRequest, cluster *cluster.Cluster) (result *operations.Result, err error) { - var ( patches []operations.PatchOperation isPatched bool diff --git a/src/internal/agent/hooks/flux-helmrepo.go b/src/internal/agent/hooks/flux-helmrepo.go index 90aab22f7a..c053bb669b 100644 --- a/src/internal/agent/hooks/flux-helmrepo.go +++ b/src/internal/agent/hooks/flux-helmrepo.go @@ -36,7 +36,6 @@ 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) { - src := &flux.HelmRepository{} if err := json.Unmarshal(r.Object.Raw, &src); err != nil { return nil, fmt.Errorf(lang.ErrUnmarshal, err) diff --git a/src/internal/agent/hooks/flux-ocirepo.go b/src/internal/agent/hooks/flux-ocirepo.go index 045b315e3a..021a0a619d 100644 --- a/src/internal/agent/hooks/flux-ocirepo.go +++ b/src/internal/agent/hooks/flux-ocirepo.go @@ -35,7 +35,6 @@ 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) { - src := &flux.OCIRepository{} if err := json.Unmarshal(r.Object.Raw, &src); err != nil { return nil, fmt.Errorf(lang.ErrUnmarshal, err) diff --git a/src/internal/packager/git/gitea.go b/src/internal/packager/git/gitea.go index a6c2f4b48a..4bfbcf60ab 100644 --- a/src/internal/packager/git/gitea.go +++ b/src/internal/packager/git/gitea.go @@ -103,7 +103,6 @@ func (g *Git) CreateReadOnlyUser(ctx context.Context) error { // UpdateZarfGiteaUsers updates Zarf gitea users func (g *Git) UpdateZarfGiteaUsers(ctx context.Context, oldState *types.ZarfState) error { - //Update git read only user password err := g.UpdateGitUser(ctx, oldState.GitServer.PushPassword, g.Server.PullUsername, g.Server.PullPassword) if err != nil { diff --git a/src/internal/packager/helm/post-render.go b/src/internal/packager/helm/post-render.go index 9a514fc6a6..60d8fde0e3 100644 --- a/src/internal/packager/helm/post-render.go +++ b/src/internal/packager/helm/post-render.go @@ -125,7 +125,6 @@ func (r *renderer) adoptAndUpdateNamespaces(ctx context.Context) error { return err } for name, namespace := range r.namespaces { - // Check to see if this namespace already exists var existingNamespace bool for _, serverNamespace := range namespaceList.Items { @@ -205,7 +204,6 @@ func (r *renderer) adoptAndUpdateNamespaces(ctx context.Context) error { if err != nil { message.WarnErrf(err, "Problem creating git server secret for the %s namespace", name) } - } } return nil diff --git a/src/internal/packager/helm/repo.go b/src/internal/packager/helm/repo.go index 148a4176a4..1e47b6e6bf 100644 --- a/src/internal/packager/helm/repo.go +++ b/src/internal/packager/helm/repo.go @@ -58,7 +58,6 @@ func (h *Helm) PackageChart(ctx context.Context, cosignKeyPath string) error { return fmt.Errorf("unable to download the published chart %q: %w", h.chart.Name, err) } } - } else { err := h.PackageChartFromLocalFiles(cosignKeyPath) if err != nil { diff --git a/src/pkg/cluster/zarf.go b/src/pkg/cluster/zarf.go index 7320e4610b..71d6f73c9e 100644 --- a/src/pkg/cluster/zarf.go +++ b/src/pkg/cluster/zarf.go @@ -105,7 +105,6 @@ func (c *Cluster) StripZarfLabelsAndSecretsFromNamespaces(ctx context.Context) { // PackageSecretNeedsWait checks if a package component has a running webhook that needs to be waited on. func (c *Cluster) PackageSecretNeedsWait(deployedPackage *types.DeployedPackage, component types.ZarfComponent, skipWebhooks bool) (needsWait bool, waitSeconds int, hookName string) { - // Skip checking webhook status when '--skip-webhooks' flag is provided and for YOLO packages if skipWebhooks || deployedPackage == nil || deployedPackage.Data.Metadata.YOLO { return false, 0, "" diff --git a/src/pkg/interactive/prompt.go b/src/pkg/interactive/prompt.go index 759f520948..c22b05e449 100644 --- a/src/pkg/interactive/prompt.go +++ b/src/pkg/interactive/prompt.go @@ -24,7 +24,6 @@ func PromptSigPassword() ([]byte, error) { // PromptVariable prompts the user for a value for a variable func PromptVariable(variable variables.InteractiveVariable) (value string, err error) { - if variable.Description != "" { message.Question(variable.Description) } diff --git a/src/pkg/message/credentials.go b/src/pkg/message/credentials.go index 74b127a1c6..34134e6484 100644 --- a/src/pkg/message/credentials.go +++ b/src/pkg/message/credentials.go @@ -91,7 +91,6 @@ func PrintCredentialUpdates(oldState *types.ZarfState, newState *types.ZarfState } for _, service := range services { - HorizontalRule() switch service { diff --git a/src/pkg/packager/actions/actions.go b/src/pkg/packager/actions/actions.go index c92457675c..541c73b0fe 100644 --- a/src/pkg/packager/actions/actions.go +++ b/src/pkg/packager/actions/actions.go @@ -97,7 +97,6 @@ func runAction(defaultCfg types.ZarfComponentActionDefaults, action types.ZarfCo // Keep trying until the max retries is reached. retryCmd: for remaining := actionDefaults.MaxRetries + 1; remaining > 0; remaining-- { - // Perform the action run. tryCmd := func(ctx context.Context) error { // Try running the command and continue the retry loop if it fails. diff --git a/src/pkg/packager/common.go b/src/pkg/packager/common.go index d790275d12..a5b77ff9d1 100644 --- a/src/pkg/packager/common.go +++ b/src/pkg/packager/common.go @@ -170,7 +170,6 @@ func (p *Packager) hasImages() bool { // attemptClusterChecks attempts to connect to the cluster and check for useful metadata and config mismatches. // NOTE: attemptClusterChecks should only return an error if there is a problem significant enough to halt a deployment, otherwise it should return nil and print a warning message. func (p *Packager) attemptClusterChecks(ctx context.Context) (err error) { - spinner := message.NewProgressSpinner("Gathering additional cluster information (if available)") defer spinner.Stop() diff --git a/src/pkg/packager/composer/oci.go b/src/pkg/packager/composer/oci.go index 129013d487..2541e45f32 100644 --- a/src/pkg/packager/composer/oci.go +++ b/src/pkg/packager/composer/oci.go @@ -104,7 +104,6 @@ func (ic *ImportChain) fetchOCISkeleton(ctx context.Context) error { if err != nil { return err } - } } diff --git a/src/pkg/packager/creator/skeleton.go b/src/pkg/packager/creator/skeleton.go index 091874c84f..3c95623542 100644 --- a/src/pkg/packager/creator/skeleton.go +++ b/src/pkg/packager/creator/skeleton.go @@ -182,7 +182,6 @@ func (sc *SkeletonCreator) addComponent(component types.ZarfComponent, dst *layo // If any helm charts are defined, process them. for chartIdx, chart := range component.Charts { - if chart.LocalPath != "" { rel := filepath.Join(layout.ChartsDir, fmt.Sprintf("%s-%d", chart.Name, chartIdx)) dst := filepath.Join(componentPaths.Base, rel) diff --git a/src/pkg/packager/deploy.go b/src/pkg/packager/deploy.go index 73aec8f006..735a0b69db 100644 --- a/src/pkg/packager/deploy.go +++ b/src/pkg/packager/deploy.go @@ -142,7 +142,6 @@ func (p *Packager) deployComponents(ctx context.Context) (deployedComponents []t // Process all the components we are deploying for _, component := range p.cfg.Pkg.Components { - deployedComponent := types.DeployedComponent{ Name: component.Name, Status: types.ComponentStatusDeploying, @@ -716,7 +715,6 @@ func (p *Packager) installChartAndManifests(ctx context.Context, componentPaths } func (p *Packager) printTablesForDeployment(ctx context.Context, componentsToDeploy []types.DeployedComponent) { - // If not init config, print the application connection table if !p.cfg.Pkg.IsInitConfig() { message.PrintConnectStringTable(p.connectStrings) diff --git a/src/pkg/packager/filters/deploy_test.go b/src/pkg/packager/filters/deploy_test.go index 5b31a2269e..7c69007223 100644 --- a/src/pkg/packager/filters/deploy_test.go +++ b/src/pkg/packager/filters/deploy_test.go @@ -111,7 +111,6 @@ func componentMatrix(_ *testing.T) []types.ZarfComponent { } func TestDeployFilter_Apply(t *testing.T) { - possibilities := componentMatrix(t) tests := map[string]struct { diff --git a/src/pkg/packager/filters/os_test.go b/src/pkg/packager/filters/os_test.go index 4dcc4b5279..98c5678c96 100644 --- a/src/pkg/packager/filters/os_test.go +++ b/src/pkg/packager/filters/os_test.go @@ -12,7 +12,6 @@ import ( ) func TestLocalOSFilter(t *testing.T) { - pkg := types.ZarfPackage{} for _, os := range types.SupportedOS() { pkg.Components = append(pkg.Components, types.ZarfComponent{ diff --git a/src/pkg/packager/prepare.go b/src/pkg/packager/prepare.go index 2b888c3966..ea883d6970 100644 --- a/src/pkg/packager/prepare.go +++ b/src/pkg/packager/prepare.go @@ -118,7 +118,6 @@ func (p *Packager) findImages(ctx context.Context) (imgMap map[string][]string, } for _, component := range p.cfg.Pkg.Components { - if len(component.Charts)+len(component.Manifests)+len(component.Repos) < 1 { // Skip if it doesn't have what we need continue @@ -163,7 +162,6 @@ func (p *Packager) findImages(ctx context.Context) (imgMap map[string][]string, } for _, chart := range component.Charts { - helmCfg := helm.New( chart, componentPaths.Charts, diff --git a/src/pkg/utils/bytes.go b/src/pkg/utils/bytes.go index 032cc65334..7dd159b91f 100644 --- a/src/pkg/utils/bytes.go +++ b/src/pkg/utils/bytes.go @@ -60,7 +60,6 @@ func ByteFormat(inputNum float64, precision int) string { // RenderProgressBarForLocalDirWrite creates a progress bar that continuously tracks the progress of writing files to a local directory and all of its subdirectories. // NOTE: This function runs infinitely until either completeChan or errChan is triggered, this function should be run in a goroutine while a different thread/process is writing to the directory. func RenderProgressBarForLocalDirWrite(filepath string, expectedTotal int64, completeChan chan error, updateText string, successText string) { - // Create a progress bar title := fmt.Sprintf("%s (%s of %s)", updateText, ByteFormat(float64(0), 2), ByteFormat(float64(expectedTotal), 2)) progressBar := message.NewProgressBar(expectedTotal, title) diff --git a/src/pkg/utils/image.go b/src/pkg/utils/image.go index 828fea84ad..3756a759e1 100644 --- a/src/pkg/utils/image.go +++ b/src/pkg/utils/image.go @@ -35,7 +35,6 @@ func LoadOCIImage(imgPath string, refInfo transform.Image) (v1.Image, error) { if manifest.Annotations[ocispec.AnnotationBaseImageName] == refInfo.Reference || // A backwards compatibility shim for older Zarf versions that would leave docker.io off of image annotations (manifest.Annotations[ocispec.AnnotationBaseImageName] == refInfo.Path+refInfo.TagOrDigest && refInfo.Host == "docker.io") { - // This is the image we are looking for, load it and then return return layoutPath.Image(manifest.Digest) } diff --git a/src/pkg/utils/wait.go b/src/pkg/utils/wait.go index fd2d7f1422..a6727d9e35 100644 --- a/src/pkg/utils/wait.go +++ b/src/pkg/utils/wait.go @@ -153,10 +153,8 @@ func waitForNetworkEndpoint(resource, name, condition string, timeout time.Durat select { case <-expired: return errors.New("wait timed out") - default: switch resource { - case "http", "https": // Handle HTTP and HTTPS endpoints. url := fmt.Sprintf("%s://%s", resource, name) @@ -191,7 +189,6 @@ func waitForNetworkEndpoint(resource, name, condition string, timeout time.Durat message.Debug(err) continue } - default: // Fallback to any generic protocol using net.Dial conn, err := net.Dial(resource, name) diff --git a/src/pkg/zoci/copier.go b/src/pkg/zoci/copier.go index 74c8636a74..f1564bfaed 100644 --- a/src/pkg/zoci/copier.go +++ b/src/pkg/zoci/copier.go @@ -17,7 +17,6 @@ import ( // CopyPackage copies a zarf package from one OCI registry to another func CopyPackage(ctx context.Context, src *Remote, dst *Remote, concurrency int) error { - srcManifest, err := src.FetchRoot(ctx) if err != nil { return err diff --git a/src/test/e2e/02_component_actions_test.go b/src/test/e2e/02_component_actions_test.go index 94f9d997db..8ef710ee90 100644 --- a/src/test/e2e/02_component_actions_test.go +++ b/src/test/e2e/02_component_actions_test.go @@ -88,7 +88,6 @@ func TestComponentActions(t *testing.T) { stdOut, stdErr, err = e2e.Zarf(t, "package", "deploy", path, "--components=on-deploy-with-variable", "--confirm") require.NoError(t, err, stdOut, stdErr) require.Contains(t, stdErr, "the dog says ruff") - }) t.Run("action on-deploy-with-dynamic-variable", func(t *testing.T) { @@ -100,7 +99,6 @@ func TestComponentActions(t *testing.T) { require.Contains(t, stdErr, "the dog says ruff") require.Contains(t, stdErr, "the snake says hiss") require.Contains(t, stdErr, "with a TF_VAR, the snake also says hiss") - }) t.Run("action on-deploy-with-env-var", func(t *testing.T) { diff --git a/src/test/e2e/12_lint_test.go b/src/test/e2e/12_lint_test.go index 6b7239a17a..58e19536ce 100644 --- a/src/test/e2e/12_lint_test.go +++ b/src/test/e2e/12_lint_test.go @@ -55,7 +55,5 @@ func TestLint(t *testing.T) { // Check reported filepaths require.Contains(t, strippedStderr, "Linting package \"dos-games\" at oci://🦄/dos-games:1.0.0") require.Contains(t, strippedStderr, fmt.Sprintf("Linting package \"lint\" at %s", testPackagePath)) - }) - } diff --git a/src/test/e2e/13_find_images_test.go b/src/test/e2e/13_find_images_test.go index a161ed15f6..474aa27eb8 100644 --- a/src/test/e2e/13_find_images_test.go +++ b/src/test/e2e/13_find_images_test.go @@ -85,7 +85,5 @@ func TestFindImages(t *testing.T) { require.Contains(t, stdOut, "component: httpd-local") require.Contains(t, stdOut, "manifest: simple-httpd-deployment") require.Contains(t, stdOut, "image: httpd:alpine3.18") - }) - } diff --git a/src/test/e2e/14_create_sha_index_test.go b/src/test/e2e/14_create_sha_index_test.go index eb2849975a..40b198738b 100644 --- a/src/test/e2e/14_create_sha_index_test.go +++ b/src/test/e2e/14_create_sha_index_test.go @@ -37,5 +37,4 @@ func TestCreateIndexShaErrors(t *testing.T) { require.Contains(t, stderr, tc.expectedImageInStderr) }) } - } diff --git a/src/test/e2e/50_oci_publish_deploy_test.go b/src/test/e2e/50_oci_publish_deploy_test.go index f72fbb28b5..905a5f7ed7 100644 --- a/src/test/e2e/50_oci_publish_deploy_test.go +++ b/src/test/e2e/50_oci_publish_deploy_test.go @@ -164,6 +164,5 @@ func (suite *PublishDeploySuiteTestSuite) Test_3_Copy() { } func TestPublishDeploySuite(t *testing.T) { - suite.Run(t, new(PublishDeploySuiteTestSuite)) } diff --git a/src/test/e2e/51_oci_compose_test.go b/src/test/e2e/51_oci_compose_test.go index 0d98d13c8b..034fc0e15a 100644 --- a/src/test/e2e/51_oci_compose_test.go +++ b/src/test/e2e/51_oci_compose_test.go @@ -185,7 +185,6 @@ func (suite *SkeletonSuite) DirOrFileExists(path string) { } func (suite *SkeletonSuite) verifyComponentPaths(unpackedPath string, components []types.ZarfComponent, isSkeleton bool) { - if isSkeleton { suite.NoDirExists(filepath.Join(unpackedPath, "images")) suite.NoDirExists(filepath.Join(unpackedPath, "sboms")) @@ -280,10 +279,8 @@ func (suite *SkeletonSuite) verifyComponentPaths(unpackedPath string, components } } } - } func TestSkeletonSuite(t *testing.T) { - suite.Run(t, new(SkeletonSuite)) } diff --git a/src/test/external/ext_out_cluster_test.go b/src/test/external/ext_out_cluster_test.go index dfcc9da580..86f2ef0edd 100644 --- a/src/test/external/ext_out_cluster_test.go +++ b/src/test/external/ext_out_cluster_test.go @@ -54,7 +54,6 @@ type ExtOutClusterTestSuite struct { } func (suite *ExtOutClusterTestSuite) SetupSuite() { - suite.Assertions = require.New(suite.T()) // Teardown any leftovers from previous tests diff --git a/src/types/validate.go b/src/types/validate.go index 4d39d36b23..63ee4584d9 100644 --- a/src/types/validate.go +++ b/src/types/validate.go @@ -241,7 +241,6 @@ func (as ZarfComponentActionSet) Validate() error { if actionErr := action.Validate(); actionErr != nil { err = errors.Join(err, fmt.Errorf(lang.PkgValidateErrAction, actionErr)) } - } }