1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2025-11-23 21:44:44 +02:00

Add godot linter to harmonitze toplevel comments (#3650)

This commit is contained in:
Robert Kaussow
2024-05-13 22:58:21 +02:00
committed by GitHub
parent 83eba294c7
commit 89e100cfd1
144 changed files with 302 additions and 302 deletions

View File

@@ -26,9 +26,11 @@ const (
EventManual = "manual"
)
// Different ways to handle failure states
// Different ways to handle failure states.
const (
FailureIgnore = "ignore"
FailureFail = "fail"
// FailureCancel = "cancel" // Not implemented yet
//nolint:godot
// TODO: Not implemented yet.
// FailureCancel = "cancel"
)

View File

@@ -38,7 +38,7 @@ func (m *Metadata) Environ() map[string]string {
)
branchParts := strings.Split(m.Curr.Commit.Refspec, ":")
if len(branchParts) == 2 { //nolint: gomnd
if len(branchParts) == 2 { //nolint:mnd
sourceBranch = branchParts[0]
targetBranch = branchParts[1]
}
@@ -124,7 +124,7 @@ func (m *Metadata) Environ() map[string]string {
"CI_FORGE_TYPE": m.Forge.Type,
"CI_FORGE_URL": m.Forge.URL,
// TODO Deprecated, remove in 3.x
// TODO: Deprecated, remove in 3.x
"CI_COMMIT_URL": m.Curr.ForgeURL,
}
if m.Curr.Event == EventTag || m.Curr.Event == EventRelease || strings.HasPrefix(m.Curr.Commit.Ref, "refs/tags/") {

View File

@@ -93,7 +93,7 @@ type (
Number int `json:"number,omitempty"`
}
// Secret defines a runtime secret
// Secret defines a runtime secret.
Secret struct {
Name string `json:"name,omitempty"`
Value string `json:"value,omitempty"`
@@ -110,13 +110,13 @@ type (
Version string `json:"version,omitempty"`
}
// Forge defines runtime metadata about the forge that host the repo
// Forge defines runtime metadata about the forge that host the repo.
Forge struct {
Type string `json:"type,omitempty"`
URL string `json:"url,omitempty"`
}
// ServerForge represent the needed func of a server forge to get its metadata
// ServerForge represent the needed func of a server forge to get its metadata.
ServerForge interface {
// Name returns the string name of this driver
Name() string

View File

@@ -28,7 +28,7 @@ const (
defaultCloneName = "clone"
)
// Registry represents registry credentials
// Registry represents registry credentials.
type Registry struct {
Hostname string
Username string
@@ -89,7 +89,7 @@ type ResourceLimit struct {
CPUSet string
}
// Compiler compiles the yaml
// Compiler compiles the yaml.
type Compiler struct {
local bool
escalated []string

View File

@@ -122,7 +122,7 @@ func (c *Compiler) createProcess(container *yaml_types.Container, stepType backe
}
environment[requested.Target] = secretValue
// TODO deprecated, remove in 3.x
// TODO: deprecated, remove in 3.x
environment[strings.ToUpper(requested.Target)] = secretValue
}

View File

@@ -150,7 +150,7 @@ func WithEnviron(env map[string]string) Option {
}
// WithNetworks configures the compiler with additional networks
// to be connected to pipeline containers
// to be connected to pipeline containers.
func WithNetworks(networks ...string) Option {
return func(compiler *Compiler) {
compiler.networks = networks
@@ -178,14 +178,14 @@ func WithDefaultCloneImage(cloneImage string) Option {
}
}
// WithTrusted configures the compiler with the trusted repo option
// WithTrusted configures the compiler with the trusted repo option.
func WithTrusted(trusted bool) Option {
return func(compiler *Compiler) {
compiler.trustedPipeline = trusted
}
}
// WithNetrcOnlyTrusted configures the compiler with the netrcOnlyTrusted repo option
// WithNetrcOnlyTrusted configures the compiler with the netrcOnlyTrusted repo option.
func WithNetrcOnlyTrusted(only bool) Option {
return func(compiler *Compiler) {
compiler.netrcOnlyTrusted = only

View File

@@ -42,7 +42,7 @@ func ParamsToEnv(from map[string]any, to map[string]string, prefix string, upper
return nil
}
// format the environment variable key
// sanitizeParamKey formats the environment variable key.
func sanitizeParamKey(prefix string, upper bool, k string) string {
r := strings.ReplaceAll(strings.ReplaceAll(k, ".", "_"), "-", "_")
if upper {
@@ -51,7 +51,7 @@ func sanitizeParamKey(prefix string, upper bool, k string) string {
return prefix + r
}
// indicate if a data type can be turned into string without encoding as json
// isComplex indicate if a data type can be turned into string without encoding as json.
func isComplex(t reflect.Kind) bool {
switch t {
case reflect.Bool,
@@ -64,7 +64,7 @@ func isComplex(t reflect.Kind) bool {
}
}
// sanitizeParamValue returns the value of a setting as string prepared to be injected as environment variable
// sanitizeParamValue returns the value of a setting as string prepared to be injected as environment variable.
func sanitizeParamValue(v any, getSecretValue func(name string) (string, error)) (string, error) {
t := reflect.TypeOf(v)
vv := reflect.ValueOf(v)
@@ -141,7 +141,7 @@ func sanitizeParamValue(v any, getSecretValue func(name string) (string, error))
return handleComplex(vv.Interface(), getSecretValue)
}
// handleComplex uses yaml2json to get json strings as values for environment variables
// handleComplex uses yaml2json to get json strings as values for environment variables.
func handleComplex(v any, getSecretValue func(name string) (string, error)) (string, error) {
v, err := injectSecretRecursive(v, getSecretValue)
if err != nil {
@@ -161,7 +161,7 @@ func handleComplex(v any, getSecretValue func(name string) (string, error)) (str
// injectSecret probes if a map is a from_secret request.
// If it's a from_secret request it either returns the secret value or an error if the secret was not found
// else it just indicates to progress normally using the provided map as is
// else it just indicates to progress normally using the provided map as is.
func injectSecret(v map[string]any, getSecretValue func(name string) (string, error)) (string, bool, error) {
if secretNameI, ok := v["from_secret"]; ok {
if secretName, ok := secretNameI.(string); ok {
@@ -178,7 +178,7 @@ func injectSecret(v map[string]any, getSecretValue func(name string) (string, er
}
// injectSecretRecursive iterates over all types and if they contain elements
// it iterates recursively over them too, using injectSecret internally
// it iterates recursively over them too, using injectSecret internally.
func injectSecretRecursive(v any, getSecretValue func(name string) (string, error)) (any, error) {
t := reflect.TypeOf(v)

View File

@@ -49,7 +49,7 @@ type (
Local yamlBaseTypes.BoolTrue
Path Path
Evaluate string `yaml:"evaluate,omitempty"`
// TODO change to StringOrSlice in 3.x
// TODO: change to StringOrSlice in 3.x
Event List
}
@@ -122,7 +122,7 @@ func (when *When) IncludesStatusSuccess() bool {
return false
}
// False if (any) non local
// False if (any) non local.
func (when *When) IsLocal() bool {
for _, c := range when.Constraints {
if !c.Local.Bool() {
@@ -206,7 +206,7 @@ func (c *Constraint) Match(m metadata.Metadata, global bool, env map[string]stri
return match, nil
}
// IsEmpty return true if a constraint has no conditions
// IsEmpty return true if a constraint has no conditions.
func (c List) IsEmpty() bool {
return len(c.Include) == 0 && len(c.Exclude) == 0
}

View File

@@ -29,7 +29,7 @@ import (
//go:embed schema.json
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) {
schemaLoader := gojsonschema.NewBytesLoader(schemaDefinition)

View File

@@ -46,7 +46,7 @@ func (s *StringOrInt) UnmarshalYAML(unmarshal func(any) error) error {
}
// MemStringOrInt represents a string or an integer
// the String supports notations like 10m for then Megabyte of memory
// the String supports notations like 10m for then Megabyte of memory.
type MemStringOrInt int64
// UnmarshalYAML implements the Unmarshaler interface.

View File

@@ -20,7 +20,7 @@ import (
"strings"
)
// SliceOrMap represents a map of strings, string slice are converted into a map
// SliceOrMap represents a map of strings, string slice are converted into a map.
type SliceOrMap map[string]any
// UnmarshalYAML implements the Unmarshaler interface.

View File

@@ -49,9 +49,9 @@ type (
Ports []string `yaml:"ports,omitempty"`
DependsOn base.StringOrSlice `yaml:"depends_on,omitempty"`
// TODO make []string in 3.x
// TODO: make []string in 3.x
Secrets Secrets `yaml:"secrets,omitempty"`
// TODO make map[string]any in 3.x
// TODO: make map[string]any in 3.x
Environment base.SliceOrMap `yaml:"environment,omitempty"`
// Docker and Kubernetes Specific

View File

@@ -26,7 +26,7 @@ type Volumes struct {
Volumes []*Volume
}
// Volume represent a service volume
// Volume represent a service volume.
type Volume struct {
Source string `yaml:"-"`
Destination string `yaml:"-"`
@@ -68,7 +68,7 @@ func (v *Volumes) UnmarshalYAML(unmarshal func(any) error) error {
}
elts := strings.SplitN(name, ":", 3)
var vol *Volume
//nolint: gomnd
//nolint:mnd
switch {
case len(elts) == 1:
vol = &Volume{