Skip to content

Commit

Permalink
fix: add whitespace linter and fix all warnings (#2764)
Browse files Browse the repository at this point in the history
Signed-off-by: Philip Laine <[email protected]>
  • Loading branch information
phillebaba authored Jul 25, 2024
1 parent 1c8e55f commit 5f91e88
Show file tree
Hide file tree
Showing 32 changed files with 1 addition and 41 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
1 change: 0 additions & 1 deletion src/cmd/tools/yq.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
)

func init() {

yqCmd := yq.New()
yqCmd.Example = lang.CmdToolsYqExample
yqCmd.Use = "yq"
Expand Down
1 change: 0 additions & 1 deletion src/extensions/bigbang/flux.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ func readFluxImages(localPath string) (images []string, err error) {
for _, container := range pod.Containers {
images = append(images, container.Image)
}

}
}

Expand Down
1 change: 0 additions & 1 deletion src/internal/agent/hooks/flux-gitrepo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/internal/agent/hooks/flux-helmrepo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion src/internal/agent/hooks/flux-ocirepo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion src/internal/packager/git/gitea.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 0 additions & 2 deletions src/internal/packager/helm/post-render.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/internal/packager/helm/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion src/pkg/cluster/zarf.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, ""
Expand Down
1 change: 0 additions & 1 deletion src/pkg/interactive/prompt.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
1 change: 0 additions & 1 deletion src/pkg/message/credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ func PrintCredentialUpdates(oldState *types.ZarfState, newState *types.ZarfState
}

for _, service := range services {

HorizontalRule()

switch service {
Expand Down
1 change: 0 additions & 1 deletion src/pkg/packager/actions/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion src/pkg/packager/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
1 change: 0 additions & 1 deletion src/pkg/packager/composer/oci.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ func (ic *ImportChain) fetchOCISkeleton(ctx context.Context) error {
if err != nil {
return err
}

}
}

Expand Down
1 change: 0 additions & 1 deletion src/pkg/packager/creator/skeleton.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions src/pkg/packager/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion src/pkg/packager/filters/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ func componentMatrix(_ *testing.T) []types.ZarfComponent {
}

func TestDeployFilter_Apply(t *testing.T) {

possibilities := componentMatrix(t)

tests := map[string]struct {
Expand Down
1 change: 0 additions & 1 deletion src/pkg/packager/filters/os_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
2 changes: 0 additions & 2 deletions src/pkg/packager/prepare.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion src/pkg/utils/bytes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion src/pkg/utils/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
3 changes: 0 additions & 3 deletions src/pkg/utils/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion src/pkg/zoci/copier.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions src/test/e2e/02_component_actions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
2 changes: 0 additions & 2 deletions src/test/e2e/12_lint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))

})

}
2 changes: 0 additions & 2 deletions src/test/e2e/13_find_images_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

})

}
1 change: 0 additions & 1 deletion src/test/e2e/14_create_sha_index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,4 @@ func TestCreateIndexShaErrors(t *testing.T) {
require.Contains(t, stderr, tc.expectedImageInStderr)
})
}

}
1 change: 0 additions & 1 deletion src/test/e2e/50_oci_publish_deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,5 @@ func (suite *PublishDeploySuiteTestSuite) Test_3_Copy() {
}

func TestPublishDeploySuite(t *testing.T) {

suite.Run(t, new(PublishDeploySuiteTestSuite))
}
3 changes: 0 additions & 3 deletions src/test/e2e/51_oci_compose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down Expand Up @@ -280,10 +279,8 @@ func (suite *SkeletonSuite) verifyComponentPaths(unpackedPath string, components
}
}
}

}

func TestSkeletonSuite(t *testing.T) {

suite.Run(t, new(SkeletonSuite))
}
1 change: 0 additions & 1 deletion src/test/external/ext_out_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ type ExtOutClusterTestSuite struct {
}

func (suite *ExtOutClusterTestSuite) SetupSuite() {

suite.Assertions = require.New(suite.T())

// Teardown any leftovers from previous tests
Expand Down
1 change: 0 additions & 1 deletion src/types/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ func (as ZarfComponentActionSet) Validate() error {
if actionErr := action.Validate(); actionErr != nil {
err = errors.Join(err, fmt.Errorf(lang.PkgValidateErrAction, actionErr))
}

}
}

Expand Down

0 comments on commit 5f91e88

Please sign in to comment.