mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-25 11:21:02 +00:00
cspell lint go code (#3706)
This commit is contained in:
parent
4628a97c93
commit
42f2734308
44 changed files with 214 additions and 161 deletions
63
.cspell.json
63
.cspell.json
|
@ -1,7 +1,17 @@
|
||||||
{
|
{
|
||||||
"version": "0.2",
|
"version": "0.2",
|
||||||
"language": "en",
|
"language": "en",
|
||||||
|
"dictionaries": [
|
||||||
|
// language
|
||||||
|
"en_us",
|
||||||
|
// code
|
||||||
|
"go",
|
||||||
|
"node",
|
||||||
|
// package names
|
||||||
|
"npm"
|
||||||
|
],
|
||||||
"words": [
|
"words": [
|
||||||
|
"abool",
|
||||||
"BUILDPLATFORM",
|
"BUILDPLATFORM",
|
||||||
"Codeberg",
|
"Codeberg",
|
||||||
"Curr",
|
"Curr",
|
||||||
|
@ -21,35 +31,40 @@
|
||||||
"Ionescu",
|
"Ionescu",
|
||||||
"Kaniko",
|
"Kaniko",
|
||||||
"Keyfunc",
|
"Keyfunc",
|
||||||
|
"LASTEXITCODE",
|
||||||
"Laszlo",
|
"Laszlo",
|
||||||
"Msgf",
|
"Msgf",
|
||||||
"Netrc",
|
"Netrc",
|
||||||
"PROTOC",
|
"PROTOC",
|
||||||
"Pinia",
|
"Pinia",
|
||||||
"Println",
|
"Println",
|
||||||
|
"pwsh",
|
||||||
"Refspec",
|
"Refspec",
|
||||||
"Reviewdog",
|
"Reviewdog",
|
||||||
"Rydzewski",
|
"Rydzewski",
|
||||||
|
"SSHURL",
|
||||||
"TARGETARCH",
|
"TARGETARCH",
|
||||||
"TARGETOS",
|
"TARGETOS",
|
||||||
|
"Typeflag",
|
||||||
"Upsert",
|
"Upsert",
|
||||||
"WORKDIR",
|
"WORKDIR",
|
||||||
"Warnf",
|
"Warnf",
|
||||||
"Weblate",
|
"Weblate",
|
||||||
"Wrapf",
|
"Wrapf",
|
||||||
"anbraten",
|
"anbraten",
|
||||||
|
"apimachinery",
|
||||||
"autoincr",
|
"autoincr",
|
||||||
"autoscaler",
|
"autoscaler",
|
||||||
"binutils",
|
"binutils",
|
||||||
"bitbucketdatacenter",
|
"bitbucketdatacenter",
|
||||||
"bradrydzewski",
|
"bradrydzewski",
|
||||||
"brightbox",
|
|
||||||
"buildx",
|
"buildx",
|
||||||
"ccmenu",
|
"ccmenu",
|
||||||
"charmbracelet",
|
"charmbracelet",
|
||||||
"ciphertext",
|
"ciphertext",
|
||||||
"compatiblelicenses",
|
"compatiblelicenses",
|
||||||
"corepack",
|
"corepack",
|
||||||
|
"cpuset",
|
||||||
"creativecommons",
|
"creativecommons",
|
||||||
"datacenter",
|
"datacenter",
|
||||||
"desaturate",
|
"desaturate",
|
||||||
|
@ -57,11 +72,14 @@
|
||||||
"doublestar",
|
"doublestar",
|
||||||
"envsubst",
|
"envsubst",
|
||||||
"estree",
|
"estree",
|
||||||
|
"errgroup",
|
||||||
"evenodd",
|
"evenodd",
|
||||||
"excalidraw",
|
"excalidraw",
|
||||||
"favicons",
|
"favicons",
|
||||||
|
"forbidigo",
|
||||||
"fsnotify",
|
"fsnotify",
|
||||||
"gitea",
|
"gitea",
|
||||||
|
"gocritic",
|
||||||
"golangci",
|
"golangci",
|
||||||
"gomod",
|
"gomod",
|
||||||
"gonic",
|
"gonic",
|
||||||
|
@ -73,7 +91,10 @@
|
||||||
"laszlocph",
|
"laszlocph",
|
||||||
"logfile",
|
"logfile",
|
||||||
"loglevel",
|
"loglevel",
|
||||||
|
"mapstructure",
|
||||||
"markdownlint",
|
"markdownlint",
|
||||||
|
"memswap",
|
||||||
|
"moby",
|
||||||
"multiarch",
|
"multiarch",
|
||||||
"multierr",
|
"multierr",
|
||||||
"netdns",
|
"netdns",
|
||||||
|
@ -86,24 +107,37 @@
|
||||||
"ppid",
|
"ppid",
|
||||||
"prismjs",
|
"prismjs",
|
||||||
"proto",
|
"proto",
|
||||||
|
"protobuf",
|
||||||
"protoc",
|
"protoc",
|
||||||
|
"protoimpl",
|
||||||
|
"protoreflect",
|
||||||
"rawurl",
|
"rawurl",
|
||||||
|
"regcred",
|
||||||
"repology",
|
"repology",
|
||||||
|
"reslimit",
|
||||||
|
"riscv",
|
||||||
|
"rundll32",
|
||||||
|
"seccomp",
|
||||||
|
"secprofile",
|
||||||
"securecookie",
|
"securecookie",
|
||||||
"sess",
|
"sess",
|
||||||
|
"shellescape",
|
||||||
"stepbuilder",
|
"stepbuilder",
|
||||||
"stretchr",
|
"stretchr",
|
||||||
"sublicensable",
|
"sublicensable",
|
||||||
|
"swaggo",
|
||||||
"techknowlogick",
|
"techknowlogick",
|
||||||
"testdata",
|
"testdata",
|
||||||
"tink",
|
"tink",
|
||||||
"tinycolor",
|
"tinycolor",
|
||||||
|
"tmpfs",
|
||||||
|
"tmpl",
|
||||||
|
"tolerations",
|
||||||
|
"ttlcache",
|
||||||
"typecheck",
|
"typecheck",
|
||||||
"unplugin",
|
"unplugin",
|
||||||
"urfave",
|
"urfave",
|
||||||
"varchar",
|
"varchar",
|
||||||
"vite",
|
|
||||||
"vitejs",
|
|
||||||
"vueuse",
|
"vueuse",
|
||||||
"waivable",
|
"waivable",
|
||||||
"windi",
|
"windi",
|
||||||
|
@ -112,6 +146,7 @@
|
||||||
"xlog",
|
"xlog",
|
||||||
"xorm",
|
"xorm",
|
||||||
"xormigrate",
|
"xormigrate",
|
||||||
|
"xyaml",
|
||||||
"zerolog",
|
"zerolog",
|
||||||
"zerologger"
|
"zerologger"
|
||||||
],
|
],
|
||||||
|
@ -119,6 +154,7 @@
|
||||||
"**/node_modules/**/*",
|
"**/node_modules/**/*",
|
||||||
"*.excalidraw",
|
"*.excalidraw",
|
||||||
"*.svg",
|
"*.svg",
|
||||||
|
"*_test.go",
|
||||||
".cspell.json",
|
".cspell.json",
|
||||||
".git/**/*",
|
".git/**/*",
|
||||||
".gitignore",
|
".gitignore",
|
||||||
|
@ -130,18 +166,29 @@
|
||||||
"flake.nix",
|
"flake.nix",
|
||||||
"go.mod",
|
"go.mod",
|
||||||
"go.sum",
|
"go.sum",
|
||||||
|
"pipeline/rpc/proto/woodpecker.pb.go",
|
||||||
"pnpm-lock.yaml",
|
"pnpm-lock.yaml",
|
||||||
"server/store/datastore/migration/**/*",
|
"server/store/datastore/migration/**/*",
|
||||||
"web/components.d.ts",
|
"web/components.d.ts",
|
||||||
"web/src/assets/locales/**/*",
|
"web/src/assets/locales/**/*",
|
||||||
|
"**/fixtures/**",
|
||||||
|
"**/testdata/**",
|
||||||
// TODO: remove the following
|
// TODO: remove the following
|
||||||
".woodpecker/",
|
|
||||||
"agent/",
|
|
||||||
"cli/",
|
|
||||||
"cmd/",
|
|
||||||
"docs/",
|
"docs/",
|
||||||
"pipeline/",
|
|
||||||
"server/"
|
"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"]
|
"enableFiletypes": ["dockercompose"]
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,8 @@ variables:
|
||||||
- &node_image 'docker.io/node:22-alpine'
|
- &node_image 'docker.io/node:22-alpine'
|
||||||
- &xgo_image 'docker.io/techknowlogick/xgo:go-1.22.x'
|
- &xgo_image 'docker.io/techknowlogick/xgo:go-1.22.x'
|
||||||
|
|
||||||
|
# cspell:words bindata netgo TARGZ
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
build-web:
|
build-web:
|
||||||
image: *node_image
|
image: *node_image
|
||||||
|
|
|
@ -9,6 +9,8 @@ variables:
|
||||||
- &platforms_alpine 'linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/amd64,linux/ppc64le'
|
- &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}'
|
- &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
|
# vars used on push / tag events only
|
||||||
- publish_logins: &publish_logins # Default DockerHub login
|
- publish_logins: &publish_logins # Default DockerHub login
|
||||||
- registry: https://index.docker.io/v1/
|
- registry: https://index.docker.io/v1/
|
||||||
|
@ -96,7 +98,7 @@ steps:
|
||||||
- make cross-compile-server
|
- make cross-compile-server
|
||||||
environment:
|
environment:
|
||||||
PLATFORMS: linux|amd64
|
PLATFORMS: linux|amd64
|
||||||
TAGS: bindata sqlite sqlite_unlock_notify netgo
|
TAGS: sqlite sqlite_unlock_notify netgo
|
||||||
when:
|
when:
|
||||||
- event: pull_request
|
- event: pull_request
|
||||||
evaluate: 'CI_COMMIT_PULL_REQUEST_LABELS contains "build_pr_images"'
|
evaluate: 'CI_COMMIT_PULL_REQUEST_LABELS contains "build_pr_images"'
|
||||||
|
@ -118,7 +120,7 @@ steps:
|
||||||
- make cross-compile-server
|
- make cross-compile-server
|
||||||
environment:
|
environment:
|
||||||
PLATFORMS: linux|arm/v7;linux|arm64/v8;linux|amd64;linux|ppc64le;linux|riscv64
|
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:
|
when:
|
||||||
branch:
|
branch:
|
||||||
- ${CI_REPO_DEFAULT_BRANCH}
|
- ${CI_REPO_DEFAULT_BRANCH}
|
||||||
|
|
|
@ -6,8 +6,7 @@ when:
|
||||||
- renovate/*
|
- renovate/*
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
- &trivy_image aquasec/trivy:0.46.1
|
- &trivy_plugin docker.io/woodpeckerci/plugin-trivy:1.0.1
|
||||||
- &trivy_plugin woodpeckerci/plugin-trivy:1.0.1
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
backend:
|
backend:
|
||||||
|
@ -22,7 +21,7 @@ steps:
|
||||||
settings:
|
settings:
|
||||||
skip-dirs: node_modules/,plugins/woodpecker-plugins/node_modules/
|
skip-dirs: node_modules/,plugins/woodpecker-plugins/node_modules/
|
||||||
dir: docs/
|
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 ...
|
# but this is not an issue as we just generate a static site anyway ...
|
||||||
failure: ignore
|
failure: ignore
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,8 @@ steps:
|
||||||
commands:
|
commands:
|
||||||
- corepack enable
|
- corepack enable
|
||||||
- pnpx cspell lint --no-progress --gitignore '{**,.*}/{*,.*}'
|
- 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
|
- tree --gitignore -I 012_columns_rename_procs_to_steps.go -I versioned_docs -I '*opensource.svg'| pnpx cspell lint --no-progress stdin
|
||||||
|
|
||||||
- name: prettier
|
- name: prettier
|
||||||
|
@ -28,7 +29,7 @@ steps:
|
||||||
version: 3.2.5
|
version: 3.2.5
|
||||||
|
|
||||||
- name: links
|
- name: links
|
||||||
image: lycheeverse/lychee:0.14.3
|
image: docker.io/lycheeverse/lychee:0.14.3
|
||||||
depends_on: []
|
depends_on: []
|
||||||
commands:
|
commands:
|
||||||
- lychee pipeline/frontend/yaml/linter/schema/schema.json
|
- lychee pipeline/frontend/yaml/linter/schema/schema.json
|
||||||
|
|
|
@ -74,7 +74,7 @@ steps:
|
||||||
lint-license-header:
|
lint-license-header:
|
||||||
image: *golang_image
|
image: *golang_image
|
||||||
commands:
|
commands:
|
||||||
- go install github.com/google/addlicense@latest
|
- go install github.com/google/addlicense@latest # cspell:words addlicense
|
||||||
- 'addlicense -check -ignore "vendor/**" **/*.go'
|
- 'addlicense -check -ignore "vendor/**" **/*.go'
|
||||||
when: *when
|
when: *when
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ steps:
|
||||||
image: *golang_image
|
image: *golang_image
|
||||||
environment:
|
environment:
|
||||||
WOODPECKER_DATABASE_DRIVER: postgres
|
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:
|
commands:
|
||||||
- make test-server-datastore
|
- make test-server-datastore
|
||||||
when: *when
|
when: *when
|
||||||
|
|
|
@ -35,7 +35,7 @@ steps:
|
||||||
- pnpm lint
|
- pnpm lint
|
||||||
when: *when
|
when: *when
|
||||||
|
|
||||||
formatcheck:
|
format-check:
|
||||||
depends_on:
|
depends_on:
|
||||||
- install-dependencies
|
- install-dependencies
|
||||||
image: *node_image
|
image: *node_image
|
||||||
|
|
|
@ -28,7 +28,7 @@ import (
|
||||||
|
|
||||||
func (r *Runner) createLogger(logger zerolog.Logger, uploads *sync.WaitGroup, workflow *rpc.Workflow) pipeline.Logger {
|
func (r *Runner) createLogger(logger zerolog.Logger, uploads *sync.WaitGroup, workflow *rpc.Workflow) pipeline.Logger {
|
||||||
return func(step *backend.Step, rc io.Reader) error {
|
return func(step *backend.Step, rc io.Reader) error {
|
||||||
loglogger := logger.With().
|
logLogger := logger.With().
|
||||||
Str("image", step.Image).
|
Str("image", step.Image).
|
||||||
Str("workflowID", workflow.ID).
|
Str("workflowID", workflow.ID).
|
||||||
Logger()
|
Logger()
|
||||||
|
@ -40,14 +40,14 @@ func (r *Runner) createLogger(logger zerolog.Logger, uploads *sync.WaitGroup, wo
|
||||||
secrets = append(secrets, secret.Value)
|
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...)
|
logStream := rpc.NewLineWriter(r.client, step.UUID, secrets...)
|
||||||
if _, err := io.Copy(logStream, rc); err != nil {
|
if _, err := io.Copy(logStream, rc); err != nil {
|
||||||
log.Error().Err(err).Msg("copy limited logStream part")
|
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()
|
uploads.Done()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -54,7 +54,7 @@ func (r *Runner) Run(runnerCtx context.Context) error { //nolint:contextcheck
|
||||||
log.Debug().Msg("request next execution")
|
log.Debug().Msg("request next execution")
|
||||||
|
|
||||||
meta, _ := metadata.FromOutgoingContext(runnerCtx)
|
meta, _ := metadata.FromOutgoingContext(runnerCtx)
|
||||||
ctxmeta := metadata.NewOutgoingContext(context.Background(), meta)
|
ctxMeta := metadata.NewOutgoingContext(context.Background(), meta)
|
||||||
|
|
||||||
// get the next workflow from the queue
|
// get the next workflow from the queue
|
||||||
work, err := r.client.Next(runnerCtx, r.filter)
|
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")
|
logger.Debug().Msg("received execution")
|
||||||
|
|
||||||
workflowCtx, cancel := context.WithTimeout(ctxmeta, timeout)
|
workflowCtx, cancel := context.WithTimeout(ctxMeta, timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
// Add sigterm support for internal context.
|
// Add sigterm support for internal context.
|
||||||
|
@ -103,9 +103,9 @@ func (r *Runner) Run(runnerCtx context.Context) error { //nolint:contextcheck
|
||||||
go func() {
|
go func() {
|
||||||
logger.Debug().Msg("listen for cancel signal")
|
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)
|
canceled.SetTo(true)
|
||||||
logger.Warn().Err(werr).Msg("cancel signal received")
|
logger.Warn().Err(err).Msg("cancel signal received")
|
||||||
|
|
||||||
cancel()
|
cancel()
|
||||||
} else {
|
} else {
|
||||||
|
@ -144,7 +144,7 @@ func (r *Runner) Run(runnerCtx context.Context) error { //nolint:contextcheck
|
||||||
pipeline.WithContext(workflowCtx),
|
pipeline.WithContext(workflowCtx),
|
||||||
pipeline.WithTaskUUID(fmt.Sprint(work.ID)),
|
pipeline.WithTaskUUID(fmt.Sprint(work.ID)),
|
||||||
pipeline.WithLogger(r.createLogger(logger, &uploads, work)),
|
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.WithBackend(*r.backend),
|
||||||
pipeline.WithDescription(map[string]string{
|
pipeline.WithDescription(map[string]string{
|
||||||
"ID": work.ID,
|
"ID": work.ID,
|
||||||
|
|
|
@ -26,9 +26,9 @@ import (
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/pipeline/rpc"
|
"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 {
|
return func(state *pipeline.State) error {
|
||||||
steplogger := logger.With().
|
stepLogger := logger.With().
|
||||||
Str("image", state.Pipeline.Step.Image).
|
Str("image", state.Pipeline.Step.Image).
|
||||||
Str("workflowID", workflow.ID).
|
Str("workflowID", workflow.ID).
|
||||||
Err(state.Process.Error).
|
Err(state.Process.Error).
|
||||||
|
@ -48,15 +48,15 @@ func (r *Runner) createTracer(ctxmeta context.Context, logger zerolog.Logger, wo
|
||||||
}
|
}
|
||||||
|
|
||||||
defer func() {
|
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 {
|
if err := r.client.Update(ctxMeta, workflow.ID, stepState); err != nil {
|
||||||
steplogger.Debug().
|
stepLogger.Debug().
|
||||||
Err(uerr).
|
Err(err).
|
||||||
Msg("update step status error")
|
Msg("update step status error")
|
||||||
}
|
}
|
||||||
|
|
||||||
steplogger.Debug().Msg("update step status complete")
|
stepLogger.Debug().Msg("update step status complete")
|
||||||
}()
|
}()
|
||||||
if state.Process.Exited {
|
if state.Process.Exited {
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -78,9 +78,9 @@ func deploy(c *cli.Context) error {
|
||||||
var number int64
|
var number int64
|
||||||
if pipelineArg == "last" {
|
if pipelineArg == "last" {
|
||||||
// Fetch the pipeline number from the last pipeline
|
// Fetch the pipeline number from the last pipeline
|
||||||
pipelines, berr := client.PipelineList(repoID)
|
pipelines, err := client.PipelineList(repoID)
|
||||||
if berr != nil {
|
if err != nil {
|
||||||
return berr
|
return err
|
||||||
}
|
}
|
||||||
for _, pipeline := range pipelines {
|
for _, pipeline := range pipelines {
|
||||||
if branch != "" && pipeline.Branch != branch {
|
if branch != "" && pipeline.Branch != branch {
|
||||||
|
|
|
@ -146,14 +146,14 @@ func execWithAxis(c *cli.Context, file, repoPath string, axis matrix.Axis) error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
confstr, err := tmpl.Execute(func(name string) string {
|
confStr, err := tmpl.Execute(func(name string) string {
|
||||||
return environ[name]
|
return environ[name]
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
conf, err := yaml.ParseString(confstr)
|
conf, err := yaml.ParseString(confStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -177,12 +177,12 @@ func execWithAxis(c *cli.Context, file, repoPath string, axis matrix.Axis) error
|
||||||
}
|
}
|
||||||
|
|
||||||
// lint the yaml file
|
// 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),
|
File: path.Base(file),
|
||||||
RawConfig: confstr,
|
RawConfig: confStr,
|
||||||
Workflow: conf,
|
Workflow: conf,
|
||||||
}}); lerr != nil {
|
}}); err != nil {
|
||||||
return lerr
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// compiles the yaml file
|
// compiles the yaml file
|
||||||
|
|
|
@ -35,7 +35,7 @@ func NewClient(c *cli.Context) (woodpecker.Client, error) {
|
||||||
var (
|
var (
|
||||||
skip = c.Bool("skip-verify")
|
skip = c.Bool("skip-verify")
|
||||||
socks = c.String("socks-proxy")
|
socks = c.String("socks-proxy")
|
||||||
socksoff = c.Bool("socks-proxy-off")
|
socksOff = c.Bool("socks-proxy-off")
|
||||||
token = c.String("token")
|
token = c.String("token")
|
||||||
server = c.String("server")
|
server = c.String("server")
|
||||||
)
|
)
|
||||||
|
@ -70,7 +70,7 @@ func NewClient(c *cli.Context) (woodpecker.Client, error) {
|
||||||
|
|
||||||
trans, _ := client.Transport.(*oauth2.Transport)
|
trans, _ := client.Transport.(*oauth2.Transport)
|
||||||
|
|
||||||
if len(socks) != 0 && !socksoff {
|
if len(socks) != 0 && !socksOff {
|
||||||
dialer, err := proxy.SOCKS5("tcp", socks, nil, proxy.Direct)
|
dialer, err := proxy.SOCKS5("tcp", socks, nil, proxy.Direct)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -22,7 +22,7 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/muesli/termenv"
|
term_env "github.com/muesli/termenv"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
|
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/common"
|
"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 {
|
func lintFile(_ *cli.Context, file string) error {
|
||||||
output := termenv.NewOutput(os.Stdout)
|
output := term_env.NewOutput(os.Stdout)
|
||||||
|
|
||||||
fi, err := os.Open(file)
|
fi, err := os.Open(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -64,7 +64,7 @@ func (o *Table) AddFieldFn(field string, fn FieldFn) *Table {
|
||||||
return o
|
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) {
|
func (o *Table) AddAllowedFields(obj any) (*Table, error) {
|
||||||
v := reflect.ValueOf(obj)
|
v := reflect.ValueOf(obj)
|
||||||
if v.Kind() != reflect.Struct {
|
if v.Kind() != reflect.Struct {
|
||||||
|
|
|
@ -47,7 +47,7 @@ var Command = &cli.Command{
|
||||||
}
|
}
|
||||||
|
|
||||||
func pipelineOutput(c *cli.Context, resources []woodpecker.Pipeline, fd ...io.Writer) error {
|
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")
|
noHeader := c.Bool("output-no-headers")
|
||||||
|
|
||||||
var out io.Writer
|
var out io.Writer
|
||||||
|
@ -60,13 +60,13 @@ func pipelineOutput(c *cli.Context, resources []woodpecker.Pipeline, fd ...io.Wr
|
||||||
out = os.Stdout
|
out = os.Stdout
|
||||||
}
|
}
|
||||||
|
|
||||||
switch outfmt {
|
switch outFmt {
|
||||||
case "go-template":
|
case "go-template":
|
||||||
if len(outopt) < 1 {
|
if len(outOpt) < 1 {
|
||||||
return fmt.Errorf("%w: missing template", output.ErrOutputOptionRequired)
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -79,8 +79,8 @@ func pipelineOutput(c *cli.Context, resources []woodpecker.Pipeline, fd ...io.Wr
|
||||||
table := output.NewTable(out)
|
table := output.NewTable(out)
|
||||||
cols := []string{"Number", "Status", "Event", "Branch", "Commit", "Author"}
|
cols := []string{"Number", "Status", "Event", "Branch", "Commit", "Author"}
|
||||||
|
|
||||||
if len(outopt) > 0 {
|
if len(outOpt) > 0 {
|
||||||
cols = outopt
|
cols = outOpt
|
||||||
}
|
}
|
||||||
if !noHeader {
|
if !noHeader {
|
||||||
table.WriteHeader(cols)
|
table.WriteHeader(cols)
|
||||||
|
|
|
@ -73,14 +73,13 @@ func registryCreate(c *cli.Context) error {
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(registry.Password, "@") {
|
if strings.HasPrefix(registry.Password, "@") {
|
||||||
path := strings.TrimPrefix(registry.Password, "@")
|
path := strings.TrimPrefix(registry.Password, "@")
|
||||||
out, ferr := os.ReadFile(path)
|
out, err := os.ReadFile(path)
|
||||||
if ferr != nil {
|
if err != nil {
|
||||||
return ferr
|
return err
|
||||||
}
|
}
|
||||||
registry.Password = string(out)
|
registry.Password = string(out)
|
||||||
}
|
}
|
||||||
_, err = client.RegistryCreate(repoID, registry)
|
if _, err := client.RegistryCreate(repoID, registry); err != nil {
|
||||||
if err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -73,9 +73,9 @@ func registryUpdate(c *cli.Context) error {
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(registry.Password, "@") {
|
if strings.HasPrefix(registry.Password, "@") {
|
||||||
path := strings.TrimPrefix(registry.Password, "@")
|
path := strings.TrimPrefix(registry.Password, "@")
|
||||||
out, ferr := os.ReadFile(path)
|
out, err := os.ReadFile(path)
|
||||||
if ferr != nil {
|
if err != nil {
|
||||||
return ferr
|
return err
|
||||||
}
|
}
|
||||||
registry.Password = string(out)
|
registry.Password = string(out)
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
|
|
||||||
const tarDirectoryMode fs.FileMode = 0x755
|
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)
|
gzr, err := gzip.NewReader(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -122,7 +122,7 @@ func extractNewVersion(tarFilePath string) (string, error) {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = Untar(tmpDir, tarFile)
|
err = UnTar(tmpDir, tarFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,14 +31,14 @@ import (
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/codes"
|
"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/credentials/insecure"
|
||||||
"google.golang.org/grpc/keepalive"
|
"google.golang.org/grpc/keepalive"
|
||||||
"google.golang.org/grpc/metadata"
|
"google.golang.org/grpc/metadata"
|
||||||
"google.golang.org/grpc/status"
|
"google.golang.org/grpc/status"
|
||||||
|
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/agent"
|
"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"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/pipeline/backend/types"
|
"go.woodpecker-ci.org/woodpecker/v2/pipeline/backend/types"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/pipeline/rpc"
|
"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
|
var transport grpc.DialOption
|
||||||
if c.Bool("grpc-secure") {
|
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 {
|
} else {
|
||||||
transport = grpc.WithTransportCredentials(insecure.NewCredentials())
|
transport = grpc.WithTransportCredentials(insecure.NewCredentials())
|
||||||
}
|
}
|
||||||
|
@ -88,8 +88,8 @@ func run(c *cli.Context, backends []types.Backend) error {
|
||||||
agentConfig := readAgentConfig(agentConfigPath)
|
agentConfig := readAgentConfig(agentConfigPath)
|
||||||
|
|
||||||
agentToken := c.String("grpc-token")
|
agentToken := c.String("grpc-token")
|
||||||
authClient := agentRpc.NewAuthGrpcClient(authConn, agentToken, agentConfig.AgentID)
|
authClient := agent_rpc.NewAuthGrpcClient(authConn, agentToken, agentConfig.AgentID)
|
||||||
authInterceptor, err := agentRpc.NewAuthInterceptor(authClient, 30*time.Minute) //nolint:mnd
|
authInterceptor, err := agent_rpc.NewAuthInterceptor(authClient, 30*time.Minute) //nolint:mnd
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ func run(c *cli.Context, backends []types.Backend) error {
|
||||||
}
|
}
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
|
||||||
client := agentRpc.NewGrpcClient(conn)
|
client := agent_rpc.NewGrpcClient(conn)
|
||||||
|
|
||||||
sigterm := abool.New()
|
sigterm := abool.New()
|
||||||
ctx := metadata.NewOutgoingContext(
|
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")
|
log.Error().Err(err).Msg("could not get grpc server version")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if grpcServerVersion.GrpcVersion != agentRpc.ClientGrpcVersion {
|
if grpcServerVersion.GrpcVersion != agent_rpc.ClientGrpcVersion {
|
||||||
err := errors.New("GRPC version mismatch")
|
err := errors.New("GRPC version mismatch")
|
||||||
log.Error().Err(err).Msgf("server version %s does report grpc version %d but we only understand %d",
|
log.Error().Err(err).Msgf("server version %s does report grpc version %d but we only understand %d",
|
||||||
grpcServerVersion.ServerVersion,
|
grpcServerVersion.ServerVersion,
|
||||||
grpcServerVersion.GrpcVersion,
|
grpcServerVersion.GrpcVersion,
|
||||||
agentRpc.ClientGrpcVersion)
|
agent_rpc.ClientGrpcVersion)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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.",
|
Usage: "List of labels to filter tasks on. An agent must be assigned every tag listed in a task to be selected.",
|
||||||
},
|
},
|
||||||
&cli.IntFlag{
|
&cli.IntFlag{
|
||||||
EnvVars: []string{"WOODPECKER_MAX_WORKFLOWS", "WOODPECKER_MAX_PROCS"},
|
EnvVars: []string{"WOODPECKER_MAX_WORKFLOWS", "WOODPECKER_MAX_PROCS"}, // cspell:words PROCS
|
||||||
Name: "max-workflows",
|
Name: "max-workflows",
|
||||||
Usage: "agent parallel workflows",
|
Usage: "agent parallel workflows",
|
||||||
Value: 1,
|
Value: 1,
|
||||||
|
|
|
@ -32,8 +32,8 @@ import (
|
||||||
// https://github.com/mozilla-services/Dockerflow
|
// https://github.com/mozilla-services/Dockerflow
|
||||||
|
|
||||||
func initHealth() {
|
func initHealth() {
|
||||||
http.HandleFunc("/varz", handleStats)
|
http.HandleFunc("/varz", handleStats) // cspell:words varz
|
||||||
http.HandleFunc("/healthz", handleHeartbeat)
|
http.HandleFunc("/healthz", handleHeartbeat) // cspell:words healthz
|
||||||
http.HandleFunc("/version", handleVersion)
|
http.HandleFunc("/version", handleVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ func GenerateContainerConf(commands []string, goos string) (env map[string]strin
|
||||||
env["CI_SCRIPT"] = base64.StdEncoding.EncodeToString([]byte(generateScriptWindows(commands)))
|
env["CI_SCRIPT"] = base64.StdEncoding.EncodeToString([]byte(generateScriptWindows(commands)))
|
||||||
env["HOME"] = "c:\\root"
|
env["HOME"] = "c:\\root"
|
||||||
env["SHELL"] = "powershell.exe"
|
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"}
|
entry = []string{"powershell", "-noprofile", "-noninteractive", "-command", "[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($Env:CI_SCRIPT)) | iex"}
|
||||||
} else {
|
} else {
|
||||||
env["CI_SCRIPT"] = base64.StdEncoding.EncodeToString([]byte(generateScriptPosix(commands)))
|
env["CI_SCRIPT"] = base64.StdEncoding.EncodeToString([]byte(generateScriptPosix(commands)))
|
||||||
|
|
|
@ -197,6 +197,7 @@ func encodeAuthToBase64(authConfig types.Auth) (string, error) {
|
||||||
//
|
//
|
||||||
// It handles Windows and Linux style volume paths.
|
// It handles Windows and Linux style volume paths.
|
||||||
func splitVolumeParts(volumeParts string) ([]string, error) {
|
func splitVolumeParts(volumeParts string) ([]string, error) {
|
||||||
|
// cspell:disable-next-line
|
||||||
pattern := `^((?:[\w]\:)?[^\:]*)\:((?:[\w]\:)?[^\:]*)(?:\:([rwom]*))?`
|
pattern := `^((?:[\w]\:)?[^\:]*)\:((?:[\w]\:)?[^\:]*)(?:\:([rwom]*))?`
|
||||||
r, err := regexp.Compile(pattern)
|
r, err := regexp.Compile(pattern)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -25,10 +25,10 @@ import (
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/api/types/network"
|
"github.com/docker/docker/api/types/network"
|
||||||
"github.com/docker/docker/api/types/volume"
|
"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/client"
|
||||||
"github.com/moby/moby/pkg/jsonmessage"
|
json_message "github.com/moby/moby/pkg/jsonmessage"
|
||||||
"github.com/moby/moby/pkg/stdcopy"
|
std_copy "github.com/moby/moby/pkg/stdcopy"
|
||||||
"github.com/moby/term"
|
"github.com/moby/term"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
|
@ -75,13 +75,13 @@ func httpClientOfOpts(dockerCertPath string, verifyTLS bool) *http.Client {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
options := tlsconfig.Options{
|
options := tls_config.Options{
|
||||||
CAFile: filepath.Join(dockerCertPath, "ca.pem"),
|
CAFile: filepath.Join(dockerCertPath, "ca.pem"),
|
||||||
CertFile: filepath.Join(dockerCertPath, "cert.pem"),
|
CertFile: filepath.Join(dockerCertPath, "cert.pem"),
|
||||||
KeyFile: filepath.Join(dockerCertPath, "key.pem"),
|
KeyFile: filepath.Join(dockerCertPath, "key.pem"),
|
||||||
InsecureSkipVerify: !verifyTLS,
|
InsecureSkipVerify: !verifyTLS,
|
||||||
}
|
}
|
||||||
tlsConf, err := tlsconfig.Client(options)
|
tlsConf, err := tls_config.Client(options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msg("could not create http client out of docker backend options")
|
log.Error().Err(err).Msg("could not create http client out of docker backend options")
|
||||||
return nil
|
return nil
|
||||||
|
@ -188,27 +188,27 @@ func (e *docker) StartStep(ctx context.Context, step *backend.Step, taskUUID str
|
||||||
containerName := toContainerName(step)
|
containerName := toContainerName(step)
|
||||||
|
|
||||||
// create pull options with encoded authorization credentials.
|
// create pull options with encoded authorization credentials.
|
||||||
pullopts := types.ImagePullOptions{}
|
pullOpts := types.ImagePullOptions{}
|
||||||
if step.AuthConfig.Username != "" && step.AuthConfig.Password != "" {
|
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
|
// automatically pull the latest version of the image if requested
|
||||||
// by the process configuration.
|
// by the process configuration.
|
||||||
if step.Pull {
|
if step.Pull {
|
||||||
responseBody, perr := e.client.ImagePull(ctx, config.Image, pullopts)
|
responseBody, pErr := e.client.ImagePull(ctx, config.Image, pullOpts)
|
||||||
if perr == nil {
|
if pErr == nil {
|
||||||
// TODO(1936): show image pull progress in web-ui
|
// TODO(1936): show image pull progress in web-ui
|
||||||
fd, isTerminal := term.GetFdInfo(os.Stdout)
|
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")
|
log.Error().Err(err).Msg("DisplayJSONMessagesStream")
|
||||||
}
|
}
|
||||||
responseBody.Close()
|
responseBody.Close()
|
||||||
}
|
}
|
||||||
// Fix "Show warning when fail to auth to docker registry"
|
// Fix "Show warning when fail to auth to docker registry"
|
||||||
// (https://web.archive.org/web/20201023145804/https://github.com/drone/drone/issues/1917)
|
// (https://web.archive.org/web/20201023145804/https://github.com/drone/drone/issues/1917)
|
||||||
if perr != nil && step.AuthConfig.Password != "" {
|
if pErr != nil && step.AuthConfig.Password != "" {
|
||||||
return perr
|
return pErr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,13 +219,13 @@ func (e *docker) StartStep(ctx context.Context, step *backend.Step, taskUUID str
|
||||||
if client.IsErrNotFound(err) {
|
if client.IsErrNotFound(err) {
|
||||||
// automatically pull and try to re-create the image if the
|
// automatically pull and try to re-create the image if the
|
||||||
// failure is caused because the image does not exist.
|
// failure is caused because the image does not exist.
|
||||||
responseBody, perr := e.client.ImagePull(ctx, config.Image, pullopts)
|
responseBody, pErr := e.client.ImagePull(ctx, config.Image, pullOpts)
|
||||||
if perr != nil {
|
if pErr != nil {
|
||||||
return perr
|
return pErr
|
||||||
}
|
}
|
||||||
// TODO(1936): show image pull progress in web-ui
|
// TODO(1936): show image pull progress in web-ui
|
||||||
fd, isTerminal := term.GetFdInfo(os.Stdout)
|
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")
|
log.Error().Err(err).Msg("DisplayJSONMessagesStream")
|
||||||
}
|
}
|
||||||
responseBody.Close()
|
responseBody.Close()
|
||||||
|
@ -263,10 +263,10 @@ func (e *docker) WaitStep(ctx context.Context, step *backend.Step, taskUUID stri
|
||||||
|
|
||||||
containerName := toContainerName(step)
|
containerName := toContainerName(step)
|
||||||
|
|
||||||
wait, errc := e.client.ContainerWait(ctx, containerName, "")
|
wait, errC := e.client.ContainerWait(ctx, containerName, "")
|
||||||
select {
|
select {
|
||||||
case <-wait:
|
case <-wait:
|
||||||
case <-errc:
|
case <-errC:
|
||||||
}
|
}
|
||||||
|
|
||||||
info, err := e.client.ContainerInspect(ctx, containerName)
|
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
|
// de multiplex 'logs' who contains two streams, previously multiplexed together using StdWriter
|
||||||
go func() {
|
go func() {
|
||||||
_, _ = stdcopy.StdCopy(wc, wc, logs)
|
_, _ = std_copy.StdCopy(wc, wc, logs)
|
||||||
_ = logs.Close()
|
_ = logs.Close()
|
||||||
_ = wc.Close()
|
_ = wc.Close()
|
||||||
}()
|
}()
|
||||||
|
|
|
@ -68,7 +68,7 @@ var Flags = []cli.Flag{
|
||||||
Value: false,
|
Value: false,
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&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",
|
Name: "backend-k8s-secctx-nonroot",
|
||||||
Usage: "`run as non root` Kubernetes security context option",
|
Usage: "`run as non root` Kubernetes security context option",
|
||||||
},
|
},
|
||||||
|
|
|
@ -28,7 +28,7 @@ import (
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
v1 "k8s.io/api/core/v1"
|
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/informers"
|
||||||
"k8s.io/client-go/kubernetes"
|
"k8s.io/client-go/kubernetes"
|
||||||
"k8s.io/client-go/kubernetes/scheme"
|
"k8s.io/client-go/kubernetes/scheme"
|
||||||
|
@ -69,11 +69,11 @@ type SecurityContextConfig struct {
|
||||||
RunAsNonRoot bool
|
RunAsNonRoot bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func newDefaultDeleteOptions() metav1.DeleteOptions {
|
func newDefaultDeleteOptions() meta_v1.DeleteOptions {
|
||||||
gracePeriodSeconds := int64(0) // immediately
|
gracePeriodSeconds := int64(0) // immediately
|
||||||
propagationPolicy := metav1.DeletePropagationBackground
|
propagationPolicy := meta_v1.DeletePropagationBackground
|
||||||
|
|
||||||
return metav1.DeleteOptions{
|
return meta_v1.DeleteOptions{
|
||||||
GracePeriodSeconds: &gracePeriodSeconds,
|
GracePeriodSeconds: &gracePeriodSeconds,
|
||||||
PropagationPolicy: &propagationPolicy,
|
PropagationPolicy: &propagationPolicy,
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ func configFromCliContext(ctx context.Context) (*config, error) {
|
||||||
PodAnnotationsAllowFromStep: c.Bool("backend-k8s-pod-annotations-allow-from-step"),
|
PodAnnotationsAllowFromStep: c.Bool("backend-k8s-pod-annotations-allow-from-step"),
|
||||||
ImagePullSecretNames: c.StringSlice("backend-k8s-pod-image-pull-secret-names"),
|
ImagePullSecretNames: c.StringSlice("backend-k8s-pod-image-pull-secret-names"),
|
||||||
SecurityContext: SecurityContextConfig{
|
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
|
// 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
|
// TODO: Cancel on ctx.Done
|
||||||
<-finished
|
<-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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ import (
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/api/errors"
|
"k8s.io/apimachinery/pkg/api/errors"
|
||||||
"k8s.io/apimachinery/pkg/api/resource"
|
"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/common"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/pipeline/backend/types"
|
"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)
|
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
|
var err error
|
||||||
meta := metav1.ObjectMeta{
|
meta := meta_v1.ObjectMeta{
|
||||||
Name: podName,
|
Name: podName,
|
||||||
Namespace: config.Namespace,
|
Namespace: config.Namespace,
|
||||||
Annotations: podAnnotations(config, options, podName),
|
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)
|
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)
|
podName, err := stepToPodName(step)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -22,8 +22,8 @@ import (
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/api/errors"
|
"k8s.io/apimachinery/pkg/api/errors"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
int_str "k8s.io/apimachinery/pkg/util/intstr"
|
||||||
|
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/pipeline/backend/types"
|
"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")
|
log.Trace().Str("name", name).Interface("selector", selector).Interface("ports", svcPorts).Msg("creating service")
|
||||||
return &v1.Service{
|
return &v1.Service{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: meta_v1.ObjectMeta{
|
||||||
Name: name,
|
Name: name,
|
||||||
Namespace: config.Namespace,
|
Namespace: config.Namespace,
|
||||||
},
|
},
|
||||||
|
@ -73,7 +73,7 @@ func servicePort(port types.Port) v1.ServicePort {
|
||||||
Name: fmt.Sprintf("port-%d", portNumber),
|
Name: fmt.Sprintf("port-%d", portNumber),
|
||||||
Port: portNumber,
|
Port: portNumber,
|
||||||
Protocol: v1.Protocol(portProtocol),
|
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")
|
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)
|
svcName, err := serviceName(step)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -23,7 +23,7 @@ import (
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/client-go/kubernetes"
|
"k8s.io/client-go/kubernetes"
|
||||||
"k8s.io/client-go/rest"
|
"k8s.io/client-go/rest"
|
||||||
"k8s.io/client-go/tools/clientcmd"
|
client_cmd "k8s.io/client-go/tools/clientcmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -65,15 +65,15 @@ func isImagePullBackOffState(pod *v1.Pod) bool {
|
||||||
return false
|
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) {
|
func getClientOutOfCluster() (kubernetes.Interface, error) {
|
||||||
kubeConfigPath := os.Getenv("KUBECONFIG")
|
kubeConfigPath := os.Getenv("KUBECONFIG") // cspell:words KUBECONFIG
|
||||||
if kubeConfigPath == "" {
|
if kubeConfigPath == "" {
|
||||||
kubeConfigPath = os.Getenv("HOME") + "/.kube/config"
|
kubeConfigPath = os.Getenv("HOME") + "/.kube/config"
|
||||||
}
|
}
|
||||||
|
|
||||||
// use the current context in kubeconfig
|
// use the current context in kube config
|
||||||
config, err := clientcmd.BuildConfigFromFlags("", kubeConfigPath)
|
config, err := client_cmd.BuildConfigFromFlags("", kubeConfigPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ func getClientOutOfCluster() (kubernetes.Interface, error) {
|
||||||
return kubernetes.NewForConfig(config)
|
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) {
|
func getClientInsideOfCluster() (kubernetes.Interface, error) {
|
||||||
config, err := rest.InClusterConfig()
|
config, err := rest.InClusterConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -22,7 +22,7 @@ import (
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/api/errors"
|
"k8s.io/apimachinery/pkg/api/errors"
|
||||||
"k8s.io/apimachinery/pkg/api/resource"
|
"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) {
|
func mkPersistentVolumeClaim(config *config, name string) (*v1.PersistentVolumeClaim, error) {
|
||||||
|
@ -45,7 +45,7 @@ func mkPersistentVolumeClaim(config *config, name string) (*v1.PersistentVolumeC
|
||||||
}
|
}
|
||||||
|
|
||||||
pvc := &v1.PersistentVolumeClaim{
|
pvc := &v1.PersistentVolumeClaim{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: meta_v1.ObjectMeta{
|
||||||
Name: volumeName,
|
Name: volumeName,
|
||||||
Namespace: config.Namespace,
|
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)
|
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)
|
pvcName, err := volumeName(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -24,9 +24,9 @@ import (
|
||||||
"github.com/alessio/shellescape"
|
"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 := ""
|
script := ""
|
||||||
for _, cmd := range cmds {
|
for _, cmd := range cmdList {
|
||||||
script += fmt.Sprintf("echo %s\n%s\n", strings.TrimSpace(shellescape.Quote("+ "+cmd)), cmd)
|
script += fmt.Sprintf("echo %s\n%s\n", strings.TrimSpace(shellescape.Quote("+ "+cmd)), cmd)
|
||||||
}
|
}
|
||||||
script = strings.TrimSpace(script)
|
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") {
|
switch strings.TrimSuffix(strings.ToLower(shell), ".exe") {
|
||||||
case "cmd":
|
case "cmd":
|
||||||
script := "@SET PROMPT=$\n"
|
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("@echo + %s\n", strings.TrimSpace(shellescape.Quote(cmd)))
|
||||||
script += fmt.Sprintf("@%s\n", cmd)
|
script += fmt.Sprintf("@%s\n", cmd)
|
||||||
script += "@IF NOT %ERRORLEVEL% == 0 exit %ERRORLEVEL%\n"
|
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
|
return []string{"/c", cmd.Name()}, nil
|
||||||
case "fish":
|
case "fish":
|
||||||
script := ""
|
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)
|
script += fmt.Sprintf("echo %s\n%s || exit $status\n", strings.TrimSpace(shellescape.Quote("+ "+cmd)), cmd)
|
||||||
}
|
}
|
||||||
return []string{"-c", script}, nil
|
return []string{"-c", script}, nil
|
||||||
case "powershell", "pwsh":
|
case "powershell", "pwsh":
|
||||||
|
// cspell:disable-next-line
|
||||||
return []string{"-noprofile", "-noninteractive", "-c", "$ErrorActionPreference = \"Stop\"; " + script}, nil
|
return []string{"-noprofile", "-noninteractive", "-c", "$ErrorActionPreference = \"Stop\"; " + script}, nil
|
||||||
default:
|
default:
|
||||||
// normal posix shells
|
// normal posix shells
|
||||||
|
|
|
@ -159,12 +159,12 @@ func WithNetworks(networks ...string) Option {
|
||||||
|
|
||||||
// WithResourceLimit configures the compiler with default resource limits that
|
// WithResourceLimit configures the compiler with default resource limits that
|
||||||
// are applied each container in the pipeline.
|
// 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) {
|
return func(compiler *Compiler) {
|
||||||
compiler.reslimit = ResourceLimit{
|
compiler.reslimit = ResourceLimit{
|
||||||
MemSwapLimit: swap,
|
MemSwapLimit: swap,
|
||||||
MemLimit: mem,
|
MemLimit: mem,
|
||||||
ShmSize: shmsize,
|
ShmSize: shmSize,
|
||||||
CPUQuota: cpuQuota,
|
CPUQuota: cpuQuota,
|
||||||
CPUShares: cpuShares,
|
CPUShares: cpuShares,
|
||||||
CPUSet: cpuSet,
|
CPUSet: cpuSet,
|
||||||
|
|
|
@ -197,11 +197,11 @@ func (c *Constraint) Match(m metadata.Metadata, global bool, env map[string]stri
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
bresult, ok := result.(bool)
|
bResult, ok := result.(bool)
|
||||||
if !ok {
|
if !ok {
|
||||||
return false, fmt.Errorf("could not parse result: %v", result)
|
return false, fmt.Errorf("could not parse result: %v", result)
|
||||||
}
|
}
|
||||||
match = match && bresult
|
match = match && bResult
|
||||||
}
|
}
|
||||||
|
|
||||||
return match, nil
|
return match, nil
|
||||||
|
@ -247,7 +247,7 @@ func (c *List) Excludes(v string) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalYAML unmarshals the constraint.
|
// UnmarshalYAML unmarshal the constraint.
|
||||||
func (c *List) UnmarshalYAML(value *yaml.Node) error {
|
func (c *List) UnmarshalYAML(value *yaml.Node) error {
|
||||||
out1 := struct {
|
out1 := struct {
|
||||||
Include yamlBaseTypes.StringOrSlice
|
Include yamlBaseTypes.StringOrSlice
|
||||||
|
|
|
@ -22,7 +22,7 @@ import (
|
||||||
|
|
||||||
"codeberg.org/6543/go-yaml2json"
|
"codeberg.org/6543/go-yaml2json"
|
||||||
"codeberg.org/6543/xyaml"
|
"codeberg.org/6543/xyaml"
|
||||||
"github.com/xeipuuv/gojsonschema"
|
json_schema "github.com/xeipuuv/gojsonschema"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -30,8 +30,8 @@ import (
|
||||||
var schemaDefinition []byte
|
var schemaDefinition []byte
|
||||||
|
|
||||||
// Lint lints an io.Reader against the Woodpecker `schema.json`.
|
// Lint lints an io.Reader against the Woodpecker `schema.json`.
|
||||||
func Lint(r io.Reader) ([]gojsonschema.ResultError, error) {
|
func Lint(r io.Reader) ([]json_schema.ResultError, error) {
|
||||||
schemaLoader := gojsonschema.NewBytesLoader(schemaDefinition)
|
schemaLoader := json_schema.NewBytesLoader(schemaDefinition)
|
||||||
|
|
||||||
// read yaml config
|
// read yaml config
|
||||||
rBytes, err := io.ReadAll(r)
|
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)
|
return nil, fmt.Errorf("failed to convert yaml %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
documentLoader := gojsonschema.NewBytesLoader(jsonDoc)
|
documentLoader := json_schema.NewBytesLoader(jsonDoc)
|
||||||
result, err := gojsonschema.Validate(schemaLoader, documentLoader)
|
result, err := json_schema.Validate(schemaLoader, documentLoader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("validation failed %w", err)
|
return nil, fmt.Errorf("validation failed %w", err)
|
||||||
}
|
}
|
||||||
|
@ -64,6 +64,6 @@ func Lint(r io.Reader) ([]gojsonschema.ResultError, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func LintString(s string) ([]gojsonschema.ResultError, error) {
|
func LintString(s string) ([]json_schema.ResultError, error) {
|
||||||
return Lint(bytes.NewBufferString(s))
|
return Lint(bytes.NewBufferString(s))
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,11 +86,11 @@ func calc(matrix Matrix) []Axis {
|
||||||
// for each axis calculate the unique set of values that should be used.
|
// for each axis calculate the unique set of values that should be used.
|
||||||
for p := 0; p < perm; p++ {
|
for p := 0; p < perm; p++ {
|
||||||
axis := map[string]string{}
|
axis := map[string]string{}
|
||||||
decr := perm
|
decrease := perm
|
||||||
for i, tag := range tags {
|
for i, tag := range tags {
|
||||||
elems := matrix[tag]
|
elems := matrix[tag]
|
||||||
decr /= len(elems)
|
decrease /= len(elems)
|
||||||
elem := p / decr % len(elems)
|
elem := p / decrease % len(elems)
|
||||||
axis[tag] = elems[elem]
|
axis[tag] = elems[elem]
|
||||||
|
|
||||||
// enforce a maximum number of tags in the pipeline matrix.
|
// enforce a maximum number of tags in the pipeline matrix.
|
||||||
|
|
|
@ -25,7 +25,7 @@ type BoolTrue struct {
|
||||||
value bool
|
value bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalYAML implements custom Yaml unmarshaling.
|
// UnmarshalYAML implements custom Yaml unmarshal.
|
||||||
func (b *BoolTrue) UnmarshalYAML(value *yaml.Node) error {
|
func (b *BoolTrue) UnmarshalYAML(value *yaml.Node) error {
|
||||||
var s string
|
var s string
|
||||||
if err := value.Decode(&s); err != nil {
|
if err := value.Decode(&s); err != nil {
|
||||||
|
|
|
@ -66,24 +66,24 @@ func (v *Volumes) UnmarshalYAML(unmarshal func(any) error) error {
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("cannot unmarshal '%v' to type %T into a string value", name, name)
|
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
|
var vol *Volume
|
||||||
//nolint:mnd
|
//nolint:mnd
|
||||||
switch {
|
switch {
|
||||||
case len(elts) == 1:
|
case len(elements) == 1:
|
||||||
vol = &Volume{
|
vol = &Volume{
|
||||||
Destination: elts[0],
|
Destination: elements[0],
|
||||||
}
|
}
|
||||||
case len(elts) == 2:
|
case len(elements) == 2:
|
||||||
vol = &Volume{
|
vol = &Volume{
|
||||||
Source: elts[0],
|
Source: elements[0],
|
||||||
Destination: elts[1],
|
Destination: elements[1],
|
||||||
}
|
}
|
||||||
case len(elts) == 3:
|
case len(elements) == 3:
|
||||||
vol = &Volume{
|
vol = &Volume{
|
||||||
Source: elts[0],
|
Source: elements[0],
|
||||||
Destination: elts[1],
|
Destination: elements[1],
|
||||||
AccessMode: elts[2],
|
AccessMode: elements[2],
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
// FIXME
|
// FIXME
|
||||||
|
|
|
@ -134,7 +134,7 @@ message RegisterAgentResponse {
|
||||||
int64 agent_id = 1;
|
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 {
|
service WoodpeckerAuth {
|
||||||
rpc Auth (AuthRequest) returns (AuthResponse) {}
|
rpc Auth (AuthRequest) returns (AuthResponse) {}
|
||||||
|
|
|
@ -22,7 +22,7 @@ import "strings"
|
||||||
// secrets with asterisks. Each secret string is split on newlines to
|
// secrets with asterisks. Each secret string is split on newlines to
|
||||||
// handle multi-line secrets.
|
// handle multi-line secrets.
|
||||||
func NewSecretsReplacer(secrets []string) *strings.Replacer {
|
func NewSecretsReplacer(secrets []string) *strings.Replacer {
|
||||||
var oldnew []string
|
var oldNew []string
|
||||||
|
|
||||||
// Strings shorter than minStringLength are not considered secrets.
|
// Strings shorter than minStringLength are not considered secrets.
|
||||||
// Do not sanitize them.
|
// Do not sanitize them.
|
||||||
|
@ -38,10 +38,10 @@ func NewSecretsReplacer(secrets []string) *strings.Replacer {
|
||||||
if len(part) == 0 {
|
if len(part) == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
oldnew = append(oldnew, part)
|
oldNew = append(oldNew, part)
|
||||||
oldnew = append(oldnew, "********")
|
oldNew = append(oldNew, "********")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return strings.NewReplacer(oldnew...)
|
return strings.NewReplacer(oldNew...)
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ import (
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
swaggerfiles "github.com/swaggo/files"
|
swagger_files "github.com/swaggo/files"
|
||||||
ginSwagger "github.com/swaggo/gin-swagger"
|
ginSwagger "github.com/swaggo/gin-swagger"
|
||||||
|
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cmd/server/docs"
|
"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) {
|
func setupSwaggerConfigAndRoutes(e *gin.Engine) {
|
||||||
docs.SwaggerInfo.Host = getHost(server.Config.Server.Host)
|
docs.SwaggerInfo.Host = getHost(server.Config.Server.Host)
|
||||||
docs.SwaggerInfo.BasePath = server.Config.Server.RootPath + "/api"
|
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 {
|
func getHost(s string) string {
|
||||||
|
|
|
@ -80,10 +80,10 @@ func (h *http) Fetch(ctx context.Context, forge forge.Forge, user *model.User, r
|
||||||
return oldConfigData, nil
|
return oldConfigData, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
fileMetas := make([]*types.FileMeta, len(response.Configs))
|
fileMetaList := make([]*types.FileMeta, len(response.Configs))
|
||||||
for i, config := range 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
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,7 @@ func (m *manager) RegistryService() registry.Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *manager) ConfigServiceFromRepo(_ *model.Repo) config.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
|
return m.config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue