From 44bac51fcad8051d4abb8814dbc700d58f766850 Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Fri, 30 Sep 2022 14:25:31 +0200 Subject: [PATCH] bump golangci-lint to v1.49.0 Motivated to have a working `make lint` on Fedora 37 (beta). Most changes come from the new `gofmt` standards. Signed-off-by: Valentin Rothberg --- .golangci.yml | 1 + Makefile | 2 +- cmd/podman/common/completion_test.go | 1 + cmd/podman/utils/error.go | 10 +- cmd/podman/validate/choice.go | 3 +- libpod/container_path_resolution.go | 2 +- libpod/define/container_inspect.go | 1 + libpod/lock/shm/shm_lock.go | 2 +- libpod/oci.go | 2 +- libpod/oci_conmon_attach_common.go | 31 ++++-- libpod/oci_conmon_common.go | 2 +- libpod/plugin/volume_api.go | 8 +- libpod/state.go | 2 +- pkg/api/handlers/decoder.go | 3 +- pkg/api/handlers/swagger/doc.go | 22 ++-- pkg/api/handlers/utils/containers.go | 2 +- pkg/api/handlers/utils/handler_test.go | 6 +- pkg/api/server/doc.go | 56 +++++----- pkg/api/server/idle/tracker.go | 8 +- pkg/api/server/listener_api.go | 3 +- pkg/autoupdate/autoupdate.go | 2 +- pkg/bindings/containers/types.go | 105 ++++++++++++------ pkg/bindings/generate/types.go | 6 +- pkg/bindings/images/types.go | 48 +++++--- pkg/bindings/kube/types.go | 3 +- pkg/bindings/manifests/types.go | 18 ++- pkg/bindings/network/types.go | 21 ++-- pkg/bindings/pods/types.go | 42 ++++--- pkg/bindings/secrets/types.go | 12 +- pkg/bindings/system/types.go | 15 ++- pkg/bindings/test/common_test.go | 4 +- pkg/bindings/volumes/types.go | 18 ++- pkg/channel/doc.go | 12 +- pkg/domain/entities/engine_container.go | 2 +- pkg/domain/entities/engine_image.go | 2 +- pkg/domain/infra/tunnel/helpers.go | 3 +- pkg/k8s.io/api/apps/v1/types.go | 5 +- pkg/k8s.io/api/core/v1/resource.go | 1 + pkg/k8s.io/api/core/v1/types.go | 42 ++++--- .../apimachinery/pkg/api/resource/quantity.go | 33 ++++-- .../apimachinery/pkg/apis/meta/v1/types.go | 30 ++--- pkg/machine/applehv/machine.go | 2 +- pkg/machine/qemu/machine_unsupported.go | 2 +- pkg/machine/wsl/util_windows.go | 6 +- pkg/specgen/generate/kube/seccomp.go | 1 + pkg/specgen/generate/ports.go | 3 +- pkg/timetype/timestamp.go | 6 +- pkg/util/camelcase/camelcase.go | 48 ++++---- version/version.go | 3 +- 49 files changed, 400 insertions(+), 262 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index d8e80ec274..cf0c2279d0 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -14,6 +14,7 @@ linters: disable: # All these break for one reason or another - tagliatelle # too many JSON keys cannot be changed due to compat + - nosnakecase # too many false positives due to the `unix` package - gocognit - testpackage - goerr113 diff --git a/Makefile b/Makefile index a9ac293f00..10944dcc96 100644 --- a/Makefile +++ b/Makefile @@ -866,7 +866,7 @@ install.tools: .install.ginkgo .install.golangci-lint .install.swagger ## Instal .PHONY: .install.golangci-lint .install.golangci-lint: - VERSION=1.46.2 ./hack/install_golangci.sh + VERSION=1.49.0 ./hack/install_golangci.sh .PHONY: .install.swagger .install.swagger: diff --git a/cmd/podman/common/completion_test.go b/cmd/podman/common/completion_test.go index d8be48ad78..0ec8f03f57 100644 --- a/cmd/podman/common/completion_test.go +++ b/cmd/podman/common/completion_test.go @@ -50,6 +50,7 @@ func (c *Car) Color() string { } // This is for reflect testing required. +// //nolint:unused func (c Car) internal() int { return 0 diff --git a/cmd/podman/utils/error.go b/cmd/podman/utils/error.go index 3efff0301a..aa477833b9 100644 --- a/cmd/podman/utils/error.go +++ b/cmd/podman/utils/error.go @@ -25,11 +25,13 @@ func (o OutputErrors) PrintErrors() (lastError error) { return } -/* For remote client, server does not returns error with exit code - instead returns a message and we cast it to a new error. +/* +For remote client, server does not returns error with exit code - Following function performs parsing on build error and returns - exit status which was expected for this current build + instead returns a message and we cast it to a new error. + + Following function performs parsing on build error and returns + exit status which was expected for this current build */ func ExitCodeFromBuildError(errorMsg string) (int, error) { if strings.Contains(errorMsg, "exit status") { diff --git a/cmd/podman/validate/choice.go b/cmd/podman/validate/choice.go index 8bb21c5916..5a2e6f4cc4 100644 --- a/cmd/podman/validate/choice.go +++ b/cmd/podman/validate/choice.go @@ -14,7 +14,8 @@ type ChoiceValue struct { // Value may be used in cobra FlagSet methods Var/VarP/VarPF() to select from a set of values // // Example: -// created := validate.ChoiceValue(&opts.Sort, "command", "created", "id", "image", "names", "runningfor", "size", "status") +// +// created := validate.ChoiceValue(&opts.Sort, "command", "created", "id", "image", "names", "runningfor", "size", "status") // flags.Var(created, "sort", "Sort output by: "+created.Choices()) func Value(p *string, choices ...string) *ChoiceValue { return &ChoiceValue{ diff --git a/libpod/container_path_resolution.go b/libpod/container_path_resolution.go index cd86df5409..bd8c3f478a 100644 --- a/libpod/container_path_resolution.go +++ b/libpod/container_path_resolution.go @@ -166,7 +166,7 @@ func findBindMount(c *Container, containerPath string) *specs.Mount { return nil } -/// isPathOnMount returns true if the specified containerPath is a subdir of any +// / isPathOnMount returns true if the specified containerPath is a subdir of any // Mount's destination. func isPathOnMount(c *Container, containerPath string) bool { cleanedContainerPath := filepath.Clean(containerPath) diff --git a/libpod/define/container_inspect.go b/libpod/define/container_inspect.go index 7a00d708c7..690b255e1c 100644 --- a/libpod/define/container_inspect.go +++ b/libpod/define/container_inspect.go @@ -265,6 +265,7 @@ type HealthCheckLog struct { // as possible from the spec and container config. // Some things cannot be inferred. These will be populated by spec annotations // (if available). +// //nolint:revive,stylecheck // Field names are fixed for compatibility and cannot be changed. type InspectContainerHostConfig struct { // Binds contains an array of user-added mounts. diff --git a/libpod/lock/shm/shm_lock.go b/libpod/lock/shm/shm_lock.go index 3334a4018d..c8ae17a140 100644 --- a/libpod/lock/shm/shm_lock.go +++ b/libpod/lock/shm/shm_lock.go @@ -29,7 +29,7 @@ var ( // SHMLocks is a struct enabling POSIX semaphore locking in a shared memory // segment. -type SHMLocks struct { +type SHMLocks struct { //nolint:revive // linter complains about stutter lockStruct *C.shm_struct_t maxLocks uint32 valid bool diff --git a/libpod/oci.go b/libpod/oci.go index e5b9a0dcd4..30fb43b905 100644 --- a/libpod/oci.go +++ b/libpod/oci.go @@ -16,7 +16,7 @@ import ( // The code calling the OCIRuntime will manage this. // TODO: May want to move the conmon cleanup code here - it depends on // Conmon being in use. -type OCIRuntime interface { +type OCIRuntime interface { //nolint:interfacebloat // Name returns the name of the runtime. Name() string // Path returns the path to the runtime executable. diff --git a/libpod/oci_conmon_attach_common.go b/libpod/oci_conmon_attach_common.go index dec7498377..8d5a7f813b 100644 --- a/libpod/oci_conmon_attach_common.go +++ b/libpod/oci_conmon_attach_common.go @@ -103,17 +103,28 @@ func (r *ConmonOCIRuntime) Attach(c *Container, params *AttachOptions) error { return readStdio(conn, params.Streams, receiveStdoutError, stdinDone) } -// Attach to the given container's exec session -// attachFd and startFd must be open file descriptors -// attachFd must be the output side of the fd. attachFd is used for two things: -// conmon will first send a nonce value across the pipe indicating it has set up its side of the console socket -// this ensures attachToExec gets all of the output of the called process -// conmon will then send the exit code of the exec process, or an error in the exec session +// Attach to the given container's exec session. +// +// attachFd and startFd must be open file descriptors. attachFd must be the +// output side of the fd and is used for two things: +// +// 1. conmon will first send a nonce value across the pipe indicating it has +// set up its side of the console socket this ensures attachToExec gets all of +// the output of the called process. +// +// 2. conmon will then send the exit code of the exec process, or an error in the exec session. +// // startFd must be the input side of the fd. -// newSize resizes the tty to this size before the process is started, must be nil if the exec session has no tty -// conmon will wait to start the exec session until the parent process has set up the console socket. -// Once attachToExec successfully attaches to the console socket, the child conmon process responsible for calling runtime exec -// will read from the output side of start fd, thus learning to start the child process. +// +// newSize resizes the tty to this size before the process is started, must be +// nil if the exec session has no tty +// +// conmon will wait to start the exec session until the parent process has set up the console socket. +// +// Once attachToExec successfully attaches to the console socket, the child +// conmon process responsible for calling runtime exec will read from the +// output side of start fd, thus learning to start the child process. +// // Thus, the order goes as follow: // 1. conmon parent process sets up its console socket. sends on attachFd // 2. attachToExec attaches to the console socket after reading on attachFd and resizes the tty diff --git a/libpod/oci_conmon_common.go b/libpod/oci_conmon_common.go index 157cbe2598..f5acf079d9 100644 --- a/libpod/oci_conmon_common.go +++ b/libpod/oci_conmon_common.go @@ -1317,7 +1317,7 @@ func (r *ConmonOCIRuntime) sharedConmonArgs(ctr *Container, cuuid, bundlePath, p case define.PassthroughLogging: logDriverArg = define.PassthroughLogging //lint:ignore ST1015 the default case has to be here - default: //nolint:stylecheck,gocritic + default: //nolint:gocritic // No case here should happen except JSONLogging, but keep this here in case the options are extended logrus.Errorf("%s logging specified but not supported. Choosing k8s-file logging instead", ctr.LogDriver()) fallthrough diff --git a/libpod/plugin/volume_api.go b/libpod/plugin/volume_api.go index c595937ae9..2c20166851 100644 --- a/libpod/plugin/volume_api.go +++ b/libpod/plugin/volume_api.go @@ -74,7 +74,7 @@ type activateResponse struct { func validatePlugin(newPlugin *VolumePlugin) error { // It's a socket. Is it a plugin? // Hit the Activate endpoint to find out if it is, and if so what kind - req, err := http.NewRequest("POST", "http://plugin"+activatePath, nil) + req, err := http.NewRequest(http.MethodPost, "http://plugin"+activatePath, nil) if err != nil { return fmt.Errorf("making request to volume plugin %s activation endpoint: %w", newPlugin.Name, err) } @@ -90,7 +90,7 @@ func validatePlugin(newPlugin *VolumePlugin) error { // Response code MUST be 200. Anything else, we have to assume it's not // a valid plugin. - if resp.StatusCode != 200 { + if resp.StatusCode != http.StatusOK { return fmt.Errorf("got status code %d from activation endpoint for plugin %s: %w", resp.StatusCode, newPlugin.Name, ErrNotPlugin) } @@ -216,7 +216,7 @@ func (p *VolumePlugin) sendRequest(toJSON interface{}, endpoint string) (*http.R } } - req, err := http.NewRequest("POST", "http://plugin"+endpoint, bytes.NewReader(reqJSON)) + req, err := http.NewRequest(http.MethodPost, "http://plugin"+endpoint, bytes.NewReader(reqJSON)) if err != nil { return nil, fmt.Errorf("making request to volume plugin %s endpoint %s: %w", p.Name, endpoint, err) } @@ -251,7 +251,7 @@ func (p *VolumePlugin) handleErrorResponse(resp *http.Response, endpoint, volNam // errors, but I don't think we can guarantee all plugins do that. // Let's interpret anything other than 200 as an error. // If there isn't an error, don't even bother decoding the response. - if resp.StatusCode != 200 { + if resp.StatusCode != http.StatusOK { errResp, err := io.ReadAll(resp.Body) if err != nil { return fmt.Errorf("reading response body from volume plugin %s: %w", p.Name, err) diff --git a/libpod/state.go b/libpod/state.go index 9d96045635..5fa8dc257b 100644 --- a/libpod/state.go +++ b/libpod/state.go @@ -15,7 +15,7 @@ import "github.com/containers/common/libnetwork/types" // retrieved after they are pulled from the database. // Generally speaking, the syncContainer() call should be run at the beginning // of all API operations, which will silently handle this. -type State interface { +type State interface { //nolint:interfacebloat // Close performs any pre-exit cleanup (e.g. closing database // connections) that may be required Close() error diff --git a/pkg/api/handlers/decoder.go b/pkg/api/handlers/decoder.go index fbe03d97b3..0696920142 100644 --- a/pkg/api/handlers/decoder.go +++ b/pkg/api/handlers/decoder.go @@ -29,7 +29,8 @@ func NewAPIDecoder() *schema.Decoder { } // On client: -// v := map[string][]string{ +// +// v := map[string][]string{ // "dangling": {"true"}, // } // diff --git a/pkg/api/handlers/swagger/doc.go b/pkg/api/handlers/swagger/doc.go index 67ede275ad..7e535ea298 100644 --- a/pkg/api/handlers/swagger/doc.go +++ b/pkg/api/handlers/swagger/doc.go @@ -1,17 +1,15 @@ // Package swagger defines the payloads used by the Podman API // -// - errors.go: declares the errors used in the API. By embedding errors.ErrorModel, more meaningful -// comments can be provided for the developer documentation. -// - models.go: declares the models used in API requests. -// - responses.go: declares the responses used in the API responses. -// +// - errors.go: declares the errors used in the API. By embedding errors.ErrorModel, more meaningful +// comments can be provided for the developer documentation. +// - models.go: declares the models used in API requests. +// - responses.go: declares the responses used in the API responses. // // Notes: -// 1. As a developer of the Podman API, you are responsible for maintaining the associations between -// these models and responses, and the handler code. -// 2. There are a number of warnings produces when compiling the swagger yaml file. This is expected. -// Most are because embedded structs have been discovered but not used in the API declarations. -// 3. Response and model references that are exported (start with upper-case letter) imply that they -// exist outside this package and should be found in the entities package. -// +// 1. As a developer of the Podman API, you are responsible for maintaining the associations between +// these models and responses, and the handler code. +// 2. There are a number of warnings produces when compiling the swagger yaml file. This is expected. +// Most are because embedded structs have been discovered but not used in the API declarations. +// 3. Response and model references that are exported (start with upper-case letter) imply that they +// exist outside this package and should be found in the entities package. package swagger diff --git a/pkg/api/handlers/utils/containers.go b/pkg/api/handlers/utils/containers.go index e198bdd6c6..500abf9ca2 100644 --- a/pkg/api/handlers/utils/containers.go +++ b/pkg/api/handlers/utils/containers.go @@ -69,7 +69,7 @@ func WaitContainerDocker(w http.ResponseWriter, r *http.Request) { // In docker compatibility mode we have to send headers in advance, // otherwise docker client would freeze. w.Header().Set("Content-Type", "application/json") - w.WriteHeader(200) + w.WriteHeader(http.StatusOK) if flusher, ok := w.(http.Flusher); ok { flusher.Flush() } diff --git a/pkg/api/handlers/utils/handler_test.go b/pkg/api/handlers/utils/handler_test.go index 924f5d2468..afa6f17eb1 100644 --- a/pkg/api/handlers/utils/handler_test.go +++ b/pkg/api/handlers/utils/handler_test.go @@ -12,7 +12,7 @@ import ( ) func TestSupportedVersion(t *testing.T) { - req, err := http.NewRequest("GET", + req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("/v%s/libpod/testing/versions", version.APIVersion[version.Libpod][version.CurrentAPI]), nil) if err != nil { @@ -55,7 +55,7 @@ func TestSupportedVersion(t *testing.T) { func TestUnsupportedVersion(t *testing.T) { version := "999.999.999" - req, err := http.NewRequest("GET", + req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("/v%s/libpod/testing/versions", version), nil) if err != nil { @@ -98,7 +98,7 @@ func TestUnsupportedVersion(t *testing.T) { func TestEqualVersion(t *testing.T) { version := "1.30.0" - req, err := http.NewRequest("GET", + req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("/v%s/libpod/testing/versions", version), nil) if err != nil { diff --git a/pkg/api/server/doc.go b/pkg/api/server/doc.go index 0bb10a19ce..4be87dd59a 100644 --- a/pkg/api/server/doc.go +++ b/pkg/api/server/doc.go @@ -5,7 +5,7 @@ // // To start the service and keep it running for 5,000 seconds (-t 0 runs forever): // -// podman system service -t 5000 & +// podman system service -t 5000 & // // You can then use cURL on the socket using requests documented below. // @@ -23,44 +23,44 @@ // // See podman-service(1) for more information. // -// Quick Examples: +// Quick Examples: // -// 'podman info' +// 'podman info' // -// curl --unix-socket /run/podman/podman.sock http://d/v4.0.0/libpod/info +// curl --unix-socket /run/podman/podman.sock http://d/v4.0.0/libpod/info // -// 'podman pull quay.io/containers/podman' +// 'podman pull quay.io/containers/podman' // -// curl -XPOST --unix-socket /run/podman/podman.sock -v 'http://d/v4.0.0/images/create?fromImage=quay.io%2Fcontainers%2Fpodman' +// curl -XPOST --unix-socket /run/podman/podman.sock -v 'http://d/v4.0.0/images/create?fromImage=quay.io%2Fcontainers%2Fpodman' // -// 'podman list images' +// 'podman list images' // -// curl --unix-socket /run/podman/podman.sock -v 'http://d/v4.0.0/libpod/images/json' | jq +// curl --unix-socket /run/podman/podman.sock -v 'http://d/v4.0.0/libpod/images/json' | jq // // Terms Of Service: // // https://github.com/containers/podman/blob/913caaa9b1de2b63692c9bae15120208194c9eb3/LICENSE // -// Schemes: http, https -// Host: podman.io -// BasePath: / -// Version: 4.0.0 -// License: Apache-2.0 https://opensource.org/licenses/Apache-2.0 -// Contact: Podman https://podman.io/community/ -// -// InfoExtensions: -// x-logo: -// - url: https://raw.githubusercontent.com/containers/libpod/main/logo/podman-logo.png -// - altText: "Podman logo" -// -// Produces: -// - application/json -// - application/octet-stream -// - text/plain -// -// Consumes: -// - application/json -// - application/x-tar +// Schemes: http, https +// Host: podman.io +// BasePath: / +// Version: 4.0.0 +// License: Apache-2.0 https://opensource.org/licenses/Apache-2.0 +// Contact: Podman https://podman.io/community/ +// +// InfoExtensions: +// x-logo: +// - url: https://raw.githubusercontent.com/containers/libpod/main/logo/podman-logo.png +// - altText: "Podman logo" +// +// Produces: +// - application/json +// - application/octet-stream +// - text/plain +// +// Consumes: +// - application/json +// - application/x-tar // // swagger:meta package server diff --git a/pkg/api/server/idle/tracker.go b/pkg/api/server/idle/tracker.go index 480239f058..fe815f6138 100644 --- a/pkg/api/server/idle/tracker.go +++ b/pkg/api/server/idle/tracker.go @@ -32,10 +32,10 @@ func NewTracker(idle time.Duration) *Tracker { } // ConnState is called on HTTP connection state changes. -// - Once StateHijacked, StateClose is _NOT_ called on that connection -// - There are two "idle" timeouts, the http idle connection (not to be confused with the TCP/IP idle socket timeout) -// and the API idle window. The caller should set the http idle timeout to 2x the time provided to NewTacker() which -// is the API idle window. +// - Once StateHijacked, StateClose is _NOT_ called on that connection +// - There are two "idle" timeouts, the http idle connection (not to be confused with the TCP/IP idle socket timeout) +// and the API idle window. The caller should set the http idle timeout to 2x the time provided to NewTacker() which +// is the API idle window. func (t *Tracker) ConnState(conn net.Conn, state http.ConnState) { t.mux.Lock() defer t.mux.Unlock() diff --git a/pkg/api/server/listener_api.go b/pkg/api/server/listener_api.go index d1f3ea7a3e..38abe27431 100644 --- a/pkg/api/server/listener_api.go +++ b/pkg/api/server/listener_api.go @@ -8,7 +8,8 @@ import ( ) // ListenUnix follows stdlib net.Listen() API, providing a unix listener for given path -// ListenUnix will delete and create files/directories as needed +// +// ListenUnix will delete and create files/directories as needed func ListenUnix(network string, path string) (net.Listener, error) { // set up custom listener for API server err := os.MkdirAll(filepath.Dir(path), 0770) diff --git a/pkg/autoupdate/autoupdate.go b/pkg/autoupdate/autoupdate.go index a0ed8ccbac..68a0fd7b6e 100644 --- a/pkg/autoupdate/autoupdate.go +++ b/pkg/autoupdate/autoupdate.go @@ -92,7 +92,7 @@ func LookupPolicy(s string) (Policy, error) { return "", fmt.Errorf("invalid auto-update policy %q: valid policies are %+q", s, keys) } -/// AutoUpdate looks up containers with a specified auto-update policy and acts +// / AutoUpdate looks up containers with a specified auto-update policy and acts // accordingly. // // If the policy is set to PolicyRegistryImage, it checks if the image diff --git a/pkg/bindings/containers/types.go b/pkg/bindings/containers/types.go index f640ba7561..8e9f39dd5a 100644 --- a/pkg/bindings/containers/types.go +++ b/pkg/bindings/containers/types.go @@ -7,9 +7,10 @@ import ( "github.com/containers/podman/v4/libpod/define" ) -//go:generate go run ../generator/generator.go LogOptions // LogOptions describe finer control of log content or // how the content is formatted. +// +//go:generate go run ../generator/generator.go LogOptions type LogOptions struct { Follow *bool Since *string @@ -20,10 +21,11 @@ type LogOptions struct { Until *string } -//go:generate go run ../generator/generator.go CommitOptions // CommitOptions describe details about the resulting committed // image as defined by repo and tag. None of these options // are required. +// +//go:generate go run ../generator/generator.go CommitOptions type CommitOptions struct { Author *string Changes []string @@ -35,16 +37,18 @@ type CommitOptions struct { Tag *string } -//go:generate go run ../generator/generator.go AttachOptions // AttachOptions are optional options for attaching to containers +// +//go:generate go run ../generator/generator.go AttachOptions type AttachOptions struct { DetachKeys *string // Keys to detach from running container Logs *bool // Flag to return all logs from container when true Stream *bool // Flag only return container logs when false and Logs is true } -//go:generate go run ../generator/generator.go CheckpointOptions // CheckpointOptions are optional options for checkpointing containers +// +//go:generate go run ../generator/generator.go CheckpointOptions type CheckpointOptions struct { Export *string CreateImage *string @@ -58,8 +62,9 @@ type CheckpointOptions struct { FileLocks *bool } -//go:generate go run ../generator/generator.go RestoreOptions // RestoreOptions are optional options for restoring containers +// +//go:generate go run ../generator/generator.go RestoreOptions type RestoreOptions struct { IgnoreRootfs *bool IgnoreVolumes *bool @@ -82,12 +87,14 @@ type RestoreOptions struct { FileLocks *bool } -//go:generate go run ../generator/generator.go CreateOptions // CreateOptions are optional options for creating containers +// +//go:generate go run ../generator/generator.go CreateOptions type CreateOptions struct{} -//go:generate go run ../generator/generator.go DiffOptions // DiffOptions are optional options for creating containers +// +//go:generate go run ../generator/generator.go DiffOptions type DiffOptions struct { // By the default diff will compare against the parent layer. Change the Parent if you want to compare against something else. Parent *string @@ -95,39 +102,46 @@ type DiffOptions struct { DiffType *string } -//go:generate go run ../generator/generator.go ExecInspectOptions // ExecInspectOptions are optional options for inspecting // exec sessions +// +//go:generate go run ../generator/generator.go ExecInspectOptions type ExecInspectOptions struct{} -//go:generate go run ../generator/generator.go ExecStartOptions // ExecStartOptions are optional options for starting // exec sessions +// +//go:generate go run ../generator/generator.go ExecStartOptions type ExecStartOptions struct { } -//go:generate go run ../generator/generator.go HealthCheckOptions // HealthCheckOptions are optional options for checking // the health of a container +// +//go:generate go run ../generator/generator.go HealthCheckOptions type HealthCheckOptions struct{} -//go:generate go run ../generator/generator.go MountOptions // MountOptions are optional options for mounting // containers +// +//go:generate go run ../generator/generator.go MountOptions type MountOptions struct{} -//go:generate go run ../generator/generator.go UnmountOptions // UnmountOptions are optional options for unmounting // containers +// +//go:generate go run ../generator/generator.go UnmountOptions type UnmountOptions struct{} -//go:generate go run ../generator/generator.go MountedContainerPathsOptions // MountedContainerPathsOptions are optional options for getting // container mount paths +// +//go:generate go run ../generator/generator.go MountedContainerPathsOptions type MountedContainerPathsOptions struct{} -//go:generate go run ../generator/generator.go ListOptions // ListOptions are optional options for listing containers +// +//go:generate go run ../generator/generator.go ListOptions type ListOptions struct { All *bool External *bool @@ -138,14 +152,16 @@ type ListOptions struct { Sync *bool } -//go:generate go run ../generator/generator.go PruneOptions // PruneOptions are optional options for pruning containers +// +//go:generate go run ../generator/generator.go PruneOptions type PruneOptions struct { Filters map[string][]string } -//go:generate go run ../generator/generator.go RemoveOptions // RemoveOptions are optional options for removing containers +// +//go:generate go run ../generator/generator.go RemoveOptions type RemoveOptions struct { Depend *bool Ignore *bool @@ -154,106 +170,123 @@ type RemoveOptions struct { Timeout *uint } -//go:generate go run ../generator/generator.go InspectOptions // InspectOptions are optional options for inspecting containers +// +//go:generate go run ../generator/generator.go InspectOptions type InspectOptions struct { Size *bool } -//go:generate go run ../generator/generator.go KillOptions // KillOptions are optional options for killing containers +// +//go:generate go run ../generator/generator.go KillOptions type KillOptions struct { Signal *string } -//go:generate go run ../generator/generator.go PauseOptions // PauseOptions are optional options for pausing containers +// +//go:generate go run ../generator/generator.go PauseOptions type PauseOptions struct{} -//go:generate go run ../generator/generator.go RestartOptions // RestartOptions are optional options for restarting containers +// +//go:generate go run ../generator/generator.go RestartOptions type RestartOptions struct { Timeout *int } -//go:generate go run ../generator/generator.go StartOptions // StartOptions are optional options for starting containers +// +//go:generate go run ../generator/generator.go StartOptions type StartOptions struct { DetachKeys *string Recursive *bool } -//go:generate go run ../generator/generator.go StatsOptions // StatsOptions are optional options for getting stats on containers +// +//go:generate go run ../generator/generator.go StatsOptions type StatsOptions struct { Stream *bool Interval *int } -//go:generate go run ../generator/generator.go TopOptions // TopOptions are optional options for getting running // processes in containers +// +//go:generate go run ../generator/generator.go TopOptions type TopOptions struct { Descriptors *[]string } -//go:generate go run ../generator/generator.go UnpauseOptions // UnpauseOptions are optional options for unpausing containers +// +//go:generate go run ../generator/generator.go UnpauseOptions type UnpauseOptions struct{} -//go:generate go run ../generator/generator.go WaitOptions // WaitOptions are optional options for waiting on containers +// +//go:generate go run ../generator/generator.go WaitOptions type WaitOptions struct { Condition []define.ContainerStatus Interval *string } -//go:generate go run ../generator/generator.go StopOptions // StopOptions are optional options for stopping containers +// +//go:generate go run ../generator/generator.go StopOptions type StopOptions struct { Ignore *bool Timeout *uint } -//go:generate go run ../generator/generator.go ExportOptions // ExportOptions are optional options for exporting containers +// +//go:generate go run ../generator/generator.go ExportOptions type ExportOptions struct{} -//go:generate go run ../generator/generator.go InitOptions // InitOptions are optional options for initing containers +// +//go:generate go run ../generator/generator.go InitOptions type InitOptions struct{} -//go:generate go run ../generator/generator.go ShouldRestartOptions // ShouldRestartOptions +// +//go:generate go run ../generator/generator.go ShouldRestartOptions type ShouldRestartOptions struct{} -//go:generate go run ../generator/generator.go RenameOptions // RenameOptions are options for renaming containers. // The Name field is required. +// +//go:generate go run ../generator/generator.go RenameOptions type RenameOptions struct { Name *string } -//go:generate go run ../generator/generator.go ResizeTTYOptions // ResizeTTYOptions are optional options for resizing // container TTYs +// +//go:generate go run ../generator/generator.go ResizeTTYOptions type ResizeTTYOptions struct { Height *int Width *int Running *bool } -//go:generate go run ../generator/generator.go ResizeExecTTYOptions // ResizeExecTTYOptions are optional options for resizing // container ExecTTYs +// +//go:generate go run ../generator/generator.go ResizeExecTTYOptions type ResizeExecTTYOptions struct { Height *int Width *int } -//go:generate go run ../generator/generator.go ExecStartAndAttachOptions // ExecStartAndAttachOptions are optional options for resizing // container ExecTTYs +// +//go:generate go run ../generator/generator.go ExecStartAndAttachOptions type ExecStartAndAttachOptions struct { // OutputStream will be attached to container's STDOUT OutputStream *io.WriteCloser @@ -272,15 +305,17 @@ type ExecStartAndAttachOptions struct { AttachInput *bool } -//go:generate go run ../generator/generator.go ExistsOptions // ExistsOptions are optional options for checking if a container exists +// +//go:generate go run ../generator/generator.go ExistsOptions type ExistsOptions struct { // External checks for containers created outside of Podman External *bool } -//go:generate go run ../generator/generator.go CopyOptions // CopyOptions are options for copying to containers. +// +//go:generate go run ../generator/generator.go CopyOptions type CopyOptions struct { // If used with CopyFromArchive and set to true it will change ownership of files from the source tar archive // to the primary uid/gid of the target container. diff --git a/pkg/bindings/generate/types.go b/pkg/bindings/generate/types.go index 31b43897cb..235995ec0d 100644 --- a/pkg/bindings/generate/types.go +++ b/pkg/bindings/generate/types.go @@ -1,14 +1,16 @@ package generate -//go:generate go run ../generator/generator.go KubeOptions // KubeOptions are optional options for generating kube YAML files +// +//go:generate go run ../generator/generator.go KubeOptions type KubeOptions struct { // Service - generate YAML for a Kubernetes _service_ object. Service *bool } -//go:generate go run ../generator/generator.go SystemdOptions // SystemdOptions are optional options for generating systemd files +// +//go:generate go run ../generator/generator.go SystemdOptions type SystemdOptions struct { // Name - use container/pod name instead of its ID. UseName *bool diff --git a/pkg/bindings/images/types.go b/pkg/bindings/images/types.go index f8630926e6..3f9e503ca9 100644 --- a/pkg/bindings/images/types.go +++ b/pkg/bindings/images/types.go @@ -6,8 +6,9 @@ import ( buildahDefine "github.com/containers/buildah/define" ) -//go:generate go run ../generator/generator.go RemoveOptions // RemoveOptions are optional options for image removal +// +//go:generate go run ../generator/generator.go RemoveOptions type RemoveOptions struct { // All removes all images All *bool @@ -21,8 +22,9 @@ type RemoveOptions struct { NoPrune *bool } -//go:generate go run ../generator/generator.go DiffOptions // DiffOptions are optional options image diffs +// +//go:generate go run ../generator/generator.go DiffOptions type DiffOptions struct { // By the default diff will compare against the parent layer. Change the Parent if you want to compare against something else. Parent *string @@ -30,8 +32,9 @@ type DiffOptions struct { DiffType *string } -//go:generate go run ../generator/generator.go ListOptions // ListOptions are optional options for listing images +// +//go:generate go run ../generator/generator.go ListOptions type ListOptions struct { // All lists all image in the image store including dangling images All *bool @@ -39,35 +42,40 @@ type ListOptions struct { Filters map[string][]string } -//go:generate go run ../generator/generator.go GetOptions // GetOptions are optional options for inspecting an image +// +//go:generate go run ../generator/generator.go GetOptions type GetOptions struct { // Size computes the amount of storage the image consumes Size *bool } -//go:generate go run ../generator/generator.go TreeOptions // TreeOptions are optional options for a tree-based representation // of the image +// +//go:generate go run ../generator/generator.go TreeOptions type TreeOptions struct { // WhatRequires ... WhatRequires *bool } -//go:generate go run ../generator/generator.go HistoryOptions // HistoryOptions are optional options image history +// +//go:generate go run ../generator/generator.go HistoryOptions type HistoryOptions struct { } -//go:generate go run ../generator/generator.go LoadOptions // LoadOptions are optional options for loading an image +// +//go:generate go run ../generator/generator.go LoadOptions type LoadOptions struct { // Reference is the name of the loaded image Reference *string } -//go:generate go run ../generator/generator.go ExportOptions // ExportOptions are optional options for exporting images +// +//go:generate go run ../generator/generator.go ExportOptions type ExportOptions struct { // Compress the image Compress *bool @@ -77,8 +85,9 @@ type ExportOptions struct { OciAcceptUncompressedLayers *bool } -//go:generate go run ../generator/generator.go PruneOptions // PruneOptions are optional options for pruning images +// +//go:generate go run ../generator/generator.go PruneOptions type PruneOptions struct { // Prune all images All *bool @@ -88,18 +97,21 @@ type PruneOptions struct { Filters map[string][]string } -//go:generate go run ../generator/generator.go TagOptions // TagOptions are optional options for tagging images +// +//go:generate go run ../generator/generator.go TagOptions type TagOptions struct { } -//go:generate go run ../generator/generator.go UntagOptions // UntagOptions are optional options for untagging images +// +//go:generate go run ../generator/generator.go UntagOptions type UntagOptions struct { } -//go:generate go run ../generator/generator.go ImportOptions // ImportOptions are optional options for importing images +// +//go:generate go run ../generator/generator.go ImportOptions type ImportOptions struct { // Changes to be applied to the image Changes *[]string @@ -117,8 +129,9 @@ type ImportOptions struct { Variant *string } -//go:generate go run ../generator/generator.go PushOptions // PushOptions are optional options for importing images +// +//go:generate go run ../generator/generator.go PushOptions type PushOptions struct { // All indicates whether to push all images related to the image list All *bool @@ -147,8 +160,9 @@ type PushOptions struct { Quiet *bool } -//go:generate go run ../generator/generator.go SearchOptions // SearchOptions are optional options for searching images on registries +// +//go:generate go run ../generator/generator.go SearchOptions type SearchOptions struct { // Authfile is the path to the authentication file. Ignored for remote // calls. @@ -163,8 +177,9 @@ type SearchOptions struct { ListTags *bool } -//go:generate go run ../generator/generator.go PullOptions // PullOptions are optional options for pulling images +// +//go:generate go run ../generator/generator.go PullOptions type PullOptions struct { // AllTags can be specified to pull all tags of an image. Note // that this only works if the image does not include a tag. @@ -200,8 +215,9 @@ type BuildOptions struct { buildahDefine.BuildOptions } -//go:generate go run ../generator/generator.go ExistsOptions // ExistsOptions are optional options for checking if an image exists +// +//go:generate go run ../generator/generator.go ExistsOptions type ExistsOptions struct { } diff --git a/pkg/bindings/kube/types.go b/pkg/bindings/kube/types.go index 279a9f8f3f..93057972e3 100644 --- a/pkg/bindings/kube/types.go +++ b/pkg/bindings/kube/types.go @@ -4,8 +4,9 @@ import ( "net" ) -//go:generate go run ../generator/generator.go PlayOptions // PlayOptions are optional options for replaying kube YAML files +// +//go:generate go run ../generator/generator.go PlayOptions type PlayOptions struct { // Annotations - Annotations to add to Pods Annotations map[string]string diff --git a/pkg/bindings/manifests/types.go b/pkg/bindings/manifests/types.go index fec3f9d136..45c15f9540 100644 --- a/pkg/bindings/manifests/types.go +++ b/pkg/bindings/manifests/types.go @@ -1,25 +1,29 @@ package manifests -//go:generate go run ../generator/generator.go InspectOptions // InspectOptions are optional options for inspecting manifests +// +//go:generate go run ../generator/generator.go InspectOptions type InspectOptions struct { } -//go:generate go run ../generator/generator.go CreateOptions // CreateOptions are optional options for creating manifests +// +//go:generate go run ../generator/generator.go CreateOptions type CreateOptions struct { All *bool Amend *bool } -//go:generate go run ../generator/generator.go ExistsOptions // ExistsOptions are optional options for checking // if a manifest list exists +// +//go:generate go run ../generator/generator.go ExistsOptions type ExistsOptions struct { } -//go:generate go run ../generator/generator.go AddOptions // AddOptions are optional options for adding manifest lists +// +//go:generate go run ../generator/generator.go AddOptions type AddOptions struct { All *bool Annotation map[string]string @@ -35,13 +39,15 @@ type AddOptions struct { SkipTLSVerify *bool `schema:"-"` } -//go:generate go run ../generator/generator.go RemoveOptions // RemoveOptions are optional options for removing manifest lists +// +//go:generate go run ../generator/generator.go RemoveOptions type RemoveOptions struct { } -//go:generate go run ../generator/generator.go ModifyOptions // ModifyOptions are optional options for modifying manifest lists +// +//go:generate go run ../generator/generator.go ModifyOptions type ModifyOptions struct { // Operation values are "update", "remove" and "annotate". This allows the service to // efficiently perform each update on a manifest list. diff --git a/pkg/bindings/network/types.go b/pkg/bindings/network/types.go index b82c0e4385..a3d69426c2 100644 --- a/pkg/bindings/network/types.go +++ b/pkg/bindings/network/types.go @@ -4,8 +4,9 @@ import ( "net" ) -//go:generate go run ../generator/generator.go CreateOptions // CreateOptions are optional options for creating networks +// +//go:generate go run ../generator/generator.go CreateOptions type CreateOptions struct { // DisableDNS turns off use of DNSMasq for name resolution // on the network @@ -33,45 +34,51 @@ type CreateOptions struct { Name *string } -//go:generate go run ../generator/generator.go InspectOptions // InspectOptions are optional options for inspecting networks +// +//go:generate go run ../generator/generator.go InspectOptions type InspectOptions struct { } -//go:generate go run ../generator/generator.go RemoveOptions // RemoveOptions are optional options for inspecting networks +// +//go:generate go run ../generator/generator.go RemoveOptions type RemoveOptions struct { // Force removes the network even if it is being used Force *bool Timeout *uint } -//go:generate go run ../generator/generator.go ListOptions // ListOptions are optional options for listing networks +// +//go:generate go run ../generator/generator.go ListOptions type ListOptions struct { // Filters are applied to the list of networks to be more // specific on the output Filters map[string][]string } -//go:generate go run ../generator/generator.go DisconnectOptions // DisconnectOptions are optional options for disconnecting // containers from a network +// +//go:generate go run ../generator/generator.go DisconnectOptions type DisconnectOptions struct { // Force indicates to remove the container from // the network forcibly Force *bool } -//go:generate go run ../generator/generator.go ExistsOptions // ExistsOptions are optional options for checking // if a network exists +// +//go:generate go run ../generator/generator.go ExistsOptions type ExistsOptions struct { } -//go:generate go run ../generator/generator.go PruneOptions // PruneOptions are optional options for removing unused // CNI networks +// +//go:generate go run ../generator/generator.go PruneOptions type PruneOptions struct { // Filters are applied to the prune of networks to be more // specific on choosing diff --git a/pkg/bindings/pods/types.go b/pkg/bindings/pods/types.go index 71fada4ebc..904815db76 100644 --- a/pkg/bindings/pods/types.go +++ b/pkg/bindings/pods/types.go @@ -1,78 +1,92 @@ package pods -//go:generate go run ../generator/generator.go CreateOptions // CreateOptions are optional options for creating pods +// +//go:generate go run ../generator/generator.go CreateOptions type CreateOptions struct { } -//go:generate go run ../generator/generator.go InspectOptions // InspectOptions are optional options for inspecting pods +// +//go:generate go run ../generator/generator.go InspectOptions type InspectOptions struct { } -//go:generate go run ../generator/generator.go KillOptions // KillOptions are optional options for killing pods +// +//go:generate go run ../generator/generator.go KillOptions type KillOptions struct { Signal *string } -//go:generate go run ../generator/generator.go PauseOptions // PauseOptions are optional options for pausing pods +// +//go:generate go run ../generator/generator.go PauseOptions type PauseOptions struct { } -//go:generate go run ../generator/generator.go PruneOptions // PruneOptions are optional options for pruning pods +// +//go:generate go run ../generator/generator.go PruneOptions type PruneOptions struct { } -//go:generate go run ../generator/generator.go ListOptions // ListOptions are optional options for listing pods +// +//go:generate go run ../generator/generator.go ListOptions type ListOptions struct { Filters map[string][]string } -//go:generate go run ../generator/generator.go RestartOptions // RestartOptions are optional options for restarting pods +// +//go:generate go run ../generator/generator.go RestartOptions type RestartOptions struct { } -//go:generate go run ../generator/generator.go StartOptions // StartOptions are optional options for starting pods +// +//go:generate go run ../generator/generator.go StartOptions type StartOptions struct { } -//go:generate go run ../generator/generator.go StopOptions // StopOptions are optional options for stopping pods +// +//go:generate go run ../generator/generator.go StopOptions type StopOptions struct { Timeout *int } -//go:generate go run ../generator/generator.go TopOptions // TopOptions are optional options for getting top on pods +// +//go:generate go run ../generator/generator.go TopOptions type TopOptions struct { Descriptors []string } -//go:generate go run ../generator/generator.go UnpauseOptions // UnpauseOptions are optional options for unpausinging pods +// +//go:generate go run ../generator/generator.go UnpauseOptions type UnpauseOptions struct { } -//go:generate go run ../generator/generator.go StatsOptions // StatsOptions are optional options for getting stats of pods +// +//go:generate go run ../generator/generator.go StatsOptions type StatsOptions struct { All *bool } -//go:generate go run ../generator/generator.go RemoveOptions // RemoveOptions are optional options for removing pods +// +//go:generate go run ../generator/generator.go RemoveOptions type RemoveOptions struct { Force *bool Timeout *uint } -//go:generate go run ../generator/generator.go ExistsOptions // ExistsOptions are optional options for checking if a pod exists +// +//go:generate go run ../generator/generator.go ExistsOptions type ExistsOptions struct { } diff --git a/pkg/bindings/secrets/types.go b/pkg/bindings/secrets/types.go index d2f4495566..a84658826b 100644 --- a/pkg/bindings/secrets/types.go +++ b/pkg/bindings/secrets/types.go @@ -1,23 +1,27 @@ package secrets -//go:generate go run ../generator/generator.go ListOptions // ListOptions are optional options for inspecting secrets +// +//go:generate go run ../generator/generator.go ListOptions type ListOptions struct { Filters map[string][]string } -//go:generate go run ../generator/generator.go InspectOptions // InspectOptions are optional options for inspecting secrets +// +//go:generate go run ../generator/generator.go InspectOptions type InspectOptions struct { } -//go:generate go run ../generator/generator.go RemoveOptions // RemoveOptions are optional options for removing secrets +// +//go:generate go run ../generator/generator.go RemoveOptions type RemoveOptions struct { } -//go:generate go run ../generator/generator.go CreateOptions // CreateOptions are optional options for Creating secrets +// +//go:generate go run ../generator/generator.go CreateOptions type CreateOptions struct { Name *string Driver *string diff --git a/pkg/bindings/system/types.go b/pkg/bindings/system/types.go index 16960b8170..9efd280044 100644 --- a/pkg/bindings/system/types.go +++ b/pkg/bindings/system/types.go @@ -1,7 +1,8 @@ package system -//go:generate go run ../generator/generator.go EventsOptions // EventsOptions are optional options for monitoring events +// +//go:generate go run ../generator/generator.go EventsOptions type EventsOptions struct { Filters map[string][]string Since *string @@ -9,26 +10,30 @@ type EventsOptions struct { Until *string } -//go:generate go run ../generator/generator.go PruneOptions // PruneOptions are optional options for pruning +// +//go:generate go run ../generator/generator.go PruneOptions type PruneOptions struct { All *bool Filters map[string][]string Volumes *bool } -//go:generate go run ../generator/generator.go VersionOptions // VersionOptions are optional options for getting version info +// +//go:generate go run ../generator/generator.go VersionOptions type VersionOptions struct { } -//go:generate go run ../generator/generator.go DiskOptions // DiskOptions are optional options for getting storage consumption +// +//go:generate go run ../generator/generator.go DiskOptions type DiskOptions struct { } -//go:generate go run ../generator/generator.go InfoOptions // InfoOptions are optional options for getting info // about libpod +// +//go:generate go run ../generator/generator.go InfoOptions type InfoOptions struct { } diff --git a/pkg/bindings/test/common_test.go b/pkg/bindings/test/common_test.go index f174b84f89..5ffa7cbd09 100644 --- a/pkg/bindings/test/common_test.go +++ b/pkg/bindings/test/common_test.go @@ -242,8 +242,8 @@ func (b *bindingTest) PodcreateAndExpose(name *string, port *string) { b.runPodman(command).Wait(45) } -// StringInSlice returns a boolean based on whether a given -// string is in a given slice +// StringInSlice returns a boolean based on whether a given +// string is in a given slice func StringInSlice(s string, sl []string) bool { for _, val := range sl { if s == val { diff --git a/pkg/bindings/volumes/types.go b/pkg/bindings/volumes/types.go index d2f19c0c88..791fc12405 100644 --- a/pkg/bindings/volumes/types.go +++ b/pkg/bindings/volumes/types.go @@ -1,39 +1,45 @@ package volumes -//go:generate go run ../generator/generator.go CreateOptions // CreateOptions are optional options for creating volumes +// +//go:generate go run ../generator/generator.go CreateOptions type CreateOptions struct { } -//go:generate go run ../generator/generator.go InspectOptions // InspectOptions are optional options for inspecting volumes +// +//go:generate go run ../generator/generator.go InspectOptions type InspectOptions struct { } -//go:generate go run ../generator/generator.go ListOptions // ListOptions are optional options for listing volumes +// +//go:generate go run ../generator/generator.go ListOptions type ListOptions struct { // Filters applied to the listing of volumes Filters map[string][]string } -//go:generate go run ../generator/generator.go PruneOptions // PruneOptions are optional options for pruning volumes +// +//go:generate go run ../generator/generator.go PruneOptions type PruneOptions struct { // Filters applied to the pruning of volumes Filters map[string][]string } -//go:generate go run ../generator/generator.go RemoveOptions // RemoveOptions are optional options for removing volumes +// +//go:generate go run ../generator/generator.go RemoveOptions type RemoveOptions struct { // Force removes the volume even if it is being used Force *bool Timeout *uint } -//go:generate go run ../generator/generator.go ExistsOptions // ExistsOptions are optional options for checking // if a volume exists +// +//go:generate go run ../generator/generator.go ExistsOptions type ExistsOptions struct { } diff --git a/pkg/channel/doc.go b/pkg/channel/doc.go index 656fbddaa8..351988c542 100644 --- a/pkg/channel/doc.go +++ b/pkg/channel/doc.go @@ -3,13 +3,13 @@ Package channel provides helper structs/methods/funcs for working with channels Proxy from an io.Writer to a channel: - w := channel.NewWriter(make(chan []byte, 10)) - go func() { - w.Write([]byte("Hello, World")) - }() + w := channel.NewWriter(make(chan []byte, 10)) + go func() { + w.Write([]byte("Hello, World")) + }() - fmt.Println(string(<-w.Chan())) - w.Close() + fmt.Println(string(<-w.Chan())) + w.Close() Use of the constructor is required to initialize the channel. Provide a channel of sufficient size to handle messages from writer(s). diff --git a/pkg/domain/entities/engine_container.go b/pkg/domain/entities/engine_container.go index 19b666f8e0..51058e318d 100644 --- a/pkg/domain/entities/engine_container.go +++ b/pkg/domain/entities/engine_container.go @@ -13,7 +13,7 @@ import ( type ContainerCopyFunc func() error -type ContainerEngine interface { +type ContainerEngine interface { //nolint:interfacebloat AutoUpdate(ctx context.Context, options AutoUpdateOptions) ([]*AutoUpdateReport, []error) Config(ctx context.Context) (*config.Config, error) ContainerAttach(ctx context.Context, nameOrID string, options AttachOptions) error diff --git a/pkg/domain/entities/engine_image.go b/pkg/domain/entities/engine_image.go index b8b6948730..43de27a756 100644 --- a/pkg/domain/entities/engine_image.go +++ b/pkg/domain/entities/engine_image.go @@ -8,7 +8,7 @@ import ( "github.com/containers/podman/v4/pkg/domain/entities/reports" ) -type ImageEngine interface { +type ImageEngine interface { //nolint:interfacebloat Build(ctx context.Context, containerFiles []string, opts BuildOptions) (*BuildReport, error) Config(ctx context.Context) (*config.Config, error) Exists(ctx context.Context, nameOrID string) (*BoolReport, error) diff --git a/pkg/domain/infra/tunnel/helpers.go b/pkg/domain/infra/tunnel/helpers.go index 90d5581195..207b06733f 100644 --- a/pkg/domain/infra/tunnel/helpers.go +++ b/pkg/domain/infra/tunnel/helpers.go @@ -13,7 +13,8 @@ import ( ) // FIXME: the `ignore` parameter is very likely wrong here as it should rather -// be used on *errors* from operations such as remove. +// +// be used on *errors* from operations such as remove. func getContainersByContext(contextWithConnection context.Context, all, ignore bool, namesOrIDs []string) ([]entities.ListContainer, error) { //nolint:unparam ctrs, _, err := getContainersAndInputByContext(contextWithConnection, all, ignore, namesOrIDs, nil) return ctrs, err diff --git a/pkg/k8s.io/api/apps/v1/types.go b/pkg/k8s.io/api/apps/v1/types.go index 3be9f6dbd1..3fa643ef94 100644 --- a/pkg/k8s.io/api/apps/v1/types.go +++ b/pkg/k8s.io/api/apps/v1/types.go @@ -38,8 +38,9 @@ const ( // StatefulSet represents a set of pods with consistent identities. // Identities are defined as: -// - Network: A single stable DNS and hostname. -// - Storage: As many VolumeClaims as requested. +// - Network: A single stable DNS and hostname. +// - Storage: As many VolumeClaims as requested. +// // The StatefulSet guarantees that a given network identity will always // map to the same storage identity. type StatefulSet struct { diff --git a/pkg/k8s.io/api/core/v1/resource.go b/pkg/k8s.io/api/core/v1/resource.go index 2fbb663c7a..91aa95f9a3 100644 --- a/pkg/k8s.io/api/core/v1/resource.go +++ b/pkg/k8s.io/api/core/v1/resource.go @@ -26,6 +26,7 @@ func (rn ResourceName) String() string { } // Cpu returns the Cpu limit if specified. +// //nolint:revive,stylecheck func (rl *ResourceList) Cpu() *resource.Quantity { return rl.Name(ResourceCPU, resource.DecimalSI) diff --git a/pkg/k8s.io/api/core/v1/types.go b/pkg/k8s.io/api/core/v1/types.go index 4447847e3e..114c552e5a 100644 --- a/pkg/k8s.io/api/core/v1/types.go +++ b/pkg/k8s.io/api/core/v1/types.go @@ -2237,7 +2237,8 @@ type PodDNSConfigOption struct { // IP address information for entries in the (plural) PodIPs field. // Each entry includes: -// IP: An IP address allocated to the pod. Routable at least within the cluster. +// +// IP: An IP address allocated to the pod. Routable at least within the cluster. type PodIP struct { // ip is an IP address (IPv4 or IPv6) assigned to the pod IP string `json:"ip,omitempty"` @@ -3286,17 +3287,18 @@ type ServiceAccountList struct { // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // Endpoints is a collection of endpoints that implement the actual service. Example: -// Name: "mysvc", -// Subsets: [ -// { -// Addresses: [{"ip": "10.10.1.1"}, {"ip": "10.10.2.2"}], -// Ports: [{"name": "a", "port": 8675}, {"name": "b", "port": 309}] -// }, -// { -// Addresses: [{"ip": "10.10.3.3"}], -// Ports: [{"name": "a", "port": 93}, {"name": "b", "port": 76}] -// }, -// ] +// +// Name: "mysvc", +// Subsets: [ +// { +// Addresses: [{"ip": "10.10.1.1"}, {"ip": "10.10.2.2"}], +// Ports: [{"name": "a", "port": 8675}, {"name": "b", "port": 309}] +// }, +// { +// Addresses: [{"ip": "10.10.3.3"}], +// Ports: [{"name": "a", "port": 93}, {"name": "b", "port": 76}] +// }, +// ] type Endpoints struct { metav1.TypeMeta `json:",inline"` // Standard object's metadata. @@ -3318,13 +3320,16 @@ type Endpoints struct { // EndpointSubset is a group of addresses with a common set of ports. The // expanded set of endpoints is the Cartesian product of Addresses x Ports. // For example, given: -// { -// Addresses: [{"ip": "10.10.1.1"}, {"ip": "10.10.2.2"}], -// Ports: [{"name": "a", "port": 8675}, {"name": "b", "port": 309}] -// } +// +// { +// Addresses: [{"ip": "10.10.1.1"}, {"ip": "10.10.2.2"}], +// Ports: [{"name": "a", "port": 8675}, {"name": "b", "port": 309}] +// } +// // The resulting set of endpoints can be viewed as: -// a: [ 10.10.1.1:8675, 10.10.2.2:8675 ], -// b: [ 10.10.1.1:309, 10.10.2.2:309 ] +// +// a: [ 10.10.1.1:8675, 10.10.2.2:8675 ], +// b: [ 10.10.1.1:309, 10.10.2.2:309 ] type EndpointSubset struct { // IP addresses which offer the related ports that are marked as ready. These endpoints // should be considered safe for load balancers and clients to utilize. @@ -3656,6 +3661,7 @@ type ServiceProxyOptions struct { // and the version of the actual struct is irrelevant. // 5. We cannot easily change it. Because this type is embedded in many locations, updates to this type // will affect numerous schemas. Don't make new APIs embed an underspecified API type they do not control. +// // Instead of using this type, create a locally provided and used type that is well-focused on your reference. // For example, ServiceReferences for admission registration: https://github.com/kubernetes/api/blob/release-1.17/admissionregistration/v1/types.go#L533 . // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object diff --git a/pkg/k8s.io/apimachinery/pkg/api/resource/quantity.go b/pkg/k8s.io/apimachinery/pkg/api/resource/quantity.go index 588a189bf3..8c642b34ed 100644 --- a/pkg/k8s.io/apimachinery/pkg/api/resource/quantity.go +++ b/pkg/k8s.io/apimachinery/pkg/api/resource/quantity.go @@ -35,7 +35,9 @@ import ( // The serialization format is: // // ::= -// (Note that may be empty, from the "" case in .) +// +// (Note that may be empty, from the "" case in .) +// // ::= 0 | 1 | ... | 9 // ::= | // ::= | . | . | . @@ -43,9 +45,13 @@ import ( // ::= | // ::= | | // ::= Ki | Mi | Gi | Ti | Pi | Ei -// (International System of units; See: http://physics.nist.gov/cuu/Units/binary.html) +// +// (International System of units; See: http://physics.nist.gov/cuu/Units/binary.html) +// // ::= m | "" | k | M | G | T | P | E -// (Note that 1024 = 1Ki but 1000 = 1k; I didn't choose the capitalization.) +// +// (Note that 1024 = 1Ki but 1000 = 1k; I didn't choose the capitalization.) +// // ::= "e" | "E" // // No matter which of the three exponent forms is used, no quantity may represent @@ -60,14 +66,17 @@ import ( // Before serializing, Quantity will be put in "canonical form". // This means that Exponent/suffix will be adjusted up or down (with a // corresponding increase or decrease in Mantissa) such that: -// a. No precision is lost -// b. No fractional digits will be emitted -// c. The exponent (or suffix) is as large as possible. +// +// a. No precision is lost +// b. No fractional digits will be emitted +// c. The exponent (or suffix) is as large as possible. +// // The sign will be omitted unless the number is negative. // // Examples: -// 1.5 will be serialized as "1500m" -// 1.5Gi will be serialized as "1536Mi" +// +// 1.5 will be serialized as "1500m" +// 1.5Gi will be serialized as "1536Mi" // // Note that the quantity will NEVER be internally represented by a // floating point number. That is the whole point of this exercise. @@ -391,10 +400,10 @@ func (q Quantity) DeepCopy() Quantity { // CanonicalizeBytes returns the canonical form of q and its suffix (see comment on Quantity). // // Note about BinarySI: -// * If q.Format is set to BinarySI and q.Amount represents a non-zero value between -// -1 and +1, it will be emitted as if q.Format were DecimalSI. -// * Otherwise, if q.Format is set to BinarySI, fractional parts of q.Amount will be -// rounded up. (1.1i becomes 2i.) +// - If q.Format is set to BinarySI and q.Amount represents a non-zero value between +// -1 and +1, it will be emitted as if q.Format were DecimalSI. +// - Otherwise, if q.Format is set to BinarySI, fractional parts of q.Amount will be +// rounded up. (1.1i becomes 2i.) func (q *Quantity) CanonicalizeBytes(out []byte) (result, suffix []byte) { if q.IsZero() { return zeroBytes, nil diff --git a/pkg/k8s.io/apimachinery/pkg/apis/meta/v1/types.go b/pkg/k8s.io/apimachinery/pkg/apis/meta/v1/types.go index 39073c06bd..117514129b 100644 --- a/pkg/k8s.io/apimachinery/pkg/apis/meta/v1/types.go +++ b/pkg/k8s.io/apimachinery/pkg/apis/meta/v1/types.go @@ -17,10 +17,11 @@ limitations under the License. // Package v1 contains API types that are common to all versions. // // The package contains two categories of types: -// - external (serialized) types that lack their own version (e.g TypeMeta) -// - internal (never-serialized) types that are needed by several different -// api groups, and so live here, to avoid duplication and/or import loops -// (e.g. LabelSelector). +// - external (serialized) types that lack their own version (e.g TypeMeta) +// - internal (never-serialized) types that are needed by several different +// api groups, and so live here, to avoid duplication and/or import loops +// (e.g. LabelSelector). +// // In the future, we will probably move these categories of objects into // separate packages. package v1 @@ -1272,17 +1273,18 @@ type PartialObjectMetadataList struct { // Condition contains details for one aspect of the current state of this API Resource. // --- // This struct is intended for direct use as an array at the field path .status.conditions. For example, -// type FooStatus struct{ -// // Represents the observations of a foo's current state. -// // Known .status.conditions.type are: "Available", "Progressing", and "Degraded" -// // +patchMergeKey=type -// // +patchStrategy=merge -// // +listType=map -// // +listMapKey=type -// Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"` // -// // other fields -// } +// type FooStatus struct{ +// // Represents the observations of a foo's current state. +// // Known .status.conditions.type are: "Available", "Progressing", and "Degraded" +// // +patchMergeKey=type +// // +patchStrategy=merge +// // +listType=map +// // +listMapKey=type +// Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"` +// +// // other fields +// } type Condition struct { // type of condition in CamelCase or in foo.example.com/CamelCase. // --- diff --git a/pkg/machine/applehv/machine.go b/pkg/machine/applehv/machine.go index 35a8e98514..bc4a805d46 100644 --- a/pkg/machine/applehv/machine.go +++ b/pkg/machine/applehv/machine.go @@ -1,5 +1,5 @@ //go:build arm64 && !windows && !linux -// +build darwin +// +build arm64,!windows,!linux package applehv diff --git a/pkg/machine/qemu/machine_unsupported.go b/pkg/machine/qemu/machine_unsupported.go index 7a9a2531d0..b00a4f4b90 100644 --- a/pkg/machine/qemu/machine_unsupported.go +++ b/pkg/machine/qemu/machine_unsupported.go @@ -1,4 +1,4 @@ -//go:build (!amd64 && !arm64) +//go:build !amd64 && !arm64 // +build !amd64,!arm64 package qemu diff --git a/pkg/machine/wsl/util_windows.go b/pkg/machine/wsl/util_windows.go index 5f8da10ecf..6fb4ec7ad8 100644 --- a/pkg/machine/wsl/util_windows.go +++ b/pkg/machine/wsl/util_windows.go @@ -19,7 +19,7 @@ import ( "github.com/containers/storage/pkg/homedir" ) -//nolint +// nolint type SHELLEXECUTEINFO struct { cbSize uint32 fMask uint32 @@ -38,7 +38,7 @@ type SHELLEXECUTEINFO struct { hProcess syscall.Handle } -//nolint +// nolint type Luid struct { lowPart uint32 highPart int32 @@ -54,7 +54,7 @@ type TokenPrivileges struct { privileges [1]LuidAndAttributes } -//nolint // Cleaner to refer to the official OS constant names, and consistent with syscall +// nolint // Cleaner to refer to the official OS constant names, and consistent with syscall const ( SEE_MASK_NOCLOSEPROCESS = 0x40 EWX_FORCEIFHUNG = 0x10 diff --git a/pkg/specgen/generate/kube/seccomp.go b/pkg/specgen/generate/kube/seccomp.go index 6e3accd8b2..4a30975b4e 100644 --- a/pkg/specgen/generate/kube/seccomp.go +++ b/pkg/specgen/generate/kube/seccomp.go @@ -11,6 +11,7 @@ import ( // KubeSeccompPaths holds information about a pod YAML's seccomp configuration // it holds both container and pod seccomp paths +// //nolint:revive type KubeSeccompPaths struct { containerPaths map[string]string diff --git a/pkg/specgen/generate/ports.go b/pkg/specgen/generate/ports.go index 8ad249409a..dbfd2a4a2c 100644 --- a/pkg/specgen/generate/ports.go +++ b/pkg/specgen/generate/ports.go @@ -55,7 +55,8 @@ func joinTwoPortsToRangePortIfPossible(ports *[]types.PortMapping, allHostPorts, } // joinTwoContainerPortsToRangePortIfPossible will expect two ports with both no host port set, -// the previous port one must have a lower or equal containerPort than the current port. +// +// the previous port one must have a lower or equal containerPort than the current port. func joinTwoContainerPortsToRangePortIfPossible(ports *[]types.PortMapping, allHostPorts, allContainerPorts, currentHostPorts *[65536]bool, previousPort *types.PortMapping, port types.PortMapping) (*types.PortMapping, error) { // no previous port just return the current one diff --git a/pkg/timetype/timestamp.go b/pkg/timetype/timestamp.go index 5e9c6a1591..4defa32ea6 100644 --- a/pkg/timetype/timestamp.go +++ b/pkg/timetype/timestamp.go @@ -103,8 +103,10 @@ func GetTimestamp(value string, reference time.Time) (string, error) { // if the incoming nanosecond portion is longer or shorter than 9 digits it is // converted to nanoseconds. The expectation is that the seconds and // seconds will be used to create a time variable. For example: -// seconds, nanoseconds, err := ParseTimestamp("1136073600.000000001",0) -// if err == nil since := time.Unix(seconds, nanoseconds) +// +// seconds, nanoseconds, err := ParseTimestamp("1136073600.000000001",0) +// if err == nil since := time.Unix(seconds, nanoseconds) +// // returns seconds as def(aultSeconds) if value == "" func ParseTimestamps(value string, def int64) (int64, int64, error) { if value == "" { diff --git a/pkg/util/camelcase/camelcase.go b/pkg/util/camelcase/camelcase.go index eaf7c01784..88dfcd8c02 100644 --- a/pkg/util/camelcase/camelcase.go +++ b/pkg/util/camelcase/camelcase.go @@ -13,37 +13,37 @@ import ( // // Examples // -// "" => [""] -// "lowercase" => ["lowercase"] -// "Class" => ["Class"] -// "MyClass" => ["My", "Class"] -// "MyC" => ["My", "C"] -// "HTML" => ["HTML"] -// "PDFLoader" => ["PDF", "Loader"] -// "AString" => ["A", "String"] -// "SimpleXMLParser" => ["Simple", "XML", "Parser"] -// "vimRPCPlugin" => ["vim", "RPC", "Plugin"] -// "GL11Version" => ["GL", "11", "Version"] -// "99Bottles" => ["99", "Bottles"] -// "May5" => ["May", "5"] -// "BFG9000" => ["BFG", "9000"] -// "BöseÜberraschung" => ["Böse", "Überraschung"] -// "Two spaces" => ["Two", " ", "spaces"] -// "BadUTF8\xe2\xe2\xa1" => ["BadUTF8\xe2\xe2\xa1"] +// "" => [""] +// "lowercase" => ["lowercase"] +// "Class" => ["Class"] +// "MyClass" => ["My", "Class"] +// "MyC" => ["My", "C"] +// "HTML" => ["HTML"] +// "PDFLoader" => ["PDF", "Loader"] +// "AString" => ["A", "String"] +// "SimpleXMLParser" => ["Simple", "XML", "Parser"] +// "vimRPCPlugin" => ["vim", "RPC", "Plugin"] +// "GL11Version" => ["GL", "11", "Version"] +// "99Bottles" => ["99", "Bottles"] +// "May5" => ["May", "5"] +// "BFG9000" => ["BFG", "9000"] +// "BöseÜberraschung" => ["Böse", "Überraschung"] +// "Two spaces" => ["Two", " ", "spaces"] +// "BadUTF8\xe2\xe2\xa1" => ["BadUTF8\xe2\xe2\xa1"] // // Splitting rules // -// 1) If string is not valid UTF-8, return it without splitting as +// 1. If string is not valid UTF-8, return it without splitting as // single item array. -// 2) Assign all unicode characters into one of 4 sets: lower case +// 2. Assign all unicode characters into one of 4 sets: lower case // letters, upper case letters, numbers, and all other characters. -// 3) Iterate through characters of string, introducing splits +// 3. Iterate through characters of string, introducing splits // between adjacent characters that belong to different sets. -// 4) Iterate through array of split strings, and if a given string +// 4. Iterate through array of split strings, and if a given string // is upper case: -// if subsequent string is lower case: -// move last character of upper case string to beginning of -// lower case string +// if subsequent string is lower case: +// move last character of upper case string to beginning of +// lower case string func Split(src string) (entries []string) { // don't split invalid utf8 if !utf8.ValidString(src) { diff --git a/version/version.go b/version/version.go index 417f3a9b1e..33c5ea595c 100644 --- a/version/version.go +++ b/version/version.go @@ -34,7 +34,8 @@ var Version = semver.MustParse("4.3.0-dev") // APIVersion provides the current and minimal API versions for compat and libpod endpoint trees // Note: GET|HEAD /_ping is never versioned and provides the API-Version and Libpod-API-Version headers to allow -// clients to shop for the Version they wish to support +// +// clients to shop for the Version they wish to support var APIVersion = map[Tree]map[Level]semver.Version{ Libpod: { CurrentAPI: Version,