From 034396956e7dd1074bf48146a39fb051a68f16ca Mon Sep 17 00:00:00 2001 From: Ilya Lesikov Date: Thu, 16 Jun 2022 14:37:24 +0300 Subject: [PATCH] chore: fix and update linters/formatters Signed-off-by: Ilya Lesikov --- .golangci.yaml | 10 +++++++- Makefile | 4 ++-- cmd/werf/common/templates/templater.go | 2 +- cmd/werf/export/export.go | 2 +- cmd/werf/kube_run/kube_run.go | 10 ++++---- cmd/werf/main.go | 3 +-- .../build/stapel_image/git/stages_test.go | 6 ++--- integration/suites/cleanup/suite_test.go | 2 +- integration/suites/giterminism/common_test.go | 6 ++--- pkg/build/build_phase.go | 13 +++++----- pkg/build/builder/ansible_assets.go | 2 +- pkg/build/conveyor.go | 3 +-- pkg/build/import_server/rsync_server.go | 2 +- pkg/build/stage/dockerfile.go | 8 +++---- pkg/build/stage/interface.go | 2 +- pkg/buildah/common.go | 2 +- pkg/buildah/docker_with_fuse.go | 4 ++-- pkg/buildah/native_linux.go | 2 +- .../reference_to_scan.go | 6 ++--- pkg/cleaning/stage_manager/manager.go | 4 ++-- pkg/config/common.go | 2 +- pkg/config/deploy_params/deploy_params.go | 6 ++--- pkg/config/parser.go | 6 ++--- pkg/config/raw_docker.go | 2 +- pkg/config/raw_stapel_image.go | 2 +- .../build_stapel_stage_options.go | 4 ++-- pkg/container_backend/buildah_backend.go | 10 ++++---- pkg/context_manager/context_manager.go | 6 ++--- pkg/deploy/bundles/pull.go | 2 +- pkg/deploy/bundles/registry/cache.go | 2 +- pkg/deploy/bundles/registry/client.go | 2 +- .../chart_extender/helpers/service_values.go | 2 +- .../helm/external_deps_annotations_parser.go | 6 ++--- pkg/deploy/helm/gvk_builder.go | 1 - pkg/docker_registry/docker_registry.go | 4 ++-- pkg/docker_registry/github_packages_api.go | 2 +- pkg/git_repo/base.go | 24 +++++++++---------- pkg/git_repo/git_repo.go | 14 +++++------ pkg/giterminism_manager/file_reader/errors.go | 2 +- pkg/giterminism_manager/file_reader/git.go | 4 ++-- pkg/image/info_getter.go | 2 +- pkg/image/info_getter_test.go | 2 +- pkg/path_matcher/common.go | 4 ++-- pkg/slug/slug.go | 2 +- pkg/storage/manager/storage_manager.go | 2 +- pkg/storage/repo_stages_storage.go | 2 +- pkg/true_git/ls_tree/result.go | 2 +- pkg/true_git/merge_base.go | 2 +- pkg/true_git/service_branch.go | 12 +++++----- pkg/true_git/work_tree.go | 6 ++--- pkg/util/archive.go | 2 +- pkg/util/parallel/parallel.go | 4 ++-- test/e2e/build/images_dependencies_test.go | 4 ++-- .../suite_init/k8s_docker_registry_data.go | 2 +- test/pkg/utils/docker/container_command.go | 4 ++-- test/pkg/utils/git.go | 2 +- test/pkg/utils/storage.go | 2 +- 57 files changed, 128 insertions(+), 124 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index 7bfa4205a9..44585964f8 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -2,10 +2,18 @@ run: timeout: 10m skip-dirs: - playground + - docs + - scripts + - stapel linters-settings: + gofumpt: + extra-rules: true gci: - local-prefixes: github.com/werf/ + sections: + - standard + - default + - prefix(github.com/werf/) gocritic: disabled-checks: - ifElseChain diff --git a/Makefile b/Makefile index ded1b558c9..6be0b9df7a 100644 --- a/Makefile +++ b/Makefile @@ -41,8 +41,8 @@ unit-tests: CGO_ENABLED=1 go test -v -compiler gc -ldflags="-linkmode external -extldflags=-static" -tags="dfrunmount dfssh containers_image_openpgp osusergo exclude_graphdriver_devicemapper netgo no_devmapper static_build" github.com/werf/werf/pkg/... fmt: - gci -w -local github.com/werf/ pkg/ cmd/ test/ - gofumpt -w cmd/ pkg/ test/ integration/ + gci write -s Standard -s Default -s 'Prefix(github.com/werf)' pkg/ cmd/ test/ integration/ + gofumpt -extra -w cmd/ pkg/ test/ integration/ lint: golangci-lint run ./... --build-tags="dfrunmount dfssh containers_image_openpgp osusergo exclude_graphdriver_devicemapper netgo no_devmapper static_build" diff --git a/cmd/werf/common/templates/templater.go b/cmd/werf/common/templates/templater.go index 5d5bd28f8d..ee01b8bd82 100644 --- a/cmd/werf/common/templates/templater.go +++ b/cmd/werf/common/templates/templater.go @@ -250,7 +250,7 @@ func appendIfNotPresent(s, stringToAppend string) string { return s + " " + stringToAppend } -func flagsNotIntersected(l *flag.FlagSet, r *flag.FlagSet) *flag.FlagSet { +func flagsNotIntersected(l, r *flag.FlagSet) *flag.FlagSet { f := flag.NewFlagSet("notIntersected", flag.ContinueOnError) l.VisitAll(func(flag *flag.Flag) { if r.Lookup(flag.Name) == nil { diff --git a/cmd/werf/export/export.go b/cmd/werf/export/export.go index 2ad60e1fdc..595cd2360c 100644 --- a/cmd/werf/export/export.go +++ b/cmd/werf/export/export.go @@ -270,7 +270,7 @@ func getExportTagFunc(tmpl *template.Template, templateName string, imageNameLis tagOrFormat := buf.String() var tagFunc image.ExportTagFunc - tagFunc = func(imageName string, contentBasedTag string) string { + tagFunc = func(imageName, contentBasedTag string) string { if strings.ContainsRune(tagOrFormat, '%') { return fmt.Sprintf(tagOrFormat, imageName, slug.Slug(imageName), slug.DockerTag(imageName), contentBasedTag) } else { diff --git a/cmd/werf/kube_run/kube_run.go b/cmd/werf/kube_run/kube_run.go index a12ad6b9a8..f47274ba87 100644 --- a/cmd/werf/kube_run/kube_run.go +++ b/cmd/werf/kube_run/kube_run.go @@ -510,7 +510,7 @@ func createPod(ctx context.Context, namespace, pod, image, secret string, extraA return nil } -func createKubectlRunArgs(pod string, image string, secret string, extraArgs []string) ([]string, error) { +func createKubectlRunArgs(pod, image, secret string, extraArgs []string) ([]string, error) { args := []string{ "run", pod, @@ -639,7 +639,7 @@ func waitPodReadiness(ctx context.Context, namespace, pod string, extraArgs []st } } -func getPodPhase(namespace string, pod string, extraArgs []string) (corev1.PodPhase, error) { +func getPodPhase(namespace, pod string, extraArgs []string) (corev1.PodPhase, error) { args := []string{ "get", "pod", "--template", "{{.status.phase}}", pod, } @@ -658,7 +658,7 @@ func getPodPhase(namespace string, pod string, extraArgs []string) (corev1.PodPh return corev1.PodPhase(strings.TrimSpace(stdout.String())), nil } -func isPodReady(namespace string, pod string, extraArgs []string) (bool, error) { +func isPodReady(namespace, pod string, extraArgs []string) (bool, error) { args := []string{ "get", "pod", "--template", "{{range .status.conditions}}{{if eq .type \"Ready\"}}{{.status}}{{end}}{{end}}", pod, } @@ -907,7 +907,7 @@ func isNamespaceExist(ctx context.Context, namespace string) (bool, error) { return false, nil } -func isPodExist(ctx context.Context, pod string, namespace string) (bool, error) { +func isPodExist(ctx context.Context, pod, namespace string) (bool, error) { if matchedPods, err := kube.Client.CoreV1().Pods(namespace).List(ctx, v1.ListOptions{ FieldSelector: fields.OneTermEqualSelector("metadata.name", pod).String(), }); err != nil { @@ -919,7 +919,7 @@ func isPodExist(ctx context.Context, pod string, namespace string) (bool, error) return false, nil } -func isSecretExist(ctx context.Context, secret string, namespace string) (bool, error) { +func isSecretExist(ctx context.Context, secret, namespace string) (bool, error) { if matchedSecrets, err := kube.Client.CoreV1().Secrets(namespace).List(ctx, v1.ListOptions{ FieldSelector: fields.OneTermEqualSelector("metadata.name", secret).String(), }); err != nil { diff --git a/cmd/werf/main.go b/cmd/werf/main.go index 2082649168..f0c72a87d9 100644 --- a/cmd/werf/main.go +++ b/cmd/werf/main.go @@ -6,10 +6,9 @@ import ( "os" "path/filepath" - helm_v3 "helm.sh/helm/v3/cmd/helm" - "github.com/sirupsen/logrus" "github.com/spf13/cobra" + helm_v3 "helm.sh/helm/v3/cmd/helm" "github.com/werf/logboek" "github.com/werf/werf/cmd/werf/build" diff --git a/integration/suites/build/stapel_image/git/stages_test.go b/integration/suites/build/stapel_image/git/stages_test.go index 0bf6f59077..81454d7544 100644 --- a/integration/suites/build/stapel_image/git/stages_test.go +++ b/integration/suites/build/stapel_image/git/stages_test.go @@ -547,7 +547,7 @@ func checkResultedFilesChecksum() { ) } -func createAndCommitFile(dirPath string, filename string, contentSize int) { +func createAndCommitFile(dirPath, filename string, contentSize int) { newFilePath := filepath.Join(dirPath, filename) newFileData := []byte(utils.GetRandomString(contentSize)) utils.WriteFile(newFilePath, newFileData) @@ -555,7 +555,7 @@ func createAndCommitFile(dirPath string, filename string, contentSize int) { addAndCommitFile(dirPath, filename, "Add file "+filename) } -func addFile(dirPath string, filename string) { +func addFile(dirPath, filename string) { utils.RunSucceedCommand( dirPath, "git", @@ -563,7 +563,7 @@ func addFile(dirPath string, filename string) { ) } -func addAndCommitFile(dirPath string, filename string, commitMsg string) { +func addAndCommitFile(dirPath, filename, commitMsg string) { addFile(dirPath, filename) utils.RunSucceedCommand( diff --git a/integration/suites/cleanup/suite_test.go b/integration/suites/cleanup/suite_test.go index 1d2bed4499..c579646d3f 100644 --- a/integration/suites/cleanup/suite_test.go +++ b/integration/suites/cleanup/suite_test.go @@ -61,7 +61,7 @@ func perImplementationBeforeEach(implementationName string) func() { } } -func InitStagesStorage(stagesStorageAddress string, implementationName string, dockerRegistryOptions docker_registry.DockerRegistryOptions) { +func InitStagesStorage(stagesStorageAddress, implementationName string, dockerRegistryOptions docker_registry.DockerRegistryOptions) { SuiteData.StagesStorage = utils.NewStagesStorage(stagesStorageAddress, implementationName, dockerRegistryOptions) } diff --git a/integration/suites/giterminism/common_test.go b/integration/suites/giterminism/common_test.go index 025876ea17..030b700649 100644 --- a/integration/suites/giterminism/common_test.go +++ b/integration/suites/giterminism/common_test.go @@ -60,7 +60,7 @@ func fileCreateOrAppend(relPath, content string) { Ω(f.Close()).ShouldNot(HaveOccurred()) } -func symlinkFileCreateOrModify(relPath string, link string) { +func symlinkFileCreateOrModify(relPath, link string) { relPath = filepath.ToSlash(relPath) link = filepath.ToSlash(link) @@ -73,7 +73,7 @@ func symlinkFileCreateOrModify(relPath string, link string) { ) } -func symlinkFileCreateOrModifyAndAdd(relPath string, link string) { +func symlinkFileCreateOrModifyAndAdd(relPath, link string) { relPath = filepath.ToSlash(relPath) link = filepath.ToSlash(link) @@ -100,7 +100,7 @@ func symlinkFileCreateOrModifyAndAdd(relPath string, link string) { ) } -func getLinkTo(linkFile string, targetPath string) string { +func getLinkTo(linkFile, targetPath string) string { target, err := filepath.Rel(filepath.Dir(linkFile), targetPath) if err != nil { panic(err) diff --git a/pkg/build/build_phase.go b/pkg/build/build_phase.go index ded1129766..b37acf4617 100644 --- a/pkg/build/build_phase.go +++ b/pkg/build/build_phase.go @@ -22,7 +22,6 @@ import ( "github.com/werf/werf/pkg/container_backend" "github.com/werf/werf/pkg/docker_registry" "github.com/werf/werf/pkg/git_repo" - "github.com/werf/werf/pkg/image" imagePkg "github.com/werf/werf/pkg/image" "github.com/werf/werf/pkg/stapel" "github.com/werf/werf/pkg/storage" @@ -44,7 +43,7 @@ type BuildOptions struct { ReportFormat ReportFormat SkipImageMetadataPublication bool - CustomTagFuncList []image.CustomTagFunc + CustomTagFuncList []imagePkg.CustomTagFunc } type IntrospectOptions struct { @@ -249,7 +248,7 @@ func (phase *BuildPhase) AfterImageStages(ctx context.Context, img *Image) error } var customTagStorage storage.StagesStorage - var customTagStage *image.StageDescription + var customTagStage *imagePkg.StageDescription if phase.Conveyor.StorageManager.GetFinalStagesStorage() != nil { customTagStorage = phase.Conveyor.StorageManager.GetFinalStagesStorage() customTagStage = manager.ConvertStageDescriptionForStagesStorage(img.GetLastNonEmptyStage().GetStageImage().Image.GetStageDescription(), phase.Conveyor.StorageManager.GetFinalStagesStorage()) @@ -326,11 +325,11 @@ func (phase *BuildPhase) publishImageMetadata(ctx context.Context, img *Image) e }) } -func (phase *BuildPhase) addCustomImageTagsToStagesStorage(ctx context.Context, imageName string, stageDesc *image.StageDescription, stagesStorage storage.StagesStorage) error { +func (phase *BuildPhase) addCustomImageTagsToStagesStorage(ctx context.Context, imageName string, stageDesc *imagePkg.StageDescription, stagesStorage storage.StagesStorage) error { return addCustomImageTags(ctx, stagesStorage, imageName, stageDesc, phase.CustomTagFuncList) } -func addCustomImageTags(ctx context.Context, stagesStorage storage.StagesStorage, imageName string, stageDesc *image.StageDescription, customTagFuncList []image.CustomTagFunc) error { +func addCustomImageTags(ctx context.Context, stagesStorage storage.StagesStorage, imageName string, stageDesc *imagePkg.StageDescription, customTagFuncList []imagePkg.CustomTagFunc) error { if len(customTagFuncList) == 0 { return nil } @@ -351,7 +350,7 @@ func addCustomImageTags(ctx context.Context, stagesStorage storage.StagesStorage }) } -func addCustomImageTag(ctx context.Context, stagesStorage storage.StagesStorage, stageDesc *image.StageDescription, tag string) error { +func addCustomImageTag(ctx context.Context, stagesStorage storage.StagesStorage, stageDesc *imagePkg.StageDescription, tag string) error { return logboek.Context(ctx).Default().LogProcess("tag %s", tag). DoError(func() error { if err := stagesStorage.AddStageCustomTag(ctx, stageDesc, tag); err != nil { @@ -364,7 +363,7 @@ func addCustomImageTag(ctx context.Context, stagesStorage storage.StagesStorage, }) } -func (phase *BuildPhase) checkCustomImageTagsExistence(ctx context.Context, imageName string, stageDesc *image.StageDescription, stagesStorage storage.StagesStorage) error { +func (phase *BuildPhase) checkCustomImageTagsExistence(ctx context.Context, imageName string, stageDesc *imagePkg.StageDescription, stagesStorage storage.StagesStorage) error { if len(phase.CustomTagFuncList) == 0 { return nil } diff --git a/pkg/build/builder/ansible_assets.go b/pkg/build/builder/ansible_assets.go index b9d577ddf0..2bc6fa4035 100644 --- a/pkg/build/builder/ansible_assets.go +++ b/pkg/build/builder/ansible_assets.go @@ -214,6 +214,6 @@ func mkdirP(path string) error { return os.MkdirAll(path, os.FileMode(0o775)) } -func writeFile(path string, content string) error { +func writeFile(path, content string) error { return ioutil.WriteFile(path, []byte(content), os.FileMode(0o664)) } diff --git a/pkg/build/conveyor.go b/pkg/build/conveyor.go index b4873a1d96..086e4600b0 100644 --- a/pkg/build/conveyor.go +++ b/pkg/build/conveyor.go @@ -27,7 +27,6 @@ import ( "github.com/werf/werf/pkg/container_backend" "github.com/werf/werf/pkg/git_repo" "github.com/werf/werf/pkg/giterminism_manager" - "github.com/werf/werf/pkg/image" imagePkg "github.com/werf/werf/pkg/image" "github.com/werf/werf/pkg/logging" "github.com/werf/werf/pkg/path_matcher" @@ -308,7 +307,7 @@ func (c *Conveyor) GetRemoteGitRepo(key string) *git_repo.Remote { } type ShouldBeBuiltOptions struct { - CustomTagFuncList []image.CustomTagFunc + CustomTagFuncList []imagePkg.CustomTagFunc } func (c *Conveyor) ShouldBeBuilt(ctx context.Context, opts ShouldBeBuiltOptions) error { diff --git a/pkg/build/import_server/rsync_server.go b/pkg/build/import_server/rsync_server.go index c70249cbe7..ba32d14a97 100644 --- a/pkg/build/import_server/rsync_server.go +++ b/pkg/build/import_server/rsync_server.go @@ -28,7 +28,7 @@ type RsyncServer struct { AuthUser, AuthPassword string } -func RunRsyncServer(ctx context.Context, dockerImageName string, tmpDir string) (*RsyncServer, error) { +func RunRsyncServer(ctx context.Context, dockerImageName, tmpDir string) (*RsyncServer, error) { logboek.Context(ctx).Debug().LogF("RunRsyncServer for docker image %q\n", dockerImageName) srv := &RsyncServer{ diff --git a/pkg/build/stage/dockerfile.go b/pkg/build/stage/dockerfile.go index 0449491388..58b09432ed 100644 --- a/pkg/build/stage/dockerfile.go +++ b/pkg/build/stage/dockerfile.go @@ -147,7 +147,7 @@ func (ds *DockerStages) resolveDockerMetaArgs(resolvedDependenciesArgsHash map[s } // addDockerMetaArg function sets --build-arg value or resolved meta ARG value -func (ds *DockerStages) resolveDockerMetaArg(key, value string, resolvedDockerMetaArgsHash map[string]string, resolvedDependenciesArgsHash map[string]string) (string, string, error) { +func (ds *DockerStages) resolveDockerMetaArg(key, value string, resolvedDockerMetaArgsHash, resolvedDependenciesArgsHash map[string]string) (string, string, error) { resolvedKey, err := ds.ShlexProcessWordWithMetaArgs(key, resolvedDockerMetaArgsHash) if err != nil { return "", "", err @@ -200,7 +200,7 @@ func resolveDependenciesArgsHash(dependencies []*config.Dependency, c Conveyor) } // resolveDockerStageArg function sets dependency arg value, or --build-arg value, or resolved dockerfile stage ARG value, or resolved meta ARG value (if stage ARG value is empty) -func (ds *DockerStages) resolveDockerStageArg(dockerStageID int, key, value string, resolvedDockerMetaArgsHash map[string]string, resolvedDependenciesArgsHash map[string]string) (string, string, error) { +func (ds *DockerStages) resolveDockerStageArg(dockerStageID int, key, value string, resolvedDockerMetaArgsHash, resolvedDependenciesArgsHash map[string]string) (string, string, error) { resolvedKey, err := ds.ShlexProcessWordWithStageArgsAndEnvs(dockerStageID, key) if err != nil { return "", "", err @@ -501,7 +501,7 @@ func (s *DockerfileStage) GetDependencies(ctx context.Context, c Conveyor, _ con return util.Sha256Hash(dockerfileStageDependencies...), nil } -func (s *DockerfileStage) dockerfileInstructionDependencies(ctx context.Context, giterminismManager giterminism_manager.Interface, resolvedDockerMetaArgsHash map[string]string, resolvedDependenciesArgsHash map[string]string, dockerStageID int, cmd interface{}, isOnbuildInstruction bool, isBaseImageOnbuildInstruction bool) ([]string, []string, error) { +func (s *DockerfileStage) dockerfileInstructionDependencies(ctx context.Context, giterminismManager giterminism_manager.Interface, resolvedDockerMetaArgsHash, resolvedDependenciesArgsHash map[string]string, dockerStageID int, cmd interface{}, isOnbuildInstruction, isBaseImageOnbuildInstruction bool) ([]string, []string, error) { var dependencies []string var onBuildDependencies []string @@ -666,7 +666,7 @@ func (s *DockerfileStage) dockerfileInstructionDependencies(ctx context.Context, return dependencies, onBuildDependencies, nil } -func (s *DockerfileStage) dockerfileOnBuildInstructionDependencies(ctx context.Context, giterminismManager giterminism_manager.Interface, resolvedDockerMetaArgsHash map[string]string, resolvedDependenciesArgsHash map[string]string, dockerStageID int, expression string, isBaseImageOnbuildInstruction bool) ([]string, []string, error) { +func (s *DockerfileStage) dockerfileOnBuildInstructionDependencies(ctx context.Context, giterminismManager giterminism_manager.Interface, resolvedDockerMetaArgsHash, resolvedDependenciesArgsHash map[string]string, dockerStageID int, expression string, isBaseImageOnbuildInstruction bool) ([]string, []string, error) { p, err := parser.Parse(bytes.NewReader([]byte(expression))) if err != nil { return nil, nil, err diff --git a/pkg/build/stage/interface.go b/pkg/build/stage/interface.go index a91876c293..96f3771e11 100644 --- a/pkg/build/stage/interface.go +++ b/pkg/build/stage/interface.go @@ -15,7 +15,7 @@ type Interface interface { IsEmpty(ctx context.Context, c Conveyor, prevBuiltImage *StageImage) (bool, error) FetchDependencies(ctx context.Context, c Conveyor, cb container_backend.ContainerBackend, dockerRegistry docker_registry.ApiInterface) error - GetDependencies(ctx context.Context, c Conveyor, cb container_backend.ContainerBackend, prevImage *StageImage, prevBuiltImage *StageImage) (string, error) + GetDependencies(ctx context.Context, c Conveyor, cb container_backend.ContainerBackend, prevImage, prevBuiltImage *StageImage) (string, error) GetNextStageDependencies(ctx context.Context, c Conveyor) (string, error) PrepareImage(ctx context.Context, c Conveyor, cb container_backend.ContainerBackend, prevBuiltImage, stageImage *StageImage) error diff --git a/pkg/buildah/common.go b/pkg/buildah/common.go index 01cdc85bac..c348f72613 100644 --- a/pkg/buildah/common.go +++ b/pkg/buildah/common.go @@ -96,7 +96,7 @@ type Buildah interface { Push(ctx context.Context, ref string, opts PushOpts) error BuildFromDockerfile(ctx context.Context, dockerfile []byte, opts BuildFromDockerfileOpts) (string, error) RunCommand(ctx context.Context, container string, command []string, opts RunCommandOpts) error - FromCommand(ctx context.Context, container string, image string, opts FromCommandOpts) (string, error) + FromCommand(ctx context.Context, container, image string, opts FromCommandOpts) (string, error) Pull(ctx context.Context, ref string, opts PullOpts) error Inspect(ctx context.Context, ref string) (*thirdparty.BuilderInfo, error) Rm(ctx context.Context, ref string, opts RmOpts) error diff --git a/pkg/buildah/docker_with_fuse.go b/pkg/buildah/docker_with_fuse.go index 4fe20ce3ae..2e9cdf4caf 100644 --- a/pkg/buildah/docker_with_fuse.go +++ b/pkg/buildah/docker_with_fuse.go @@ -128,7 +128,7 @@ func (b *DockerWithFuseBuildah) RunCommand(ctx context.Context, container string return err } -func (b *DockerWithFuseBuildah) FromCommand(ctx context.Context, container string, image string, opts FromCommandOpts) (string, error) { +func (b *DockerWithFuseBuildah) FromCommand(ctx context.Context, container, image string, opts FromCommandOpts) (string, error) { container, _, err := b.runBuildah(ctx, []string{}, []string{ "from", fmt.Sprintf("--tls-verify=%s", strconv.FormatBool(!b.Insecure)), "--name", container, "--shm-size", DefaultShmSize, "--signature-policy", b.SignaturePolicyPath, "--quiet", "--isolation", b.Isolation.String(), "--format", "docker", image, @@ -204,7 +204,7 @@ func (b *DockerWithFuseBuildah) Config(ctx context.Context, container string, op return err } -func (b *DockerWithFuseBuildah) runBuildah(ctx context.Context, dockerArgs []string, buildahArgs []string, logWriter io.Writer) (string, string, error) { +func (b *DockerWithFuseBuildah) runBuildah(ctx context.Context, dockerArgs, buildahArgs []string, logWriter io.Writer) (string, string, error) { stdout := &bytes.Buffer{} stderr := &bytes.Buffer{} diff --git a/pkg/buildah/native_linux.go b/pkg/buildah/native_linux.go index 1c67e5dffb..6af11b6c73 100644 --- a/pkg/buildah/native_linux.go +++ b/pkg/buildah/native_linux.go @@ -277,7 +277,7 @@ func (b *NativeBuildah) RunCommand(ctx context.Context, container string, comman return nil } -func (b *NativeBuildah) FromCommand(ctx context.Context, container string, image string, opts FromCommandOpts) (string, error) { +func (b *NativeBuildah) FromCommand(ctx context.Context, container, image string, opts FromCommandOpts) (string, error) { builder, err := buildah.NewBuilder(ctx, b.Store, buildah.BuilderOptions{ FromImage: image, Container: container, diff --git a/pkg/cleaning/git_history_based_cleanup/reference_to_scan.go b/pkg/cleaning/git_history_based_cleanup/reference_to_scan.go index e00ee900e2..f433ae3318 100644 --- a/pkg/cleaning/git_history_based_cleanup/reference_to_scan.go +++ b/pkg/cleaning/git_history_based_cleanup/reference_to_scan.go @@ -306,11 +306,11 @@ func applyImagesPerReference(policyBranchesRefs []*ReferenceToScan, imagesPerRef } } -func referencesOr(refs1 []*ReferenceToScan, refs2 []*ReferenceToScan) []*ReferenceToScan { +func referencesOr(refs1, refs2 []*ReferenceToScan) []*ReferenceToScan { return mergeReferences(refs1, refs2) } -func referencesAnd(refs1 []*ReferenceToScan, refs2 []*ReferenceToScan) []*ReferenceToScan { +func referencesAnd(refs1, refs2 []*ReferenceToScan) []*ReferenceToScan { var result []*ReferenceToScan outerLoop: @@ -352,7 +352,7 @@ func filterReferencesByLast(refs []*ReferenceToScan, last int) []*ReferenceToSca return refs[:last] } -func mergeReferences(refs1 []*ReferenceToScan, refs2 []*ReferenceToScan) []*ReferenceToScan { +func mergeReferences(refs1, refs2 []*ReferenceToScan) []*ReferenceToScan { result := refs2 outerLoop: diff --git a/pkg/cleaning/stage_manager/manager.go b/pkg/cleaning/stage_manager/manager.go index 9b45ca6d6d..41826023a3 100644 --- a/pkg/cleaning/stage_manager/manager.go +++ b/pkg/cleaning/stage_manager/manager.go @@ -45,7 +45,7 @@ type imageMetadata struct { isNonexistentStage bool } -func (m *Manager) getOrCreateImageMetadata(imageName string, stageID string) *imageMetadata { +func (m *Manager) getOrCreateImageMetadata(imageName, stageID string) *imageMetadata { for _, im := range m.imageMetadataList { if im.imageName == imageName && im.stageID == stageID { return im @@ -58,7 +58,7 @@ func (m *Manager) getOrCreateImageMetadata(imageName string, stageID string) *im return im } -func (m *Manager) newImageMetadata(imageName string, stageID string) *imageMetadata { +func (m *Manager) newImageMetadata(imageName, stageID string) *imageMetadata { return &imageMetadata{imageName: imageName, stageID: stageID, isNonexistentStage: !m.IsStageExist(stageID)} } diff --git a/pkg/config/common.go b/pkg/config/common.go index 9a825f1702..80b6386d26 100644 --- a/pkg/config/common.go +++ b/pkg/config/common.go @@ -80,7 +80,7 @@ func oneOrNone(conditions []bool) bool { return true } -func InterfaceToStringArray(stringOrStringArray interface{}, configSection interface{}, doc *doc) ([]string, error) { +func InterfaceToStringArray(stringOrStringArray, configSection interface{}, doc *doc) ([]string, error) { if stringOrStringArray == nil { return []string{}, nil } else if val, ok := stringOrStringArray.(string); ok { diff --git a/pkg/config/deploy_params/deploy_params.go b/pkg/config/deploy_params/deploy_params.go index 82d1db25c1..8c39ae00fb 100644 --- a/pkg/config/deploy_params/deploy_params.go +++ b/pkg/config/deploy_params/deploy_params.go @@ -11,7 +11,7 @@ import ( "github.com/werf/werf/pkg/slug" ) -func GetHelmRelease(releaseOption string, environmentOption string, namespace string, werfConfig *config.WerfConfig) (string, error) { +func GetHelmRelease(releaseOption, environmentOption, namespace string, werfConfig *config.WerfConfig) (string, error) { if releaseOption != "" { err := slug.ValidateHelmRelease(releaseOption) if err != nil { @@ -60,7 +60,7 @@ func GetHelmRelease(releaseOption string, environmentOption string, namespace st return renderedRelease, nil } -func GetKubernetesNamespace(namespaceOption string, environmentOption string, werfConfig *config.WerfConfig) (string, error) { +func GetKubernetesNamespace(namespaceOption, environmentOption string, werfConfig *config.WerfConfig) (string, error) { if namespaceOption != "" { err := slug.ValidateKubernetesNamespace(namespaceOption) if err != nil { @@ -107,7 +107,7 @@ func GetKubernetesNamespace(namespaceOption string, environmentOption string, we return renderedNamespace, nil } -func renderDeployParamTemplate(templateName, templateText string, environmentOption string, extraData map[string]string, werfConfig *config.WerfConfig) (string, error) { +func renderDeployParamTemplate(templateName, templateText, environmentOption string, extraData map[string]string, werfConfig *config.WerfConfig) (string, error) { tmpl := template.New(templateName).Delims("[[", "]]") funcMap := sprig.TxtFuncMap() diff --git a/pkg/config/parser.go b/pkg/config/parser.go index 8f1683f553..82596183a3 100644 --- a/pkg/config/parser.go +++ b/pkg/config/parser.go @@ -141,7 +141,7 @@ func GetDefaultProjectName(ctx context.Context, giterminismManager giterminism_m return slug.Project(name), nil } -func writeWerfConfigRender(werfConfigRenderContent string, werfConfigRenderPath string) error { +func writeWerfConfigRender(werfConfigRenderContent, werfConfigRenderPath string) error { werfConfigRenderFile, err := os.OpenFile(werfConfigRenderPath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0o644) if err != nil { return err @@ -160,7 +160,7 @@ func writeWerfConfigRender(werfConfigRenderContent string, werfConfigRenderPath return nil } -func splitByDocs(werfConfigRenderContent string, werfConfigRenderPath string) ([]*doc, error) { +func splitByDocs(werfConfigRenderContent, werfConfigRenderPath string) ([]*doc, error) { var docs []*doc var line int for _, docContent := range splitContent([]byte(werfConfigRenderContent)) { @@ -253,7 +253,7 @@ func parseWerfConfigTemplatesDir(ctx context.Context, tmpl *template.Template, g }) } -func addTemplate(tmpl *template.Template, templateName string, templateContent string) error { +func addTemplate(tmpl *template.Template, templateName, templateContent string) error { extraTemplate := tmpl.New(templateName) _, err := extraTemplate.Parse(templateContent) return err diff --git a/pkg/config/raw_docker.go b/pkg/config/raw_docker.go index bad837acd5..4d7f780039 100644 --- a/pkg/config/raw_docker.go +++ b/pkg/config/raw_docker.go @@ -86,7 +86,7 @@ func (c *rawDocker) toDirective() (docker *Docker, err error) { return docker, nil } -func prepareCommand(stringOrArray interface{}, configSection interface{}, doc *doc) (cmd string, err error) { +func prepareCommand(stringOrArray, configSection interface{}, doc *doc) (cmd string, err error) { if stringOrArray != nil { if val, ok := stringOrArray.(string); ok { cmd = val diff --git a/pkg/config/raw_stapel_image.go b/pkg/config/raw_stapel_image.go index 925313efd8..c0cf16fdc5 100644 --- a/pkg/config/raw_stapel_image.go +++ b/pkg/config/raw_stapel_image.go @@ -157,7 +157,7 @@ func (c *rawStapelImage) validateStapelImageDirective(image *StapelImage) (err e return nil } -func (c *rawStapelImage) toShellDirectiveByCommandAndStage(command string, stage string) (shell *Shell) { +func (c *rawStapelImage) toShellDirectiveByCommandAndStage(command, stage string) (shell *Shell) { shell = &Shell{} switch stage { case "beforeInstall": diff --git a/pkg/container_backend/build_stapel_stage_options.go b/pkg/container_backend/build_stapel_stage_options.go index 1e01cd1e4a..2187c05ed4 100644 --- a/pkg/container_backend/build_stapel_stage_options.go +++ b/pkg/container_backend/build_stapel_stage_options.go @@ -22,7 +22,7 @@ type BuildStapelStageOptionsInterface interface { AddCommands(commands ...string) BuildStapelStageOptionsInterface AddDataArchive(archive io.ReadCloser, archiveType ArchiveType, to string) BuildStapelStageOptionsInterface - RemoveData(removeType RemoveType, paths []string, keepParentDirs []string) BuildStapelStageOptionsInterface + RemoveData(removeType RemoveType, paths, keepParentDirs []string) BuildStapelStageOptionsInterface AddDependencyImport(imageName, fromPath, toPath string, includePaths, excludePaths []string, owner, group string) BuildStapelStageOptionsInterface } @@ -164,7 +164,7 @@ func (opts *BuildStapelStageOptions) AddDataArchive(archive io.ReadCloser, archi return opts } -func (opts *BuildStapelStageOptions) RemoveData(removeType RemoveType, paths []string, keepParentDirs []string) BuildStapelStageOptionsInterface { +func (opts *BuildStapelStageOptions) RemoveData(removeType RemoveType, paths, keepParentDirs []string) BuildStapelStageOptionsInterface { opts.RemoveDataSpecs = append(opts.RemoveDataSpecs, RemoveDataSpec{ Type: removeType, Paths: paths, diff --git a/pkg/container_backend/buildah_backend.go b/pkg/container_backend/buildah_backend.go index 61a1ecd4c5..a7168a71f3 100644 --- a/pkg/container_backend/buildah_backend.go +++ b/pkg/container_backend/buildah_backend.go @@ -131,7 +131,7 @@ fi `, strings.Join(scriptCommands, "\n"))) } -func (runtime *BuildahBackend) applyCommands(ctx context.Context, container *containerDesc, buildVolumes []string, commands []string) error { +func (runtime *BuildahBackend) applyCommands(ctx context.Context, container *containerDesc, buildVolumes, commands []string) error { hostScriptPath := filepath.Join(runtime.TmpDir, fmt.Sprintf("script-%s.sh", uuid.New().String())) if err := os.WriteFile(hostScriptPath, makeScript(commands), os.FileMode(0o555)); err != nil { return fmt.Errorf("unable to write script file %q: %w", hostScriptPath, err) @@ -685,7 +685,7 @@ func getUIDAndGID(userNameOrUID, groupNameOrGID, fsRoot string) (*uint32, *uint3 } // Returns nil pointer if username/UID is empty string. -func getUID(userNameOrUID string, fsRoot string) (*uint32, error) { +func getUID(userNameOrUID, fsRoot string) (*uint32, error) { var uid *uint32 if userNameOrUID != "" { if parsed, err := strconv.ParseUint(userNameOrUID, 10, 32); errors.Is(err, strconv.ErrSyntax) { @@ -705,7 +705,7 @@ func getUID(userNameOrUID string, fsRoot string) (*uint32, error) { } // Returns nil pointer if groupname/GID is empty string. -func getGID(groupNameOrGID string, fsRoot string) (*uint32, error) { +func getGID(groupNameOrGID, fsRoot string) (*uint32, error) { var gid *uint32 if groupNameOrGID != "" { if parsed, err := strconv.ParseUint(groupNameOrGID, 10, 32); errors.Is(err, strconv.ErrSyntax) { @@ -724,7 +724,7 @@ func getGID(groupNameOrGID string, fsRoot string) (*uint32, error) { return gid, nil } -func getUIDFromUserName(user string, etcPasswdPath string) (uint32, error) { +func getUIDFromUserName(user, etcPasswdPath string) (uint32, error) { passwd, err := os.Open(etcPasswdPath) if err != nil { return 0, fmt.Errorf("error opening passwd file: %w", err) @@ -754,7 +754,7 @@ func getUIDFromUserName(user string, etcPasswdPath string) (uint32, error) { return 0, fmt.Errorf("could not find UID for user %q in passwd file %q", user, etcPasswdPath) } -func getGIDFromGroupName(group string, etcGroupPath string) (uint32, error) { +func getGIDFromGroupName(group, etcGroupPath string) (uint32, error) { etcGroup, err := os.Open(etcGroupPath) if err != nil { return 0, fmt.Errorf("error opening group file: %w", err) diff --git a/pkg/context_manager/context_manager.go b/pkg/context_manager/context_manager.go index 2443998871..a7c48840cb 100644 --- a/pkg/context_manager/context_manager.go +++ b/pkg/context_manager/context_manager.go @@ -25,7 +25,7 @@ func GetTmpArchivePath() string { return filepath.Join(GetTmpDir(), uuid.NewV4().String()) } -func GetContextAddFilesPaths(projectDir string, contextDir string, contextAddFiles []string) ([]string, error) { +func GetContextAddFilesPaths(projectDir, contextDir string, contextAddFiles []string) ([]string, error) { var addFilePaths []string for _, addFile := range contextAddFiles { addFilePath := filepath.Join(projectDir, contextDir, addFile) @@ -56,7 +56,7 @@ func GetContextAddFilesPaths(projectDir string, contextDir string, contextAddFil return util.UniqStrings(addFilePaths), nil } -func ContextAddFilesChecksum(ctx context.Context, projectDir string, contextDir string, contextAddFiles []string, matcher path_matcher.PathMatcher) (string, error) { +func ContextAddFilesChecksum(ctx context.Context, projectDir, contextDir string, contextAddFiles []string, matcher path_matcher.PathMatcher) (string, error) { addFilePaths, err := GetContextAddFilesPaths(projectDir, contextDir, contextAddFiles) if err != nil { return "", err @@ -112,7 +112,7 @@ func ContextAddFilesChecksum(ctx context.Context, projectDir string, contextDir return fmt.Sprintf("%x", h.Sum(nil)), nil } -func AddContextAddFilesToContextArchive(ctx context.Context, originalArchivePath string, projectDir string, contextDir string, contextAddFiles []string) (string, error) { +func AddContextAddFilesToContextArchive(ctx context.Context, originalArchivePath, projectDir, contextDir string, contextAddFiles []string) (string, error) { destinationArchivePath := GetTmpArchivePath() pathsToExcludeFromSourceArchive := contextAddFiles diff --git a/pkg/deploy/bundles/pull.go b/pkg/deploy/bundles/pull.go index 262cb0555f..de632b05d6 100644 --- a/pkg/deploy/bundles/pull.go +++ b/pkg/deploy/bundles/pull.go @@ -10,7 +10,7 @@ import ( "github.com/werf/werf/pkg/deploy/bundles/registry" ) -func Pull(ctx context.Context, bundleRef string, destDir string, bundlesRegistryClient *registry.Client) error { +func Pull(ctx context.Context, bundleRef, destDir string, bundlesRegistryClient *registry.Client) error { r, err := registry.ParseReference(bundleRef) if err != nil { return err diff --git a/pkg/deploy/bundles/registry/cache.go b/pkg/deploy/bundles/registry/cache.go index e64d952bd5..082e98a0ca 100644 --- a/pkg/deploy/bundles/registry/cache.go +++ b/pkg/deploy/bundles/registry/cache.go @@ -307,7 +307,7 @@ func (cache *Cache) saveChartContentLayer(ch *chart.Chart) (*ocispec.Descriptor, } // saveChartManifest stores the chart manifest as json blob and returns a descriptor -func (cache *Cache) saveChartManifest(config *ocispec.Descriptor, contentLayer *ocispec.Descriptor) (*ocispec.Descriptor, bool, error) { +func (cache *Cache) saveChartManifest(config, contentLayer *ocispec.Descriptor) (*ocispec.Descriptor, bool, error) { manifest := ocispec.Manifest{ Versioned: specs.Versioned{SchemaVersion: 2}, Config: *config, diff --git a/pkg/deploy/bundles/registry/client.go b/pkg/deploy/bundles/registry/client.go index 0bd441ea66..1279bb1a3a 100644 --- a/pkg/deploy/bundles/registry/client.go +++ b/pkg/deploy/bundles/registry/client.go @@ -122,7 +122,7 @@ func NewClient(opts ...ClientOption) (*Client, error) { } // Login logs into a registry -func (c *Client) Login(hostname string, username string, password string, insecure bool) error { +func (c *Client) Login(hostname, username, password string, insecure bool) error { err := c.authorizer.Login(ctx(c.out, c.debug), hostname, username, password, insecure) if err != nil { return err diff --git a/pkg/deploy/helm/chart_extender/helpers/service_values.go b/pkg/deploy/helm/chart_extender/helpers/service_values.go index 2688b6ffba..e6de5d6517 100644 --- a/pkg/deploy/helm/chart_extender/helpers/service_values.go +++ b/pkg/deploy/helm/chart_extender/helpers/service_values.go @@ -44,7 +44,7 @@ type ServiceValuesOptions struct { DockerConfigPath string } -func GetServiceValues(ctx context.Context, projectName string, repo string, imageInfoGetters []*image.InfoGetter, opts ServiceValuesOptions) (map[string]interface{}, error) { +func GetServiceValues(ctx context.Context, projectName, repo string, imageInfoGetters []*image.InfoGetter, opts ServiceValuesOptions) (map[string]interface{}, error) { globalInfo := map[string]interface{}{ "werf": map[string]interface{}{ "name": projectName, diff --git a/pkg/deploy/helm/external_deps_annotations_parser.go b/pkg/deploy/helm/external_deps_annotations_parser.go index 76f0ac7f22..22b2d6c8a7 100644 --- a/pkg/deploy/helm/external_deps_annotations_parser.go +++ b/pkg/deploy/helm/external_deps_annotations_parser.go @@ -4,8 +4,9 @@ import ( "fmt" "strings" - "github.com/werf/werf/pkg/slug" "helm.sh/helm/v3/pkg/phases/stages/externaldeps" + + "github.com/werf/werf/pkg/slug" ) func NewExternalDepsAnnotationsParser() *ExternalDepsAnnotationsParser { @@ -122,8 +123,7 @@ func (s *ExternalDepsAnnotationsParser) validateResourceAnnotation(key, value st } } - switch valueElems[1] { - case "": + if valueElems[1] == "" { return fmt.Errorf("in annotation %q resource name can't be empty", key) } diff --git a/pkg/deploy/helm/gvk_builder.go b/pkg/deploy/helm/gvk_builder.go index 86e02e78ec..321ed7669e 100644 --- a/pkg/deploy/helm/gvk_builder.go +++ b/pkg/deploy/helm/gvk_builder.go @@ -7,7 +7,6 @@ import ( "k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/kubectl/pkg/scheme" ) diff --git a/pkg/docker_registry/docker_registry.go b/pkg/docker_registry/docker_registry.go index 584829d220..b1334d49a4 100644 --- a/pkg/docker_registry/docker_registry.go +++ b/pkg/docker_registry/docker_registry.go @@ -91,7 +91,7 @@ func (o *DockerRegistryOptions) defaultOptions() defaultImplementationOptions { }} } -func NewDockerRegistry(repositoryAddress string, implementation string, options DockerRegistryOptions) (Interface, error) { +func NewDockerRegistry(repositoryAddress, implementation string, options DockerRegistryOptions) (Interface, error) { dockerRegistry, err := newDockerRegistry(repositoryAddress, implementation, options) if err != nil { return nil, err @@ -101,7 +101,7 @@ func NewDockerRegistry(repositoryAddress string, implementation string, options return dockerRegistryWithCache, nil } -func newDockerRegistry(repositoryAddress string, implementation string, options DockerRegistryOptions) (Interface, error) { +func newDockerRegistry(repositoryAddress, implementation string, options DockerRegistryOptions) (Interface, error) { if err := ValidateRepositoryReference(repositoryAddress); err != nil { return nil, err } diff --git a/pkg/docker_registry/github_packages_api.go b/pkg/docker_registry/github_packages_api.go index f1300ef3a6..44d15f8353 100644 --- a/pkg/docker_registry/github_packages_api.go +++ b/pkg/docker_registry/github_packages_api.go @@ -184,7 +184,7 @@ func (api *gitHubApi) deleteContainerPackage(ctx context.Context, url, token str return nil, nil } -func (api *gitHubApi) doRequest(ctx context.Context, method string, url string, body io.Reader, options doRequestOptions) (*http.Response, []byte, error) { +func (api *gitHubApi) doRequest(ctx context.Context, method, url string, body io.Reader, options doRequestOptions) (*http.Response, []byte, error) { resp, respBody, err := doRequest(ctx, method, url, body, options) if err != nil { if resp != nil && resp.Header.Get("Retry-After") != "" { diff --git a/pkg/git_repo/base.go b/pkg/git_repo/base.go index 056784493e..04204e3216 100644 --- a/pkg/git_repo/base.go +++ b/pkg/git_repo/base.go @@ -257,7 +257,7 @@ func HasSubmodulesInCommit(commit *object.Commit) (bool, error) { return true, nil } -func (repo *Base) createDetachedMergeCommit(ctx context.Context, gitDir, path, workTreeCacheDir string, fromCommit, toCommit string) (string, error) { +func (repo *Base) createDetachedMergeCommit(ctx context.Context, gitDir, path, workTreeCacheDir, fromCommit, toCommit string) (string, error) { if lock, err := CommonGitDataManager.LockGC(ctx, true); err != nil { return "", err } else { @@ -397,7 +397,7 @@ func (repo *Base) createArchive(ctx context.Context, repoPath, gitDir, repoID, w } } -func (repo *Base) isCommitExists(ctx context.Context, repoPath, gitDir string, commit string) (bool, error) { +func (repo *Base) isCommitExists(ctx context.Context, repoPath, gitDir, commit string) (bool, error) { repository, err := git.PlainOpenWithOptions(repoPath, &git.PlainOpenOptions{EnableDotGitCommonDir: true}) if err != nil { return false, fmt.Errorf("cannot open repo %q: %w", repoPath, err) @@ -570,7 +570,7 @@ initCommitRepoHandle: return nil } -func (repo *Base) GetCommitTreeEntry(ctx context.Context, commit string, path string) (*ls_tree.LsTreeEntry, error) { +func (repo *Base) GetCommitTreeEntry(ctx context.Context, commit, path string) (*ls_tree.LsTreeEntry, error) { lsTreeResult, err := repo.lsTreeResult(ctx, commit, LsTreeOptions{ PathScope: path, AllFiles: false, @@ -584,7 +584,7 @@ func (repo *Base) GetCommitTreeEntry(ctx context.Context, commit string, path st return entry, nil } -func (repo *Base) IsCommitTreeEntryExist(ctx context.Context, commit string, relPath string) (exist bool, err error) { +func (repo *Base) IsCommitTreeEntryExist(ctx context.Context, commit, relPath string) (exist bool, err error) { logboek.Context(ctx).Debug(). LogBlock("IsCommitTreeEntryExist %q %q", commit, relPath). Options(func(options types.LogBlockOptionsInterface) { @@ -603,7 +603,7 @@ func (repo *Base) IsCommitTreeEntryExist(ctx context.Context, commit string, rel return } -func (repo *Base) isTreeEntryExist(ctx context.Context, commit string, relPath string) (bool, error) { +func (repo *Base) isTreeEntryExist(ctx context.Context, commit, relPath string) (bool, error) { entry, err := repo.GetCommitTreeEntry(ctx, commit, relPath) if err != nil { return false, err @@ -612,7 +612,7 @@ func (repo *Base) isTreeEntryExist(ctx context.Context, commit string, relPath s return !entry.Mode.IsMalformed(), nil } -func (repo *Base) IsCommitTreeEntryDirectory(ctx context.Context, commit string, relPath string) (isDirectory bool, err error) { +func (repo *Base) IsCommitTreeEntryDirectory(ctx context.Context, commit, relPath string) (isDirectory bool, err error) { logboek.Context(ctx).Debug(). LogBlock("IsCommitTreeEntryDirectory %q %q", commit, relPath). Options(func(options types.LogBlockOptionsInterface) { @@ -631,7 +631,7 @@ func (repo *Base) IsCommitTreeEntryDirectory(ctx context.Context, commit string, return } -func (repo *Base) isCommitTreeEntryDirectory(ctx context.Context, commit string, relPath string) (bool, error) { +func (repo *Base) isCommitTreeEntryDirectory(ctx context.Context, commit, relPath string) (bool, error) { entry, err := repo.GetCommitTreeEntry(ctx, commit, relPath) if err != nil { return false, err @@ -640,7 +640,7 @@ func (repo *Base) isCommitTreeEntryDirectory(ctx context.Context, commit string, return entry.Mode == filemode.Dir || entry.Mode == filemode.Submodule, nil } -func (repo *Base) ReadCommitTreeEntryContent(ctx context.Context, commit string, relPath string) ([]byte, error) { +func (repo *Base) ReadCommitTreeEntryContent(ctx context.Context, commit, relPath string) ([]byte, error) { lsTreeResult, err := repo.lsTreeResult(ctx, commit, LsTreeOptions{ PathScope: relPath, AllFiles: false, @@ -799,7 +799,7 @@ func (repo *Base) resolveAndCheckCommitFilePath(ctx context.Context, commit, pat return repo.resolveCommitFilePath(ctx, commit, path, 0, checkSymlinkTargetFunc) } -func (repo *Base) checkCommitFileMode(ctx context.Context, commit string, path string, expectedFileModeList []filemode.FileMode) (bool, error) { +func (repo *Base) checkCommitFileMode(ctx context.Context, commit, path string, expectedFileModeList []filemode.FileMode) (bool, error) { resolvedPath, err := repo.ResolveCommitFilePath(ctx, commit, path) if err != nil { if IsTreeEntryNotFoundInRepoErr(err) { @@ -900,7 +900,7 @@ func (repo *Base) readCommitFile(ctx context.Context, commit, path string) ([]by return repo.ReadCommitTreeEntryContent(ctx, commit, resolvedPath) } -func (repo *Base) IsAnyCommitTreeEntriesMatched(ctx context.Context, commit string, pathScope string, pathMatcher path_matcher.PathMatcher, allFiles bool) (bool, error) { +func (repo *Base) IsAnyCommitTreeEntriesMatched(ctx context.Context, commit, pathScope string, pathMatcher path_matcher.PathMatcher, allFiles bool) (bool, error) { result, err := repo.lsTreeResult(ctx, commit, LsTreeOptions{ PathScope: pathScope, PathMatcher: pathMatcher, @@ -913,7 +913,7 @@ func (repo *Base) IsAnyCommitTreeEntriesMatched(ctx context.Context, commit stri return !result.IsEmpty(), nil } -func (repo *Base) WalkCommitFiles(ctx context.Context, commit string, dir string, pathMatcher path_matcher.PathMatcher, fileFunc func(notResolvedPath string) error) error { +func (repo *Base) WalkCommitFiles(ctx context.Context, commit, dir string, pathMatcher path_matcher.PathMatcher, fileFunc func(notResolvedPath string) error) error { if !pathMatcher.IsDirOrSubmodulePathMatched(dir) { return nil } @@ -983,7 +983,7 @@ func (repo *Base) WalkCommitFiles(ctx context.Context, commit string, dir string // ListCommitFilesWithGlob returns the list of files by the glob, follows symlinks. // The result paths are relative to the passed directory, the method does reverse resolving for symlinks. -func (repo *Base) ListCommitFilesWithGlob(ctx context.Context, commit string, dir string, glob string) (files []string, err error) { +func (repo *Base) ListCommitFilesWithGlob(ctx context.Context, commit, dir, glob string) (files []string, err error) { var prefixWithoutPatterns string prefixWithoutPatterns, glob = util.GlobPrefixWithoutPatterns(glob) dirOrFileWithGlobPrefix := filepath.Join(dir, prefixWithoutPatterns) diff --git a/pkg/git_repo/git_repo.go b/pkg/git_repo/git_repo.go index 06bdc7eb4c..59f4233fd7 100644 --- a/pkg/git_repo/git_repo.go +++ b/pkg/git_repo/git_repo.go @@ -47,7 +47,7 @@ type GitRepo interface { SyncWithOrigin(ctx context.Context) error CreateDetachedMergeCommit(ctx context.Context, fromCommit, toCommit string) (string, error) - GetCommitTreeEntry(ctx context.Context, commit string, path string) (*ls_tree.LsTreeEntry, error) + GetCommitTreeEntry(ctx context.Context, commit, path string) (*ls_tree.LsTreeEntry, error) GetMergeCommitParents(ctx context.Context, commit string) ([]string, error) GetOrCreateArchive(ctx context.Context, opts ArchiveOptions) (Archive, error) GetOrCreateChecksum(ctx context.Context, opts ChecksumOptions) (string, error) @@ -58,18 +58,18 @@ type GitRepo interface { IsCommitDirectoryExist(ctx context.Context, commit, path string) (bool, error) IsCommitExists(ctx context.Context, commit string) (bool, error) IsCommitFileExist(ctx context.Context, commit, path string) (bool, error) - IsAnyCommitTreeEntriesMatched(ctx context.Context, commit string, pathScope string, pathMatcher path_matcher.PathMatcher, allFiles bool) (bool, error) - IsCommitTreeEntryDirectory(ctx context.Context, commit string, relPath string) (bool, error) - IsCommitTreeEntryExist(ctx context.Context, commit string, relPath string) (bool, error) + IsAnyCommitTreeEntriesMatched(ctx context.Context, commit, pathScope string, pathMatcher path_matcher.PathMatcher, allFiles bool) (bool, error) + IsCommitTreeEntryDirectory(ctx context.Context, commit, relPath string) (bool, error) + IsCommitTreeEntryExist(ctx context.Context, commit, relPath string) (bool, error) IsEmpty(ctx context.Context) (bool, error) LatestBranchCommit(ctx context.Context, branch string) (string, error) - ListCommitFilesWithGlob(ctx context.Context, commit string, dir string, glob string) ([]string, error) + ListCommitFilesWithGlob(ctx context.Context, commit, dir, glob string) ([]string, error) ReadCommitFile(ctx context.Context, commit, path string) ([]byte, error) - ReadCommitTreeEntryContent(ctx context.Context, commit string, relPath string) ([]byte, error) + ReadCommitTreeEntryContent(ctx context.Context, commit, relPath string) ([]byte, error) ResolveAndCheckCommitFilePath(ctx context.Context, commit, path string, checkSymlinkTargetFunc func(resolvedPath string) error) (string, error) ResolveCommitFilePath(ctx context.Context, commit, path string) (string, error) TagCommit(ctx context.Context, tag string) (string, error) - WalkCommitFiles(ctx context.Context, commit string, dir string, pathMatcher path_matcher.PathMatcher, fileFunc func(notResolvedPath string) error) error + WalkCommitFiles(ctx context.Context, commit, dir string, pathMatcher path_matcher.PathMatcher, fileFunc func(notResolvedPath string) error) error StatusPathList(ctx context.Context, pathMatcher path_matcher.PathMatcher) (list []string, err error) ValidateStatusResult(ctx context.Context, pathMatcher path_matcher.PathMatcher) error diff --git a/pkg/giterminism_manager/file_reader/errors.go b/pkg/giterminism_manager/file_reader/errors.go index a49e77f75a..215b440778 100644 --- a/pkg/giterminism_manager/file_reader/errors.go +++ b/pkg/giterminism_manager/file_reader/errors.go @@ -89,7 +89,7 @@ func (r FileReader) NewUncommittedFilesError(relPaths ...string) error { return r.uncommittedErrorBase(errorMsg, strings.Join(formatFilePathList(relPaths), " ")) } -func (r FileReader) uncommittedErrorBase(errorMsg string, gitAddArg string) error { +func (r FileReader) uncommittedErrorBase(errorMsg, gitAddArg string) error { if r.sharedOptions.Dev() { errorMsg = fmt.Sprintf(`%s diff --git a/pkg/giterminism_manager/file_reader/git.go b/pkg/giterminism_manager/file_reader/git.go index 6642ac5075..e669df29bf 100644 --- a/pkg/giterminism_manager/file_reader/git.go +++ b/pkg/giterminism_manager/file_reader/git.go @@ -147,7 +147,7 @@ func (r FileReader) ResolveAndCheckCommitFilePath(ctx context.Context, relPath s return r.sharedOptions.LocalGitRepo().ResolveAndCheckCommitFilePath(ctx, r.sharedOptions.HeadCommit(), r.projectDirRelativePathToWorkTreeRelativePath(relPath), checkSymlinkTargetFunc) } -func (r FileReader) ListCommitFilesWithGlob(ctx context.Context, dir string, pattern string) (files []string, err error) { +func (r FileReader) ListCommitFilesWithGlob(ctx context.Context, dir, pattern string) (files []string, err error) { logboek.Context(ctx).Debug(). LogBlock("ListCommitFilesWithGlob %q %q", dir, pattern). Options(func(options types.LogBlockOptionsInterface) { @@ -170,7 +170,7 @@ func (r FileReader) ListCommitFilesWithGlob(ctx context.Context, dir string, pat return } -func (r FileReader) listCommitFilesWithGlob(ctx context.Context, dir string, pattern string) ([]string, error) { +func (r FileReader) listCommitFilesWithGlob(ctx context.Context, dir, pattern string) ([]string, error) { list, err := r.sharedOptions.LocalGitRepo().ListCommitFilesWithGlob(ctx, r.sharedOptions.HeadCommit(), r.projectDirRelativePathToWorkTreeRelativePath(dir), pattern) if err != nil { return nil, err diff --git a/pkg/image/info_getter.go b/pkg/image/info_getter.go index 1c7ae3ec60..9fa4abdcf1 100644 --- a/pkg/image/info_getter.go +++ b/pkg/image/info_getter.go @@ -19,7 +19,7 @@ type InfoGetterOptions struct { CustomTagFunc CustomTagFunc } -func NewInfoGetter(imageName string, ref string, opts InfoGetterOptions) *InfoGetter { +func NewInfoGetter(imageName, ref string, opts InfoGetterOptions) *InfoGetter { repo, tag := ParseRepositoryAndTag(ref) return &InfoGetter{ diff --git a/pkg/image/info_getter_test.go b/pkg/image/info_getter_test.go index f3fcdb31b3..6c38e3d717 100644 --- a/pkg/image/info_getter_test.go +++ b/pkg/image/info_getter_test.go @@ -45,7 +45,7 @@ var _ = Describe("InfoGetter", func() { ImageName: "backend", Ref: "myregistry.domain.com/group/project:abcd", Opts: InfoGetterOptions{ - CustomTagFunc: func(werfImageName string, tag string) string { + CustomTagFunc: func(werfImageName, tag string) string { return fmt.Sprintf("%s-%s", werfImageName, tag) }, }, diff --git a/pkg/path_matcher/common.go b/pkg/path_matcher/common.go index dc6b31f27e..5933af912d 100644 --- a/pkg/path_matcher/common.go +++ b/pkg/path_matcher/common.go @@ -9,7 +9,7 @@ import ( "github.com/werf/werf/pkg/util" ) -func matchGlobs(pathPart string, globs []string) (inProgressGlobs []string, matchedGlobs []string) { +func matchGlobs(pathPart string, globs []string) (inProgressGlobs, matchedGlobs []string) { for _, glob := range globs { inProgressGlob, matchedGlob := matchGlob(pathPart, glob) if inProgressGlob != "" { @@ -22,7 +22,7 @@ func matchGlobs(pathPart string, globs []string) (inProgressGlobs []string, matc return } -func matchGlob(pathPart string, glob string) (inProgressGlob, matchedGlob string) { +func matchGlob(pathPart, glob string) (inProgressGlob, matchedGlob string) { globParts := util.SplitFilepath(glob) isMatched, err := doublestar.PathMatch(globParts[0], pathPart) if err != nil { diff --git a/pkg/slug/slug.go b/pkg/slug/slug.go index e100dd1ef1..d1e6187fda 100644 --- a/pkg/slug/slug.go +++ b/pkg/slug/slug.go @@ -209,7 +209,7 @@ func slug(data string, maxSize int) string { return consistentUniqSlug } -func cropSluggedData(data string, hash string, maxSize int) string { +func cropSluggedData(data, hash string, maxSize int) string { var index int maxLength := maxSize - len(hash) - len(slugSeparator) if len(data) > maxLength { diff --git a/pkg/storage/manager/storage_manager.go b/pkg/storage/manager/storage_manager.go index ecafecf91e..8ca8a94e4f 100644 --- a/pkg/storage/manager/storage_manager.go +++ b/pkg/storage/manager/storage_manager.go @@ -95,7 +95,7 @@ Retry: return err } -func NewStorageManager(projectName string, stagesStorage storage.StagesStorage, finalStagesStorage storage.StagesStorage, secondaryStagesStorageList []storage.StagesStorage, cacheStagesStorageList []storage.StagesStorage, storageLockManager storage.LockManager) *StorageManager { +func NewStorageManager(projectName string, stagesStorage, finalStagesStorage storage.StagesStorage, secondaryStagesStorageList, cacheStagesStorageList []storage.StagesStorage, storageLockManager storage.LockManager) *StorageManager { return &StorageManager{ ProjectName: projectName, StorageLockManager: storageLockManager, diff --git a/pkg/storage/repo_stages_storage.go b/pkg/storage/repo_stages_storage.go index 48ebda9638..5e0912c79f 100644 --- a/pkg/storage/repo_stages_storage.go +++ b/pkg/storage/repo_stages_storage.go @@ -673,7 +673,7 @@ func makeRepoImportMetadataName(repoAddress, importSourceID string) string { return fmt.Sprintf(RepoImportMetadata_ImageNameFormat, repoAddress, importSourceID) } -func groupImageMetadataTagsByImageName(ctx context.Context, imageNameOrManagedImageList []string, tags []string, imageTagPrefix string) (map[string]map[string][]string, map[string]map[string][]string, error) { +func groupImageMetadataTagsByImageName(ctx context.Context, imageNameOrManagedImageList, tags []string, imageTagPrefix string) (map[string]map[string][]string, map[string]map[string][]string, error) { imageMetadataIDImageNameOrManagedImageName := map[string]string{} for _, imageNameOrManagedImageName := range imageNameOrManagedImageList { imageMetadataIDImageNameOrManagedImageName[getImageMetadataID(imageNameOrManagedImageName)] = imageNameOrManagedImageName diff --git a/pkg/true_git/ls_tree/result.go b/pkg/true_git/ls_tree/result.go index 09d73c8e4d..8cfb7ce126 100644 --- a/pkg/true_git/ls_tree/result.go +++ b/pkg/true_git/ls_tree/result.go @@ -22,7 +22,7 @@ type Result struct { submodulesResults []*SubmoduleResult } -func NewResult(commit string, repositoryFullFilepath string, lsTreeEntries []*LsTreeEntry, submodulesResults []*SubmoduleResult) *Result { +func NewResult(commit, repositoryFullFilepath string, lsTreeEntries []*LsTreeEntry, submodulesResults []*SubmoduleResult) *Result { return &Result{ commit: commit, repositoryFullFilepath: repositoryFullFilepath, diff --git a/pkg/true_git/merge_base.go b/pkg/true_git/merge_base.go index 1328323645..b08ed93c71 100644 --- a/pkg/true_git/merge_base.go +++ b/pkg/true_git/merge_base.go @@ -8,7 +8,7 @@ import ( "strings" ) -func IsAncestor(ctx context.Context, ancestorCommit, descendantCommit string, gitDir string) (bool, error) { +func IsAncestor(ctx context.Context, ancestorCommit, descendantCommit, gitDir string) (bool, error) { mergeBaseCmd := NewGitCmd(ctx, &GitCmdOptions{RepoDir: gitDir}, "merge-base", "--is-ancestor", ancestorCommit, descendantCommit) if err := mergeBaseCmd.Run(ctx); err != nil { var errExit *exec.ExitError diff --git a/pkg/true_git/service_branch.go b/pkg/true_git/service_branch.go index e35313b20f..1b27afef41 100644 --- a/pkg/true_git/service_branch.go +++ b/pkg/true_git/service_branch.go @@ -88,7 +88,7 @@ func syncWorktreeWithServiceWorktreeBranch(ctx context.Context, sourceWorktreeDi return newCommit, nil } -func prepareAndCheckoutServiceBranch(ctx context.Context, serviceWorktreeDir string, sourceCommit string, branchName string) error { +func prepareAndCheckoutServiceBranch(ctx context.Context, serviceWorktreeDir, sourceCommit, branchName string) error { branchListCmd := NewGitCmd(ctx, &GitCmdOptions{RepoDir: serviceWorktreeDir}, "branch", "--list", branchName) if err := branchListCmd.Run(ctx); err != nil { return fmt.Errorf("git branch list command failed: %w", err) @@ -128,7 +128,7 @@ func prepareAndCheckoutServiceBranch(ctx context.Context, serviceWorktreeDir str return nil } -func revertExcludedChangesInServiceWorktreeIndex(ctx context.Context, sourceWorktreeDir string, serviceWorktreeDir string, sourceCommit string, serviceBranchHeadCommit string, globExcludeList []string) (bool, error) { +func revertExcludedChangesInServiceWorktreeIndex(ctx context.Context, sourceWorktreeDir, serviceWorktreeDir, sourceCommit, serviceBranchHeadCommit string, globExcludeList []string) (bool, error) { if len(globExcludeList) == 0 || serviceBranchHeadCommit == sourceCommit { return false, nil } @@ -161,7 +161,7 @@ func revertExcludedChangesInServiceWorktreeIndex(ctx context.Context, sourceWork return true, nil } -func checkNewChangesInSourceWorktreeDir(ctx context.Context, sourceWorktreeDir string, serviceWorktreeDir string, globExcludeList []string) (bool, error) { +func checkNewChangesInSourceWorktreeDir(ctx context.Context, sourceWorktreeDir, serviceWorktreeDir string, globExcludeList []string) (bool, error) { output, err := runGitAddCmd(ctx, sourceWorktreeDir, serviceWorktreeDir, globExcludeList, true) if err != nil { return false, err @@ -170,12 +170,12 @@ func checkNewChangesInSourceWorktreeDir(ctx context.Context, sourceWorktreeDir s return len(output.Bytes()) != 0, nil } -func addNewChangesInServiceWorktreeDir(ctx context.Context, sourceWorktreeDir string, serviceWorktreeDir string, globExcludeList []string) error { +func addNewChangesInServiceWorktreeDir(ctx context.Context, sourceWorktreeDir, serviceWorktreeDir string, globExcludeList []string) error { _, err := runGitAddCmd(ctx, sourceWorktreeDir, serviceWorktreeDir, globExcludeList, false) return err } -func runGitAddCmd(ctx context.Context, sourceWorktreeDir string, serviceWorktreeDir string, globExcludeList []string, dryRun bool) (*bytes.Buffer, error) { +func runGitAddCmd(ctx context.Context, sourceWorktreeDir, serviceWorktreeDir string, globExcludeList []string, dryRun bool) (*bytes.Buffer, error) { gitAddArgs := []string{ "--work-tree", sourceWorktreeDir, @@ -214,7 +214,7 @@ func runGitAddCmd(ctx context.Context, sourceWorktreeDir string, serviceWorktree return addCmd.OutBuf, nil } -func commitNewChangesInServiceBranch(ctx context.Context, serviceWorktreeDir string, branchName string) (string, error) { +func commitNewChangesInServiceBranch(ctx context.Context, serviceWorktreeDir, branchName string) (string, error) { commitCmd := NewGitCmd(ctx, &GitCmdOptions{RepoDir: serviceWorktreeDir}, "-c", "user.email=werf@werf.io", "-c", "user.name=werf", "commit", "--no-verify", "-m", time.Now().String()) if err := commitCmd.Run(ctx); err != nil { return "", fmt.Errorf("git commit command failed: %w", err) diff --git a/pkg/true_git/work_tree.go b/pkg/true_git/work_tree.go index 4c861876cc..484c47661d 100644 --- a/pkg/true_git/work_tree.go +++ b/pkg/true_git/work_tree.go @@ -23,7 +23,7 @@ type WithWorkTreeOptions struct { HasSubmodules bool } -func WithWorkTree(ctx context.Context, gitDir, workTreeCacheDir string, commit string, opts WithWorkTreeOptions, f func(workTreeDir string) error) error { +func WithWorkTree(ctx context.Context, gitDir, workTreeCacheDir, commit string, opts WithWorkTreeOptions, f func(workTreeDir string) error) error { return withWorkTreeCacheLock(ctx, workTreeCacheDir, func() error { var err error @@ -51,7 +51,7 @@ func withWorkTreeCacheLock(ctx context.Context, workTreeCacheDir string, f func( return werf.WithHostLock(ctx, lockName, lockgate.AcquireOptions{Timeout: 600 * time.Second}, f) } -func prepareWorkTree(ctx context.Context, repoDir, workTreeCacheDir string, commit string, withSubmodules bool) (string, error) { +func prepareWorkTree(ctx context.Context, repoDir, workTreeCacheDir, commit string, withSubmodules bool) (string, error) { if err := os.MkdirAll(workTreeCacheDir, os.ModePerm); err != nil { return "", fmt.Errorf("unable to create dir %s: %w", workTreeCacheDir, err) } @@ -208,7 +208,7 @@ InvalidDotGit: return "", ErrInvalidDotGit } -func switchWorkTree(ctx context.Context, repoDir, workTreeDir string, commit string, withSubmodules bool) error { +func switchWorkTree(ctx context.Context, repoDir, workTreeDir, commit string, withSubmodules bool) error { _, err := os.Stat(workTreeDir) switch { case os.IsNotExist(err): diff --git a/pkg/util/archive.go b/pkg/util/archive.go index 449ab805a0..2b7ace2d80 100644 --- a/pkg/util/archive.go +++ b/pkg/util/archive.go @@ -59,7 +59,7 @@ func CreateArchive(archivePath string, f func(tw *tar.Writer) error) error { return f(tw) } -func CopyFileIntoTar(tw *tar.Writer, tarEntryName string, filePath string) error { +func CopyFileIntoTar(tw *tar.Writer, tarEntryName, filePath string) error { stat, err := os.Lstat(filePath) if err != nil { return fmt.Errorf("unable to stat file %q: %w", filePath, err) diff --git a/pkg/util/parallel/parallel.go b/pkg/util/parallel/parallel.go index 15fcf75ac9..9c6a922510 100644 --- a/pkg/util/parallel/parallel.go +++ b/pkg/util/parallel/parallel.go @@ -108,7 +108,7 @@ func DoTasks(ctx context.Context, numberOfTasks int, options DoTasksOptions, tas return err } -func workersHandlerLiveOutput(ctx context.Context, workers []*bufWorker, taskResultDoneCh chan *bufWorkerTaskResult, taskResultFailedCh chan *bufWorkerTaskResult, quitCh chan bool, workerDoneCh chan *bufWorker) error { +func workersHandlerLiveOutput(ctx context.Context, workers []*bufWorker, taskResultDoneCh, taskResultFailedCh chan *bufWorkerTaskResult, quitCh chan bool, workerDoneCh chan *bufWorker) error { workerLoop: for _, currentWorker := range workers { for { @@ -158,7 +158,7 @@ workerLoop: return nil } -func workersHandlerStandard(ctx context.Context, workers []*bufWorker, taskResultDoneCh chan *bufWorkerTaskResult, taskResultFailedCh chan *bufWorkerTaskResult, quitCh chan bool, workerDoneCh chan *bufWorker) error { +func workersHandlerStandard(ctx context.Context, workers []*bufWorker, taskResultDoneCh, taskResultFailedCh chan *bufWorkerTaskResult, quitCh chan bool, workerDoneCh chan *bufWorker) error { var workerDoneCounter int for { select { diff --git a/test/e2e/build/images_dependencies_test.go b/test/e2e/build/images_dependencies_test.go index 8ccc0917df..cf51948468 100644 --- a/test/e2e/build/images_dependencies_test.go +++ b/test/e2e/build/images_dependencies_test.go @@ -23,7 +23,7 @@ func werfRun(dir string, opts liveexec.ExecCommandOptions, extraArgs ...string) return liveexec.ExecCommand(dir, SuiteData.WerfBinPath, opts, utils.WerfBinArgs(append([]string{"run"}, extraArgs...)...)...) } -func werfStageImage(dir string, imageName string) (string, string) { +func werfStageImage(dir, imageName string) (string, string) { res := utils.SucceedCommandOutputString( dir, SuiteData.WerfBinPath, @@ -33,7 +33,7 @@ func werfStageImage(dir string, imageName string) (string, string) { return image.ParseRepositoryAndTag(strings.TrimSpace(res)) } -func werfRunOutput(dir string, imageName string, shellCommand string) string { +func werfRunOutput(dir, imageName, shellCommand string) string { handlingOutput := false var output []string diff --git a/test/pkg/suite_init/k8s_docker_registry_data.go b/test/pkg/suite_init/k8s_docker_registry_data.go index 915c0a1385..165c283a04 100644 --- a/test/pkg/suite_init/k8s_docker_registry_data.go +++ b/test/pkg/suite_init/k8s_docker_registry_data.go @@ -18,7 +18,7 @@ func NewK8sDockerRegistryData(projectNameData *ProjectNameData, stubsData *Stubs return data } -func SetupK8sDockerRegistryRepo(repo *string, projectName *string, stubs *gostub.Stubs) bool { +func SetupK8sDockerRegistryRepo(repo, projectName *string, stubs *gostub.Stubs) bool { return ginkgo.BeforeEach(func() { *repo = fmt.Sprintf("%s/%s", os.Getenv("WERF_TEST_K8S_DOCKER_REGISTRY"), *projectName) stubs.SetEnv("WERF_REPO", *repo) diff --git a/test/pkg/utils/docker/container_command.go b/test/pkg/utils/docker/container_command.go index f862f6fb9a..3ed8a3251f 100644 --- a/test/pkg/utils/docker/container_command.go +++ b/test/pkg/utils/docker/container_command.go @@ -34,7 +34,7 @@ func CheckContainerDirectory(werfBinPath, projectPath, containerDirPath string, RunSucceedContainerCommandWithStapel(werfBinPath, projectPath, []string{}, []string{cmd}) } -func RunSucceedContainerCommandWithStapel(werfBinPath string, projectPath string, extraDockerOptions []string, cmds []string) { +func RunSucceedContainerCommandWithStapel(werfBinPath, projectPath string, extraDockerOptions, cmds []string) { container, err := stapel.GetOrCreateContainer(context.Background()) Ω(err).ShouldNot(HaveOccurred()) @@ -66,7 +66,7 @@ func RunSucceedContainerCommandWithStapel(werfBinPath string, projectPath string Ω(err).ShouldNot(HaveOccurred(), errorDesc) } -func CheckContainerFileCommand(containerDirPath string, directory bool, exist bool) string { +func CheckContainerFileCommand(containerDirPath string, directory, exist bool) string { var cmd string var flag string diff --git a/test/pkg/utils/git.go b/test/pkg/utils/git.go index 29340744ae..a908733221 100644 --- a/test/pkg/utils/git.go +++ b/test/pkg/utils/git.go @@ -7,7 +7,7 @@ import ( "github.com/werf/werf/test/pkg/utils/liveexec" ) -func SetGitRepoState(workTreeDir, repoDir string, commitMessage string) error { +func SetGitRepoState(workTreeDir, repoDir, commitMessage string) error { if err := liveexec.ExecCommand(".", "git", liveexec.ExecCommandOptions{}, []string{"init", workTreeDir, "--separate-git-dir", repoDir}...); err != nil { return fmt.Errorf("unable to init git repo %s with work tree %s: %w", repoDir, workTreeDir, err) } diff --git a/test/pkg/utils/storage.go b/test/pkg/utils/storage.go index 07468efd2f..5294d36c94 100644 --- a/test/pkg/utils/storage.go +++ b/test/pkg/utils/storage.go @@ -10,7 +10,7 @@ import ( "github.com/werf/werf/pkg/storage" ) -func NewStagesStorage(stagesStorageAddress string, implementationName string, dockerRegistryOptions docker_registry.DockerRegistryOptions) storage.StagesStorage { +func NewStagesStorage(stagesStorageAddress, implementationName string, dockerRegistryOptions docker_registry.DockerRegistryOptions) storage.StagesStorage { if stagesStorageAddress == storage.LocalStorageAddress { return storage.NewDockerServerStagesStorage(&container_backend.DockerServerBackend{}) } else {