diff --git a/.cspell.json b/.cspell.json index dcc0fa264b8..8dccf9a218e 100644 --- a/.cspell.json +++ b/.cspell.json @@ -1,7 +1,17 @@ { "version": "0.2", "language": "en", + "dictionaries": [ + // language + "en_us", + // code + "go", + "node", + // package names + "npm" + ], "words": [ + "abool", "BUILDPLATFORM", "Codeberg", "Curr", @@ -21,35 +31,40 @@ "Ionescu", "Kaniko", "Keyfunc", + "LASTEXITCODE", "Laszlo", "Msgf", "Netrc", "PROTOC", "Pinia", "Println", + "pwsh", "Refspec", "Reviewdog", "Rydzewski", + "SSHURL", "TARGETARCH", "TARGETOS", + "Typeflag", "Upsert", "WORKDIR", "Warnf", "Weblate", "Wrapf", "anbraten", + "apimachinery", "autoincr", "autoscaler", "binutils", "bitbucketdatacenter", "bradrydzewski", - "brightbox", "buildx", "ccmenu", "charmbracelet", "ciphertext", "compatiblelicenses", "corepack", + "cpuset", "creativecommons", "datacenter", "desaturate", @@ -57,11 +72,14 @@ "doublestar", "envsubst", "estree", + "errgroup", "evenodd", "excalidraw", "favicons", + "forbidigo", "fsnotify", "gitea", + "gocritic", "golangci", "gomod", "gonic", @@ -73,7 +91,10 @@ "laszlocph", "logfile", "loglevel", + "mapstructure", "markdownlint", + "memswap", + "moby", "multiarch", "multierr", "netdns", @@ -86,24 +107,37 @@ "ppid", "prismjs", "proto", + "protobuf", "protoc", + "protoimpl", + "protoreflect", "rawurl", + "regcred", "repology", + "reslimit", + "riscv", + "rundll32", + "seccomp", + "secprofile", "securecookie", "sess", + "shellescape", "stepbuilder", "stretchr", "sublicensable", + "swaggo", "techknowlogick", "testdata", "tink", "tinycolor", + "tmpfs", + "tmpl", + "tolerations", + "ttlcache", "typecheck", "unplugin", "urfave", "varchar", - "vite", - "vitejs", "vueuse", "waivable", "windi", @@ -112,6 +146,7 @@ "xlog", "xorm", "xormigrate", + "xyaml", "zerolog", "zerologger" ], @@ -119,6 +154,7 @@ "**/node_modules/**/*", "*.excalidraw", "*.svg", + "*_test.go", ".cspell.json", ".git/**/*", ".gitignore", @@ -130,18 +166,29 @@ "flake.nix", "go.mod", "go.sum", + "pipeline/rpc/proto/woodpecker.pb.go", "pnpm-lock.yaml", "server/store/datastore/migration/**/*", "web/components.d.ts", "web/src/assets/locales/**/*", + "**/fixtures/**", + "**/testdata/**", // TODO: remove the following - ".woodpecker/", - "agent/", - "cli/", - "cmd/", "docs/", - "pipeline/", "server/" ], + // Exclude imports, because they are also strings. + "ignoreRegExpList": [ + // ignore mulltiline imports + "import\\s*\\((.|[\r\n])*?\\)", + // ignore single line imports + "import\\s*.*\".*?\"", + // ignore go generate directive + "//\\s*go:generate.*", + // ignore nolint directive + "//\\s*nolint:.*", + // ignore docker image names + "\\s*docker\\.io/.*" + ], "enableFiletypes": ["dockercompose"] } diff --git a/.woodpecker/binaries.yaml b/.woodpecker/binaries.yaml index d4bcb5c5e8f..c6f1863d1cf 100644 --- a/.woodpecker/binaries.yaml +++ b/.woodpecker/binaries.yaml @@ -6,6 +6,8 @@ variables: - &node_image 'docker.io/node:22-alpine' - &xgo_image 'docker.io/techknowlogick/xgo:go-1.22.x' +# cspell:words bindata netgo TARGZ + steps: build-web: image: *node_image diff --git a/.woodpecker/docker.yaml b/.woodpecker/docker.yaml index b28e5d870e6..d7cbba81204 100644 --- a/.woodpecker/docker.yaml +++ b/.woodpecker/docker.yaml @@ -9,6 +9,8 @@ variables: - &platforms_alpine 'linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/amd64,linux/ppc64le' - &build_args 'CI_COMMIT_SHA=${CI_COMMIT_SHA},CI_COMMIT_BRANCH=${CI_COMMIT_BRANCH},CI_COMMIT_TAG=${CI_COMMIT_TAG}' + # cspell:words woodpeckerbot netgo TARGZ + # vars used on push / tag events only - publish_logins: &publish_logins # Default DockerHub login - registry: https://index.docker.io/v1/ @@ -96,7 +98,7 @@ steps: - make cross-compile-server environment: PLATFORMS: linux|amd64 - TAGS: bindata sqlite sqlite_unlock_notify netgo + TAGS: sqlite sqlite_unlock_notify netgo when: - event: pull_request evaluate: 'CI_COMMIT_PULL_REQUEST_LABELS contains "build_pr_images"' @@ -118,7 +120,7 @@ steps: - make cross-compile-server environment: PLATFORMS: linux|arm/v7;linux|arm64/v8;linux|amd64;linux|ppc64le;linux|riscv64 - TAGS: bindata sqlite sqlite_unlock_notify netgo + TAGS: sqlite sqlite_unlock_notify netgo when: branch: - ${CI_REPO_DEFAULT_BRANCH} diff --git a/.woodpecker/securityscan.yaml b/.woodpecker/securityscan.yaml index 486e4cbfc8b..6800d31c2d7 100644 --- a/.woodpecker/securityscan.yaml +++ b/.woodpecker/securityscan.yaml @@ -6,8 +6,7 @@ when: - renovate/* variables: - - &trivy_image aquasec/trivy:0.46.1 - - &trivy_plugin woodpeckerci/plugin-trivy:1.0.1 + - &trivy_plugin docker.io/woodpeckerci/plugin-trivy:1.0.1 steps: backend: @@ -22,7 +21,7 @@ steps: settings: skip-dirs: node_modules/,plugins/woodpecker-plugins/node_modules/ dir: docs/ - # well we should check it, but we can not do much about old deps if docusaurus do not take that serously + # well we should check it, but we can not do much about old deps if docusaurus do not take that seriously # but this is not an issue as we just generate a static site anyway ... failure: ignore diff --git a/.woodpecker/static.yaml b/.woodpecker/static.yaml index 40d57c92a50..07753d109f8 100644 --- a/.woodpecker/static.yaml +++ b/.woodpecker/static.yaml @@ -18,7 +18,8 @@ steps: commands: - corepack enable - pnpx cspell lint --no-progress --gitignore '{**,.*}/{*,.*}' - - apk add --no-cache -U tree # busybox tree dont understand "-I" + - apk add --no-cache -U tree # busybox tree don't understand "-I" + # cspell:disable-next-line - tree --gitignore -I 012_columns_rename_procs_to_steps.go -I versioned_docs -I '*opensource.svg'| pnpx cspell lint --no-progress stdin - name: prettier @@ -28,7 +29,7 @@ steps: version: 3.2.5 - name: links - image: lycheeverse/lychee:0.14.3 + image: docker.io/lycheeverse/lychee:0.14.3 depends_on: [] commands: - lychee pipeline/frontend/yaml/linter/schema/schema.json diff --git a/.woodpecker/test.yaml b/.woodpecker/test.yaml index a21dd6bafd7..cf0d443fa6e 100644 --- a/.woodpecker/test.yaml +++ b/.woodpecker/test.yaml @@ -74,7 +74,7 @@ steps: lint-license-header: image: *golang_image commands: - - go install github.com/google/addlicense@latest + - go install github.com/google/addlicense@latest # cspell:words addlicense - 'addlicense -check -ignore "vendor/**" **/*.go' when: *when @@ -107,7 +107,7 @@ steps: image: *golang_image environment: WOODPECKER_DATABASE_DRIVER: postgres - WOODPECKER_DATABASE_DATASOURCE: 'host=postgres user=postgres dbname=postgres sslmode=disable' + WOODPECKER_DATABASE_DATASOURCE: 'host=postgres user=postgres dbname=postgres sslmode=disable' # cspell:disable-line commands: - make test-server-datastore when: *when diff --git a/.woodpecker/web.yaml b/.woodpecker/web.yaml index 3d36922970f..b64f33f5cc1 100644 --- a/.woodpecker/web.yaml +++ b/.woodpecker/web.yaml @@ -35,7 +35,7 @@ steps: - pnpm lint when: *when - formatcheck: + format-check: depends_on: - install-dependencies image: *node_image diff --git a/agent/logger.go b/agent/logger.go index 80f5112acc2..894f044e82f 100644 --- a/agent/logger.go +++ b/agent/logger.go @@ -28,7 +28,7 @@ import ( func (r *Runner) createLogger(logger zerolog.Logger, uploads *sync.WaitGroup, workflow *rpc.Workflow) pipeline.Logger { return func(step *backend.Step, rc io.Reader) error { - loglogger := logger.With(). + logLogger := logger.With(). Str("image", step.Image). Str("workflowID", workflow.ID). Logger() @@ -40,14 +40,14 @@ func (r *Runner) createLogger(logger zerolog.Logger, uploads *sync.WaitGroup, wo secrets = append(secrets, secret.Value) } - loglogger.Debug().Msg("log stream opened") + logLogger.Debug().Msg("log stream opened") logStream := rpc.NewLineWriter(r.client, step.UUID, secrets...) if _, err := io.Copy(logStream, rc); err != nil { log.Error().Err(err).Msg("copy limited logStream part") } - loglogger.Debug().Msg("log stream copied, close ...") + logLogger.Debug().Msg("log stream copied, close ...") uploads.Done() return nil diff --git a/agent/runner.go b/agent/runner.go index b80367bbdfd..2d96ff41b6c 100644 --- a/agent/runner.go +++ b/agent/runner.go @@ -54,7 +54,7 @@ func (r *Runner) Run(runnerCtx context.Context) error { //nolint:contextcheck log.Debug().Msg("request next execution") meta, _ := metadata.FromOutgoingContext(runnerCtx) - ctxmeta := metadata.NewOutgoingContext(context.Background(), meta) + ctxMeta := metadata.NewOutgoingContext(context.Background(), meta) // get the next workflow from the queue work, err := r.client.Next(runnerCtx, r.filter) @@ -89,7 +89,7 @@ func (r *Runner) Run(runnerCtx context.Context) error { //nolint:contextcheck logger.Debug().Msg("received execution") - workflowCtx, cancel := context.WithTimeout(ctxmeta, timeout) + workflowCtx, cancel := context.WithTimeout(ctxMeta, timeout) defer cancel() // Add sigterm support for internal context. @@ -103,9 +103,9 @@ func (r *Runner) Run(runnerCtx context.Context) error { //nolint:contextcheck go func() { logger.Debug().Msg("listen for cancel signal") - if werr := r.client.Wait(workflowCtx, work.ID); werr != nil { + if err := r.client.Wait(workflowCtx, work.ID); err != nil { canceled.SetTo(true) - logger.Warn().Err(werr).Msg("cancel signal received") + logger.Warn().Err(err).Msg("cancel signal received") cancel() } else { @@ -144,7 +144,7 @@ func (r *Runner) Run(runnerCtx context.Context) error { //nolint:contextcheck pipeline.WithContext(workflowCtx), pipeline.WithTaskUUID(fmt.Sprint(work.ID)), pipeline.WithLogger(r.createLogger(logger, &uploads, work)), - pipeline.WithTracer(r.createTracer(ctxmeta, logger, work)), + pipeline.WithTracer(r.createTracer(ctxMeta, logger, work)), pipeline.WithBackend(*r.backend), pipeline.WithDescription(map[string]string{ "ID": work.ID, diff --git a/agent/tracer.go b/agent/tracer.go index 7c516134c7b..985c185d005 100644 --- a/agent/tracer.go +++ b/agent/tracer.go @@ -26,9 +26,9 @@ import ( "go.woodpecker-ci.org/woodpecker/v2/pipeline/rpc" ) -func (r *Runner) createTracer(ctxmeta context.Context, logger zerolog.Logger, workflow *rpc.Workflow) pipeline.TraceFunc { +func (r *Runner) createTracer(ctxMeta context.Context, logger zerolog.Logger, workflow *rpc.Workflow) pipeline.TraceFunc { return func(state *pipeline.State) error { - steplogger := logger.With(). + stepLogger := logger.With(). Str("image", state.Pipeline.Step.Image). Str("workflowID", workflow.ID). Err(state.Process.Error). @@ -48,15 +48,15 @@ func (r *Runner) createTracer(ctxmeta context.Context, logger zerolog.Logger, wo } defer func() { - steplogger.Debug().Msg("update step status") + stepLogger.Debug().Msg("update step status") - if uerr := r.client.Update(ctxmeta, workflow.ID, stepState); uerr != nil { - steplogger.Debug(). - Err(uerr). + if err := r.client.Update(ctxMeta, workflow.ID, stepState); err != nil { + stepLogger.Debug(). + Err(err). Msg("update step status error") } - steplogger.Debug().Msg("update step status complete") + stepLogger.Debug().Msg("update step status complete") }() if state.Process.Exited { return nil diff --git a/cli/deploy/deploy.go b/cli/deploy/deploy.go index ff19ea98359..71ba9401fdb 100644 --- a/cli/deploy/deploy.go +++ b/cli/deploy/deploy.go @@ -78,9 +78,9 @@ func deploy(c *cli.Context) error { var number int64 if pipelineArg == "last" { // Fetch the pipeline number from the last pipeline - pipelines, berr := client.PipelineList(repoID) - if berr != nil { - return berr + pipelines, err := client.PipelineList(repoID) + if err != nil { + return err } for _, pipeline := range pipelines { if branch != "" && pipeline.Branch != branch { diff --git a/cli/exec/exec.go b/cli/exec/exec.go index cb65e1050bb..3b9e4d56398 100644 --- a/cli/exec/exec.go +++ b/cli/exec/exec.go @@ -146,14 +146,14 @@ func execWithAxis(c *cli.Context, file, repoPath string, axis matrix.Axis) error if err != nil { return err } - confstr, err := tmpl.Execute(func(name string) string { + confStr, err := tmpl.Execute(func(name string) string { return environ[name] }) if err != nil { return err } - conf, err := yaml.ParseString(confstr) + conf, err := yaml.ParseString(confStr) if err != nil { return err } @@ -177,12 +177,12 @@ func execWithAxis(c *cli.Context, file, repoPath string, axis matrix.Axis) error } // lint the yaml file - if lerr := linter.New(linter.WithTrusted(true)).Lint([]*linter.WorkflowConfig{{ + if err := linter.New(linter.WithTrusted(true)).Lint([]*linter.WorkflowConfig{{ File: path.Base(file), - RawConfig: confstr, + RawConfig: confStr, Workflow: conf, - }}); lerr != nil { - return lerr + }}); err != nil { + return err } // compiles the yaml file diff --git a/cli/internal/util.go b/cli/internal/util.go index 35a1d8da07e..5532c62e8bf 100644 --- a/cli/internal/util.go +++ b/cli/internal/util.go @@ -35,7 +35,7 @@ func NewClient(c *cli.Context) (woodpecker.Client, error) { var ( skip = c.Bool("skip-verify") socks = c.String("socks-proxy") - socksoff = c.Bool("socks-proxy-off") + socksOff = c.Bool("socks-proxy-off") token = c.String("token") server = c.String("server") ) @@ -70,7 +70,7 @@ func NewClient(c *cli.Context) (woodpecker.Client, error) { trans, _ := client.Transport.(*oauth2.Transport) - if len(socks) != 0 && !socksoff { + if len(socks) != 0 && !socksOff { dialer, err := proxy.SOCKS5("tcp", socks, nil, proxy.Direct) if err != nil { return nil, err diff --git a/cli/lint/lint.go b/cli/lint/lint.go index a11927d7701..e82ebf0508c 100644 --- a/cli/lint/lint.go +++ b/cli/lint/lint.go @@ -22,7 +22,7 @@ import ( "path/filepath" "strings" - "github.com/muesli/termenv" + term_env "github.com/muesli/termenv" "github.com/urfave/cli/v2" "go.woodpecker-ci.org/woodpecker/v2/cli/common" @@ -72,7 +72,7 @@ func lintDir(c *cli.Context, dir string) error { } func lintFile(_ *cli.Context, file string) error { - output := termenv.NewOutput(os.Stdout) + output := term_env.NewOutput(os.Stdout) fi, err := os.Open(file) if err != nil { diff --git a/cli/output/table.go b/cli/output/table.go index 94e7f37c578..4b7a24e00ba 100644 --- a/cli/output/table.go +++ b/cli/output/table.go @@ -64,7 +64,7 @@ func (o *Table) AddFieldFn(field string, fn FieldFn) *Table { return o } -// AddAllowedFields reads all first level fieldnames of the struct and allows them to be used. +// AddAllowedFields reads all first level field names of the struct and allows them to be used. func (o *Table) AddAllowedFields(obj any) (*Table, error) { v := reflect.ValueOf(obj) if v.Kind() != reflect.Struct { diff --git a/cli/pipeline/pipeline.go b/cli/pipeline/pipeline.go index dbd7edf04e8..f596538cb3b 100644 --- a/cli/pipeline/pipeline.go +++ b/cli/pipeline/pipeline.go @@ -47,7 +47,7 @@ var Command = &cli.Command{ } func pipelineOutput(c *cli.Context, resources []woodpecker.Pipeline, fd ...io.Writer) error { - outfmt, outopt := output.ParseOutputOptions(c.String("output")) + outFmt, outOpt := output.ParseOutputOptions(c.String("output")) noHeader := c.Bool("output-no-headers") var out io.Writer @@ -60,13 +60,13 @@ func pipelineOutput(c *cli.Context, resources []woodpecker.Pipeline, fd ...io.Wr out = os.Stdout } - switch outfmt { + switch outFmt { case "go-template": - if len(outopt) < 1 { + if len(outOpt) < 1 { return fmt.Errorf("%w: missing template", output.ErrOutputOptionRequired) } - tmpl, err := template.New("_").Parse(outopt[0] + "\n") + tmpl, err := template.New("_").Parse(outOpt[0] + "\n") if err != nil { return err } @@ -79,8 +79,8 @@ func pipelineOutput(c *cli.Context, resources []woodpecker.Pipeline, fd ...io.Wr table := output.NewTable(out) cols := []string{"Number", "Status", "Event", "Branch", "Commit", "Author"} - if len(outopt) > 0 { - cols = outopt + if len(outOpt) > 0 { + cols = outOpt } if !noHeader { table.WriteHeader(cols) diff --git a/cli/registry/registry_add.go b/cli/registry/registry_add.go index c4c2e668861..13d6ed25cfb 100644 --- a/cli/registry/registry_add.go +++ b/cli/registry/registry_add.go @@ -73,14 +73,13 @@ func registryCreate(c *cli.Context) error { } if strings.HasPrefix(registry.Password, "@") { path := strings.TrimPrefix(registry.Password, "@") - out, ferr := os.ReadFile(path) - if ferr != nil { - return ferr + out, err := os.ReadFile(path) + if err != nil { + return err } registry.Password = string(out) } - _, err = client.RegistryCreate(repoID, registry) - if err != nil { + if _, err := client.RegistryCreate(repoID, registry); err != nil { return err } return nil diff --git a/cli/registry/registry_set.go b/cli/registry/registry_set.go index 5a4485b459c..48916ddadca 100644 --- a/cli/registry/registry_set.go +++ b/cli/registry/registry_set.go @@ -73,9 +73,9 @@ func registryUpdate(c *cli.Context) error { } if strings.HasPrefix(registry.Password, "@") { path := strings.TrimPrefix(registry.Password, "@") - out, ferr := os.ReadFile(path) - if ferr != nil { - return ferr + out, err := os.ReadFile(path) + if err != nil { + return err } registry.Password = string(out) } diff --git a/cli/update/tar.go b/cli/update/tar.go index 16fe2d0a230..acf1b03e807 100644 --- a/cli/update/tar.go +++ b/cli/update/tar.go @@ -11,7 +11,7 @@ import ( const tarDirectoryMode fs.FileMode = 0x755 -func Untar(dst string, r io.Reader) error { +func UnTar(dst string, r io.Reader) error { gzr, err := gzip.NewReader(r) if err != nil { return err diff --git a/cli/update/updater.go b/cli/update/updater.go index 41d6eb3b8bc..6fd8281d4db 100644 --- a/cli/update/updater.go +++ b/cli/update/updater.go @@ -122,7 +122,7 @@ func extractNewVersion(tarFilePath string) (string, error) { return "", err } - err = Untar(tmpDir, tarFile) + err = UnTar(tmpDir, tarFile) if err != nil { return "", err } diff --git a/cmd/agent/core/agent.go b/cmd/agent/core/agent.go index b378e72a059..1e6c57067ce 100644 --- a/cmd/agent/core/agent.go +++ b/cmd/agent/core/agent.go @@ -31,14 +31,14 @@ import ( "github.com/urfave/cli/v2" "google.golang.org/grpc" "google.golang.org/grpc/codes" - grpccredentials "google.golang.org/grpc/credentials" + grpc_credentials "google.golang.org/grpc/credentials" "google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/keepalive" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" "go.woodpecker-ci.org/woodpecker/v2/agent" - agentRpc "go.woodpecker-ci.org/woodpecker/v2/agent/rpc" + agent_rpc "go.woodpecker-ci.org/woodpecker/v2/agent/rpc" "go.woodpecker-ci.org/woodpecker/v2/pipeline/backend" "go.woodpecker-ci.org/woodpecker/v2/pipeline/backend/types" "go.woodpecker-ci.org/woodpecker/v2/pipeline/rpc" @@ -67,7 +67,7 @@ func run(c *cli.Context, backends []types.Backend) error { var transport grpc.DialOption if c.Bool("grpc-secure") { - transport = grpc.WithTransportCredentials(grpccredentials.NewTLS(&tls.Config{InsecureSkipVerify: c.Bool("grpc-skip-insecure")})) + transport = grpc.WithTransportCredentials(grpc_credentials.NewTLS(&tls.Config{InsecureSkipVerify: c.Bool("grpc-skip-insecure")})) } else { transport = grpc.WithTransportCredentials(insecure.NewCredentials()) } @@ -88,8 +88,8 @@ func run(c *cli.Context, backends []types.Backend) error { agentConfig := readAgentConfig(agentConfigPath) agentToken := c.String("grpc-token") - authClient := agentRpc.NewAuthGrpcClient(authConn, agentToken, agentConfig.AgentID) - authInterceptor, err := agentRpc.NewAuthInterceptor(authClient, 30*time.Minute) //nolint:mnd + authClient := agent_rpc.NewAuthGrpcClient(authConn, agentToken, agentConfig.AgentID) + authInterceptor, err := agent_rpc.NewAuthInterceptor(authClient, 30*time.Minute) //nolint:mnd if err != nil { return err } @@ -109,7 +109,7 @@ func run(c *cli.Context, backends []types.Backend) error { } defer conn.Close() - client := agentRpc.NewGrpcClient(conn) + client := agent_rpc.NewGrpcClient(conn) sigterm := abool.New() ctx := metadata.NewOutgoingContext( @@ -138,12 +138,12 @@ func run(c *cli.Context, backends []types.Backend) error { log.Error().Err(err).Msg("could not get grpc server version") return err } - if grpcServerVersion.GrpcVersion != agentRpc.ClientGrpcVersion { + if grpcServerVersion.GrpcVersion != agent_rpc.ClientGrpcVersion { err := errors.New("GRPC version mismatch") log.Error().Err(err).Msgf("server version %s does report grpc version %d but we only understand %d", grpcServerVersion.ServerVersion, grpcServerVersion.GrpcVersion, - agentRpc.ClientGrpcVersion) + agent_rpc.ClientGrpcVersion) return err } diff --git a/cmd/agent/core/flags.go b/cmd/agent/core/flags.go index efd747f8f60..f0ab7cbcd73 100644 --- a/cmd/agent/core/flags.go +++ b/cmd/agent/core/flags.go @@ -64,7 +64,7 @@ var flags = []cli.Flag{ Usage: "List of labels to filter tasks on. An agent must be assigned every tag listed in a task to be selected.", }, &cli.IntFlag{ - EnvVars: []string{"WOODPECKER_MAX_WORKFLOWS", "WOODPECKER_MAX_PROCS"}, + EnvVars: []string{"WOODPECKER_MAX_WORKFLOWS", "WOODPECKER_MAX_PROCS"}, // cspell:words PROCS Name: "max-workflows", Usage: "agent parallel workflows", Value: 1, diff --git a/cmd/agent/core/health.go b/cmd/agent/core/health.go index 263bd3269d3..73328ec4e3a 100644 --- a/cmd/agent/core/health.go +++ b/cmd/agent/core/health.go @@ -32,8 +32,8 @@ import ( // https://github.com/mozilla-services/Dockerflow func initHealth() { - http.HandleFunc("/varz", handleStats) - http.HandleFunc("/healthz", handleHeartbeat) + http.HandleFunc("/varz", handleStats) // cspell:words varz + http.HandleFunc("/healthz", handleHeartbeat) // cspell:words healthz http.HandleFunc("/version", handleVersion) } diff --git a/pipeline/backend/common/script.go b/pipeline/backend/common/script.go index e335983d9a1..5ad13a47755 100644 --- a/pipeline/backend/common/script.go +++ b/pipeline/backend/common/script.go @@ -24,6 +24,7 @@ func GenerateContainerConf(commands []string, goos string) (env map[string]strin env["CI_SCRIPT"] = base64.StdEncoding.EncodeToString([]byte(generateScriptWindows(commands))) env["HOME"] = "c:\\root" env["SHELL"] = "powershell.exe" + // cspell:disable-next-line entry = []string{"powershell", "-noprofile", "-noninteractive", "-command", "[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($Env:CI_SCRIPT)) | iex"} } else { env["CI_SCRIPT"] = base64.StdEncoding.EncodeToString([]byte(generateScriptPosix(commands))) diff --git a/pipeline/backend/docker/convert.go b/pipeline/backend/docker/convert.go index 4ebbd360efa..a862418ad10 100644 --- a/pipeline/backend/docker/convert.go +++ b/pipeline/backend/docker/convert.go @@ -197,6 +197,7 @@ func encodeAuthToBase64(authConfig types.Auth) (string, error) { // // It handles Windows and Linux style volume paths. func splitVolumeParts(volumeParts string) ([]string, error) { + // cspell:disable-next-line pattern := `^((?:[\w]\:)?[^\:]*)\:((?:[\w]\:)?[^\:]*)(?:\:([rwom]*))?` r, err := regexp.Compile(pattern) if err != nil { diff --git a/pipeline/backend/docker/docker.go b/pipeline/backend/docker/docker.go index 2c7a0e83509..dc4cc287ccb 100644 --- a/pipeline/backend/docker/docker.go +++ b/pipeline/backend/docker/docker.go @@ -25,10 +25,10 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/volume" - "github.com/docker/go-connections/tlsconfig" + tls_config "github.com/docker/go-connections/tlsconfig" "github.com/moby/moby/client" - "github.com/moby/moby/pkg/jsonmessage" - "github.com/moby/moby/pkg/stdcopy" + json_message "github.com/moby/moby/pkg/jsonmessage" + std_copy "github.com/moby/moby/pkg/stdcopy" "github.com/moby/term" "github.com/rs/zerolog/log" "github.com/urfave/cli/v2" @@ -75,13 +75,13 @@ func httpClientOfOpts(dockerCertPath string, verifyTLS bool) *http.Client { return nil } - options := tlsconfig.Options{ + options := tls_config.Options{ CAFile: filepath.Join(dockerCertPath, "ca.pem"), CertFile: filepath.Join(dockerCertPath, "cert.pem"), KeyFile: filepath.Join(dockerCertPath, "key.pem"), InsecureSkipVerify: !verifyTLS, } - tlsConf, err := tlsconfig.Client(options) + tlsConf, err := tls_config.Client(options) if err != nil { log.Error().Err(err).Msg("could not create http client out of docker backend options") return nil @@ -188,27 +188,27 @@ func (e *docker) StartStep(ctx context.Context, step *backend.Step, taskUUID str containerName := toContainerName(step) // create pull options with encoded authorization credentials. - pullopts := types.ImagePullOptions{} + pullOpts := types.ImagePullOptions{} if step.AuthConfig.Username != "" && step.AuthConfig.Password != "" { - pullopts.RegistryAuth, _ = encodeAuthToBase64(step.AuthConfig) + pullOpts.RegistryAuth, _ = encodeAuthToBase64(step.AuthConfig) } // automatically pull the latest version of the image if requested // by the process configuration. if step.Pull { - responseBody, perr := e.client.ImagePull(ctx, config.Image, pullopts) - if perr == nil { + responseBody, pErr := e.client.ImagePull(ctx, config.Image, pullOpts) + if pErr == nil { // TODO(1936): show image pull progress in web-ui fd, isTerminal := term.GetFdInfo(os.Stdout) - if err := jsonmessage.DisplayJSONMessagesStream(responseBody, os.Stdout, fd, isTerminal, nil); err != nil { + if err := json_message.DisplayJSONMessagesStream(responseBody, os.Stdout, fd, isTerminal, nil); err != nil { log.Error().Err(err).Msg("DisplayJSONMessagesStream") } responseBody.Close() } // Fix "Show warning when fail to auth to docker registry" // (https://web.archive.org/web/20201023145804/https://github.com/drone/drone/issues/1917) - if perr != nil && step.AuthConfig.Password != "" { - return perr + if pErr != nil && step.AuthConfig.Password != "" { + return pErr } } @@ -219,13 +219,13 @@ func (e *docker) StartStep(ctx context.Context, step *backend.Step, taskUUID str if client.IsErrNotFound(err) { // automatically pull and try to re-create the image if the // failure is caused because the image does not exist. - responseBody, perr := e.client.ImagePull(ctx, config.Image, pullopts) - if perr != nil { - return perr + responseBody, pErr := e.client.ImagePull(ctx, config.Image, pullOpts) + if pErr != nil { + return pErr } // TODO(1936): show image pull progress in web-ui fd, isTerminal := term.GetFdInfo(os.Stdout) - if err := jsonmessage.DisplayJSONMessagesStream(responseBody, os.Stdout, fd, isTerminal, nil); err != nil { + if err := json_message.DisplayJSONMessagesStream(responseBody, os.Stdout, fd, isTerminal, nil); err != nil { log.Error().Err(err).Msg("DisplayJSONMessagesStream") } responseBody.Close() @@ -263,10 +263,10 @@ func (e *docker) WaitStep(ctx context.Context, step *backend.Step, taskUUID stri containerName := toContainerName(step) - wait, errc := e.client.ContainerWait(ctx, containerName, "") + wait, errC := e.client.ContainerWait(ctx, containerName, "") select { case <-wait: - case <-errc: + case <-errC: } info, err := e.client.ContainerInspect(ctx, containerName) @@ -292,7 +292,7 @@ func (e *docker) TailStep(ctx context.Context, step *backend.Step, taskUUID stri // de multiplex 'logs' who contains two streams, previously multiplexed together using StdWriter go func() { - _, _ = stdcopy.StdCopy(wc, wc, logs) + _, _ = std_copy.StdCopy(wc, wc, logs) _ = logs.Close() _ = wc.Close() }() diff --git a/pipeline/backend/kubernetes/flags.go b/pipeline/backend/kubernetes/flags.go index 347d0bd6459..10ecd40172b 100644 --- a/pipeline/backend/kubernetes/flags.go +++ b/pipeline/backend/kubernetes/flags.go @@ -68,7 +68,7 @@ var Flags = []cli.Flag{ Value: false, }, &cli.BoolFlag{ - EnvVars: []string{"WOODPECKER_BACKEND_K8S_SECCTX_NONROOT"}, + EnvVars: []string{"WOODPECKER_BACKEND_K8S_SECCTX_NONROOT"}, // cspell:words secctx nonroot Name: "backend-k8s-secctx-nonroot", Usage: "`run as non root` Kubernetes security context option", }, diff --git a/pipeline/backend/kubernetes/kubernetes.go b/pipeline/backend/kubernetes/kubernetes.go index 07014aef0cc..a12f00b7165 100644 --- a/pipeline/backend/kubernetes/kubernetes.go +++ b/pipeline/backend/kubernetes/kubernetes.go @@ -28,7 +28,7 @@ import ( "github.com/urfave/cli/v2" "gopkg.in/yaml.v3" v1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/informers" "k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes/scheme" @@ -69,11 +69,11 @@ type SecurityContextConfig struct { RunAsNonRoot bool } -func newDefaultDeleteOptions() metav1.DeleteOptions { +func newDefaultDeleteOptions() meta_v1.DeleteOptions { gracePeriodSeconds := int64(0) // immediately - propagationPolicy := metav1.DeletePropagationBackground + propagationPolicy := meta_v1.DeletePropagationBackground - return metav1.DeleteOptions{ + return meta_v1.DeleteOptions{ GracePeriodSeconds: &gracePeriodSeconds, PropagationPolicy: &propagationPolicy, } @@ -93,7 +93,7 @@ func configFromCliContext(ctx context.Context) (*config, error) { PodAnnotationsAllowFromStep: c.Bool("backend-k8s-pod-annotations-allow-from-step"), ImagePullSecretNames: c.StringSlice("backend-k8s-pod-image-pull-secret-names"), SecurityContext: SecurityContextConfig{ - RunAsNonRoot: c.Bool("backend-k8s-secctx-nonroot"), + RunAsNonRoot: c.Bool("backend-k8s-secctx-nonroot"), // cspell:words secctx nonroot }, } // TODO: remove in next major @@ -270,7 +270,7 @@ func (e *kube) WaitStep(ctx context.Context, step *types.Step, taskUUID string) // TODO: Cancel on ctx.Done <-finished - pod, err := e.client.CoreV1().Pods(e.config.Namespace).Get(ctx, podName, metav1.GetOptions{}) + pod, err := e.client.CoreV1().Pods(e.config.Namespace).Get(ctx, podName, meta_v1.GetOptions{}) if err != nil { return nil, err } diff --git a/pipeline/backend/kubernetes/pod.go b/pipeline/backend/kubernetes/pod.go index 3e6b89872a5..99d13b7c98b 100644 --- a/pipeline/backend/kubernetes/pod.go +++ b/pipeline/backend/kubernetes/pod.go @@ -24,7 +24,7 @@ import ( v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/resource" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "go.woodpecker-ci.org/woodpecker/v2/pipeline/backend/common" "go.woodpecker-ci.org/woodpecker/v2/pipeline/backend/types" @@ -73,9 +73,9 @@ func podName(step *types.Step) (string, error) { return dnsName(podPrefix + step.UUID) } -func podMeta(step *types.Step, config *config, options BackendOptions, podName string) (metav1.ObjectMeta, error) { +func podMeta(step *types.Step, config *config, options BackendOptions, podName string) (meta_v1.ObjectMeta, error) { var err error - meta := metav1.ObjectMeta{ + meta := meta_v1.ObjectMeta{ Name: podName, Namespace: config.Namespace, Annotations: podAnnotations(config, options, podName), @@ -509,10 +509,10 @@ func startPod(ctx context.Context, engine *kube, step *types.Step, options Backe } log.Trace().Msgf("creating pod: %s", pod.Name) - return engine.client.CoreV1().Pods(engineConfig.Namespace).Create(ctx, pod, metav1.CreateOptions{}) + return engine.client.CoreV1().Pods(engineConfig.Namespace).Create(ctx, pod, meta_v1.CreateOptions{}) } -func stopPod(ctx context.Context, engine *kube, step *types.Step, deleteOpts metav1.DeleteOptions) error { +func stopPod(ctx context.Context, engine *kube, step *types.Step, deleteOpts meta_v1.DeleteOptions) error { podName, err := stepToPodName(step) if err != nil { return err diff --git a/pipeline/backend/kubernetes/service.go b/pipeline/backend/kubernetes/service.go index 48c8d3fdcb4..e187aa4bc9c 100644 --- a/pipeline/backend/kubernetes/service.go +++ b/pipeline/backend/kubernetes/service.go @@ -22,8 +22,8 @@ import ( "github.com/rs/zerolog/log" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/intstr" + meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + int_str "k8s.io/apimachinery/pkg/util/intstr" "go.woodpecker-ci.org/woodpecker/v2/pipeline/backend/types" ) @@ -50,7 +50,7 @@ func mkService(step *types.Step, config *config) (*v1.Service, error) { log.Trace().Str("name", name).Interface("selector", selector).Interface("ports", svcPorts).Msg("creating service") return &v1.Service{ - ObjectMeta: metav1.ObjectMeta{ + ObjectMeta: meta_v1.ObjectMeta{ Name: name, Namespace: config.Namespace, }, @@ -73,7 +73,7 @@ func servicePort(port types.Port) v1.ServicePort { Name: fmt.Sprintf("port-%d", portNumber), Port: portNumber, Protocol: v1.Protocol(portProtocol), - TargetPort: intstr.IntOrString{IntVal: portNumber}, + TargetPort: int_str.IntOrString{IntVal: portNumber}, } } @@ -85,10 +85,10 @@ func startService(ctx context.Context, engine *kube, step *types.Step) (*v1.Serv } log.Trace().Str("name", svc.Name).Interface("selector", svc.Spec.Selector).Interface("ports", svc.Spec.Ports).Msg("creating service") - return engine.client.CoreV1().Services(engineConfig.Namespace).Create(ctx, svc, metav1.CreateOptions{}) + return engine.client.CoreV1().Services(engineConfig.Namespace).Create(ctx, svc, meta_v1.CreateOptions{}) } -func stopService(ctx context.Context, engine *kube, step *types.Step, deleteOpts metav1.DeleteOptions) error { +func stopService(ctx context.Context, engine *kube, step *types.Step, deleteOpts meta_v1.DeleteOptions) error { svcName, err := serviceName(step) if err != nil { return err diff --git a/pipeline/backend/kubernetes/utils.go b/pipeline/backend/kubernetes/utils.go index 39606bd758c..1393c423b7c 100644 --- a/pipeline/backend/kubernetes/utils.go +++ b/pipeline/backend/kubernetes/utils.go @@ -23,7 +23,7 @@ import ( v1 "k8s.io/api/core/v1" "k8s.io/client-go/kubernetes" "k8s.io/client-go/rest" - "k8s.io/client-go/tools/clientcmd" + client_cmd "k8s.io/client-go/tools/clientcmd" ) var ( @@ -65,15 +65,15 @@ func isImagePullBackOffState(pod *v1.Pod) bool { return false } -// getClientOutOfCluster returns a k8s clientset to the request from outside of cluster. +// getClientOutOfCluster returns a k8s client set to the request from outside of cluster. func getClientOutOfCluster() (kubernetes.Interface, error) { - kubeConfigPath := os.Getenv("KUBECONFIG") + kubeConfigPath := os.Getenv("KUBECONFIG") // cspell:words KUBECONFIG if kubeConfigPath == "" { kubeConfigPath = os.Getenv("HOME") + "/.kube/config" } - // use the current context in kubeconfig - config, err := clientcmd.BuildConfigFromFlags("", kubeConfigPath) + // use the current context in kube config + config, err := client_cmd.BuildConfigFromFlags("", kubeConfigPath) if err != nil { return nil, err } @@ -81,7 +81,7 @@ func getClientOutOfCluster() (kubernetes.Interface, error) { return kubernetes.NewForConfig(config) } -// getClient returns a k8s clientset to the request from inside of cluster. +// getClient returns a k8s client set to the request from inside of cluster. func getClientInsideOfCluster() (kubernetes.Interface, error) { config, err := rest.InClusterConfig() if err != nil { diff --git a/pipeline/backend/kubernetes/volume.go b/pipeline/backend/kubernetes/volume.go index ab086917965..408c4c18ccf 100644 --- a/pipeline/backend/kubernetes/volume.go +++ b/pipeline/backend/kubernetes/volume.go @@ -22,7 +22,7 @@ import ( v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/resource" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) func mkPersistentVolumeClaim(config *config, name string) (*v1.PersistentVolumeClaim, error) { @@ -45,7 +45,7 @@ func mkPersistentVolumeClaim(config *config, name string) (*v1.PersistentVolumeC } pvc := &v1.PersistentVolumeClaim{ - ObjectMeta: metav1.ObjectMeta{ + ObjectMeta: meta_v1.ObjectMeta{ Name: volumeName, Namespace: config.Namespace, }, @@ -83,10 +83,10 @@ func startVolume(ctx context.Context, engine *kube, name string) (*v1.Persistent } log.Trace().Msgf("creating volume: %s", pvc.Name) - return engine.client.CoreV1().PersistentVolumeClaims(engineConfig.Namespace).Create(ctx, pvc, metav1.CreateOptions{}) + return engine.client.CoreV1().PersistentVolumeClaims(engineConfig.Namespace).Create(ctx, pvc, meta_v1.CreateOptions{}) } -func stopVolume(ctx context.Context, engine *kube, name string, deleteOpts metav1.DeleteOptions) error { +func stopVolume(ctx context.Context, engine *kube, name string, deleteOpts meta_v1.DeleteOptions) error { pvcName, err := volumeName(name) if err != nil { return err diff --git a/pipeline/backend/local/command.go b/pipeline/backend/local/command.go index 52187ff9177..e36fe2451c7 100644 --- a/pipeline/backend/local/command.go +++ b/pipeline/backend/local/command.go @@ -24,9 +24,9 @@ import ( "github.com/alessio/shellescape" ) -func (e *local) genCmdByShell(shell string, cmds []string) (args []string, err error) { +func (e *local) genCmdByShell(shell string, cmdList []string) (args []string, err error) { script := "" - for _, cmd := range cmds { + for _, cmd := range cmdList { script += fmt.Sprintf("echo %s\n%s\n", strings.TrimSpace(shellescape.Quote("+ "+cmd)), cmd) } script = strings.TrimSpace(script) @@ -34,7 +34,7 @@ func (e *local) genCmdByShell(shell string, cmds []string) (args []string, err e switch strings.TrimSuffix(strings.ToLower(shell), ".exe") { case "cmd": script := "@SET PROMPT=$\n" - for _, cmd := range cmds { + for _, cmd := range cmdList { script += fmt.Sprintf("@echo + %s\n", strings.TrimSpace(shellescape.Quote(cmd))) script += fmt.Sprintf("@%s\n", cmd) script += "@IF NOT %ERRORLEVEL% == 0 exit %ERRORLEVEL%\n" @@ -50,11 +50,12 @@ func (e *local) genCmdByShell(shell string, cmds []string) (args []string, err e return []string{"/c", cmd.Name()}, nil case "fish": script := "" - for _, cmd := range cmds { + for _, cmd := range cmdList { script += fmt.Sprintf("echo %s\n%s || exit $status\n", strings.TrimSpace(shellescape.Quote("+ "+cmd)), cmd) } return []string{"-c", script}, nil case "powershell", "pwsh": + // cspell:disable-next-line return []string{"-noprofile", "-noninteractive", "-c", "$ErrorActionPreference = \"Stop\"; " + script}, nil default: // normal posix shells diff --git a/pipeline/frontend/yaml/compiler/option.go b/pipeline/frontend/yaml/compiler/option.go index c9194be627f..d222ffaa905 100644 --- a/pipeline/frontend/yaml/compiler/option.go +++ b/pipeline/frontend/yaml/compiler/option.go @@ -159,12 +159,12 @@ func WithNetworks(networks ...string) Option { // WithResourceLimit configures the compiler with default resource limits that // are applied each container in the pipeline. -func WithResourceLimit(swap, mem, shmsize, cpuQuota, cpuShares int64, cpuSet string) Option { +func WithResourceLimit(swap, mem, shmSize, cpuQuota, cpuShares int64, cpuSet string) Option { return func(compiler *Compiler) { compiler.reslimit = ResourceLimit{ MemSwapLimit: swap, MemLimit: mem, - ShmSize: shmsize, + ShmSize: shmSize, CPUQuota: cpuQuota, CPUShares: cpuShares, CPUSet: cpuSet, diff --git a/pipeline/frontend/yaml/constraint/constraint.go b/pipeline/frontend/yaml/constraint/constraint.go index 736f571ba5d..48145266f94 100644 --- a/pipeline/frontend/yaml/constraint/constraint.go +++ b/pipeline/frontend/yaml/constraint/constraint.go @@ -197,11 +197,11 @@ func (c *Constraint) Match(m metadata.Metadata, global bool, env map[string]stri if err != nil { return false, err } - bresult, ok := result.(bool) + bResult, ok := result.(bool) if !ok { return false, fmt.Errorf("could not parse result: %v", result) } - match = match && bresult + match = match && bResult } return match, nil @@ -247,7 +247,7 @@ func (c *List) Excludes(v string) bool { return false } -// UnmarshalYAML unmarshals the constraint. +// UnmarshalYAML unmarshal the constraint. func (c *List) UnmarshalYAML(value *yaml.Node) error { out1 := struct { Include yamlBaseTypes.StringOrSlice diff --git a/pipeline/frontend/yaml/linter/schema/schema.go b/pipeline/frontend/yaml/linter/schema/schema.go index 4666faa7ef4..65baad3144c 100644 --- a/pipeline/frontend/yaml/linter/schema/schema.go +++ b/pipeline/frontend/yaml/linter/schema/schema.go @@ -22,7 +22,7 @@ import ( "codeberg.org/6543/go-yaml2json" "codeberg.org/6543/xyaml" - "github.com/xeipuuv/gojsonschema" + json_schema "github.com/xeipuuv/gojsonschema" "gopkg.in/yaml.v3" ) @@ -30,8 +30,8 @@ import ( var schemaDefinition []byte // Lint lints an io.Reader against the Woodpecker `schema.json`. -func Lint(r io.Reader) ([]gojsonschema.ResultError, error) { - schemaLoader := gojsonschema.NewBytesLoader(schemaDefinition) +func Lint(r io.Reader) ([]json_schema.ResultError, error) { + schemaLoader := json_schema.NewBytesLoader(schemaDefinition) // read yaml config rBytes, err := io.ReadAll(r) @@ -51,8 +51,8 @@ func Lint(r io.Reader) ([]gojsonschema.ResultError, error) { return nil, fmt.Errorf("failed to convert yaml %w", err) } - documentLoader := gojsonschema.NewBytesLoader(jsonDoc) - result, err := gojsonschema.Validate(schemaLoader, documentLoader) + documentLoader := json_schema.NewBytesLoader(jsonDoc) + result, err := json_schema.Validate(schemaLoader, documentLoader) if err != nil { return nil, fmt.Errorf("validation failed %w", err) } @@ -64,6 +64,6 @@ func Lint(r io.Reader) ([]gojsonschema.ResultError, error) { return nil, nil } -func LintString(s string) ([]gojsonschema.ResultError, error) { +func LintString(s string) ([]json_schema.ResultError, error) { return Lint(bytes.NewBufferString(s)) } diff --git a/pipeline/frontend/yaml/matrix/matrix.go b/pipeline/frontend/yaml/matrix/matrix.go index 373c7bec93c..55855513d23 100644 --- a/pipeline/frontend/yaml/matrix/matrix.go +++ b/pipeline/frontend/yaml/matrix/matrix.go @@ -86,11 +86,11 @@ func calc(matrix Matrix) []Axis { // for each axis calculate the unique set of values that should be used. for p := 0; p < perm; p++ { axis := map[string]string{} - decr := perm + decrease := perm for i, tag := range tags { elems := matrix[tag] - decr /= len(elems) - elem := p / decr % len(elems) + decrease /= len(elems) + elem := p / decrease % len(elems) axis[tag] = elems[elem] // enforce a maximum number of tags in the pipeline matrix. diff --git a/pipeline/frontend/yaml/types/base/bool.go b/pipeline/frontend/yaml/types/base/bool.go index 32664553f5e..d60df7c51d9 100644 --- a/pipeline/frontend/yaml/types/base/bool.go +++ b/pipeline/frontend/yaml/types/base/bool.go @@ -25,7 +25,7 @@ type BoolTrue struct { value bool } -// UnmarshalYAML implements custom Yaml unmarshaling. +// UnmarshalYAML implements custom Yaml unmarshal. func (b *BoolTrue) UnmarshalYAML(value *yaml.Node) error { var s string if err := value.Decode(&s); err != nil { diff --git a/pipeline/frontend/yaml/types/volume.go b/pipeline/frontend/yaml/types/volume.go index 90d011b85fa..8a2d870cc3c 100644 --- a/pipeline/frontend/yaml/types/volume.go +++ b/pipeline/frontend/yaml/types/volume.go @@ -66,24 +66,24 @@ func (v *Volumes) UnmarshalYAML(unmarshal func(any) error) error { if !ok { return fmt.Errorf("cannot unmarshal '%v' to type %T into a string value", name, name) } - elts := strings.SplitN(name, ":", 3) + elements := strings.SplitN(name, ":", 3) var vol *Volume //nolint:mnd switch { - case len(elts) == 1: + case len(elements) == 1: vol = &Volume{ - Destination: elts[0], + Destination: elements[0], } - case len(elts) == 2: + case len(elements) == 2: vol = &Volume{ - Source: elts[0], - Destination: elts[1], + Source: elements[0], + Destination: elements[1], } - case len(elts) == 3: + case len(elements) == 3: vol = &Volume{ - Source: elts[0], - Destination: elts[1], - AccessMode: elts[2], + Source: elements[0], + Destination: elements[1], + AccessMode: elements[2], } default: // FIXME diff --git a/pipeline/rpc/proto/woodpecker.proto b/pipeline/rpc/proto/woodpecker.proto index 82191a6bc10..8c5120a6975 100644 --- a/pipeline/rpc/proto/woodpecker.proto +++ b/pipeline/rpc/proto/woodpecker.proto @@ -134,7 +134,7 @@ message RegisterAgentResponse { int64 agent_id = 1; } -// Woodpecker auth service is a simple service to authenticate agents and aquire a token +// Woodpecker auth service is a simple service to authenticate agents and acquire a token service WoodpeckerAuth { rpc Auth (AuthRequest) returns (AuthResponse) {} diff --git a/pipeline/shared/replace_secrets.go b/pipeline/shared/replace_secrets.go index 2232538002f..c259d154d2a 100644 --- a/pipeline/shared/replace_secrets.go +++ b/pipeline/shared/replace_secrets.go @@ -22,7 +22,7 @@ import "strings" // secrets with asterisks. Each secret string is split on newlines to // handle multi-line secrets. func NewSecretsReplacer(secrets []string) *strings.Replacer { - var oldnew []string + var oldNew []string // Strings shorter than minStringLength are not considered secrets. // Do not sanitize them. @@ -38,10 +38,10 @@ func NewSecretsReplacer(secrets []string) *strings.Replacer { if len(part) == 0 { continue } - oldnew = append(oldnew, part) - oldnew = append(oldnew, "********") + oldNew = append(oldNew, part) + oldNew = append(oldNew, "********") } } - return strings.NewReplacer(oldnew...) + return strings.NewReplacer(oldNew...) } diff --git a/server/router/router.go b/server/router/router.go index 0fcf47f46d1..317f0975d27 100644 --- a/server/router/router.go +++ b/server/router/router.go @@ -20,7 +20,7 @@ import ( "github.com/gin-gonic/gin" "github.com/rs/zerolog/log" - swaggerfiles "github.com/swaggo/files" + swagger_files "github.com/swaggo/files" ginSwagger "github.com/swaggo/gin-swagger" "go.woodpecker-ci.org/woodpecker/v2/cmd/server/docs" @@ -82,7 +82,7 @@ func Load(noRouteHandler http.HandlerFunc, middleware ...gin.HandlerFunc) http.H func setupSwaggerConfigAndRoutes(e *gin.Engine) { docs.SwaggerInfo.Host = getHost(server.Config.Server.Host) docs.SwaggerInfo.BasePath = server.Config.Server.RootPath + "/api" - e.GET(server.Config.Server.RootPath+"/swagger/*any", ginSwagger.WrapHandler(swaggerfiles.Handler)) + e.GET(server.Config.Server.RootPath+"/swagger/*any", ginSwagger.WrapHandler(swagger_files.Handler)) } func getHost(s string) string { diff --git a/server/services/config/http.go b/server/services/config/http.go index 59e9a4df863..cb4138ac699 100644 --- a/server/services/config/http.go +++ b/server/services/config/http.go @@ -80,10 +80,10 @@ func (h *http) Fetch(ctx context.Context, forge forge.Forge, user *model.User, r return oldConfigData, nil } - fileMetas := make([]*types.FileMeta, len(response.Configs)) + fileMetaList := make([]*types.FileMeta, len(response.Configs)) for i, config := range response.Configs { - fileMetas[i] = &types.FileMeta{Name: config.Name, Data: []byte(config.Data)} + fileMetaList[i] = &types.FileMeta{Name: config.Name, Data: []byte(config.Data)} } - return fileMetas, nil + return fileMetaList, nil } diff --git a/server/services/manager.go b/server/services/manager.go index ce0b97c1be3..079222a02d8 100644 --- a/server/services/manager.go +++ b/server/services/manager.go @@ -111,7 +111,7 @@ func (m *manager) RegistryService() registry.Service { } func (m *manager) ConfigServiceFromRepo(_ *model.Repo) config.Service { - // TODO: decied based on repo property which config service to use + // TODO: decide based on repo property which config service to use return m.config }