Run gofmt 1.19
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
This commit is contained in:
parent
4a11a40189
commit
ca3b9b50fe
@ -36,7 +36,7 @@ const (
|
||||
CtrCniMetadataExtension = "ctr.cni-containerd.metadata"
|
||||
)
|
||||
|
||||
//ctr pass cni network metadata to containerd if ctr run use option of --cni
|
||||
// ctr pass cni network metadata to containerd if ctr run use option of --cni
|
||||
type NetworkMetaData struct {
|
||||
EnableCni bool
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ import (
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
digest "github.com/opencontainers/go-digest"
|
||||
"github.com/opencontainers/go-digest"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
)
|
||||
|
||||
@ -643,7 +643,6 @@ func (s *store) ingestRoot(ref string) string {
|
||||
// - root: entire ingest directory
|
||||
// - ref: name of the starting ref, must be unique
|
||||
// - data: file where data is written
|
||||
//
|
||||
func (s *store) ingestPaths(ref string) (string, string, string) {
|
||||
var (
|
||||
fp = s.ingestRoot(ref)
|
||||
|
@ -2,16 +2,18 @@
|
||||
// +build gofuzz
|
||||
|
||||
/*
|
||||
Copyright The containerd Authors.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
Copyright The containerd Authors.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
package fuzz
|
||||
|
||||
|
@ -65,7 +65,6 @@
|
||||
// ```
|
||||
// name==foo,labels.bar
|
||||
// ```
|
||||
//
|
||||
package filters
|
||||
|
||||
import (
|
||||
|
@ -45,7 +45,6 @@ field := quoted | [A-Za-z] [A-Za-z0-9_]+
|
||||
operator := "==" | "!=" | "~="
|
||||
value := quoted | [^\s,]+
|
||||
quoted := <go string syntax>
|
||||
|
||||
*/
|
||||
func Parse(s string) (Filter, error) {
|
||||
// special case empty to match all
|
||||
|
@ -31,10 +31,10 @@ var errQuoteSyntax = errors.New("quote syntax error")
|
||||
// or character literal represented by the string s.
|
||||
// It returns four values:
|
||||
//
|
||||
// 1) value, the decoded Unicode code point or byte value;
|
||||
// 2) multibyte, a boolean indicating whether the decoded character requires a multibyte UTF-8 representation;
|
||||
// 3) tail, the remainder of the string after the character; and
|
||||
// 4) an error that will be nil if the character is syntactically valid.
|
||||
// 1. value, the decoded Unicode code point or byte value;
|
||||
// 2. multibyte, a boolean indicating whether the decoded character requires a multibyte UTF-8 representation;
|
||||
// 3. tail, the remainder of the string after the character; and
|
||||
// 4. an error that will be nil if the character is syntactically valid.
|
||||
//
|
||||
// The second argument, quote, specifies the type of literal being parsed
|
||||
// and therefore which escaped quote character is permitted.
|
||||
|
@ -20,7 +20,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"syscall"
|
||||
@ -168,7 +168,7 @@ func (c *failpointControl) updateTx(updateFn func(conf *failpointConf) error) er
|
||||
}
|
||||
defer unflock(f.Fd())
|
||||
|
||||
data, err := ioutil.ReadAll(f)
|
||||
data, err := io.ReadAll(f)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to read failpoint setting %s: %w", c.confPath, err)
|
||||
}
|
||||
|
@ -46,10 +46,13 @@
|
||||
// the structure is changed in addition to adding a migration and incrementing
|
||||
// the database version.
|
||||
// Notes:
|
||||
// * `╘══*...*` refers to maps with arbitrary keys
|
||||
// * `version` is a key to a numeric value identifying the minor revisions
|
||||
//
|
||||
// - `╘══*...*` refers to maps with arbitrary keys
|
||||
//
|
||||
// - `version` is a key to a numeric value identifying the minor revisions
|
||||
// of schema version
|
||||
// * a namespace in a schema bucket cannot be named "version"
|
||||
//
|
||||
// - a namespace in a schema bucket cannot be named "version"
|
||||
//
|
||||
// └──v1 - Schema version bucket
|
||||
// ├──version : <varint> - Latest version, see migrations
|
||||
@ -107,16 +110,16 @@
|
||||
// │ └──expected : <digest> - Expected commit digest
|
||||
// └──leases
|
||||
// ╘══*lease id*
|
||||
// ├──createdat : <binary time> - Created at
|
||||
// ├──createdat : <binary time> - Created at
|
||||
// ├──labels
|
||||
// │ ╘══*key* : <string> - Label value
|
||||
// ├──snapshots
|
||||
// ├──snapshots
|
||||
// │ ╘══*snapshotter*
|
||||
// │ ╘══*snapshot key* : <nil> - Snapshot reference
|
||||
// ├──content
|
||||
// ├──content
|
||||
// │ ╘══*blob digest* : <nil> - Content blob reference
|
||||
// └──ingests
|
||||
// ╘══*ingest reference* : <nil> - Content ingest reference
|
||||
// ╘══*ingest reference* : <nil> - Content ingest reference
|
||||
package metadata
|
||||
|
||||
import (
|
||||
|
@ -24,8 +24,6 @@ import "context"
|
||||
// oriented. A namespace is really just a name and a set of labels. Objects
|
||||
// that belong to a namespace are returned when the namespace is assigned to a
|
||||
// given context.
|
||||
//
|
||||
//
|
||||
type Store interface {
|
||||
Create(ctx context.Context, namespace string, labels map[string]string) error
|
||||
Labels(ctx context.Context, namespace string) (map[string]string, error)
|
||||
|
@ -591,6 +591,7 @@ func WithNamespacedCgroup() SpecOpts {
|
||||
|
||||
// WithUser sets the user to be used within the container.
|
||||
// It accepts a valid user string in OCI Image Spec v1.0.0:
|
||||
//
|
||||
// user, uid, user:group, uid:gid, uid:group, user:gid
|
||||
func WithUser(userstr string) SpecOpts {
|
||||
return func(ctx context.Context, client Client, c *containers.Container, s *Spec) error {
|
||||
|
@ -28,19 +28,19 @@ import (
|
||||
|
||||
// WithAllCurrentCapabilities propagates the effective capabilities of the caller process to the container process.
|
||||
// The capability set may differ from WithAllKnownCapabilities when running in a container.
|
||||
//nolint: deadcode, unused
|
||||
// nolint: deadcode, unused
|
||||
var WithAllCurrentCapabilities = func(ctx context.Context, client Client, c *containers.Container, s *Spec) error {
|
||||
return WithCapabilities(nil)(ctx, client, c, s)
|
||||
}
|
||||
|
||||
// WithAllKnownCapabilities sets all the the known linux capabilities for the container process
|
||||
//nolint: deadcode, unused
|
||||
// nolint: deadcode, unused
|
||||
var WithAllKnownCapabilities = func(ctx context.Context, client Client, c *containers.Container, s *Spec) error {
|
||||
return WithCapabilities(nil)(ctx, client, c, s)
|
||||
}
|
||||
|
||||
// WithBlockIO sets the container's blkio parameters
|
||||
//nolint: deadcode, unused
|
||||
// nolint: deadcode, unused
|
||||
func WithBlockIO(blockio interface{}) SpecOpts {
|
||||
return func(ctx context.Context, _ Client, c *containers.Container, s *Spec) error {
|
||||
return errors.New("blkio not supported")
|
||||
@ -48,7 +48,7 @@ func WithBlockIO(blockio interface{}) SpecOpts {
|
||||
}
|
||||
|
||||
// WithCPUShares sets the container's cpu shares
|
||||
//nolint: deadcode, unused
|
||||
// nolint: deadcode, unused
|
||||
func WithCPUShares(shares uint64) SpecOpts {
|
||||
return func(ctx context.Context, _ Client, c *containers.Container, s *Spec) error {
|
||||
return nil
|
||||
|
@ -18,6 +18,7 @@ package apparmor
|
||||
|
||||
// HostSupports returns true if apparmor is enabled for the host, // On non-Linux returns false
|
||||
// On Linux returns true if apparmor_parser is enabled, and if we
|
||||
//
|
||||
// are not running docker-in-docker.
|
||||
//
|
||||
// It is a modified version of libcontainer/apparmor.IsEnabled(), which does not
|
||||
|
@ -77,6 +77,7 @@ func WithProcessArgs(config *runtime.ContainerConfig, image *imagespec.ImageConf
|
||||
|
||||
// mounts defines how to sort runtime.Mount.
|
||||
// This is the same with the Docker implementation:
|
||||
//
|
||||
// https://github.com/moby/moby/blob/17.05.x/daemon/volumes.go#L26
|
||||
type orderedMounts []*runtime.Mount
|
||||
|
||||
|
@ -45,7 +45,7 @@ import (
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
restful "github.com/emicklei/go-restful/v3"
|
||||
"github.com/emicklei/go-restful/v3"
|
||||
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
remotecommandconsts "k8s.io/apimachinery/pkg/util/remotecommand"
|
||||
@ -165,6 +165,7 @@ func NewServer(config Config, runtime Runtime) (Server, error) {
|
||||
Addr: s.config.Addr,
|
||||
Handler: s.handler,
|
||||
TLSConfig: s.config.TLSConfig,
|
||||
ReadHeaderTimeout: 3 * time.Second, // Fix linter G112: Potential Slowloris Attack because ReadHeaderTimeout is not configured in the http.Server
|
||||
}
|
||||
|
||||
return s, nil
|
||||
|
@ -73,9 +73,9 @@ func (n *nopWriteCloser) Close() error {
|
||||
// serialWriteCloser wraps a write closer and makes sure all writes
|
||||
// are done in serial.
|
||||
// Parallel write won't intersect with each other. Use case:
|
||||
// 1) Pipe: Write content longer than PIPE_BUF.
|
||||
// 1. Pipe: Write content longer than PIPE_BUF.
|
||||
// See http://man7.org/linux/man-pages/man7/pipe.7.html
|
||||
// 2) <3.14 Linux Kernel: write is not atomic
|
||||
// 2. <3.14 Linux Kernel: write is not atomic
|
||||
// See http://man7.org/linux/man-pages/man2/write.2.html
|
||||
type serialWriteCloser struct {
|
||||
mu sync.Mutex
|
||||
|
@ -32,6 +32,7 @@ import (
|
||||
// - os.Open on a directory returns a os.File where Fd() is a search handle from FindFirstFile.
|
||||
// - syscall.Open does not provide a way to specify FILE_FLAG_BACKUP_SEMANTICS, which is needed to
|
||||
// open a directory.
|
||||
//
|
||||
// We could use os.Open if the path is a file, but it's easier to just use the same code for both.
|
||||
// Therefore, we call windows.CreateFile directly.
|
||||
func openPath(path string) (windows.Handle, error) {
|
||||
@ -58,6 +59,7 @@ func openPath(path string) (windows.Handle, error) {
|
||||
}
|
||||
|
||||
// GetFinalPathNameByHandle flags.
|
||||
//
|
||||
//nolint:revive // SNAKE_CASE is not idiomatic in Go, but aligned with Win32 API.
|
||||
const (
|
||||
cFILE_NAME_OPENED = 0x8
|
||||
|
@ -42,7 +42,7 @@
|
||||
//
|
||||
// More details of the specifier syntax and platform spec follow.
|
||||
//
|
||||
// Declaring Platform Support
|
||||
// # Declaring Platform Support
|
||||
//
|
||||
// Components that have strict platform requirements should use the OCI
|
||||
// platform specification to declare their support. Typically, this will be
|
||||
@ -60,7 +60,7 @@
|
||||
// specification when in doubt). ARM should set variant under certain
|
||||
// discussions, which are outlined below.
|
||||
//
|
||||
// Platform Specifiers
|
||||
// # Platform Specifiers
|
||||
//
|
||||
// While the OCI platform specifications provide a tool for components to
|
||||
// specify structured information, user input typically doesn't need the full
|
||||
@ -77,7 +77,7 @@
|
||||
// where the architecture may be known but a runtime may support images from
|
||||
// different operating systems.
|
||||
//
|
||||
// Normalization
|
||||
// # Normalization
|
||||
//
|
||||
// Because not all users are familiar with the way the Go runtime represents
|
||||
// platforms, several normalizations have been provided to make this package
|
||||
@ -95,7 +95,7 @@
|
||||
//
|
||||
// We also normalize the operating system `macos` to `darwin`.
|
||||
//
|
||||
// ARM Support
|
||||
// # ARM Support
|
||||
//
|
||||
// To qualify ARM architecture, the Variant field is used to qualify the arm
|
||||
// version. The most common arm version, v7, is represented without the variant
|
||||
|
@ -72,8 +72,10 @@ type ExitStatus struct {
|
||||
|
||||
// Result returns the exit code and time of the exit status.
|
||||
// An error may be returned here to which indicates there was an error
|
||||
//
|
||||
// at some point while waiting for the exit status. It does not signify
|
||||
// an error with the process itself.
|
||||
//
|
||||
// If an error is returned, the process may still be running.
|
||||
func (s ExitStatus) Result() (uint32, time.Time, error) {
|
||||
return s.code, s.exitedAt, s.err
|
||||
|
@ -353,6 +353,7 @@ func BlockDeviceSize(path string) (int64, error) {
|
||||
}
|
||||
|
||||
// DiscardBlocks discards all blocks for the given thin device
|
||||
//
|
||||
// ported from https://github.com/moby/moby/blob/7b9275c0da707b030e62c96b679a976f31f929d3/pkg/devicemapper/devmapper.go#L416
|
||||
func DiscardBlocks(deviceName string) error {
|
||||
inUse, err := isInUse(deviceName)
|
||||
@ -402,8 +403,10 @@ func tryGetUnixError(output string) (unix.Errno, bool) {
|
||||
}
|
||||
|
||||
// dmsetup returns error messages in format:
|
||||
//
|
||||
// device-mapper: message ioctl on <name> failed: File exists\n
|
||||
// Command failed\n
|
||||
//
|
||||
// parseDmsetupError extracts text between "failed: " and "\n"
|
||||
func parseDmsetupError(output string) string {
|
||||
lines := strings.SplitN(output, "\n", 2)
|
||||
|
@ -484,7 +484,9 @@ func (p *PoolDevice) IsLoaded(deviceName string) bool {
|
||||
// GetUsage reports total size in bytes consumed by a thin-device.
|
||||
// It relies on the number of used blocks reported by 'dmsetup status'.
|
||||
// The output looks like:
|
||||
//
|
||||
// device2: 0 204800 thin 17280 204799
|
||||
//
|
||||
// Where 17280 is the number of used sectors
|
||||
func (p *PoolDevice) GetUsage(deviceName string) (int64, error) {
|
||||
status, err := dmsetup.Status(deviceName)
|
||||
|
@ -167,7 +167,7 @@ type WalkFunc func(context.Context, Info) error
|
||||
//
|
||||
// We cover several examples below to demonstrate the utility of the snapshotter.
|
||||
//
|
||||
// Importing a Layer
|
||||
// # Importing a Layer
|
||||
//
|
||||
// To import a layer, we simply have the snapshotter provide a list of
|
||||
// mounts to be applied such that our dst will capture a changeset. We start
|
||||
@ -220,7 +220,7 @@ type WalkFunc func(context.Context, Info) error
|
||||
// Now, we have a layer in the snapshotter that can be accessed with the digest
|
||||
// provided during commit.
|
||||
//
|
||||
// Importing the Next Layer
|
||||
// # Importing the Next Layer
|
||||
//
|
||||
// Making a layer depend on the above is identical to the process described
|
||||
// above except that the parent is provided as parent when calling
|
||||
@ -231,7 +231,7 @@ type WalkFunc func(context.Context, Info) error
|
||||
// We then mount, apply and commit, as we did above. The new snapshot will be
|
||||
// based on the content of the previous one.
|
||||
//
|
||||
// Running a Container
|
||||
// # Running a Container
|
||||
//
|
||||
// To run a container, we simply provide snapshotter.Prepare() the committed image
|
||||
// snapshot as the parent. After mounting, the prepared path can
|
||||
|
@ -505,7 +505,7 @@ func checkDeletedFilesInChildSnapshot(ctx context.Context, t *testing.T, snapsho
|
||||
|
||||
}
|
||||
|
||||
//Create three layers. Deleting intermediate layer must fail.
|
||||
// Create three layers. Deleting intermediate layer must fail.
|
||||
func checkRemoveIntermediateSnapshot(ctx context.Context, t *testing.T, snapshotter snapshots.Snapshotter, work string) {
|
||||
|
||||
base, err := snapshotterPrepareMount(ctx, snapshotter, "base", "", work)
|
||||
@ -559,6 +559,7 @@ func checkRemoveIntermediateSnapshot(ctx context.Context, t *testing.T, snapshot
|
||||
|
||||
// baseTestSnapshots creates a base set of snapshots for tests, each snapshot is empty
|
||||
// Tests snapshots:
|
||||
//
|
||||
// c1 - committed snapshot, no parent
|
||||
// c2 - committed snapshot, c1 is parent
|
||||
// a1 - active snapshot, c2 is parent
|
||||
|
Loading…
Reference in New Issue
Block a user