mirror of
https://github.com/podman-container-tools/podman.git
synced 2026-10-23 14:27:36 +00:00
commit
901066acd1
74 changed files with 218 additions and 182 deletions
|
|
@ -13,7 +13,8 @@ linters:
|
|||
enable-all: true
|
||||
disable:
|
||||
# All these break for one reason or another
|
||||
- nolintlint
|
||||
- nolintlint # some linter must be disabled (see `nolint` in the code)
|
||||
- tagliatelle # too many JSON keys cannot be changed due to compat
|
||||
- gocognit
|
||||
- testpackage
|
||||
- goerr113
|
||||
|
|
@ -38,7 +39,6 @@ linters:
|
|||
- gofumpt
|
||||
- gci
|
||||
- godot
|
||||
- makezero
|
||||
- dupl
|
||||
- funlen
|
||||
- gochecknoglobals
|
||||
|
|
@ -58,16 +58,10 @@ linters:
|
|||
- cyclop
|
||||
- errname
|
||||
- forcetypeassert
|
||||
- ineffassign
|
||||
- ireturn
|
||||
- tagliatelle
|
||||
- varnamelen
|
||||
- errchkjson
|
||||
- maintidx
|
||||
- nilerr
|
||||
- wastedassign
|
||||
- nilnil
|
||||
- interfacer
|
||||
linters-settings:
|
||||
errcheck:
|
||||
check-blank: false
|
||||
|
|
|
|||
|
|
@ -721,7 +721,7 @@ func DefineCreateFlags(cmd *cobra.Command, cf *entities.ContainerCreateOptions,
|
|||
"Optional parent cgroup for the container",
|
||||
)
|
||||
_ = cmd.RegisterFlagCompletionFunc(cgroupParentFlagName, completion.AutocompleteDefault)
|
||||
conmonPidfileFlagName := ""
|
||||
var conmonPidfileFlagName string
|
||||
if !isInfra {
|
||||
conmonPidfileFlagName = "conmon-pidfile"
|
||||
} else {
|
||||
|
|
@ -734,7 +734,7 @@ func DefineCreateFlags(cmd *cobra.Command, cf *entities.ContainerCreateOptions,
|
|||
)
|
||||
_ = cmd.RegisterFlagCompletionFunc(conmonPidfileFlagName, completion.AutocompleteDefault)
|
||||
|
||||
entrypointFlagName := ""
|
||||
var entrypointFlagName string
|
||||
if !isInfra {
|
||||
entrypointFlagName = "entrypoint"
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -58,9 +58,8 @@ func clone(cmd *cobra.Command, args []string) error {
|
|||
case 3:
|
||||
ctrClone.CreateOpts.Name = args[1]
|
||||
ctrClone.Image = args[2]
|
||||
rawImageName := ""
|
||||
if !cliVals.RootFS {
|
||||
rawImageName = args[0]
|
||||
rawImageName := args[0]
|
||||
name, err := PullImage(ctrClone.Image, ctrClone.CreateOpts)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -449,7 +449,7 @@ func resolvePathOnDestinationContainer(container string, containerPath string, i
|
|||
containerInfo, err = registry.ContainerEngine().ContainerStat(registry.GetContext(), container, containerPath)
|
||||
if err == nil {
|
||||
baseName = filepath.Base(containerInfo.LinkTarget)
|
||||
return
|
||||
return // nolint: nilerr
|
||||
}
|
||||
|
||||
if strings.HasSuffix(containerPath, "/") {
|
||||
|
|
|
|||
|
|
@ -375,7 +375,7 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
|
|||
}
|
||||
}
|
||||
|
||||
cleanTmpFile := false
|
||||
var cleanTmpFile bool
|
||||
flags.Authfile, cleanTmpFile = buildahUtil.MirrorToTempFileIfPathIsDescriptor(flags.Authfile)
|
||||
if cleanTmpFile {
|
||||
defer os.Remove(flags.Authfile)
|
||||
|
|
@ -474,7 +474,7 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
|
|||
return nil, err
|
||||
}
|
||||
|
||||
format := ""
|
||||
var format string
|
||||
flags.Format = strings.ToLower(flags.Format)
|
||||
switch {
|
||||
case strings.HasPrefix(flags.Format, buildahDefine.OCI):
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ func scp(cmd *cobra.Command, args []string) (finalErr error) {
|
|||
}
|
||||
locations := []*entities.ImageScpOptions{}
|
||||
cliConnections := []string{}
|
||||
flipConnections := false
|
||||
var flipConnections bool
|
||||
for _, arg := range args {
|
||||
loc, connect, err := parseImageSCPArg(arg)
|
||||
if err != nil {
|
||||
|
|
@ -233,7 +233,7 @@ func loadToRemote(localFile string, tag string, url *urlP.URL, iden string) (str
|
|||
errOut := strconv.Itoa(int(n)) + " Bytes copied before error"
|
||||
return " ", errors.Wrapf(err, errOut)
|
||||
}
|
||||
run := ""
|
||||
var run string
|
||||
if tag != "" {
|
||||
return "", errors.Wrapf(define.ErrInvalidArg, "Renaming of an image is currently not supported")
|
||||
}
|
||||
|
|
@ -264,10 +264,12 @@ func saveToRemote(image, localFile string, tag string, uri *urlP.URL, iden strin
|
|||
run := podman + " image save " + image + " --format=oci-archive --output=" + remoteFile // run ssh image load of the file copied via scp. Files are reverse in this case...
|
||||
_, err = connection.ExecRemoteCommand(dial, run)
|
||||
if err != nil {
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
n, err := scpD.CopyFrom(dial, remoteFile, localFile)
|
||||
connection.ExecRemoteCommand(dial, "rm "+remoteFile)
|
||||
if _, conErr := connection.ExecRemoteCommand(dial, "rm "+remoteFile); conErr != nil {
|
||||
logrus.Errorf("Error removing file on endpoint: %v", conErr)
|
||||
}
|
||||
if err != nil {
|
||||
errOut := strconv.Itoa(int(n)) + " Bytes copied before error"
|
||||
return errors.Wrapf(err, errOut)
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ func searchFlags(cmd *cobra.Command) {
|
|||
|
||||
// imageSearch implements the command for searching images.
|
||||
func imageSearch(cmd *cobra.Command, args []string) error {
|
||||
searchTerm := ""
|
||||
var searchTerm string
|
||||
switch len(args) {
|
||||
case 1:
|
||||
searchTerm = args[0]
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ func init() {
|
|||
"reexec", false,
|
||||
"process was rexeced",
|
||||
)
|
||||
flags.MarkHidden("reexec")
|
||||
_ = flags.MarkHidden("reexec")
|
||||
|
||||
ImagePathFlagName := "image-path"
|
||||
flags.StringVar(&initOpts.ImagePath, ImagePathFlagName, cfg.Machine.Image, "Path to qcow image")
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ func networkCreateFlags(cmd *cobra.Command) {
|
|||
macvlanFlagName := "macvlan"
|
||||
flags.StringVar(&networkCreateOptions.MacVLAN, macvlanFlagName, "", "create a Macvlan connection based on this device")
|
||||
// This option is deprecated
|
||||
flags.MarkHidden(macvlanFlagName)
|
||||
_ = flags.MarkHidden(macvlanFlagName)
|
||||
|
||||
labelFlagName := "label"
|
||||
flags.StringArrayVar(&labels, labelFlagName, nil, "set metadata on a network")
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import "regexp"
|
|||
|
||||
var jsonFormatRegex = regexp.MustCompile(`^\s*(json|{{\s*json\s*(\.)?\s*}})\s*$`)
|
||||
|
||||
// MatchesJSONFormat test CLI --format string to be a JSON request
|
||||
// MatchesJSONFormat test CLI --format string to be a JSON request.
|
||||
func MatchesJSONFormat(s string) bool {
|
||||
return jsonFormatRegex.Match([]byte(s))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -402,7 +402,7 @@ func rootFlags(cmd *cobra.Command, opts *entities.PodmanConfig) {
|
|||
networkBackendFlagName := "network-backend"
|
||||
pFlags.StringVar(&cfg.Network.NetworkBackend, networkBackendFlagName, cfg.Network.NetworkBackend, `Network backend to use ("cni"|"netavark")`)
|
||||
_ = cmd.RegisterFlagCompletionFunc(networkBackendFlagName, common.AutocompleteNetworkBackend)
|
||||
pFlags.MarkHidden(networkBackendFlagName)
|
||||
_ = pFlags.MarkHidden(networkBackendFlagName)
|
||||
|
||||
rootFlagName := "root"
|
||||
pFlags.StringVar(&cfg.Engine.StaticDir, rootFlagName, "", "Path to the root directory in which data, including images, is stored")
|
||||
|
|
|
|||
|
|
@ -244,7 +244,7 @@ func getUDS(cmd *cobra.Command, uri *url.URL, iden string) (string, error) {
|
|||
|
||||
// ValidateAndConfigure will take a ssh url and an identity key (rsa and the like) and ensure the information given is valid
|
||||
// iden iden can be blank to mean no identity key
|
||||
// once the function validates the information it creates and returns an ssh.ClientConfig
|
||||
// once the function validates the information it creates and returns an ssh.ClientConfig.
|
||||
func ValidateAndConfigure(uri *url.URL, iden string) (*ssh.ClientConfig, error) {
|
||||
var signers []ssh.Signer
|
||||
passwd, passwdSet := uri.User.Password()
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
// Skip creating engines since this command will obtain connection information to said engines
|
||||
// Skip creating engines since this command will obtain connection information to said engines.
|
||||
dfltCmd = &cobra.Command{
|
||||
Use: "default NAME",
|
||||
Args: cobra.ExactArgs(1),
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
// Skip creating engines since this command will obtain connection information to said engines
|
||||
// Skip creating engines since this command will obtain connection information to said engines.
|
||||
rmCmd = &cobra.Command{
|
||||
Use: "remove [options] NAME",
|
||||
Aliases: []string{"rm"},
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ func printVerbose(cmd *cobra.Command, reports *entities.SystemDfReport) error {
|
|||
return err
|
||||
}
|
||||
if err := writeTemplate(rpt, hdrs, dfImages); err != nil {
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Fprint(rpt.Writer(), "\nContainers space usage:\n\n")
|
||||
|
|
@ -191,7 +191,7 @@ func printVerbose(cmd *cobra.Command, reports *entities.SystemDfReport) error {
|
|||
return err
|
||||
}
|
||||
if err := writeTemplate(rpt, hdrs, dfContainers); err != nil {
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Fprint(rpt.Writer(), "\nLocal Volumes space usage:\n\n")
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ func init() {
|
|||
|
||||
flags.StringVarP(&srvArgs.PProfAddr, "pprof-address", "", "",
|
||||
"Binding network address for pprof profile endpoints, default: do not expose endpoints")
|
||||
flags.MarkHidden("pprof-address")
|
||||
_ = flags.MarkHidden("pprof-address")
|
||||
}
|
||||
|
||||
func aliasTimeoutFlag(_ *pflag.FlagSet, name string) pflag.NormalizedName {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ func SubCommandExists(cmd *cobra.Command, args []string) error {
|
|||
}
|
||||
return errors.Errorf("unrecognized command `%[1]s %[2]s`\n\nDid you mean this?\n\t%[3]s\n\nTry '%[1]s --help' for more information.", cmd.CommandPath(), args[0], strings.Join(suggestions, "\n\t"))
|
||||
}
|
||||
cmd.Help()
|
||||
cmd.Help() // nolint: errcheck
|
||||
return errors.Errorf("missing command '%[1]s COMMAND'", cmd.CommandPath())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -253,9 +253,9 @@ func serve(listener net.Listener, pm rkport.Manager) {
|
|||
ctx := context.TODO()
|
||||
err = handler(ctx, conn, pm)
|
||||
if err != nil {
|
||||
conn.Write([]byte(err.Error()))
|
||||
_, _ = conn.Write([]byte(err.Error()))
|
||||
} else {
|
||||
conn.Write([]byte("OK"))
|
||||
_, _ = conn.Write([]byte("OK"))
|
||||
}
|
||||
conn.Close()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -366,7 +366,7 @@ func (s *BoltState) GetDBConfig() (*DBConfig, error) {
|
|||
err = db.View(func(tx *bolt.Tx) error {
|
||||
configBucket, err := getRuntimeConfigBucket(tx)
|
||||
if err != nil {
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
|
||||
// Some of these may be nil
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
package common
|
||||
|
||||
// IsTrue determines whether the given string equals "true"
|
||||
// IsTrue determines whether the given string equals "true".
|
||||
func IsTrue(str string) bool {
|
||||
return str == "true"
|
||||
}
|
||||
|
||||
// IsFalse determines whether the given string equals "false"
|
||||
// IsFalse determines whether the given string equals "false".
|
||||
func IsFalse(str string) bool {
|
||||
return str == "false"
|
||||
}
|
||||
|
||||
// IsValidBool determines whether the given string equals "true" or "false"
|
||||
// IsValidBool determines whether the given string equals "true" or "false".
|
||||
func IsValidBool(str string) bool {
|
||||
return IsTrue(str) || IsFalse(str)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -921,7 +921,11 @@ func (c *Container) Stat(ctx context.Context, containerPath string) (*define.Fil
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer c.unmount(false)
|
||||
defer func() {
|
||||
if err := c.unmount(false); err != nil {
|
||||
logrus.Errorf("Unmounting container %s: %v", c.ID(), err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
info, _, _, err := c.stat(ctx, mountPoint, containerPath)
|
||||
|
|
|
|||
|
|
@ -2587,7 +2587,7 @@ func (c *Container) generateUserGroupEntry(addedGID int) (string, int, error) {
|
|||
|
||||
gid, err := strconv.ParseUint(group, 10, 32)
|
||||
if err != nil {
|
||||
return "", 0, nil
|
||||
return "", 0, nil // nolint: nilerr
|
||||
}
|
||||
|
||||
if addedGID != 0 && addedGID == int(gid) {
|
||||
|
|
@ -2740,7 +2740,7 @@ func (c *Container) generateUserPasswdEntry(addedUID int) (string, int, int, err
|
|||
// If a non numeric User, then don't generate passwd
|
||||
uid, err := strconv.ParseUint(userspec, 10, 32)
|
||||
if err != nil {
|
||||
return "", 0, 0, nil
|
||||
return "", 0, 0, nil // nolint: nilerr
|
||||
}
|
||||
|
||||
if addedUID != 0 && int(uid) == addedUID {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import (
|
|||
"github.com/containers/podman/v4/pkg/util"
|
||||
"github.com/containers/storage/pkg/lockfile"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// EventLogFile is the structure for event writing to a logfile. It contains the eventer
|
||||
|
|
@ -59,7 +60,9 @@ func (e EventLogFile) Read(ctx context.Context, options ReadOptions) error {
|
|||
}
|
||||
go func() {
|
||||
time.Sleep(time.Until(untilTime))
|
||||
t.Stop()
|
||||
if err := t.Stop(); err != nil {
|
||||
logrus.Errorf("Stopping logger: %v", err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
funcDone := make(chan bool)
|
||||
|
|
|
|||
|
|
@ -1149,7 +1149,7 @@ func (c *Container) inspectJoinedNetworkNS(networkns string) (q types.StatusBloc
|
|||
// result
|
||||
func resultToBasicNetworkConfig(result types.StatusBlock) (define.InspectBasicNetworkConfig, error) {
|
||||
config := define.InspectBasicNetworkConfig{}
|
||||
interfaceNames := make([]string, len(result.Interfaces))
|
||||
interfaceNames := make([]string, 0, len(result.Interfaces))
|
||||
for interfaceName := range result.Interfaces {
|
||||
interfaceNames = append(interfaceNames, interfaceName)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -750,7 +750,7 @@ func openControlFile(ctr *Container, parentDir string) (*os.File, error) {
|
|||
for i := 0; i < 600; i++ {
|
||||
controlFile, err := os.OpenFile(controlPath, unix.O_WRONLY|unix.O_NONBLOCK, 0)
|
||||
if err == nil {
|
||||
return controlFile, err
|
||||
return controlFile, nil
|
||||
}
|
||||
if !isRetryable(err) {
|
||||
return nil, errors.Wrapf(err, "could not open ctl file for terminal resize for container %s", ctr.ID())
|
||||
|
|
@ -1015,7 +1015,8 @@ func (r *ConmonOCIRuntime) getLogTag(ctr *Container) (string, error) {
|
|||
}
|
||||
data, err := ctr.inspectLocked(false)
|
||||
if err != nil {
|
||||
return "", nil
|
||||
// FIXME: this error should probably be returned
|
||||
return "", nil // nolint: nilerr
|
||||
}
|
||||
tmpl, err := template.New("container").Parse(logTag)
|
||||
if err != nil {
|
||||
|
|
@ -1596,7 +1597,7 @@ func readConmonPipeData(runtimeName string, pipe *os.File, ociLog string) (int,
|
|||
ch <- syncStruct{si: si}
|
||||
}()
|
||||
|
||||
data := -1
|
||||
data := -1 //nolint: wastedassign
|
||||
select {
|
||||
case ss := <-ch:
|
||||
if ss.err != nil {
|
||||
|
|
|
|||
|
|
@ -1,122 +1,122 @@
|
|||
package annotations
|
||||
|
||||
const (
|
||||
// Annotations carries the received Kubelet annotations
|
||||
// Annotations carries the received Kubelet annotations.
|
||||
Annotations = "io.kubernetes.cri-o.Annotations"
|
||||
|
||||
// ContainerID is the container ID annotation
|
||||
// ContainerID is the container ID annotation.
|
||||
ContainerID = "io.kubernetes.cri-o.ContainerID"
|
||||
|
||||
// ContainerName is the container name annotation
|
||||
// ContainerName is the container name annotation.
|
||||
ContainerName = "io.kubernetes.cri-o.ContainerName"
|
||||
|
||||
// ContainerType is the container type (sandbox or container) annotation
|
||||
// ContainerType is the container type (sandbox or container) annotation.
|
||||
ContainerType = "io.kubernetes.cri-o.ContainerType"
|
||||
|
||||
// Created is the container creation time annotation
|
||||
// Created is the container creation time annotation.
|
||||
Created = "io.kubernetes.cri-o.Created"
|
||||
|
||||
// HostName is the container host name annotation
|
||||
// HostName is the container host name annotation.
|
||||
HostName = "io.kubernetes.cri-o.HostName"
|
||||
|
||||
// CgroupParent is the sandbox cgroup parent
|
||||
// CgroupParent is the sandbox cgroup parent.
|
||||
CgroupParent = "io.kubernetes.cri-o.CgroupParent"
|
||||
|
||||
// IP is the container ipv4 or ipv6 address
|
||||
// IP is the container ipv4 or ipv6 address.
|
||||
IP = "io.kubernetes.cri-o.IP"
|
||||
|
||||
// NamespaceOptions store the options for namespaces
|
||||
// NamespaceOptions store the options for namespaces.
|
||||
NamespaceOptions = "io.kubernetes.cri-o.NamespaceOptions"
|
||||
|
||||
// SeccompProfilePath is the node seccomp profile path
|
||||
// SeccompProfilePath is the node seccomp profile path.
|
||||
SeccompProfilePath = "io.kubernetes.cri-o.SeccompProfilePath"
|
||||
|
||||
// Image is the container image ID annotation
|
||||
// Image is the container image ID annotation.
|
||||
Image = "io.kubernetes.cri-o.Image"
|
||||
|
||||
// ImageName is the container image name annotation
|
||||
// ImageName is the container image name annotation.
|
||||
ImageName = "io.kubernetes.cri-o.ImageName"
|
||||
|
||||
// ImageRef is the container image ref annotation
|
||||
// ImageRef is the container image ref annotation.
|
||||
ImageRef = "io.kubernetes.cri-o.ImageRef"
|
||||
|
||||
// KubeName is the kubernetes name annotation
|
||||
// KubeName is the kubernetes name annotation.
|
||||
KubeName = "io.kubernetes.cri-o.KubeName"
|
||||
|
||||
// PortMappings holds the port mappings for the sandbox
|
||||
// PortMappings holds the port mappings for the sandbox.
|
||||
PortMappings = "io.kubernetes.cri-o.PortMappings"
|
||||
|
||||
// Labels are the kubernetes labels annotation
|
||||
// Labels are the kubernetes labels annotation.
|
||||
Labels = "io.kubernetes.cri-o.Labels"
|
||||
|
||||
// LogPath is the container logging path annotation
|
||||
// LogPath is the container logging path annotation.
|
||||
LogPath = "io.kubernetes.cri-o.LogPath"
|
||||
|
||||
// Metadata is the container metadata annotation
|
||||
// Metadata is the container metadata annotation.
|
||||
Metadata = "io.kubernetes.cri-o.Metadata"
|
||||
|
||||
// Name is the pod name annotation
|
||||
// Name is the pod name annotation.
|
||||
Name = "io.kubernetes.cri-o.Name"
|
||||
|
||||
// Namespace is the pod namespace annotation
|
||||
// Namespace is the pod namespace annotation.
|
||||
Namespace = "io.kubernetes.cri-o.Namespace"
|
||||
|
||||
// PrivilegedRuntime is the annotation for the privileged runtime path
|
||||
// PrivilegedRuntime is the annotation for the privileged runtime path.
|
||||
PrivilegedRuntime = "io.kubernetes.cri-o.PrivilegedRuntime"
|
||||
|
||||
// ResolvPath is the resolver configuration path annotation
|
||||
// ResolvPath is the resolver configuration path annotation.
|
||||
ResolvPath = "io.kubernetes.cri-o.ResolvPath"
|
||||
|
||||
// HostnamePath is the path to /etc/hostname to bind mount annotation
|
||||
// HostnamePath is the path to /etc/hostname to bind mount annotation.
|
||||
HostnamePath = "io.kubernetes.cri-o.HostnamePath"
|
||||
|
||||
// SandboxID is the sandbox ID annotation
|
||||
// SandboxID is the sandbox ID annotation.
|
||||
SandboxID = "io.kubernetes.cri-o.SandboxID"
|
||||
|
||||
// SandboxName is the sandbox name annotation
|
||||
// SandboxName is the sandbox name annotation.
|
||||
SandboxName = "io.kubernetes.cri-o.SandboxName"
|
||||
|
||||
// ShmPath is the shared memory path annotation
|
||||
// ShmPath is the shared memory path annotation.
|
||||
ShmPath = "io.kubernetes.cri-o.ShmPath"
|
||||
|
||||
// MountPoint is the mount point of the container rootfs
|
||||
// MountPoint is the mount point of the container rootfs.
|
||||
MountPoint = "io.kubernetes.cri-o.MountPoint"
|
||||
|
||||
// RuntimeHandler is the annotation for runtime handler
|
||||
// RuntimeHandler is the annotation for runtime handler.
|
||||
RuntimeHandler = "io.kubernetes.cri-o.RuntimeHandler"
|
||||
|
||||
// TTY is the terminal path annotation
|
||||
// TTY is the terminal path annotation.
|
||||
TTY = "io.kubernetes.cri-o.TTY"
|
||||
|
||||
// Stdin is the stdin annotation
|
||||
// Stdin is the stdin annotation.
|
||||
Stdin = "io.kubernetes.cri-o.Stdin"
|
||||
|
||||
// StdinOnce is the stdin_once annotation
|
||||
// StdinOnce is the stdin_once annotation.
|
||||
StdinOnce = "io.kubernetes.cri-o.StdinOnce"
|
||||
|
||||
// Volumes is the volumes annotation
|
||||
// Volumes is the volumes annotation.
|
||||
Volumes = "io.kubernetes.cri-o.Volumes"
|
||||
|
||||
// HostNetwork indicates whether the host network namespace is used or not
|
||||
// HostNetwork indicates whether the host network namespace is used or not.
|
||||
HostNetwork = "io.kubernetes.cri-o.HostNetwork"
|
||||
|
||||
// CNIResult is the JSON string representation of the Result from CNI
|
||||
// CNIResult is the JSON string representation of the Result from CNI.
|
||||
CNIResult = "io.kubernetes.cri-o.CNIResult"
|
||||
|
||||
// ContainerManager is the annotation key for indicating the creator and
|
||||
// manager of the container
|
||||
// manager of the container.
|
||||
ContainerManager = "io.container.manager"
|
||||
)
|
||||
|
||||
// ContainerType values
|
||||
const (
|
||||
// ContainerTypeSandbox represents a pod sandbox container
|
||||
// ContainerTypeSandbox represents a pod sandbox container.
|
||||
ContainerTypeSandbox = "sandbox"
|
||||
|
||||
// ContainerTypeContainer represents a container running within a pod
|
||||
// ContainerTypeContainer represents a container running within a pod.
|
||||
ContainerTypeContainer = "container"
|
||||
)
|
||||
|
||||
// ContainerManagerLibpod indicates that libpod created and manages the
|
||||
// container
|
||||
// container.
|
||||
const ContainerManagerLibpod = "libpod"
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ func PruneImages(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
idr := make([]types.ImageDeleteResponseItem, len(imagePruneReports))
|
||||
idr := make([]types.ImageDeleteResponseItem, 0, len(imagePruneReports))
|
||||
var reclaimedSpace uint64
|
||||
var errorMsg bytes.Buffer
|
||||
for _, p := range imagePruneReports {
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ func IsRegistryReference(name string) error {
|
|||
imageRef, err := alltransports.ParseImageName(name)
|
||||
if err != nil {
|
||||
// No supported transport -> assume a docker-stype reference.
|
||||
return nil
|
||||
return nil // nolint: nilerr
|
||||
}
|
||||
if imageRef.Transport().Name() == docker.Transport.Name() {
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -279,7 +279,7 @@ func DemuxFrame(r io.Reader, buffer []byte, length int) (frame []byte, err error
|
|||
|
||||
n, err := io.ReadFull(r, buffer[0:length])
|
||||
if err != nil {
|
||||
return nil, nil
|
||||
return nil, err
|
||||
}
|
||||
if n < length {
|
||||
err = io.ErrUnexpectedEOF
|
||||
|
|
|
|||
|
|
@ -44,7 +44,8 @@ var _ = Describe("Podman containers attach", func() {
|
|||
timeout := uint(5)
|
||||
err := containers.Stop(bt.conn, id, new(containers.StopOptions).WithTimeout(timeout))
|
||||
if err != nil {
|
||||
GinkgoWriter.Write([]byte(err.Error()))
|
||||
_, writeErr := GinkgoWriter.Write([]byte(err.Error()))
|
||||
Expect(writeErr).ShouldNot(HaveOccurred())
|
||||
}
|
||||
}()
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,8 @@ var _ = Describe("Podman images", func() {
|
|||
AfterEach(func() {
|
||||
s.Kill()
|
||||
bt.cleanup()
|
||||
registry.Stop()
|
||||
err := registry.Stop()
|
||||
Expect(err).To(BeNil())
|
||||
})
|
||||
|
||||
// Test using credentials.
|
||||
|
|
|
|||
|
|
@ -211,7 +211,7 @@ func (b *bindingTest) RunTopContainer(containerName *string, podName *string) (s
|
|||
}
|
||||
ctr, err := containers.CreateWithSpec(b.conn, s, nil)
|
||||
if err != nil {
|
||||
return "", nil
|
||||
return "", err
|
||||
}
|
||||
err = containers.Start(b.conn, ctr.ID, nil)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -322,7 +322,8 @@ var _ = Describe("Podman containers ", func() {
|
|||
|
||||
// a container that has no healthcheck should be a 409
|
||||
var name = "top"
|
||||
bt.RunTopContainer(&name, nil)
|
||||
_, err = bt.RunTopContainer(&name, nil)
|
||||
Expect(err).To(BeNil())
|
||||
_, err = containers.RunHealthCheck(bt.conn, name, nil)
|
||||
Expect(err).ToNot(BeNil())
|
||||
code, _ = bindings.CheckResponseCode(err)
|
||||
|
|
|
|||
|
|
@ -99,13 +99,12 @@ func CRRemoveDeletedFiles(id, baseDirectory, containerRootDirectory string) erro
|
|||
// root file system changes on top of containerRootDirectory
|
||||
func CRApplyRootFsDiffTar(baseDirectory, containerRootDirectory string) error {
|
||||
rootfsDiffPath := filepath.Join(baseDirectory, metadata.RootFsDiffTar)
|
||||
if _, err := os.Stat(rootfsDiffPath); err != nil {
|
||||
// Only do this if a rootfs-diff.tar actually exists
|
||||
return nil
|
||||
}
|
||||
|
||||
// Only do this if a rootfs-diff.tar actually exists
|
||||
rootfsDiffFile, err := os.Open(rootfsDiffPath)
|
||||
if err != nil {
|
||||
if errors.Is(err, os.ErrNotExist) {
|
||||
return nil
|
||||
}
|
||||
return errors.Wrap(err, "failed to open root file-system diff file")
|
||||
}
|
||||
defer rootfsDiffFile.Close()
|
||||
|
|
|
|||
|
|
@ -213,8 +213,10 @@ func GenerateContainerFilterFuncs(filter string, filterValues []string, r *libpo
|
|||
for _, val := range filterValues {
|
||||
net, err := r.Network().NetworkInspect(val)
|
||||
if err != nil {
|
||||
// ignore not found errors
|
||||
break
|
||||
if errors.Is(err, define.ErrNoSuchNetwork) {
|
||||
continue
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
inputNetNames = append(inputNetNames, net.Name)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -131,8 +131,10 @@ func GeneratePodFilterFunc(filter string, filterValues []string, r *libpod.Runti
|
|||
for _, val := range filterValues {
|
||||
net, err := r.Network().NetworkInspect(val)
|
||||
if err != nil {
|
||||
// ignore not found errors
|
||||
break
|
||||
if errors.Is(err, define.ErrNoSuchNetwork) {
|
||||
continue
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
inputNetNames = append(inputNetNames, net.Name)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -848,13 +848,12 @@ func execPodman(execUser *user.User, command []string) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() error {
|
||||
err := cmdLogin.Process.Kill()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return cmdLogin.Wait()
|
||||
|
||||
defer func() {
|
||||
_ = cmdLogin.Process.Kill()
|
||||
_ = cmdLogin.Wait()
|
||||
}()
|
||||
|
||||
cmd := exec.Command(command[0], command[1:]...)
|
||||
cmd.Env = []string{"PATH=" + os.Getenv("PATH"), "TERM=" + os.Getenv("TERM")}
|
||||
cmd.Stderr = os.Stderr
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ func (ic *ContainerEngine) playKubePod(ctx context.Context, podName string, podY
|
|||
// FIXME This is very hard to support properly with a good ux
|
||||
if len(options.StaticIPs) > *ipIndex {
|
||||
if !podOpt.Net.Network.IsBridge() {
|
||||
errors.Wrap(define.ErrInvalidArg, "static ip addresses can only be set when the network mode is bridge")
|
||||
return nil, errors.Wrap(define.ErrInvalidArg, "static ip addresses can only be set when the network mode is bridge")
|
||||
}
|
||||
if len(podOpt.Net.Networks) != 1 {
|
||||
return nil, errors.Wrap(define.ErrInvalidArg, "cannot set static ip addresses for more than network, use netname:ip=<ip> syntax to specify ips for more than network")
|
||||
|
|
@ -230,7 +230,7 @@ func (ic *ContainerEngine) playKubePod(ctx context.Context, podName string, podY
|
|||
}
|
||||
if len(options.StaticMACs) > *ipIndex {
|
||||
if !podOpt.Net.Network.IsBridge() {
|
||||
errors.Wrap(define.ErrInvalidArg, "static mac address can only be set when the network mode is bridge")
|
||||
return nil, errors.Wrap(define.ErrInvalidArg, "static mac address can only be set when the network mode is bridge")
|
||||
}
|
||||
if len(podOpt.Net.Networks) != 1 {
|
||||
return nil, errors.Wrap(define.ErrInvalidArg, "cannot set static mac address for more than network, use netname:mac=<mac> syntax to specify mac for more than network")
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ const signalBufferSize = 2048
|
|||
func ProxySignals(ctr *libpod.Container) {
|
||||
// Stop catching the shutdown signals (SIGINT, SIGTERM) - they're going
|
||||
// to the container now.
|
||||
shutdown.Stop()
|
||||
shutdown.Stop() // nolint: errcheck
|
||||
|
||||
sigBuffer := make(chan os.Signal, signalBufferSize)
|
||||
signal.CatchAll(sigBuffer)
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ func ExecAttachCtr(ctx context.Context, ctr *libpod.Container, execConfig *libpo
|
|||
// StartAttachCtr starts and (if required) attaches to a container
|
||||
// if you change the signature of this function from os.File to io.Writer, it will trigger a downstream
|
||||
// error. we may need to just lint disable this one.
|
||||
func StartAttachCtr(ctx context.Context, ctr *libpod.Container, stdout, stderr, stdin *os.File, detachKeys string, sigProxy bool, startContainer bool) error { //nolint-interfacer
|
||||
func StartAttachCtr(ctx context.Context, ctr *libpod.Container, stdout, stderr, stdin *os.File, detachKeys string, sigProxy bool, startContainer bool) error { //nolint: interfacer
|
||||
resize := make(chan define.TerminalSize)
|
||||
|
||||
haveTerminal := terminal.IsTerminal(int(os.Stdin.Fd()))
|
||||
|
|
|
|||
|
|
@ -171,7 +171,8 @@ func (ic *ContainerEngine) VolumeMounted(ctx context.Context, nameOrID string) (
|
|||
}
|
||||
mountCount, err := vol.MountCount()
|
||||
if err != nil {
|
||||
return &entities.BoolReport{Value: false}, nil
|
||||
// FIXME: this error should probably be returned
|
||||
return &entities.BoolReport{Value: false}, nil // nolint: nilerr
|
||||
}
|
||||
if mountCount > 0 {
|
||||
return &entities.BoolReport{Value: true}, nil
|
||||
|
|
|
|||
|
|
@ -840,7 +840,7 @@ func (ic *ContainerEngine) ContainerRun(ctx context.Context, opts entities.Conta
|
|||
if eventsErr != nil || lastEvent == nil {
|
||||
logrus.Errorf("Cannot get exit code: %v", err)
|
||||
report.ExitCode = define.ExecErrorCodeNotFound
|
||||
return &report, nil // compat with local client
|
||||
return &report, nil // nolint: nilerr
|
||||
}
|
||||
|
||||
report.ExitCode = lastEvent.ContainerExitCode
|
||||
|
|
@ -938,7 +938,7 @@ func (ic *ContainerEngine) ContainerStat(ctx context.Context, nameOrID string, p
|
|||
return containers.Stat(ic.ClientCtx, nameOrID, path)
|
||||
}
|
||||
|
||||
// Shutdown Libpod engine
|
||||
// Shutdown Libpod engine.
|
||||
func (ic *ContainerEngine) Shutdown(_ context.Context) {
|
||||
}
|
||||
|
||||
|
|
@ -949,7 +949,7 @@ func (ic *ContainerEngine) ContainerStats(ctx context.Context, namesOrIds []stri
|
|||
return containers.Stats(ic.ClientCtx, namesOrIds, new(containers.StatsOptions).WithStream(options.Stream).WithInterval(options.Interval))
|
||||
}
|
||||
|
||||
// ShouldRestart reports back whether the container will restart
|
||||
// ShouldRestart reports back whether the container will restart.
|
||||
func (ic *ContainerEngine) ShouldRestart(_ context.Context, id string) (bool, error) {
|
||||
return containers.ShouldRestart(ic.ClientCtx, id, nil)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ func (ic *ContainerEngine) Events(ctx context.Context, opts entities.EventsOptio
|
|||
}
|
||||
|
||||
// GetLastContainerEvent takes a container name or ID and an event status and returns
|
||||
// the last occurrence of the container event
|
||||
// the last occurrence of the container event.
|
||||
func (ic *ContainerEngine) GetLastContainerEvent(ctx context.Context, nameOrID string, containerEvent events.Status) (*events.Event, error) {
|
||||
// check to make sure the event.Status is valid
|
||||
if _, err := events.StringToStatus(containerEvent.String()); err != nil {
|
||||
|
|
|
|||
2
pkg/env/env.go
vendored
2
pkg/env/env.go
vendored
|
|
@ -26,7 +26,7 @@ func DefaultEnvVariables() map[string]string {
|
|||
// Slice transforms the specified map of environment variables into a
|
||||
// slice. If a value is non-empty, the key and value are joined with '='.
|
||||
func Slice(m map[string]string) []string {
|
||||
env := make([]string, len(m))
|
||||
env := make([]string, 0, len(m))
|
||||
for k, v := range m {
|
||||
var s string
|
||||
if len(v) > 0 {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ func JoinErrors(errs []error) error {
|
|||
|
||||
finalErr := multiE.ErrorOrNil()
|
||||
if finalErr == nil {
|
||||
return finalErr
|
||||
return nil
|
||||
}
|
||||
return errors.New(strings.TrimSpace(finalErr.Error()))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import (
|
|||
v1 "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
)
|
||||
|
||||
// ImageData holds the inspect information of an image
|
||||
// ImageData holds the inspect information of an image.
|
||||
type ImageData struct {
|
||||
ID string `json:"Id"`
|
||||
Digest digest.Digest `json:"Digest"`
|
||||
|
|
@ -36,13 +36,13 @@ type ImageData struct {
|
|||
HealthCheck *manifest.Schema2HealthConfig `json:"Healthcheck,omitempty"`
|
||||
}
|
||||
|
||||
// RootFS holds the root fs information of an image
|
||||
// RootFS holds the root fs information of an image.
|
||||
type RootFS struct {
|
||||
Type string `json:"Type"`
|
||||
Layers []digest.Digest `json:"Layers"`
|
||||
}
|
||||
|
||||
// ImageResult is used for podman images for collection and output
|
||||
// ImageResult is used for podman images for collection and output.
|
||||
type ImageResult struct {
|
||||
Tag string
|
||||
Repository string
|
||||
|
|
|
|||
|
|
@ -579,9 +579,9 @@ func (q Quantity) MarshalJSON() ([]byte, error) {
|
|||
// if CanonicalizeBytes needed more space than our slice provided, we may need to allocate again so use
|
||||
// append
|
||||
result = result[:1]
|
||||
result = append(result, number...)
|
||||
result = append(result, suffix...)
|
||||
result = append(result, '"')
|
||||
result = append(result, number...) // nolint: makezero
|
||||
result = append(result, suffix...) // nolint: makezero
|
||||
result = append(result, '"') // nolint: makezero
|
||||
return result, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ const (
|
|||
etcgroup = "/etc/group"
|
||||
)
|
||||
|
||||
// Overrides allows you to override defaults in GetUserGroupInfo
|
||||
// Overrides allows you to override defaults in GetUserGroupInfo.
|
||||
type Overrides struct {
|
||||
DefaultUser *user.ExecUser
|
||||
ContainerEtcPasswdPath string
|
||||
|
|
|
|||
|
|
@ -36,9 +36,9 @@ type InitOptions struct {
|
|||
type QemuMachineStatus = string
|
||||
|
||||
const (
|
||||
// Running indicates the qemu vm is running
|
||||
// Running indicates the qemu vm is running.
|
||||
Running QemuMachineStatus = "running"
|
||||
// Stopped indicates the vm has stopped
|
||||
// Stopped indicates the vm has stopped.
|
||||
Stopped QemuMachineStatus = "stopped"
|
||||
DefaultMachineName string = "podman-machine-default"
|
||||
)
|
||||
|
|
@ -147,7 +147,7 @@ func (rc RemoteConnectionType) MakeSSHURL(host, path, port, userName string) url
|
|||
}
|
||||
|
||||
// GetDataDir returns the filepath where vm images should
|
||||
// live for podman-machine
|
||||
// live for podman-machine.
|
||||
func GetDataDir(vmType string) (string, error) {
|
||||
data, err := homedir.GetDataHome()
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -59,7 +59,10 @@ func (f FedoraDownload) Get() *Download {
|
|||
func (f FedoraDownload) HasUsableCache() (bool, error) {
|
||||
info, err := os.Stat(f.LocalPath)
|
||||
if err != nil {
|
||||
return false, nil
|
||||
if errors.Is(err, os.ErrNotExist) {
|
||||
return false, nil
|
||||
}
|
||||
return false, err
|
||||
}
|
||||
return info.Size() == f.Size, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,6 +61,6 @@ type Monitor struct {
|
|||
|
||||
var (
|
||||
// defaultQMPTimeout is the timeout duration for the
|
||||
// qmp monitor interactions
|
||||
// qmp monitor interactions.
|
||||
defaultQMPTimeout time.Duration = 2 * time.Second
|
||||
)
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ import (
|
|||
|
||||
var (
|
||||
qemuProvider = &Provider{}
|
||||
// vmtype refers to qemu (vs libvirt, krun, etc)
|
||||
// vmtype refers to qemu (vs libvirt, krun, etc).
|
||||
vmtype = "qemu"
|
||||
)
|
||||
|
||||
|
|
@ -278,7 +278,9 @@ func (v *MachineVM) Init(opts machine.InitOptions) (bool, error) {
|
|||
fmt.Println("An ignition path was provided. No SSH connection was added to Podman")
|
||||
}
|
||||
// Write the JSON file
|
||||
v.writeConfig()
|
||||
if err := v.writeConfig(); err != nil {
|
||||
return false, fmt.Errorf("writing JSON file: %w", err)
|
||||
}
|
||||
|
||||
// User has provided ignition file so keygen
|
||||
// will be skipped.
|
||||
|
|
@ -626,7 +628,8 @@ func (v *MachineVM) Stop(name string, _ machine.StopOptions) error {
|
|||
}
|
||||
|
||||
if err := qmpMonitor.Disconnect(); err != nil {
|
||||
return nil
|
||||
// FIXME: this error should probably be returned
|
||||
return nil // nolint: nilerr
|
||||
}
|
||||
|
||||
disconnected = true
|
||||
|
|
@ -755,7 +758,8 @@ func (v *MachineVM) isRunning() (bool, error) {
|
|||
// Check if we can dial it
|
||||
monitor, err := qmp.NewSocketMonitor(v.QMPMonitor.Network, v.QMPMonitor.Address, v.QMPMonitor.Timeout)
|
||||
if err != nil {
|
||||
return false, nil
|
||||
// FIXME: this error should probably be returned
|
||||
return false, nil // nolint: nilerr
|
||||
}
|
||||
if err := monitor.Connect(); err != nil {
|
||||
return false, err
|
||||
|
|
@ -1097,10 +1101,13 @@ func waitAndPingAPI(sock string) {
|
|||
Transport: &http.Transport{
|
||||
DialContext: func(context.Context, string, string) (net.Conn, error) {
|
||||
con, err := net.DialTimeout("unix", sock, apiUpTimeout)
|
||||
if err == nil {
|
||||
con.SetDeadline(time.Now().Add(apiUpTimeout))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return con, err
|
||||
if err := con.SetDeadline(time.Now().Add(apiUpTimeout)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return con, nil
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package rootless
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"sort"
|
||||
"sync"
|
||||
|
|
@ -8,7 +10,6 @@ import (
|
|||
"github.com/containers/storage/pkg/lockfile"
|
||||
"github.com/opencontainers/runc/libcontainer/user"
|
||||
spec "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// TryJoinPauseProcess attempts to join the namespaces of the pause PID via
|
||||
|
|
@ -16,12 +17,15 @@ import (
|
|||
// file.
|
||||
func TryJoinPauseProcess(pausePidPath string) (bool, int, error) {
|
||||
if _, err := os.Stat(pausePidPath); err != nil {
|
||||
return false, -1, nil
|
||||
if errors.Is(err, os.ErrNotExist) {
|
||||
return false, -1, nil
|
||||
}
|
||||
return false, -1, err
|
||||
}
|
||||
|
||||
became, ret, err := TryJoinFromFilePaths("", false, []string{pausePidPath})
|
||||
if err == nil {
|
||||
return became, ret, err
|
||||
return became, ret, nil
|
||||
}
|
||||
|
||||
// It could not join the pause process, let's lock the file before trying to delete it.
|
||||
|
|
@ -31,7 +35,7 @@ func TryJoinPauseProcess(pausePidPath string) (bool, int, error) {
|
|||
if os.IsNotExist(err) {
|
||||
return false, -1, nil
|
||||
}
|
||||
return false, -1, errors.Wrapf(err, "error acquiring lock on %s", pausePidPath)
|
||||
return false, -1, fmt.Errorf("error acquiring lock on %s: %w", pausePidPath, err)
|
||||
}
|
||||
|
||||
pidFileLock.Lock()
|
||||
|
|
@ -46,7 +50,7 @@ func TryJoinPauseProcess(pausePidPath string) (bool, int, error) {
|
|||
if err != nil {
|
||||
// It is still failing. We can safely remove it.
|
||||
os.Remove(pausePidPath)
|
||||
return false, -1, nil
|
||||
return false, -1, nil // nolint: nilerr
|
||||
}
|
||||
return became, ret, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ func ParseSignal(rawSignal string) (syscall.Signal, error) {
|
|||
}
|
||||
|
||||
// ParseSignalNameOrNumber translates a string to a valid syscall signal. Input
|
||||
// can be a name or number representation i.e. "KILL" "9"
|
||||
// can be a name or number representation i.e. "KILL" "9".
|
||||
func ParseSignalNameOrNumber(rawSignal string) (syscall.Signal, error) {
|
||||
basename := strings.TrimPrefix(rawSignal, "-")
|
||||
s, err := ParseSignal(basename)
|
||||
|
|
|
|||
|
|
@ -262,8 +262,8 @@ func addDevice(g *generate.Generator, device string) error {
|
|||
|
||||
// ParseDevice parses device mapping string to a src, dest & permissions string
|
||||
func ParseDevice(device string) (string, string, string, error) { //nolint
|
||||
src := ""
|
||||
dst := ""
|
||||
var src string
|
||||
var dst string
|
||||
permissions := "rwm"
|
||||
arr := strings.Split(device, ":")
|
||||
switch len(arr) {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import (
|
|||
|
||||
func benchmarkParsePortMapping(b *testing.B, ports []types.PortMapping) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
ParsePortMapping(ports, nil)
|
||||
_, _ = ParsePortMapping(ports, nil)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -847,7 +847,8 @@ func makeHealthCheckFromCli(inCmd, interval string, retries uint, timeout, start
|
|||
if len(cmdArr) == 0 {
|
||||
return nil, errors.New("Must define a healthcheck command for all healthchecks")
|
||||
}
|
||||
concat := ""
|
||||
|
||||
var concat string
|
||||
if cmdArr[0] == "CMD" || cmdArr[0] == "none" { // this is for compat, we are already split properly for most compat cases
|
||||
cmdArr = strings.Fields(inCmd)
|
||||
} else if cmdArr[0] != "CMD-SHELL" { // this is for podman side of things, won't contain the keywords
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ func IsSystemdSessionValid(uid int) bool {
|
|||
|
||||
if rootless.IsRootless() {
|
||||
conn, err = GetLogindConnection(rootless.GetRootlessUID())
|
||||
object = conn.Object(dbusDest, godbus.ObjectPath(dbusPath))
|
||||
if err != nil {
|
||||
//unable to fetch systemd object for logind
|
||||
logrus.Debugf("systemd-logind: %s", err)
|
||||
|
|
|
|||
|
|
@ -362,7 +362,9 @@ func executeContainerTemplate(info *containerInfo, options entities.GenerateSyst
|
|||
fs.StringArrayP("env", "e", nil, "")
|
||||
fs.String("sdnotify", "", "")
|
||||
fs.String("restart", "", "")
|
||||
fs.Parse(remainingCmd)
|
||||
if err := fs.Parse(remainingCmd); err != nil {
|
||||
return "", fmt.Errorf("parsing remaining command-line arguments: %w", err)
|
||||
}
|
||||
|
||||
remainingCmd = filterCommonContainerFlags(remainingCmd, fs.NArg())
|
||||
// If the container is in a pod, make sure that the
|
||||
|
|
|
|||
|
|
@ -335,7 +335,9 @@ func executePodTemplate(info *podInfo, options entities.GenerateSystemdOptions)
|
|||
fs.SetInterspersed(false)
|
||||
fs.String("name", "", "")
|
||||
fs.Bool("replace", false, "")
|
||||
fs.Parse(podCreateArgs)
|
||||
if err := fs.Parse(podCreateArgs); err != nil {
|
||||
return "", fmt.Errorf("parsing remaining command-line arguments: %w", err)
|
||||
}
|
||||
|
||||
hasNameParam := fs.Lookup("name").Changed
|
||||
hasReplaceParam, err := fs.GetBool("replace")
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
package terminal
|
||||
|
||||
// SetConsole for non-windows environments is a no-op
|
||||
// SetConsole for non-windows environments is a no-op.
|
||||
func SetConsole() error {
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,10 +51,10 @@ func Split(src string) (entries []string) {
|
|||
}
|
||||
entries = []string{}
|
||||
var runes [][]rune
|
||||
lastClass := 0
|
||||
class := 0
|
||||
var lastClass int
|
||||
// split into fields based on class of unicode character
|
||||
for _, r := range src {
|
||||
var class int
|
||||
switch {
|
||||
case unicode.IsLower(r):
|
||||
class = 1
|
||||
|
|
|
|||
|
|
@ -727,7 +727,7 @@ func SocketPath() (string, error) {
|
|||
func LookupUser(name string) (*user.User, error) {
|
||||
// Assume UID look up first, if it fails lookup by username
|
||||
if u, err := user.LookupId(name); err == nil {
|
||||
return u, err
|
||||
return u, nil
|
||||
}
|
||||
return user.Lookup(name)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package integration
|
||||
|
||||
import (
|
||||
"os"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
|
|
@ -20,12 +19,11 @@ var _ = Describe("Podman attach", func() {
|
|||
|
||||
BeforeEach(func() {
|
||||
tempdir, err = CreateTempDirInTempDir()
|
||||
if err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
Expect(err).To(BeNil())
|
||||
podmanTest = PodmanTestCreate(tempdir)
|
||||
podmanTest.Setup()
|
||||
podmanTest.SeedImages()
|
||||
err = podmanTest.SeedImages()
|
||||
Expect(err).To(BeNil())
|
||||
})
|
||||
|
||||
AfterEach(func() {
|
||||
|
|
|
|||
|
|
@ -37,12 +37,12 @@ var _ = Describe("Podman checkpoint", func() {
|
|||
BeforeEach(func() {
|
||||
SkipIfRootless("checkpoint not supported in rootless mode")
|
||||
tempdir, err = CreateTempDirInTempDir()
|
||||
if err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
Expect(err).To(BeNil())
|
||||
|
||||
podmanTest = PodmanTestCreate(tempdir)
|
||||
podmanTest.Setup()
|
||||
podmanTest.SeedImages()
|
||||
err = podmanTest.SeedImages()
|
||||
Expect(err).To(BeNil())
|
||||
// Check if the runtime implements checkpointing. Currently only
|
||||
// runc's checkpoint/restore implementation is supported.
|
||||
cmd := exec.Command(podmanTest.OCIRuntime, "checkpoint", "--help")
|
||||
|
|
|
|||
|
|
@ -21,12 +21,11 @@ var _ = Describe("Podman commit", func() {
|
|||
|
||||
BeforeEach(func() {
|
||||
tempdir, err = CreateTempDirInTempDir()
|
||||
if err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
Expect(err).To(BeNil())
|
||||
podmanTest = PodmanTestCreate(tempdir)
|
||||
podmanTest.Setup()
|
||||
podmanTest.SeedImages()
|
||||
err = podmanTest.SeedImages()
|
||||
Expect(err).To(BeNil())
|
||||
})
|
||||
|
||||
AfterEach(func() {
|
||||
|
|
|
|||
|
|
@ -809,7 +809,8 @@ func (p *PodmanTestIntegration) RestoreArtifactToCache(image string) error {
|
|||
|
||||
func populateCache(podman *PodmanTestIntegration) {
|
||||
for _, image := range CACHE_IMAGES {
|
||||
podman.RestoreArtifactToCache(image)
|
||||
err := podman.RestoreArtifactToCache(image)
|
||||
Expect(err).To(BeNil())
|
||||
}
|
||||
// logformatter uses this to recognize the first test
|
||||
fmt.Printf("-----------------------------\n")
|
||||
|
|
|
|||
|
|
@ -24,12 +24,11 @@ var _ = Describe("Podman create", func() {
|
|||
|
||||
BeforeEach(func() {
|
||||
tempdir, err = CreateTempDirInTempDir()
|
||||
if err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
Expect(err).To(BeNil())
|
||||
podmanTest = PodmanTestCreate(tempdir)
|
||||
podmanTest.Setup()
|
||||
podmanTest.SeedImages()
|
||||
err = podmanTest.SeedImages()
|
||||
Expect(err).To(BeNil())
|
||||
})
|
||||
|
||||
AfterEach(func() {
|
||||
|
|
|
|||
|
|
@ -86,6 +86,7 @@ var _ = Describe("Podman inspect", func() {
|
|||
|
||||
It("podman inspect container with GO format for ConmonPidFile", func() {
|
||||
session, ec, _ := podmanTest.RunLsContainer("test1")
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(ec).To(Equal(0))
|
||||
|
||||
session = podmanTest.Podman([]string{"inspect", "--format", "{{.ConmonPidFile}}", "test1"})
|
||||
|
|
@ -94,7 +95,8 @@ var _ = Describe("Podman inspect", func() {
|
|||
})
|
||||
|
||||
It("podman inspect container with size", func() {
|
||||
_, ec, _ := podmanTest.RunLsContainer("sizetest")
|
||||
session, ec, _ := podmanTest.RunLsContainer("sizetest")
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(ec).To(Equal(0))
|
||||
|
||||
result := podmanTest.Podman([]string{"inspect", "--size", "sizetest"})
|
||||
|
|
@ -107,6 +109,7 @@ var _ = Describe("Podman inspect", func() {
|
|||
|
||||
It("podman inspect container and image", func() {
|
||||
ls, ec, _ := podmanTest.RunLsContainer("")
|
||||
ls.WaitWithDefaultTimeout()
|
||||
Expect(ec).To(Equal(0))
|
||||
cid := ls.OutputToString()
|
||||
|
||||
|
|
@ -118,6 +121,7 @@ var _ = Describe("Podman inspect", func() {
|
|||
|
||||
It("podman inspect container and filter for Image{ID}", func() {
|
||||
ls, ec, _ := podmanTest.RunLsContainer("")
|
||||
ls.WaitWithDefaultTimeout()
|
||||
Expect(ec).To(Equal(0))
|
||||
cid := ls.OutputToString()
|
||||
|
||||
|
|
@ -134,6 +138,7 @@ var _ = Describe("Podman inspect", func() {
|
|||
|
||||
It("podman inspect container and filter for CreateCommand", func() {
|
||||
ls, ec, _ := podmanTest.RunLsContainer("")
|
||||
ls.WaitWithDefaultTimeout()
|
||||
Expect(ec).To(Equal(0))
|
||||
cid := ls.OutputToString()
|
||||
|
||||
|
|
@ -529,6 +534,7 @@ var _ = Describe("Podman inspect", func() {
|
|||
It("podman inspect container with GO format for PidFile", func() {
|
||||
SkipIfRemote("pidfile not handled by remote")
|
||||
session, ec, _ := podmanTest.RunLsContainer("test1")
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(ec).To(Equal(0))
|
||||
|
||||
session = podmanTest.Podman([]string{"inspect", "--format", "{{.PidFile}}", "test1"})
|
||||
|
|
|
|||
|
|
@ -51,7 +51,8 @@ var _ = Describe("Common functions test", func() {
|
|||
txt := fmt.Sprintf("ID=%s\nVERSION_ID=%s", id, ver)
|
||||
if !empty {
|
||||
f, _ := os.Create(path)
|
||||
f.WriteString(txt)
|
||||
_, err := f.WriteString(txt)
|
||||
Expect(err).To(BeNil(), "Failed to write data.")
|
||||
f.Close()
|
||||
}
|
||||
|
||||
|
|
@ -102,9 +103,10 @@ var _ = Describe("Common functions test", func() {
|
|||
Item2: []string{"test"},
|
||||
}
|
||||
|
||||
testByte, _ := json.Marshal(testData)
|
||||
err := WriteJSONFile(testByte, "/tmp/testJSON")
|
||||
testByte, err := json.Marshal(testData)
|
||||
Expect(err).To(BeNil(), "Failed to marshal data.")
|
||||
|
||||
err = WriteJSONFile(testByte, "/tmp/testJSON")
|
||||
Expect(err).To(BeNil(), "Failed to write JSON to file.")
|
||||
|
||||
read, err := os.Open("/tmp/testJSON")
|
||||
|
|
@ -135,7 +137,8 @@ var _ = Describe("Common functions test", func() {
|
|||
}
|
||||
if createFile {
|
||||
f, _ := os.Create(path)
|
||||
f.WriteString(txt)
|
||||
_, err := f.WriteString(txt)
|
||||
Expect(err).To(BeNil(), "Failed to write data.")
|
||||
f.Close()
|
||||
}
|
||||
ProcessOneCgroupPath = path
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import (
|
|||
"github.com/onsi/gomega/types"
|
||||
)
|
||||
|
||||
// HaveActiveService verifies the given service is the active service
|
||||
// HaveActiveService verifies the given service is the active service.
|
||||
func HaveActiveService(name interface{}) OmegaMatcher {
|
||||
return WithTransform(
|
||||
func(cfg *config.Config) string {
|
||||
|
|
@ -86,7 +86,7 @@ type URLMatcher struct {
|
|||
matchers.EqualMatcher
|
||||
}
|
||||
|
||||
// VerifyURL matches when actual is a valid URL and matches expected
|
||||
// VerifyURL matches when actual is a valid URL and matches expected.
|
||||
func VerifyURL(uri interface{}) OmegaMatcher {
|
||||
return &URLMatcher{matchers.EqualMatcher{Expected: uri}}
|
||||
}
|
||||
|
|
@ -129,7 +129,7 @@ func ExitWithError(optionalExitCode ...int) *ExitMatcher {
|
|||
return &ExitMatcher{Expected: exitCode}
|
||||
}
|
||||
|
||||
// Match follows gexec.Matcher interface
|
||||
// Match follows gexec.Matcher interface.
|
||||
func (matcher *ExitMatcher) Match(actual interface{}) (success bool, err error) {
|
||||
exiter, ok := actual.(gexec.Exiter)
|
||||
if !ok {
|
||||
|
|
@ -184,7 +184,7 @@ func (matcher *ValidJSONMatcher) Match(actual interface{}) (success bool, err er
|
|||
|
||||
var i interface{}
|
||||
if err := json.Unmarshal([]byte(s), &i); err != nil {
|
||||
return false, nil
|
||||
return false, err
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -479,7 +479,10 @@ func IsCommandAvailable(command string) bool {
|
|||
func WriteJSONFile(data []byte, filePath string) error {
|
||||
var jsonData map[string]interface{}
|
||||
json.Unmarshal(data, &jsonData)
|
||||
formatJSON, _ := json.MarshalIndent(jsonData, "", " ")
|
||||
formatJSON, err := json.MarshalIndent(jsonData, "", " ")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return ioutil.WriteFile(filePath, formatJSON, 0644)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import (
|
|||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// Find a random, open port on the host
|
||||
// Find a random, open port on the host.
|
||||
func GetRandomPort() (int, error) {
|
||||
l, err := net.Listen("tcp", ":0")
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import (
|
|||
)
|
||||
|
||||
// ExecCmd executes a command with args and returns its output as a string along
|
||||
// with an error, if any
|
||||
// with an error, if any.
|
||||
func ExecCmd(name string, args ...string) (string, error) {
|
||||
cmd := exec.Command(name, args...)
|
||||
var stdout bytes.Buffer
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue