mirror of
https://github.com/containers/podman.git
synced 2025-06-29 23:22:40 +08:00
enable gocritic linter
The linter ensures a common code style. - use switch/case instead of else if - use if instead of switch/case for single case statement - add space between comment and text - detect the use of defer with os.Exit() - use short form var += "..." instead of var = var + "..." - detect problems with append() ``` newSlice := append(orgSlice, val) ``` This could lead to nasty bugs because the orgSlice will be changed in place if it has enough capacity too hold the new elements. Thus we newSlice might not be a copy. Of course most of the changes are just cosmetic and do not cause any logic errors but I think it is a good idea to enforce a common style. This should help maintainability. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
.golangci.yml
cmd/podman
common
completion
images
pods
secrets
system
utils
libpod
container.gocontainer_api.gocontainer_exec.gocontainer_internal_linux.gocontainer_stat_linux.go
define
kube.gologs
networking_linux.gonetworking_machine.gonetworking_slirp4netns.gooci_conmon_exec_linux.gooci_conmon_linux.gooptions.goruntime.gopkg
api/handlers
bindings
domain
hooks
k8s.io
lookup
machine
namespaces
specgen
specgenutil
systemd
timetype
test
@ -46,7 +46,6 @@ linters:
|
|||||||
- lll
|
- lll
|
||||||
- unconvert
|
- unconvert
|
||||||
- errcheck
|
- errcheck
|
||||||
- gocritic
|
|
||||||
- gosec
|
- gosec
|
||||||
- maligned
|
- maligned
|
||||||
- gomoddirectives
|
- gomoddirectives
|
||||||
|
@ -327,7 +327,7 @@ func suffixCompSlice(suf string, slice []string) []string {
|
|||||||
if len(split) > 1 {
|
if len(split) > 1 {
|
||||||
slice[i] = split[0] + suf + "\t" + split[1]
|
slice[i] = split[0] + suf + "\t" + split[1]
|
||||||
} else {
|
} else {
|
||||||
slice[i] = slice[i] + suf
|
slice[i] += suf
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return slice
|
return slice
|
||||||
@ -647,7 +647,10 @@ func AutocompleteInspect(cmd *cobra.Command, args []string, toComplete string) (
|
|||||||
pods, _ := getPods(cmd, toComplete, completeDefault)
|
pods, _ := getPods(cmd, toComplete, completeDefault)
|
||||||
networks, _ := getNetworks(cmd, toComplete, completeDefault)
|
networks, _ := getNetworks(cmd, toComplete, completeDefault)
|
||||||
volumes, _ := getVolumes(cmd, toComplete)
|
volumes, _ := getVolumes(cmd, toComplete)
|
||||||
suggestions := append(containers, images...)
|
|
||||||
|
suggestions := make([]string, 0, len(containers)+len(images)+len(pods)+len(networks)+len(volumes))
|
||||||
|
suggestions = append(suggestions, containers...)
|
||||||
|
suggestions = append(suggestions, images...)
|
||||||
suggestions = append(suggestions, pods...)
|
suggestions = append(suggestions, pods...)
|
||||||
suggestions = append(suggestions, networks...)
|
suggestions = append(suggestions, networks...)
|
||||||
suggestions = append(suggestions, volumes...)
|
suggestions = append(suggestions, volumes...)
|
||||||
@ -961,6 +964,8 @@ func AutocompleteFormat(o interface{}) func(cmd *cobra.Command, args []string, t
|
|||||||
// this function provides shell completion for go templates
|
// this function provides shell completion for go templates
|
||||||
return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||||
// autocomplete json when nothing or json is typed
|
// autocomplete json when nothing or json is typed
|
||||||
|
// gocritic complains about the argument order but this is correct in this case
|
||||||
|
//nolint:gocritic
|
||||||
if strings.HasPrefix("json", toComplete) {
|
if strings.HasPrefix("json", toComplete) {
|
||||||
return []string{"json"}, cobra.ShellCompDirectiveNoFileComp
|
return []string{"json"}, cobra.ShellCompDirectiveNoFileComp
|
||||||
}
|
}
|
||||||
|
@ -896,7 +896,7 @@ func DefineCreateFlags(cmd *cobra.Command, cf *entities.ContainerCreateOptions,
|
|||||||
)
|
)
|
||||||
_ = cmd.RegisterFlagCompletionFunc(memorySwappinessFlagName, completion.AutocompleteNone)
|
_ = cmd.RegisterFlagCompletionFunc(memorySwappinessFlagName, completion.AutocompleteNone)
|
||||||
}
|
}
|
||||||
//anyone can use these
|
// anyone can use these
|
||||||
cpusFlagName := "cpus"
|
cpusFlagName := "cpus"
|
||||||
createFlags.Float64Var(
|
createFlags.Float64Var(
|
||||||
&cf.CPUS,
|
&cf.CPUS,
|
||||||
|
@ -31,7 +31,7 @@ var (
|
|||||||
Example: `podman completion bash
|
Example: `podman completion bash
|
||||||
podman completion zsh -f _podman
|
podman completion zsh -f _podman
|
||||||
podman completion fish --no-desc`,
|
podman completion fish --no-desc`,
|
||||||
//don't show this command to users
|
// don't show this command to users
|
||||||
Hidden: true,
|
Hidden: true,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -121,13 +121,8 @@ func scp(cmd *cobra.Command, args []string) (finalErr error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if flipConnections { // the order of cliConnections matters, we need to flip both arrays since the args are parsed separately sometimes.
|
if flipConnections { // the order of cliConnections matters, we need to flip both arrays since the args are parsed separately sometimes.
|
||||||
connect := cliConnections[0]
|
cliConnections[0], cliConnections[1] = cliConnections[1], cliConnections[0]
|
||||||
cliConnections[0] = cliConnections[1]
|
locations[0], locations[1] = locations[1], locations[0]
|
||||||
cliConnections[1] = connect
|
|
||||||
|
|
||||||
loc := locations[0]
|
|
||||||
locations[0] = locations[1]
|
|
||||||
locations[1] = loc
|
|
||||||
}
|
}
|
||||||
dest = *locations[1]
|
dest = *locations[1]
|
||||||
case len(locations) == 1:
|
case len(locations) == 1:
|
||||||
|
@ -224,7 +224,8 @@ func create(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
sort.Ints(vals)
|
sort.Ints(vals)
|
||||||
for ind, core := range vals {
|
for ind, core := range vals {
|
||||||
if core > int(cpuSet) {
|
switch {
|
||||||
|
case core > int(cpuSet):
|
||||||
if copy == "" {
|
if copy == "" {
|
||||||
copy = "0-" + strconv.Itoa(int(cpuSet))
|
copy = "0-" + strconv.Itoa(int(cpuSet))
|
||||||
infraOptions.CPUSetCPUs = copy
|
infraOptions.CPUSetCPUs = copy
|
||||||
@ -233,9 +234,9 @@ func create(cmd *cobra.Command, args []string) error {
|
|||||||
infraOptions.CPUSetCPUs = copy
|
infraOptions.CPUSetCPUs = copy
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
} else if ind != 0 {
|
case ind != 0:
|
||||||
copy += "," + strconv.Itoa(core)
|
copy += "," + strconv.Itoa(core)
|
||||||
} else {
|
default:
|
||||||
copy = "" + strconv.Itoa(core)
|
copy = "" + strconv.Itoa(core)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,13 +62,14 @@ func create(cmd *cobra.Command, args []string) error {
|
|||||||
path := args[1]
|
path := args[1]
|
||||||
|
|
||||||
var reader io.Reader
|
var reader io.Reader
|
||||||
if env {
|
switch {
|
||||||
|
case env:
|
||||||
envValue := os.Getenv(path)
|
envValue := os.Getenv(path)
|
||||||
if envValue == "" {
|
if envValue == "" {
|
||||||
return errors.Errorf("cannot create store secret data: environment variable %s is not set", path)
|
return errors.Errorf("cannot create store secret data: environment variable %s is not set", path)
|
||||||
}
|
}
|
||||||
reader = strings.NewReader(envValue)
|
reader = strings.NewReader(envValue)
|
||||||
} else if path == "-" || path == "/dev/stdin" {
|
case path == "-" || path == "/dev/stdin":
|
||||||
stat, err := os.Stdin.Stat()
|
stat, err := os.Stdin.Stat()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -77,7 +78,7 @@ func create(cmd *cobra.Command, args []string) error {
|
|||||||
return errors.New("if `-` is used, data must be passed into stdin")
|
return errors.New("if `-` is used, data must be passed into stdin")
|
||||||
}
|
}
|
||||||
reader = os.Stdin
|
reader = os.Stdin
|
||||||
} else {
|
default:
|
||||||
file, err := os.Open(path)
|
file, err := os.Open(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -69,6 +69,10 @@ func migrate(cmd *cobra.Command, args []string) {
|
|||||||
err = engine.Migrate(registry.Context(), cmd.Flags(), registry.PodmanConfig(), migrateOptions)
|
err = engine.Migrate(registry.Context(), cmd.Flags(), registry.PodmanConfig(), migrateOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
|
|
||||||
|
// FIXME change this to return the error like other commands
|
||||||
|
// defer will never run on os.Exit()
|
||||||
|
//nolint:gocritic
|
||||||
os.Exit(define.ExecErrorCodeGeneric)
|
os.Exit(define.ExecErrorCodeGeneric)
|
||||||
}
|
}
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
|
@ -56,6 +56,9 @@ func renumber(cmd *cobra.Command, args []string) {
|
|||||||
err = engine.Renumber(registry.Context(), cmd.Flags(), registry.PodmanConfig())
|
err = engine.Renumber(registry.Context(), cmd.Flags(), registry.PodmanConfig())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
|
// FIXME change this to return the error like other commands
|
||||||
|
// defer will never run on os.Exit()
|
||||||
|
//nolint:gocritic
|
||||||
os.Exit(define.ExecErrorCodeGeneric)
|
os.Exit(define.ExecErrorCodeGeneric)
|
||||||
}
|
}
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
|
@ -95,6 +95,9 @@ func reset(cmd *cobra.Command, args []string) {
|
|||||||
|
|
||||||
if err := engine.Reset(registry.Context()); err != nil {
|
if err := engine.Reset(registry.Context()); err != nil {
|
||||||
logrus.Error(err)
|
logrus.Error(err)
|
||||||
|
// FIXME change this to return the error like other commands
|
||||||
|
// defer will never run on os.Exit()
|
||||||
|
//nolint:gocritic
|
||||||
os.Exit(define.ExecErrorCodeGeneric)
|
os.Exit(define.ExecErrorCodeGeneric)
|
||||||
}
|
}
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
|
@ -37,8 +37,7 @@ func AliasFlags(f *pflag.FlagSet, name string) pflag.NormalizedName {
|
|||||||
|
|
||||||
// TimeoutAliasFlags is a function to handle backwards compatibility with old timeout flags
|
// TimeoutAliasFlags is a function to handle backwards compatibility with old timeout flags
|
||||||
func TimeoutAliasFlags(f *pflag.FlagSet, name string) pflag.NormalizedName {
|
func TimeoutAliasFlags(f *pflag.FlagSet, name string) pflag.NormalizedName {
|
||||||
switch name {
|
if name == "timeout" {
|
||||||
case "timeout":
|
|
||||||
name = "time"
|
name = "time"
|
||||||
}
|
}
|
||||||
return pflag.NormalizedName(name)
|
return pflag.NormalizedName(name)
|
||||||
|
@ -1180,7 +1180,7 @@ func (c *Container) Umask() string {
|
|||||||
return c.config.Umask
|
return c.config.Umask
|
||||||
}
|
}
|
||||||
|
|
||||||
//Secrets return the secrets in the container
|
// Secrets return the secrets in the container
|
||||||
func (c *Container) Secrets() []*ContainerSecret {
|
func (c *Container) Secrets() []*ContainerSecret {
|
||||||
return c.config.Secrets
|
return c.config.Secrets
|
||||||
}
|
}
|
||||||
|
@ -229,8 +229,7 @@ func (c *Container) Kill(signal uint) error {
|
|||||||
// This function returns when the attach finishes. It does not hold the lock for
|
// This function returns when the attach finishes. It does not hold the lock for
|
||||||
// the duration of its runtime, only using it at the beginning to verify state.
|
// the duration of its runtime, only using it at the beginning to verify state.
|
||||||
func (c *Container) Attach(streams *define.AttachStreams, keys string, resize <-chan define.TerminalSize) error {
|
func (c *Container) Attach(streams *define.AttachStreams, keys string, resize <-chan define.TerminalSize) error {
|
||||||
switch c.LogDriver() {
|
if c.LogDriver() == define.PassthroughLogging {
|
||||||
case define.PassthroughLogging:
|
|
||||||
return errors.Wrapf(define.ErrNoLogs, "this container is using the 'passthrough' log driver, cannot attach")
|
return errors.Wrapf(define.ErrNoLogs, "this container is using the 'passthrough' log driver, cannot attach")
|
||||||
}
|
}
|
||||||
if !c.batched {
|
if !c.batched {
|
||||||
|
@ -817,16 +817,16 @@ func (c *Container) Exec(config *ExecConfig, streams *define.AttachStreams, resi
|
|||||||
// Please be careful when using this function since it might temporarily unlock
|
// Please be careful when using this function since it might temporarily unlock
|
||||||
// the container when os.RemoveAll($bundlePath) fails with ENOTEMPTY or EBUSY
|
// the container when os.RemoveAll($bundlePath) fails with ENOTEMPTY or EBUSY
|
||||||
// errors.
|
// errors.
|
||||||
func (c *Container) cleanupExecBundle(sessionID string) (Err error) {
|
func (c *Container) cleanupExecBundle(sessionID string) (err error) {
|
||||||
path := c.execBundlePath(sessionID)
|
path := c.execBundlePath(sessionID)
|
||||||
for attempts := 0; attempts < 50; attempts++ {
|
for attempts := 0; attempts < 50; attempts++ {
|
||||||
Err = os.RemoveAll(path)
|
err = os.RemoveAll(path)
|
||||||
if Err == nil || os.IsNotExist(Err) {
|
if err == nil || os.IsNotExist(err) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if pathErr, ok := Err.(*os.PathError); ok {
|
if pathErr, ok := err.(*os.PathError); ok {
|
||||||
Err = pathErr.Err
|
err = pathErr.Err
|
||||||
if errors.Cause(Err) == unix.ENOTEMPTY || errors.Cause(Err) == unix.EBUSY {
|
if errors.Cause(err) == unix.ENOTEMPTY || errors.Cause(err) == unix.EBUSY {
|
||||||
// give other processes a chance to use the container
|
// give other processes a chance to use the container
|
||||||
if !c.batched {
|
if !c.batched {
|
||||||
if err := c.save(); err != nil {
|
if err := c.save(); err != nil {
|
||||||
|
@ -505,8 +505,7 @@ func (c *Container) generateSpec(ctx context.Context) (*spec.Spec, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, o := range namedVol.Options {
|
for _, o := range namedVol.Options {
|
||||||
switch o {
|
if o == "U" {
|
||||||
case "U":
|
|
||||||
if err := c.ChangeHostPathOwnership(mountPoint, true, int(hostUID), int(hostGID)); err != nil {
|
if err := c.ChangeHostPathOwnership(mountPoint, true, int(hostUID), int(hostGID)); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -596,8 +595,7 @@ func (c *Container) generateSpec(ctx context.Context) (*spec.Spec, error) {
|
|||||||
|
|
||||||
// Check overlay volume options
|
// Check overlay volume options
|
||||||
for _, o := range overlayVol.Options {
|
for _, o := range overlayVol.Options {
|
||||||
switch o {
|
if o == "U" {
|
||||||
case "U":
|
|
||||||
if err := c.ChangeHostPathOwnership(overlayVol.Source, true, int(hostUID), int(hostGID)); err != nil {
|
if err := c.ChangeHostPathOwnership(overlayVol.Source, true, int(hostUID), int(hostGID)); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -2144,13 +2142,11 @@ func (c *Container) makeBindMounts() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else if !c.config.UseImageHosts && c.state.BindMounts["/etc/hosts"] == "" {
|
||||||
if !c.config.UseImageHosts && c.state.BindMounts["/etc/hosts"] == "" {
|
|
||||||
if err := c.createHosts(); err != nil {
|
if err := c.createHosts(); err != nil {
|
||||||
return errors.Wrapf(err, "error creating hosts file for container %s", c.ID())
|
return errors.Wrapf(err, "error creating hosts file for container %s", c.ID())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if c.config.ShmDir != "" {
|
if c.config.ShmDir != "" {
|
||||||
// If ShmDir has a value SHM is always added when we mount the container
|
// If ShmDir has a value SHM is always added when we mount the container
|
||||||
@ -2267,7 +2263,7 @@ rootless=%d
|
|||||||
base := "/run/secrets"
|
base := "/run/secrets"
|
||||||
if secret.Target != "" {
|
if secret.Target != "" {
|
||||||
secretFileName = secret.Target
|
secretFileName = secret.Target
|
||||||
//If absolute path for target given remove base.
|
// If absolute path for target given remove base.
|
||||||
if filepath.IsAbs(secretFileName) {
|
if filepath.IsAbs(secretFileName) {
|
||||||
base = ""
|
base = ""
|
||||||
}
|
}
|
||||||
@ -2351,7 +2347,7 @@ func (c *Container) generateResolvConf() (string, error) {
|
|||||||
return "", errors.Wrapf(err, "error parsing host resolv.conf")
|
return "", errors.Wrapf(err, "error parsing host resolv.conf")
|
||||||
}
|
}
|
||||||
|
|
||||||
dns := make([]net.IP, 0, len(c.runtime.config.Containers.DNSServers))
|
dns := make([]net.IP, 0, len(c.runtime.config.Containers.DNSServers)+len(c.config.DNSServer))
|
||||||
for _, i := range c.runtime.config.Containers.DNSServers {
|
for _, i := range c.runtime.config.Containers.DNSServers {
|
||||||
result := net.ParseIP(i)
|
result := net.ParseIP(i)
|
||||||
if result == nil {
|
if result == nil {
|
||||||
@ -2359,13 +2355,13 @@ func (c *Container) generateResolvConf() (string, error) {
|
|||||||
}
|
}
|
||||||
dns = append(dns, result)
|
dns = append(dns, result)
|
||||||
}
|
}
|
||||||
dnsServers := append(dns, c.config.DNSServer...)
|
dns = append(dns, c.config.DNSServer...)
|
||||||
// If the user provided dns, it trumps all; then dns masq; then resolv.conf
|
// If the user provided dns, it trumps all; then dns masq; then resolv.conf
|
||||||
var search []string
|
var search []string
|
||||||
switch {
|
switch {
|
||||||
case len(dnsServers) > 0:
|
case len(dns) > 0:
|
||||||
// We store DNS servers as net.IP, so need to convert to string
|
// We store DNS servers as net.IP, so need to convert to string
|
||||||
for _, server := range dnsServers {
|
for _, server := range dns {
|
||||||
nameservers = append(nameservers, server.String())
|
nameservers = append(nameservers, server.String())
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -2890,11 +2886,11 @@ func (c *Container) generateUserPasswdEntry(addedUID int) (string, error) {
|
|||||||
|
|
||||||
func (c *Container) passwdEntry(username string, uid, gid, name, homeDir string) string {
|
func (c *Container) passwdEntry(username string, uid, gid, name, homeDir string) string {
|
||||||
s := c.config.PasswdEntry
|
s := c.config.PasswdEntry
|
||||||
s = strings.Replace(s, "$USERNAME", username, -1)
|
s = strings.ReplaceAll(s, "$USERNAME", username)
|
||||||
s = strings.Replace(s, "$UID", uid, -1)
|
s = strings.ReplaceAll(s, "$UID", uid)
|
||||||
s = strings.Replace(s, "$GID", gid, -1)
|
s = strings.ReplaceAll(s, "$GID", gid)
|
||||||
s = strings.Replace(s, "$NAME", name, -1)
|
s = strings.ReplaceAll(s, "$NAME", name)
|
||||||
s = strings.Replace(s, "$HOME", homeDir, -1)
|
s = strings.ReplaceAll(s, "$HOME", homeDir)
|
||||||
return s + "\n"
|
return s + "\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,15 +94,16 @@ func (c *Container) stat(containerMountPoint string, containerPath string) (*def
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if statInfo.IsSymlink {
|
switch {
|
||||||
|
case statInfo.IsSymlink:
|
||||||
// Symlinks are already evaluated and always relative to the
|
// Symlinks are already evaluated and always relative to the
|
||||||
// container's mount point.
|
// container's mount point.
|
||||||
absContainerPath = statInfo.ImmediateTarget
|
absContainerPath = statInfo.ImmediateTarget
|
||||||
} else if strings.HasPrefix(resolvedPath, containerMountPoint) {
|
case strings.HasPrefix(resolvedPath, containerMountPoint):
|
||||||
// If the path is on the container's mount point, strip it off.
|
// If the path is on the container's mount point, strip it off.
|
||||||
absContainerPath = strings.TrimPrefix(resolvedPath, containerMountPoint)
|
absContainerPath = strings.TrimPrefix(resolvedPath, containerMountPoint)
|
||||||
absContainerPath = filepath.Join("/", absContainerPath)
|
absContainerPath = filepath.Join("/", absContainerPath)
|
||||||
} else {
|
default:
|
||||||
// No symlink and not on the container's mount point, so let's
|
// No symlink and not on the container's mount point, so let's
|
||||||
// move it back to the original input. It must have evaluated
|
// move it back to the original input. It must have evaluated
|
||||||
// to a volume or bind mount but we cannot return host paths.
|
// to a volume or bind mount but we cannot return host paths.
|
||||||
|
@ -100,7 +100,7 @@ type InspectRestartPolicy struct {
|
|||||||
// InspectLogConfig holds information about a container's configured log driver
|
// InspectLogConfig holds information about a container's configured log driver
|
||||||
type InspectLogConfig struct {
|
type InspectLogConfig struct {
|
||||||
Type string `json:"Type"`
|
Type string `json:"Type"`
|
||||||
Config map[string]string `json:"Config"` //idk type, TODO
|
Config map[string]string `json:"Config"`
|
||||||
// Path specifies a path to the log file
|
// Path specifies a path to the log file
|
||||||
Path string `json:"Path"`
|
Path string `json:"Path"`
|
||||||
// Tag specifies a custom log tag for the container
|
// Tag specifies a custom log tag for the container
|
||||||
@ -680,7 +680,7 @@ type InspectContainerData struct {
|
|||||||
SizeRootFs int64 `json:"SizeRootFs,omitempty"`
|
SizeRootFs int64 `json:"SizeRootFs,omitempty"`
|
||||||
Mounts []InspectMount `json:"Mounts"`
|
Mounts []InspectMount `json:"Mounts"`
|
||||||
Dependencies []string `json:"Dependencies"`
|
Dependencies []string `json:"Dependencies"`
|
||||||
NetworkSettings *InspectNetworkSettings `json:"NetworkSettings"` //TODO
|
NetworkSettings *InspectNetworkSettings `json:"NetworkSettings"`
|
||||||
Namespace string `json:"Namespace"`
|
Namespace string `json:"Namespace"`
|
||||||
IsInfra bool `json:"IsInfra"`
|
IsInfra bool `json:"IsInfra"`
|
||||||
Config *InspectContainerConfig `json:"Config"`
|
Config *InspectContainerConfig `json:"Config"`
|
||||||
|
@ -12,7 +12,7 @@ type Info struct {
|
|||||||
Version Version `json:"version"`
|
Version Version `json:"version"`
|
||||||
}
|
}
|
||||||
|
|
||||||
//HostInfo describes the libpod host
|
// HostInfo describes the libpod host
|
||||||
type SecurityInfo struct {
|
type SecurityInfo struct {
|
||||||
AppArmorEnabled bool `json:"apparmorEnabled"`
|
AppArmorEnabled bool `json:"apparmorEnabled"`
|
||||||
DefaultCapabilities string `json:"capabilities"`
|
DefaultCapabilities string `json:"capabilities"`
|
||||||
|
@ -220,7 +220,7 @@ func ConvertV1PodToYAMLPod(pod *v1.Pod) *YAMLPod {
|
|||||||
cs = append(cs, &YAMLContainer{Container: cc, Resources: res})
|
cs = append(cs, &YAMLContainer{Container: cc, Resources: res})
|
||||||
}
|
}
|
||||||
mpo := &YAMLPod{Pod: *pod}
|
mpo := &YAMLPod{Pod: *pod}
|
||||||
mpo.Spec = &YAMLPodSpec{PodSpec: (*pod).Spec, Containers: cs}
|
mpo.Spec = &YAMLPodSpec{PodSpec: pod.Spec, Containers: cs}
|
||||||
for _, ctr := range pod.Spec.Containers {
|
for _, ctr := range pod.Spec.Containers {
|
||||||
if ctr.SecurityContext == nil || ctr.SecurityContext.SELinuxOptions == nil {
|
if ctr.SecurityContext == nil || ctr.SecurityContext.SELinuxOptions == nil {
|
||||||
continue
|
continue
|
||||||
@ -527,7 +527,7 @@ func simplePodWithV1Containers(ctx context.Context, ctrs []*Container) (*v1.Pod,
|
|||||||
// Check if the pod name and container name will end up conflicting
|
// Check if the pod name and container name will end up conflicting
|
||||||
// Append -pod if so
|
// Append -pod if so
|
||||||
if util.StringInSlice(podName, ctrNames) {
|
if util.StringInSlice(podName, ctrNames) {
|
||||||
podName = podName + "-pod"
|
podName += "-pod"
|
||||||
}
|
}
|
||||||
|
|
||||||
return newPodObject(
|
return newPodObject(
|
||||||
@ -633,7 +633,7 @@ func containerToV1Container(ctx context.Context, c *Container) (v1.Container, []
|
|||||||
|
|
||||||
kubeContainer.Ports = ports
|
kubeContainer.Ports = ports
|
||||||
// This should not be applicable
|
// This should not be applicable
|
||||||
//container.EnvFromSource =
|
// container.EnvFromSource =
|
||||||
kubeContainer.SecurityContext = kubeSec
|
kubeContainer.SecurityContext = kubeSec
|
||||||
kubeContainer.StdinOnce = false
|
kubeContainer.StdinOnce = false
|
||||||
kubeContainer.TTY = c.config.Spec.Process.Terminal
|
kubeContainer.TTY = c.config.Spec.Process.Terminal
|
||||||
@ -885,7 +885,7 @@ func convertVolumePathToName(hostSourcePath string) (string, error) {
|
|||||||
}
|
}
|
||||||
// First, trim trailing slashes, then replace slashes with dashes.
|
// First, trim trailing slashes, then replace slashes with dashes.
|
||||||
// Thus, /mnt/data/ will become mnt-data
|
// Thus, /mnt/data/ will become mnt-data
|
||||||
return strings.Replace(strings.Trim(hostSourcePath, "/"), "/", "-", -1), nil
|
return strings.ReplaceAll(strings.Trim(hostSourcePath, "/"), "/", "-"), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func determineCapAddDropFromCapabilities(defaultCaps, containerCaps []string) *v1.Capabilities {
|
func determineCapAddDropFromCapabilities(defaultCaps, containerCaps []string) *v1.Capabilities {
|
||||||
@ -927,14 +927,20 @@ func capAddDrop(caps *specs.LinuxCapabilities) (*v1.Capabilities, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defCaps := g.Config.Process.Capabilities
|
||||||
// Combine all the default capabilities into a slice
|
// Combine all the default capabilities into a slice
|
||||||
defaultCaps := append(g.Config.Process.Capabilities.Ambient, g.Config.Process.Capabilities.Bounding...)
|
defaultCaps := make([]string, 0, len(defCaps.Ambient)+len(defCaps.Bounding)+len(defCaps.Effective)+len(defCaps.Inheritable)+len(defCaps.Permitted))
|
||||||
defaultCaps = append(defaultCaps, g.Config.Process.Capabilities.Effective...)
|
defaultCaps = append(defaultCaps, defCaps.Ambient...)
|
||||||
defaultCaps = append(defaultCaps, g.Config.Process.Capabilities.Inheritable...)
|
defaultCaps = append(defaultCaps, defCaps.Bounding...)
|
||||||
defaultCaps = append(defaultCaps, g.Config.Process.Capabilities.Permitted...)
|
defaultCaps = append(defaultCaps, defCaps.Effective...)
|
||||||
|
defaultCaps = append(defaultCaps, defCaps.Inheritable...)
|
||||||
|
defaultCaps = append(defaultCaps, defCaps.Permitted...)
|
||||||
|
|
||||||
// Combine all the container's capabilities into a slice
|
// Combine all the container's capabilities into a slice
|
||||||
containerCaps := append(caps.Ambient, caps.Bounding...)
|
containerCaps := make([]string, 0, len(caps.Ambient)+len(caps.Bounding)+len(caps.Effective)+len(caps.Inheritable)+len(caps.Permitted))
|
||||||
|
containerCaps = append(containerCaps, caps.Ambient...)
|
||||||
|
containerCaps = append(containerCaps, caps.Bounding...)
|
||||||
containerCaps = append(containerCaps, caps.Effective...)
|
containerCaps = append(containerCaps, caps.Effective...)
|
||||||
containerCaps = append(containerCaps, caps.Inheritable...)
|
containerCaps = append(containerCaps, caps.Inheritable...)
|
||||||
containerCaps = append(containerCaps, caps.Permitted...)
|
containerCaps = append(containerCaps, caps.Permitted...)
|
||||||
@ -1042,7 +1048,7 @@ func generateKubeVolumeDeviceFromLinuxDevice(devices []specs.LinuxDevice) []v1.V
|
|||||||
}
|
}
|
||||||
|
|
||||||
func removeUnderscores(s string) string {
|
func removeUnderscores(s string) string {
|
||||||
return strings.Replace(s, "_", "", -1)
|
return strings.ReplaceAll(s, "_", "")
|
||||||
}
|
}
|
||||||
|
|
||||||
// getAutoUpdateAnnotations searches for auto-update container labels
|
// getAutoUpdateAnnotations searches for auto-update container labels
|
||||||
|
@ -28,7 +28,7 @@ const (
|
|||||||
// FullLogType signifies a log line is full
|
// FullLogType signifies a log line is full
|
||||||
FullLogType = "F"
|
FullLogType = "F"
|
||||||
|
|
||||||
//ANSIEscapeResetCode is a code that resets all colors and text effects
|
// ANSIEscapeResetCode is a code that resets all colors and text effects
|
||||||
ANSIEscapeResetCode = "\033[0m"
|
ANSIEscapeResetCode = "\033[0m"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -167,7 +167,7 @@ func getTailLog(path string, tail int) ([]*LogLine, error) {
|
|||||||
return tailLog, nil
|
return tailLog, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//getColor returns a ANSI escape code for color based on the colorID
|
// getColor returns a ANSI escape code for color based on the colorID
|
||||||
func getColor(colorID int64) string {
|
func getColor(colorID int64) string {
|
||||||
colors := map[int64]string{
|
colors := map[int64]string{
|
||||||
0: "\033[37m", // Light Gray
|
0: "\033[37m", // Light Gray
|
||||||
|
@ -579,7 +579,7 @@ func (r *Runtime) GetRootlessNetNs(new bool) (*RootlessNetNS, error) {
|
|||||||
// lets add /usr/sbin to $PATH ourselves.
|
// lets add /usr/sbin to $PATH ourselves.
|
||||||
path = os.Getenv("PATH")
|
path = os.Getenv("PATH")
|
||||||
if !strings.Contains(path, "/usr/sbin") {
|
if !strings.Contains(path, "/usr/sbin") {
|
||||||
path = path + ":/usr/sbin"
|
path += ":/usr/sbin"
|
||||||
os.Setenv("PATH", path)
|
os.Setenv("PATH", path)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1148,7 +1148,7 @@ func resultToBasicNetworkConfig(result types.StatusBlock) define.InspectBasicNet
|
|||||||
for _, netAddress := range netInt.Subnets {
|
for _, netAddress := range netInt.Subnets {
|
||||||
size, _ := netAddress.IPNet.Mask.Size()
|
size, _ := netAddress.IPNet.Mask.Size()
|
||||||
if netAddress.IPNet.IP.To4() != nil {
|
if netAddress.IPNet.IP.To4() != nil {
|
||||||
//ipv4
|
// ipv4
|
||||||
if config.IPAddress == "" {
|
if config.IPAddress == "" {
|
||||||
config.IPAddress = netAddress.IPNet.IP.String()
|
config.IPAddress = netAddress.IPNet.IP.String()
|
||||||
config.IPPrefixLen = size
|
config.IPPrefixLen = size
|
||||||
@ -1157,7 +1157,7 @@ func resultToBasicNetworkConfig(result types.StatusBlock) define.InspectBasicNet
|
|||||||
config.SecondaryIPAddresses = append(config.SecondaryIPAddresses, define.Address{Addr: netAddress.IPNet.IP.String(), PrefixLength: size})
|
config.SecondaryIPAddresses = append(config.SecondaryIPAddresses, define.Address{Addr: netAddress.IPNet.IP.String(), PrefixLength: size})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//ipv6
|
// ipv6
|
||||||
if config.GlobalIPv6Address == "" {
|
if config.GlobalIPv6Address == "" {
|
||||||
config.GlobalIPv6Address = netAddress.IPNet.IP.String()
|
config.GlobalIPv6Address = netAddress.IPNet.IP.String()
|
||||||
config.GlobalIPv6PrefixLen = size
|
config.GlobalIPv6PrefixLen = size
|
||||||
@ -1508,7 +1508,7 @@ func ocicniPortsToNetTypesPorts(ports []types.OCICNIPortMapping) []types.PortMap
|
|||||||
ports[i].Protocol == currentPort.Protocol &&
|
ports[i].Protocol == currentPort.Protocol &&
|
||||||
ports[i].HostPort-int32(currentPort.Range) == int32(currentPort.HostPort) &&
|
ports[i].HostPort-int32(currentPort.Range) == int32(currentPort.HostPort) &&
|
||||||
ports[i].ContainerPort-int32(currentPort.Range) == int32(currentPort.ContainerPort) {
|
ports[i].ContainerPort-int32(currentPort.Range) == int32(currentPort.ContainerPort) {
|
||||||
currentPort.Range = currentPort.Range + 1
|
currentPort.Range++
|
||||||
} else {
|
} else {
|
||||||
newPorts = append(newPorts, currentPort)
|
newPorts = append(newPorts, currentPort)
|
||||||
currentPort = types.PortMapping{
|
currentPort = types.PortMapping{
|
||||||
|
@ -33,9 +33,9 @@ type machineExpose struct {
|
|||||||
func requestMachinePorts(expose bool, ports []types.PortMapping) error {
|
func requestMachinePorts(expose bool, ports []types.PortMapping) error {
|
||||||
url := "http://" + machineGvproxyEndpoint + "/services/forwarder/"
|
url := "http://" + machineGvproxyEndpoint + "/services/forwarder/"
|
||||||
if expose {
|
if expose {
|
||||||
url = url + "expose"
|
url += "expose"
|
||||||
} else {
|
} else {
|
||||||
url = url + "unexpose"
|
url += "unexpose"
|
||||||
}
|
}
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
client := &http.Client{
|
client := &http.Client{
|
||||||
|
@ -82,7 +82,9 @@ func checkSlirpFlags(path string) (*slirpFeatures, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func parseSlirp4netnsNetworkOptions(r *Runtime, extraOptions []string) (*slirp4netnsNetworkOptions, error) {
|
func parseSlirp4netnsNetworkOptions(r *Runtime, extraOptions []string) (*slirp4netnsNetworkOptions, error) {
|
||||||
slirpOptions := append(r.config.Engine.NetworkCmdOptions, extraOptions...)
|
slirpOptions := make([]string, 0, len(r.config.Engine.NetworkCmdOptions)+len(extraOptions))
|
||||||
|
slirpOptions = append(slirpOptions, r.config.Engine.NetworkCmdOptions...)
|
||||||
|
slirpOptions = append(slirpOptions, extraOptions...)
|
||||||
slirp4netnsOpts := &slirp4netnsNetworkOptions{
|
slirp4netnsOpts := &slirp4netnsNetworkOptions{
|
||||||
// overwrite defaults
|
// overwrite defaults
|
||||||
disableHostLoopback: true,
|
disableHostLoopback: true,
|
||||||
|
@ -766,14 +766,12 @@ func prepareProcessExec(c *Container, options *ExecOptions, env []string, sessio
|
|||||||
if execUser.Uid == 0 {
|
if execUser.Uid == 0 {
|
||||||
pspec.Capabilities.Effective = pspec.Capabilities.Bounding
|
pspec.Capabilities.Effective = pspec.Capabilities.Bounding
|
||||||
pspec.Capabilities.Permitted = pspec.Capabilities.Bounding
|
pspec.Capabilities.Permitted = pspec.Capabilities.Bounding
|
||||||
} else {
|
} else if user == c.config.User {
|
||||||
if user == c.config.User {
|
|
||||||
pspec.Capabilities.Effective = ctrSpec.Process.Capabilities.Effective
|
pspec.Capabilities.Effective = ctrSpec.Process.Capabilities.Effective
|
||||||
pspec.Capabilities.Inheritable = ctrSpec.Process.Capabilities.Effective
|
pspec.Capabilities.Inheritable = ctrSpec.Process.Capabilities.Effective
|
||||||
pspec.Capabilities.Permitted = ctrSpec.Process.Capabilities.Effective
|
pspec.Capabilities.Permitted = ctrSpec.Process.Capabilities.Effective
|
||||||
pspec.Capabilities.Ambient = ctrSpec.Process.Capabilities.Effective
|
pspec.Capabilities.Ambient = ctrSpec.Process.Capabilities.Effective
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
hasHomeSet := false
|
hasHomeSet := false
|
||||||
for _, s := range pspec.Env {
|
for _, s := range pspec.Env {
|
||||||
|
@ -1371,7 +1371,7 @@ func (r *ConmonOCIRuntime) sharedConmonArgs(ctr *Container, cuuid, bundlePath, p
|
|||||||
case define.JSONLogging:
|
case define.JSONLogging:
|
||||||
fallthrough
|
fallthrough
|
||||||
//lint:ignore ST1015 the default case has to be here
|
//lint:ignore ST1015 the default case has to be here
|
||||||
default: //nolint:stylecheck
|
default: //nolint:stylecheck,gocritic
|
||||||
// No case here should happen except JSONLogging, but keep this here in case the options are extended
|
// 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())
|
logrus.Errorf("%s logging specified but not supported. Choosing k8s-file logging instead", ctr.LogDriver())
|
||||||
fallthrough
|
fallthrough
|
||||||
|
@ -1662,7 +1662,7 @@ func WithTimezone(path string) CtrCreateOption {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
//We don't want to mount a timezone directory
|
// We don't want to mount a timezone directory
|
||||||
if file.IsDir() {
|
if file.IsDir() {
|
||||||
return errors.New("Invalid timezone: is a directory")
|
return errors.New("Invalid timezone: is a directory")
|
||||||
}
|
}
|
||||||
|
@ -550,6 +550,10 @@ func makeRuntime(runtime *Runtime) (retErr error) {
|
|||||||
// Check if the pause process was created. If it was created, then
|
// Check if the pause process was created. If it was created, then
|
||||||
// move it to its own systemd scope.
|
// move it to its own systemd scope.
|
||||||
utils.MovePauseProcessToScope(pausePid)
|
utils.MovePauseProcessToScope(pausePid)
|
||||||
|
|
||||||
|
// gocritic complains because defer is not run on os.Exit()
|
||||||
|
// However this is fine because the lock is released anyway when the process exits
|
||||||
|
//nolint:gocritic
|
||||||
os.Exit(ret)
|
os.Exit(ret)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -293,9 +293,10 @@ func LibpodToContainer(l *libpod.Container, sz bool) (*handlers.Container, error
|
|||||||
stateStr = "created"
|
stateStr = "created"
|
||||||
}
|
}
|
||||||
|
|
||||||
if state == define.ContainerStateConfigured || state == define.ContainerStateCreated {
|
switch state {
|
||||||
|
case define.ContainerStateConfigured, define.ContainerStateCreated:
|
||||||
status = "Created"
|
status = "Created"
|
||||||
} else if state == define.ContainerStateStopped || state == define.ContainerStateExited {
|
case define.ContainerStateStopped, define.ContainerStateExited:
|
||||||
exitCode, _, err := l.ExitCode()
|
exitCode, _, err := l.ExitCode()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -305,7 +306,7 @@ func LibpodToContainer(l *libpod.Container, sz bool) (*handlers.Container, error
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
status = fmt.Sprintf("Exited (%d) %s ago", exitCode, units.HumanDuration(time.Since(finishedTime)))
|
status = fmt.Sprintf("Exited (%d) %s ago", exitCode, units.HumanDuration(time.Since(finishedTime)))
|
||||||
} else if state == define.ContainerStateRunning || state == define.ContainerStatePaused {
|
case define.ContainerStateRunning, define.ContainerStatePaused:
|
||||||
startedTime, err := l.StartedTime()
|
startedTime, err := l.StartedTime()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -314,11 +315,11 @@ func LibpodToContainer(l *libpod.Container, sz bool) (*handlers.Container, error
|
|||||||
if state == define.ContainerStatePaused {
|
if state == define.ContainerStatePaused {
|
||||||
status += " (Paused)"
|
status += " (Paused)"
|
||||||
}
|
}
|
||||||
} else if state == define.ContainerStateRemoving {
|
case define.ContainerStateRemoving:
|
||||||
status = "Removal In Progress"
|
status = "Removal In Progress"
|
||||||
} else if state == define.ContainerStateStopping {
|
case define.ContainerStateStopping:
|
||||||
status = "Stopping"
|
status = "Stopping"
|
||||||
} else {
|
default:
|
||||||
status = "Unknown"
|
status = "Unknown"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -532,7 +532,7 @@ func ExportImages(w http.ResponseWriter, r *http.Request) {
|
|||||||
utils.Error(w, http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
|
utils.Error(w, http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if len(query.Names) <= 0 {
|
if len(query.Names) == 0 {
|
||||||
utils.Error(w, http.StatusBadRequest, fmt.Errorf("no images to download"))
|
utils.Error(w, http.StatusBadRequest, fmt.Errorf("no images to download"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -286,7 +286,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
secrets = append(secrets, strings.Join(modifiedOpt[:], ","))
|
secrets = append(secrets, strings.Join(modifiedOpt, ","))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ func PruneImages(w http.ResponseWriter, r *http.Request) {
|
|||||||
idr = append(idr, types.ImageDeleteResponseItem{
|
idr = append(idr, types.ImageDeleteResponseItem{
|
||||||
Deleted: p.Id,
|
Deleted: p.Id,
|
||||||
})
|
})
|
||||||
reclaimedSpace = reclaimedSpace + p.Size
|
reclaimedSpace += p.Size
|
||||||
}
|
}
|
||||||
if errorMsg.Len() > 0 {
|
if errorMsg.Len() > 0 {
|
||||||
utils.InternalServerError(w, errors.New(errorMsg.String()))
|
utils.InternalServerError(w, errors.New(errorMsg.String()))
|
||||||
|
@ -150,7 +150,7 @@ func MarshalErrorJSONIsEmpty(ptr unsafe.Pointer) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func MarshalErrorSliceJSONIsEmpty(ptr unsafe.Pointer) bool {
|
func MarshalErrorSliceJSONIsEmpty(ptr unsafe.Pointer) bool {
|
||||||
return len(*((*[]error)(ptr))) <= 0
|
return len(*((*[]error)(ptr))) == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// WriteJSON writes an interface value encoded as JSON to w
|
// WriteJSON writes an interface value encoded as JSON to w
|
||||||
|
@ -225,11 +225,9 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO
|
|||||||
platform = "linux"
|
platform = "linux"
|
||||||
}
|
}
|
||||||
platform += "/" + options.Architecture
|
platform += "/" + options.Architecture
|
||||||
} else {
|
} else if len(platform) > 0 {
|
||||||
if len(platform) > 0 {
|
|
||||||
platform += "/" + runtime.GOARCH
|
platform += "/" + runtime.GOARCH
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if len(platform) > 0 {
|
if len(platform) > 0 {
|
||||||
params.Set("platform", platform)
|
params.Set("platform", platform)
|
||||||
}
|
}
|
||||||
@ -447,7 +445,7 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
secretsForRemote = append(secretsForRemote, strings.Join(modifiedOpt[:], ","))
|
secretsForRemote = append(secretsForRemote, strings.Join(modifiedOpt, ","))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -603,8 +601,8 @@ func nTar(excludes []string, sources ...string) (io.ReadCloser, error) {
|
|||||||
// are required to visit all files. :(
|
// are required to visit all files. :(
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
switch {
|
||||||
if d.Type().IsRegular() { // add file item
|
case d.Type().IsRegular(): // add file item
|
||||||
info, err := d.Info()
|
info, err := d.Info()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -644,7 +642,7 @@ func nTar(excludes []string, sources ...string) (io.ReadCloser, error) {
|
|||||||
seen[di] = name
|
seen[di] = name
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
} else if d.IsDir() { // add folders
|
case d.IsDir(): // add folders
|
||||||
info, err := d.Info()
|
info, err := d.Info()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -658,7 +656,7 @@ func nTar(excludes []string, sources ...string) (io.ReadCloser, error) {
|
|||||||
if lerr := tw.WriteHeader(hdr); lerr != nil {
|
if lerr := tw.WriteHeader(hdr); lerr != nil {
|
||||||
return lerr
|
return lerr
|
||||||
}
|
}
|
||||||
} else if d.Type()&os.ModeSymlink != 0 { // add symlinks as it, not content
|
case d.Type()&os.ModeSymlink != 0: // add symlinks as it, not content
|
||||||
link, err := os.Readlink(path)
|
link, err := os.Readlink(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -177,7 +177,7 @@ type PullOptions struct {
|
|||||||
Variant *string
|
Variant *string
|
||||||
}
|
}
|
||||||
|
|
||||||
//BuildOptions are optional options for building images
|
// BuildOptions are optional options for building images
|
||||||
type BuildOptions struct {
|
type BuildOptions struct {
|
||||||
buildahDefine.BuildOptions
|
buildahDefine.BuildOptions
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ func List(ctx context.Context, options *ListOptions) ([]types.Network, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Disconnect removes a container from a given network
|
// Disconnect removes a container from a given network
|
||||||
func Disconnect(ctx context.Context, networkName string, ContainerNameOrID string, options *DisconnectOptions) error {
|
func Disconnect(ctx context.Context, networkName string, containerNameOrID string, options *DisconnectOptions) error {
|
||||||
if options == nil {
|
if options == nil {
|
||||||
options = new(DisconnectOptions)
|
options = new(DisconnectOptions)
|
||||||
}
|
}
|
||||||
@ -114,7 +114,7 @@ func Disconnect(ctx context.Context, networkName string, ContainerNameOrID strin
|
|||||||
Container string
|
Container string
|
||||||
Force bool
|
Force bool
|
||||||
}{
|
}{
|
||||||
Container: ContainerNameOrID,
|
Container: containerNameOrID,
|
||||||
}
|
}
|
||||||
if force := options.GetForce(); options.Changed("Force") {
|
if force := options.GetForce(); options.Changed("Force") {
|
||||||
disconnect.Force = force
|
disconnect.Force = force
|
||||||
|
@ -104,9 +104,9 @@ var _ = Describe("Podman containers ", func() {
|
|||||||
// Pause by name
|
// Pause by name
|
||||||
err = containers.Pause(bt.conn, name, nil)
|
err = containers.Pause(bt.conn, name, nil)
|
||||||
Expect(err).To(BeNil(), "error from containers.Pause()")
|
Expect(err).To(BeNil(), "error from containers.Pause()")
|
||||||
//paused := "paused"
|
// paused := "paused"
|
||||||
//_, err = containers.Wait(bt.conn, cid, &paused)
|
// _, err = containers.Wait(bt.conn, cid, &paused)
|
||||||
//Expect(err).To(BeNil())
|
// Expect(err).To(BeNil())
|
||||||
err = containers.Unpause(bt.conn, name, nil)
|
err = containers.Unpause(bt.conn, name, nil)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
|
|
||||||
@ -332,8 +332,8 @@ var _ = Describe("Podman containers ", func() {
|
|||||||
// TODO for the life of me, i cannot get this to work. maybe another set
|
// TODO for the life of me, i cannot get this to work. maybe another set
|
||||||
// of eyes will
|
// of eyes will
|
||||||
// successful healthcheck
|
// successful healthcheck
|
||||||
//status := define.HealthCheckHealthy
|
// status := define.HealthCheckHealthy
|
||||||
//for i:=0; i < 10; i++ {
|
// for i:=0; i < 10; i++ {
|
||||||
// result, err := containers.RunHealthCheck(connText, "hc")
|
// result, err := containers.RunHealthCheck(connText, "hc")
|
||||||
// Expect(err).To(BeNil())
|
// Expect(err).To(BeNil())
|
||||||
// if result.Status != define.HealthCheckHealthy {
|
// if result.Status != define.HealthCheckHealthy {
|
||||||
@ -343,18 +343,18 @@ var _ = Describe("Podman containers ", func() {
|
|||||||
// }
|
// }
|
||||||
// status = result.Status
|
// status = result.Status
|
||||||
// break
|
// break
|
||||||
//}
|
// }
|
||||||
//Expect(status).To(Equal(define.HealthCheckHealthy))
|
// Expect(status).To(Equal(define.HealthCheckHealthy))
|
||||||
|
|
||||||
// TODO enable this when wait is working
|
// TODO enable this when wait is working
|
||||||
// healthcheck on a stopped container should be a 409
|
// healthcheck on a stopped container should be a 409
|
||||||
//err = containers.Stop(connText, "hc", nil)
|
// err = containers.Stop(connText, "hc", nil)
|
||||||
//Expect(err).To(BeNil())
|
// Expect(err).To(BeNil())
|
||||||
//_, err = containers.Wait(connText, "hc")
|
// _, err = containers.Wait(connText, "hc")
|
||||||
//Expect(err).To(BeNil())
|
// Expect(err).To(BeNil())
|
||||||
//_, err = containers.RunHealthCheck(connText, "hc")
|
// _, err = containers.RunHealthCheck(connText, "hc")
|
||||||
//code, _ = bindings.CheckResponseCode(err)
|
// code, _ = bindings.CheckResponseCode(err)
|
||||||
//Expect(code).To(BeNumerically("==", http.StatusConflict))
|
// Expect(code).To(BeNumerically("==", http.StatusConflict))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("logging", func() {
|
It("logging", func() {
|
||||||
@ -490,7 +490,7 @@ var _ = Describe("Podman containers ", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("podman kill a running container by bogus signal", func() {
|
It("podman kill a running container by bogus signal", func() {
|
||||||
//Killing a running container by bogus signal should fail
|
// Killing a running container by bogus signal should fail
|
||||||
var name = "top"
|
var name = "top"
|
||||||
cid, err := bt.RunTopContainer(&name, nil)
|
cid, err := bt.RunTopContainer(&name, nil)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
@ -580,7 +580,7 @@ var _ = Describe("Podman containers ", func() {
|
|||||||
|
|
||||||
// Valid filter params container should be pruned now.
|
// Valid filter params container should be pruned now.
|
||||||
filters := map[string][]string{
|
filters := map[string][]string{
|
||||||
"until": {"5000000000"}, //Friday, June 11, 2128
|
"until": {"5000000000"}, // Friday, June 11, 2128
|
||||||
}
|
}
|
||||||
pruneResponse, err = containers.Prune(bt.conn, new(containers.PruneOptions).WithFilters(filters))
|
pruneResponse, err = containers.Prune(bt.conn, new(containers.PruneOptions).WithFilters(filters))
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
@ -594,7 +594,7 @@ var _ = Describe("Podman containers ", func() {
|
|||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
|
|
||||||
filters := map[string][]string{
|
filters := map[string][]string{
|
||||||
"until": {"5000000000"}, //Friday, June 11, 2128
|
"until": {"5000000000"}, // Friday, June 11, 2128
|
||||||
}
|
}
|
||||||
c, err := containers.List(bt.conn, new(containers.ListOptions).WithFilters(filters).WithAll(true))
|
c, err := containers.List(bt.conn, new(containers.ListOptions).WithFilters(filters).WithAll(true))
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
|
@ -43,13 +43,13 @@ var _ = Describe("Podman pods", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("inspect pod", func() {
|
It("inspect pod", func() {
|
||||||
//Inspect an invalid pod name
|
// Inspect an invalid pod name
|
||||||
_, err := pods.Inspect(bt.conn, "dummyname", nil)
|
_, err := pods.Inspect(bt.conn, "dummyname", nil)
|
||||||
Expect(err).ToNot(BeNil())
|
Expect(err).ToNot(BeNil())
|
||||||
code, _ := bindings.CheckResponseCode(err)
|
code, _ := bindings.CheckResponseCode(err)
|
||||||
Expect(code).To(BeNumerically("==", http.StatusNotFound))
|
Expect(code).To(BeNumerically("==", http.StatusNotFound))
|
||||||
|
|
||||||
//Inspect an valid pod name
|
// Inspect an valid pod name
|
||||||
response, err := pods.Inspect(bt.conn, newpod, nil)
|
response, err := pods.Inspect(bt.conn, newpod, nil)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
Expect(response.Name).To(Equal(newpod))
|
Expect(response.Name).To(Equal(newpod))
|
||||||
@ -57,7 +57,7 @@ var _ = Describe("Podman pods", func() {
|
|||||||
|
|
||||||
// Test validates the list all api returns
|
// Test validates the list all api returns
|
||||||
It("list pod", func() {
|
It("list pod", func() {
|
||||||
//List all the pods in the current instance
|
// List all the pods in the current instance
|
||||||
podSummary, err := pods.List(bt.conn, nil)
|
podSummary, err := pods.List(bt.conn, nil)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
Expect(len(podSummary)).To(Equal(1))
|
Expect(len(podSummary)).To(Equal(1))
|
||||||
|
@ -18,9 +18,6 @@ import (
|
|||||||
|
|
||||||
var _ = Describe("Podman volumes", func() {
|
var _ = Describe("Podman volumes", func() {
|
||||||
var (
|
var (
|
||||||
//tempdir string
|
|
||||||
//err error
|
|
||||||
//podmanTest *PodmanTestIntegration
|
|
||||||
bt *bindingTest
|
bt *bindingTest
|
||||||
s *gexec.Session
|
s *gexec.Session
|
||||||
connText context.Context
|
connText context.Context
|
||||||
@ -28,13 +25,6 @@ var _ = Describe("Podman volumes", func() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
//tempdir, err = CreateTempDirInTempDir()
|
|
||||||
//if err != nil {
|
|
||||||
// os.Exit(1)
|
|
||||||
//}
|
|
||||||
//podmanTest = PodmanTestCreate(tempdir)
|
|
||||||
//podmanTest.Setup()
|
|
||||||
//podmanTest.SeedImages()
|
|
||||||
bt = newBindingTest()
|
bt = newBindingTest()
|
||||||
bt.RestoreImagesFromCache()
|
bt.RestoreImagesFromCache()
|
||||||
s = bt.startAPIService()
|
s = bt.startAPIService()
|
||||||
@ -44,9 +34,6 @@ var _ = Describe("Podman volumes", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
AfterEach(func() {
|
AfterEach(func() {
|
||||||
//podmanTest.Cleanup()
|
|
||||||
//f := CurrentGinkgoTestDescription()
|
|
||||||
//processTestResult(f)
|
|
||||||
s.Kill()
|
s.Kill()
|
||||||
bt.cleanup()
|
bt.cleanup()
|
||||||
})
|
})
|
||||||
|
@ -385,7 +385,7 @@ type ContainerInitReport struct {
|
|||||||
Id string //nolint
|
Id string //nolint
|
||||||
}
|
}
|
||||||
|
|
||||||
//ContainerMountOptions describes the input values for mounting containers
|
// ContainerMountOptions describes the input values for mounting containers
|
||||||
// in the CLI
|
// in the CLI
|
||||||
type ContainerMountOptions struct {
|
type ContainerMountOptions struct {
|
||||||
All bool
|
All bool
|
||||||
|
@ -33,7 +33,7 @@ type NetworkRmOptions struct {
|
|||||||
Timeout *uint
|
Timeout *uint
|
||||||
}
|
}
|
||||||
|
|
||||||
//NetworkRmReport describes the results of network removal
|
// NetworkRmReport describes the results of network removal
|
||||||
type NetworkRmReport struct {
|
type NetworkRmReport struct {
|
||||||
Name string
|
Name string
|
||||||
Err error
|
Err error
|
||||||
|
@ -34,7 +34,7 @@ func PruneReportsSize(r []*PruneReport) uint64 {
|
|||||||
if v == nil {
|
if v == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
size = size + v.Size
|
size += v.Size
|
||||||
}
|
}
|
||||||
return size
|
return size
|
||||||
}
|
}
|
||||||
|
@ -785,12 +785,19 @@ func transferRootless(source entities.ImageScpOptions, dest entities.ImageScpOpt
|
|||||||
return cmdLoad.Run()
|
return cmdLoad.Run()
|
||||||
}
|
}
|
||||||
|
|
||||||
// TransferRootful creates new podman processes using exec.Command and a new uid/gid alongside a cleared environment
|
// transferRootful creates new podman processes using exec.Command and a new uid/gid alongside a cleared environment
|
||||||
func transferRootful(source entities.ImageScpOptions, dest entities.ImageScpOptions, podman string, parentFlags []string) error {
|
func transferRootful(source entities.ImageScpOptions, dest entities.ImageScpOptions, podman string, parentFlags []string) error {
|
||||||
basicCommand := []string{podman}
|
basicCommand := make([]string, 0, len(parentFlags)+1)
|
||||||
|
basicCommand = append(basicCommand, podman)
|
||||||
basicCommand = append(basicCommand, parentFlags...)
|
basicCommand = append(basicCommand, parentFlags...)
|
||||||
saveCommand := append(basicCommand, "save")
|
|
||||||
loadCommand := append(basicCommand, "load")
|
saveCommand := make([]string, 0, len(basicCommand)+4)
|
||||||
|
saveCommand = append(saveCommand, basicCommand...)
|
||||||
|
saveCommand = append(saveCommand, "save")
|
||||||
|
|
||||||
|
loadCommand := make([]string, 0, len(basicCommand)+3)
|
||||||
|
loadCommand = append(loadCommand, basicCommand...)
|
||||||
|
loadCommand = append(loadCommand, "load")
|
||||||
if source.Quiet {
|
if source.Quiet {
|
||||||
saveCommand = append(saveCommand, "-q")
|
saveCommand = append(saveCommand, "-q")
|
||||||
loadCommand = append(loadCommand, "-q")
|
loadCommand = append(loadCommand, "-q")
|
||||||
|
@ -435,7 +435,7 @@ func (ic *ContainerEngine) playKubePod(ctx context.Context, podName string, podY
|
|||||||
initContainers = append(initContainers, ctr)
|
initContainers = append(initContainers, ctr)
|
||||||
}
|
}
|
||||||
for _, container := range podYAML.Spec.Containers {
|
for _, container := range podYAML.Spec.Containers {
|
||||||
if !strings.Contains("infra", container.Name) {
|
if !strings.Contains(container.Name, "infra") {
|
||||||
// Error out if the same name is used for more than one container
|
// Error out if the same name is used for more than one container
|
||||||
if _, ok := ctrNames[container.Name]; ok {
|
if _, ok := ctrNames[container.Name]; ok {
|
||||||
return nil, errors.Errorf("the pod %q is invalid; duplicate container name %q detected", podName, container.Name)
|
return nil, errors.Errorf("the pod %q is invalid; duplicate container name %q detected", podName, container.Name)
|
||||||
@ -770,7 +770,7 @@ func getBuildFile(imageName string, cwd string) (string, error) {
|
|||||||
logrus.Error(err.Error())
|
logrus.Error(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = os.Stat(filepath.Join(dockerfilePath))
|
_, err = os.Stat(dockerfilePath)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
logrus.Debugf("Building %s with %s", imageName, dockerfilePath)
|
logrus.Debugf("Building %s with %s", imageName, dockerfilePath)
|
||||||
return dockerfilePath, nil
|
return dockerfilePath, nil
|
||||||
|
@ -150,7 +150,7 @@ func (ic *ContainerEngine) SystemPrune(ctx context.Context, options entities.Sys
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
reclaimedSpace = reclaimedSpace + reports.PruneReportsSize(containerPruneReports)
|
reclaimedSpace += reports.PruneReportsSize(containerPruneReports)
|
||||||
systemPruneReport.ContainerPruneReports = append(systemPruneReport.ContainerPruneReports, containerPruneReports...)
|
systemPruneReport.ContainerPruneReports = append(systemPruneReport.ContainerPruneReports, containerPruneReports...)
|
||||||
imagePruneOptions := entities.ImagePruneOptions{
|
imagePruneOptions := entities.ImagePruneOptions{
|
||||||
All: options.All,
|
All: options.All,
|
||||||
@ -158,7 +158,7 @@ func (ic *ContainerEngine) SystemPrune(ctx context.Context, options entities.Sys
|
|||||||
}
|
}
|
||||||
imageEngine := ImageEngine{Libpod: ic.Libpod}
|
imageEngine := ImageEngine{Libpod: ic.Libpod}
|
||||||
imagePruneReports, err := imageEngine.Prune(ctx, imagePruneOptions)
|
imagePruneReports, err := imageEngine.Prune(ctx, imagePruneOptions)
|
||||||
reclaimedSpace = reclaimedSpace + reports.PruneReportsSize(imagePruneReports)
|
reclaimedSpace += reports.PruneReportsSize(imagePruneReports)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -178,7 +178,7 @@ func (ic *ContainerEngine) SystemPrune(ctx context.Context, options entities.Sys
|
|||||||
if len(volumePruneReport) > 0 {
|
if len(volumePruneReport) > 0 {
|
||||||
found = true
|
found = true
|
||||||
}
|
}
|
||||||
reclaimedSpace = reclaimedSpace + reports.PruneReportsSize(volumePruneReport)
|
reclaimedSpace += reports.PruneReportsSize(volumePruneReport)
|
||||||
systemPruneReport.VolumePruneReports = append(systemPruneReport.VolumePruneReports, volumePruneReport...)
|
systemPruneReport.VolumePruneReports = append(systemPruneReport.VolumePruneReports, volumePruneReport...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,15 +142,15 @@ func getPolicyShowOutput(policyContentStruct trust.PolicyContent, systemRegistri
|
|||||||
Type: trustTypeDescription(repoval[0].Type),
|
Type: trustTypeDescription(repoval[0].Type),
|
||||||
}
|
}
|
||||||
// TODO - keyarr is not used and I don't know its intent; commenting out for now for someone to fix later
|
// TODO - keyarr is not used and I don't know its intent; commenting out for now for someone to fix later
|
||||||
//keyarr := []string{}
|
// keyarr := []string{}
|
||||||
uids := []string{}
|
uids := []string{}
|
||||||
for _, repoele := range repoval {
|
for _, repoele := range repoval {
|
||||||
if len(repoele.KeyPath) > 0 {
|
if len(repoele.KeyPath) > 0 {
|
||||||
//keyarr = append(keyarr, repoele.KeyPath)
|
// keyarr = append(keyarr, repoele.KeyPath)
|
||||||
uids = append(uids, trust.GetGPGIdFromKeyPath(repoele.KeyPath)...)
|
uids = append(uids, trust.GetGPGIdFromKeyPath(repoele.KeyPath)...)
|
||||||
}
|
}
|
||||||
if len(repoele.KeyData) > 0 {
|
if len(repoele.KeyData) > 0 {
|
||||||
//keyarr = append(keyarr, string(repoele.KeyData))
|
// keyarr = append(keyarr, string(repoele.KeyData))
|
||||||
uids = append(uids, trust.GetGPGIdFromKeyData(repoele.KeyData)...)
|
uids = append(uids, trust.GetGPGIdFromKeyData(repoele.KeyData)...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -226,7 +226,7 @@ func TestMonitorTwoDirGood(t *testing.T) {
|
|||||||
assert.Equal(t, primaryInjected, config.Hooks) // masked by primary
|
assert.Equal(t, primaryInjected, config.Hooks) // masked by primary
|
||||||
})
|
})
|
||||||
|
|
||||||
primaryPath2 := filepath.Join(primaryDir, "0a.json") //0a because it will be before a.json alphabetically
|
primaryPath2 := filepath.Join(primaryDir, "0a.json") // 0a because it will be before a.json alphabetically
|
||||||
|
|
||||||
t.Run("bad-primary-new-addition", func(t *testing.T) {
|
t.Run("bad-primary-new-addition", func(t *testing.T) {
|
||||||
err = ioutil.WriteFile(primaryPath2, []byte("{\"version\": \"-1\"}"), 0644)
|
err = ioutil.WriteFile(primaryPath2, []byte("{\"version\": \"-1\"}"), 0644)
|
||||||
|
@ -1514,7 +1514,7 @@ const (
|
|||||||
// by the node selector terms.
|
// by the node selector terms.
|
||||||
// +structType=atomic
|
// +structType=atomic
|
||||||
type NodeSelector struct {
|
type NodeSelector struct {
|
||||||
//Required. A list of node selector terms. The terms are ORed.
|
// Required. A list of node selector terms. The terms are ORed.
|
||||||
NodeSelectorTerms []NodeSelectorTerm `json:"nodeSelectorTerms"`
|
NodeSelectorTerms []NodeSelectorTerm `json:"nodeSelectorTerms"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3040,7 +3040,7 @@ type ServiceSpec struct {
|
|||||||
SessionAffinityConfig *SessionAffinityConfig `json:"sessionAffinityConfig,omitempty"`
|
SessionAffinityConfig *SessionAffinityConfig `json:"sessionAffinityConfig,omitempty"`
|
||||||
|
|
||||||
// TopologyKeys is tombstoned to show why 16 is reserved protobuf tag.
|
// TopologyKeys is tombstoned to show why 16 is reserved protobuf tag.
|
||||||
//TopologyKeys []string `json:"topologyKeys,omitempty"`
|
// TopologyKeys []string `json:"topologyKeys,omitempty"`
|
||||||
|
|
||||||
// IPFamily is tombstoned to show why 15 is a reserved protobuf tag.
|
// IPFamily is tombstoned to show why 15 is a reserved protobuf tag.
|
||||||
// IPFamily *IPFamily `json:"ipFamily,omitempty"`
|
// IPFamily *IPFamily `json:"ipFamily,omitempty"`
|
||||||
|
@ -231,13 +231,13 @@ func (a int64Amount) AsCanonicalBytes(out []byte) (result []byte, exponent int32
|
|||||||
if !ok {
|
if !ok {
|
||||||
return infDecAmount{a.AsDec()}.AsCanonicalBytes(out)
|
return infDecAmount{a.AsDec()}.AsCanonicalBytes(out)
|
||||||
}
|
}
|
||||||
exponent = exponent - 1
|
exponent--
|
||||||
case 2, -1:
|
case 2, -1:
|
||||||
amount, ok = int64MultiplyScale100(amount)
|
amount, ok = int64MultiplyScale100(amount)
|
||||||
if !ok {
|
if !ok {
|
||||||
return infDecAmount{a.AsDec()}.AsCanonicalBytes(out)
|
return infDecAmount{a.AsDec()}.AsCanonicalBytes(out)
|
||||||
}
|
}
|
||||||
exponent = exponent - 2
|
exponent -= 2
|
||||||
}
|
}
|
||||||
return strconv.AppendInt(out, amount, 10), exponent
|
return strconv.AppendInt(out, amount, 10), exponent
|
||||||
}
|
}
|
||||||
|
@ -171,7 +171,7 @@ func negativeScaleInt64(base int64, scale Scale) (result int64, exact bool) {
|
|||||||
if !fraction && value%10 != 0 {
|
if !fraction && value%10 != 0 {
|
||||||
fraction = true
|
fraction = true
|
||||||
}
|
}
|
||||||
value = value / 10
|
value /= 10
|
||||||
if value == 0 {
|
if value == 0 {
|
||||||
if fraction {
|
if fraction {
|
||||||
if base > 0 {
|
if base > 0 {
|
||||||
@ -265,18 +265,18 @@ func removeInt64Factors(value int64, base int64) (result int64, times int32) {
|
|||||||
case 10:
|
case 10:
|
||||||
for result >= 10 && result%10 == 0 {
|
for result >= 10 && result%10 == 0 {
|
||||||
times++
|
times++
|
||||||
result = result / 10
|
result /= 10
|
||||||
}
|
}
|
||||||
// allow the compiler to optimize the common cases
|
// allow the compiler to optimize the common cases
|
||||||
case 1024:
|
case 1024:
|
||||||
for result >= 1024 && result%1024 == 0 {
|
for result >= 1024 && result%1024 == 0 {
|
||||||
times++
|
times++
|
||||||
result = result / 1024
|
result /= 1024
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
for result >= base && result%base == 0 {
|
for result >= base && result%base == 0 {
|
||||||
times++
|
times++
|
||||||
result = result / base
|
result /= base
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if negative {
|
if negative {
|
||||||
|
@ -1156,7 +1156,7 @@ type ManagedFieldsEntry struct {
|
|||||||
Time *Time `json:"time,omitempty"`
|
Time *Time `json:"time,omitempty"`
|
||||||
|
|
||||||
// Fields is tombstoned to show why 5 is a reserved protobuf tag.
|
// Fields is tombstoned to show why 5 is a reserved protobuf tag.
|
||||||
//Fields *Fields `json:"fields,omitempty"`
|
// Fields *Fields `json:"fields,omitempty"`
|
||||||
|
|
||||||
// FieldsType is the discriminator for the different fields format and version.
|
// FieldsType is the discriminator for the different fields format and version.
|
||||||
// There is currently only one possible value: "FieldsV1"
|
// There is currently only one possible value: "FieldsV1"
|
||||||
|
@ -61,7 +61,7 @@ func GetUserGroupInfo(containerMount, containerUser string, override *Overrides)
|
|||||||
defaultExecUser = override.DefaultUser
|
defaultExecUser = override.DefaultUser
|
||||||
} else {
|
} else {
|
||||||
// Define a default container user
|
// Define a default container user
|
||||||
//defaultExecUser = &user.ExecUser{
|
// defaultExecUser = &user.ExecUser{
|
||||||
// Uid: 0,
|
// Uid: 0,
|
||||||
// Gid: 0,
|
// Gid: 0,
|
||||||
// Home: "/",
|
// Home: "/",
|
||||||
|
@ -135,7 +135,7 @@ type InspectInfo struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (rc RemoteConnectionType) MakeSSHURL(host, path, port, userName string) url.URL {
|
func (rc RemoteConnectionType) MakeSSHURL(host, path, port, userName string) url.URL {
|
||||||
//TODO Should this function have input verification?
|
// TODO Should this function have input verification?
|
||||||
userInfo := url.User(userName)
|
userInfo := url.User(userName)
|
||||||
uri := url.URL{
|
uri := url.URL{
|
||||||
Scheme: "ssh",
|
Scheme: "ssh",
|
||||||
|
@ -21,6 +21,8 @@ const (
|
|||||||
githubURL = "http://github.com/fedora-cloud/docker-brew-fedora/"
|
githubURL = "http://github.com/fedora-cloud/docker-brew-fedora/"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var fedoraxzRegex = regexp.MustCompile(`fedora[^\"]+xz`)
|
||||||
|
|
||||||
type FedoraDownload struct {
|
type FedoraDownload struct {
|
||||||
Download
|
Download
|
||||||
}
|
}
|
||||||
@ -96,12 +98,8 @@ func getFedoraDownload(releaseStream string) (string, *url.URL, int64, error) {
|
|||||||
return "", nil, -1, err
|
return "", nil, -1, err
|
||||||
}
|
}
|
||||||
|
|
||||||
rx, err := regexp.Compile(`fedora[^\"]+xz`)
|
file := fedoraxzRegex.FindString(string(body))
|
||||||
if err != nil {
|
if len(file) == 0 {
|
||||||
return "", nil, -1, err
|
|
||||||
}
|
|
||||||
file := rx.FindString(string(body))
|
|
||||||
if len(file) <= 0 {
|
|
||||||
return "", nil, -1, fmt.Errorf("could not locate Fedora download at %s", dirURL)
|
return "", nil, -1, fmt.Errorf("could not locate Fedora download at %s", dirURL)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,8 +332,7 @@ func (v *MachineVM) Init(opts machine.InitOptions) (bool, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch volumeType {
|
if volumeType == VolumeTypeVirtfs {
|
||||||
case VolumeTypeVirtfs:
|
|
||||||
virtfsOptions := fmt.Sprintf("local,path=%s,mount_tag=%s,security_model=mapped-xattr", source, tag)
|
virtfsOptions := fmt.Sprintf("local,path=%s,mount_tag=%s,security_model=mapped-xattr", source, tag)
|
||||||
if readonly {
|
if readonly {
|
||||||
virtfsOptions += ",readonly"
|
virtfsOptions += ",readonly"
|
||||||
@ -783,7 +782,7 @@ func (v *MachineVM) Stop(_ string, _ machine.StopOptions) error {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
time.Sleep(waitInternal)
|
time.Sleep(waitInternal)
|
||||||
waitInternal = waitInternal * 2
|
waitInternal *= 2
|
||||||
}
|
}
|
||||||
|
|
||||||
return v.ReadySocket.Delete()
|
return v.ReadySocket.Delete()
|
||||||
@ -799,8 +798,7 @@ func NewQMPMonitor(network, name string, timeout time.Duration) (Monitor, error)
|
|||||||
rtDir = "/run"
|
rtDir = "/run"
|
||||||
}
|
}
|
||||||
rtDir = filepath.Join(rtDir, "podman")
|
rtDir = filepath.Join(rtDir, "podman")
|
||||||
if _, err := os.Stat(filepath.Join(rtDir)); os.IsNotExist(err) {
|
if _, err := os.Stat(rtDir); os.IsNotExist(err) {
|
||||||
// TODO 0644 is fine on linux but macos is weird
|
|
||||||
if err := os.MkdirAll(rtDir, 0755); err != nil {
|
if err := os.MkdirAll(rtDir, 0755); err != nil {
|
||||||
return Monitor{}, err
|
return Monitor{}, err
|
||||||
}
|
}
|
||||||
@ -872,7 +870,7 @@ func (v *MachineVM) Remove(_ string, opts machine.RemoveOptions) (string, func()
|
|||||||
confirmationMessage += msg + "\n"
|
confirmationMessage += msg + "\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
//remove socket and pid file if any: warn at low priority if things fail
|
// remove socket and pid file if any: warn at low priority if things fail
|
||||||
// Remove the pidfile
|
// Remove the pidfile
|
||||||
if err := v.PidFilePath.Delete(); err != nil {
|
if err := v.PidFilePath.Delete(); err != nil {
|
||||||
logrus.Debugf("Error while removing pidfile: %v", err)
|
logrus.Debugf("Error while removing pidfile: %v", err)
|
||||||
|
@ -375,7 +375,7 @@ func (n NetworkMode) Container() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
//UserDefined indicates user-created network
|
// UserDefined indicates user-created network
|
||||||
func (n NetworkMode) UserDefined() string {
|
func (n NetworkMode) UserDefined() string {
|
||||||
if n.IsUserDefined() {
|
if n.IsUserDefined() {
|
||||||
return string(n)
|
return string(n)
|
||||||
|
@ -122,19 +122,19 @@ func (s *SpecGenerator) Validate() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO the specgen does not appear to handle this? Should it
|
// TODO the specgen does not appear to handle this? Should it
|
||||||
//switch config.Cgroup.Cgroups {
|
// switch config.Cgroup.Cgroups {
|
||||||
//case "disabled":
|
// case "disabled":
|
||||||
// if addedResources {
|
// if addedResources {
|
||||||
// return errors.New("cannot specify resource limits when cgroups are disabled is specified")
|
// return errors.New("cannot specify resource limits when cgroups are disabled is specified")
|
||||||
// }
|
// }
|
||||||
// configSpec.Linux.Resources = &spec.LinuxResources{}
|
// configSpec.Linux.Resources = &spec.LinuxResources{}
|
||||||
//case "enabled", "no-conmon", "":
|
// case "enabled", "no-conmon", "":
|
||||||
// // Do nothing
|
// // Do nothing
|
||||||
//default:
|
// default:
|
||||||
// return errors.New("unrecognized option for cgroups; supported are 'default', 'disabled', 'no-conmon'")
|
// return errors.New("unrecognized option for cgroups; supported are 'default', 'disabled', 'no-conmon'")
|
||||||
//}
|
// }
|
||||||
invalidUlimitFormatError := errors.New("invalid default ulimit definition must be form of type=soft:hard")
|
invalidUlimitFormatError := errors.New("invalid default ulimit definition must be form of type=soft:hard")
|
||||||
//set ulimits if not rootless
|
// set ulimits if not rootless
|
||||||
if len(s.ContainerResourceConfig.Rlimits) < 1 && !rootless.IsRootless() {
|
if len(s.ContainerResourceConfig.Rlimits) < 1 && !rootless.IsRootless() {
|
||||||
// Containers common defines this as something like nproc=4194304:4194304
|
// Containers common defines this as something like nproc=4194304:4194304
|
||||||
tmpnproc := containerConfig.Ulimits()
|
tmpnproc := containerConfig.Ulimits()
|
||||||
|
@ -395,7 +395,7 @@ func ConfigToSpec(rt *libpod.Runtime, specg *specgen.SpecGenerator, contaierID s
|
|||||||
} else {
|
} else {
|
||||||
switch nameSpaces[i] {
|
switch nameSpaces[i] {
|
||||||
case "pid":
|
case "pid":
|
||||||
specg.PidNS = specgen.Namespace{NSMode: specgen.Default} //default
|
specg.PidNS = specgen.Namespace{NSMode: specgen.Default} // default
|
||||||
case "net":
|
case "net":
|
||||||
switch {
|
switch {
|
||||||
case conf.NetMode.IsBridge():
|
case conf.NetMode.IsBridge():
|
||||||
@ -435,7 +435,7 @@ func ConfigToSpec(rt *libpod.Runtime, specg *specgen.SpecGenerator, contaierID s
|
|||||||
specg.NetNS = specgen.Namespace{NSMode: specgen.FromPod, Value: strings.Split(string(conf.NetMode), ":")[1]}
|
specg.NetNS = specgen.Namespace{NSMode: specgen.FromPod, Value: strings.Split(string(conf.NetMode), ":")[1]}
|
||||||
}
|
}
|
||||||
case "cgroup":
|
case "cgroup":
|
||||||
specg.CgroupNS = specgen.Namespace{NSMode: specgen.Default} //default
|
specg.CgroupNS = specgen.Namespace{NSMode: specgen.Default} // default
|
||||||
case "ipc":
|
case "ipc":
|
||||||
switch conf.ShmDir {
|
switch conf.ShmDir {
|
||||||
case "/dev/shm":
|
case "/dev/shm":
|
||||||
@ -443,15 +443,15 @@ func ConfigToSpec(rt *libpod.Runtime, specg *specgen.SpecGenerator, contaierID s
|
|||||||
case "":
|
case "":
|
||||||
specg.IpcNS = specgen.Namespace{NSMode: specgen.None}
|
specg.IpcNS = specgen.Namespace{NSMode: specgen.None}
|
||||||
default:
|
default:
|
||||||
specg.IpcNS = specgen.Namespace{NSMode: specgen.Default} //default
|
specg.IpcNS = specgen.Namespace{NSMode: specgen.Default} // default
|
||||||
}
|
}
|
||||||
case "uts":
|
case "uts":
|
||||||
specg.UtsNS = specgen.Namespace{NSMode: specgen.Default} //default
|
specg.UtsNS = specgen.Namespace{NSMode: specgen.Default} // default
|
||||||
case "user":
|
case "user":
|
||||||
if conf.AddCurrentUserPasswdEntry {
|
if conf.AddCurrentUserPasswdEntry {
|
||||||
specg.UserNS = specgen.Namespace{NSMode: specgen.KeepID}
|
specg.UserNS = specgen.Namespace{NSMode: specgen.KeepID}
|
||||||
} else {
|
} else {
|
||||||
specg.UserNS = specgen.Namespace{NSMode: specgen.Default} //default
|
specg.UserNS = specgen.Namespace{NSMode: specgen.Default} // default
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -434,8 +434,7 @@ func createContainerOptions(rt *libpod.Runtime, s *specgen.SpecGenerator, pod *l
|
|||||||
// Security options
|
// Security options
|
||||||
if len(s.SelinuxOpts) > 0 {
|
if len(s.SelinuxOpts) > 0 {
|
||||||
options = append(options, libpod.WithSecLabels(s.SelinuxOpts))
|
options = append(options, libpod.WithSecLabels(s.SelinuxOpts))
|
||||||
} else {
|
} else if pod != nil && len(compatibleOptions.SelinuxOpts) == 0 {
|
||||||
if pod != nil && len(compatibleOptions.SelinuxOpts) == 0 {
|
|
||||||
// duplicate the security options from the pod
|
// duplicate the security options from the pod
|
||||||
processLabel, err := pod.ProcessLabel()
|
processLabel, err := pod.ProcessLabel()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -449,7 +448,6 @@ func createContainerOptions(rt *libpod.Runtime, s *specgen.SpecGenerator, pod *l
|
|||||||
options = append(options, libpod.WithSecLabels(selinuxOpts))
|
options = append(options, libpod.WithSecLabels(selinuxOpts))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
options = append(options, libpod.WithPrivileged(s.Privileged))
|
options = append(options, libpod.WithPrivileged(s.Privileged))
|
||||||
|
|
||||||
// Get namespace related options
|
// Get namespace related options
|
||||||
|
@ -449,12 +449,13 @@ func setupLivenessProbe(s *specgen.SpecGenerator, containerYAML v1.Container, re
|
|||||||
}
|
}
|
||||||
|
|
||||||
// configure healthcheck on the basis of Handler Actions.
|
// configure healthcheck on the basis of Handler Actions.
|
||||||
if probeHandler.Exec != nil {
|
switch {
|
||||||
|
case probeHandler.Exec != nil:
|
||||||
execString := strings.Join(probeHandler.Exec.Command, " ")
|
execString := strings.Join(probeHandler.Exec.Command, " ")
|
||||||
commandString = fmt.Sprintf("%s || %s", execString, failureCmd)
|
commandString = fmt.Sprintf("%s || %s", execString, failureCmd)
|
||||||
} else if probeHandler.HTTPGet != nil {
|
case probeHandler.HTTPGet != nil:
|
||||||
commandString = fmt.Sprintf("curl %s://%s:%d/%s || %s", probeHandler.HTTPGet.Scheme, probeHandler.HTTPGet.Host, probeHandler.HTTPGet.Port.IntValue(), probeHandler.HTTPGet.Path, failureCmd)
|
commandString = fmt.Sprintf("curl %s://%s:%d/%s || %s", probeHandler.HTTPGet.Scheme, probeHandler.HTTPGet.Host, probeHandler.HTTPGet.Port.IntValue(), probeHandler.HTTPGet.Path, failureCmd)
|
||||||
} else if probeHandler.TCPSocket != nil {
|
case probeHandler.TCPSocket != nil:
|
||||||
commandString = fmt.Sprintf("nc -z -v %s %d || %s", probeHandler.TCPSocket.Host, probeHandler.TCPSocket.Port.IntValue(), failureCmd)
|
commandString = fmt.Sprintf("nc -z -v %s %d || %s", probeHandler.TCPSocket.Host, probeHandler.TCPSocket.Port.IntValue(), failureCmd)
|
||||||
}
|
}
|
||||||
s.HealthConfig, err = makeHealthCheck(commandString, probe.PeriodSeconds, probe.FailureThreshold, probe.TimeoutSeconds, probe.InitialDelaySeconds)
|
s.HealthConfig, err = makeHealthCheck(commandString, probe.PeriodSeconds, probe.FailureThreshold, probe.TimeoutSeconds, probe.InitialDelaySeconds)
|
||||||
@ -490,17 +491,17 @@ func makeHealthCheck(inCmd string, interval int32, retries int32, timeout int32,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if interval < 1 {
|
if interval < 1 {
|
||||||
//kubernetes interval defaults to 10 sec and cannot be less than 1
|
// kubernetes interval defaults to 10 sec and cannot be less than 1
|
||||||
interval = 10
|
interval = 10
|
||||||
}
|
}
|
||||||
hc.Interval = (time.Duration(interval) * time.Second)
|
hc.Interval = (time.Duration(interval) * time.Second)
|
||||||
if retries < 1 {
|
if retries < 1 {
|
||||||
//kubernetes retries defaults to 3
|
// kubernetes retries defaults to 3
|
||||||
retries = 3
|
retries = 3
|
||||||
}
|
}
|
||||||
hc.Retries = int(retries)
|
hc.Retries = int(retries)
|
||||||
if timeout < 1 {
|
if timeout < 1 {
|
||||||
//kubernetes timeout defaults to 1
|
// kubernetes timeout defaults to 1
|
||||||
timeout = 1
|
timeout = 1
|
||||||
}
|
}
|
||||||
timeoutDuration := (time.Duration(timeout) * time.Second)
|
timeoutDuration := (time.Duration(timeout) * time.Second)
|
||||||
|
@ -5,7 +5,6 @@ import (
|
|||||||
|
|
||||||
v1 "github.com/containers/podman/v4/pkg/k8s.io/api/core/v1"
|
v1 "github.com/containers/podman/v4/pkg/k8s.io/api/core/v1"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
//"github.com/stretchr/testify/require"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func testPropagation(t *testing.T, propagation v1.MountPropagationMode, expected string) {
|
func testPropagation(t *testing.T, propagation v1.MountPropagationMode, expected string) {
|
||||||
|
@ -202,12 +202,10 @@ func namespaceOptions(s *specgen.SpecGenerator, rt *libpod.Runtime, pod *libpod.
|
|||||||
if s.IDMappings != nil {
|
if s.IDMappings != nil {
|
||||||
if pod == nil {
|
if pod == nil {
|
||||||
toReturn = append(toReturn, libpod.WithIDMappings(*s.IDMappings))
|
toReturn = append(toReturn, libpod.WithIDMappings(*s.IDMappings))
|
||||||
} else {
|
} else if pod.HasInfraContainer() && (len(s.IDMappings.UIDMap) > 0 || len(s.IDMappings.GIDMap) > 0) {
|
||||||
if pod.HasInfraContainer() && (len(s.IDMappings.UIDMap) > 0 || len(s.IDMappings.GIDMap) > 0) {
|
|
||||||
return nil, errors.Wrapf(define.ErrInvalidArg, "cannot specify a new uid/gid map when entering a pod with an infra container")
|
return nil, errors.Wrapf(define.ErrInvalidArg, "cannot specify a new uid/gid map when entering a pod with an infra container")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if s.User != "" {
|
if s.User != "" {
|
||||||
toReturn = append(toReturn, libpod.WithUser(s.User))
|
toReturn = append(toReturn, libpod.WithUser(s.User))
|
||||||
}
|
}
|
||||||
@ -482,7 +480,7 @@ func GetNamespaceOptions(ns []string, netnsIsHost bool) ([]libpod.PodCreateOptio
|
|||||||
var options []libpod.PodCreateOption
|
var options []libpod.PodCreateOption
|
||||||
var erroredOptions []libpod.PodCreateOption
|
var erroredOptions []libpod.PodCreateOption
|
||||||
if ns == nil {
|
if ns == nil {
|
||||||
//set the default namespaces
|
// set the default namespaces
|
||||||
ns = strings.Split(specgen.DefaultKernelNamespaces, ",")
|
ns = strings.Split(specgen.DefaultKernelNamespaces, ",")
|
||||||
}
|
}
|
||||||
for _, toShare := range ns {
|
for _, toShare := range ns {
|
||||||
|
@ -298,7 +298,8 @@ func SpecGenToOCI(ctx context.Context, s *specgen.SpecGenerator, rt *libpod.Runt
|
|||||||
g.AddAnnotation(key, val)
|
g.AddAnnotation(key, val)
|
||||||
}
|
}
|
||||||
|
|
||||||
if compatibleOptions.InfraResources == nil && s.ResourceLimits != nil {
|
switch {
|
||||||
|
case compatibleOptions.InfraResources == nil && s.ResourceLimits != nil:
|
||||||
out, err := json.Marshal(s.ResourceLimits)
|
out, err := json.Marshal(s.ResourceLimits)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -307,7 +308,7 @@ func SpecGenToOCI(ctx context.Context, s *specgen.SpecGenerator, rt *libpod.Runt
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
} else if s.ResourceLimits != nil { // if we have predefined resource limits we need to make sure we keep the infra and container limits
|
case s.ResourceLimits != nil: // if we have predefined resource limits we need to make sure we keep the infra and container limits
|
||||||
originalResources, err := json.Marshal(s.ResourceLimits)
|
originalResources, err := json.Marshal(s.ResourceLimits)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -325,7 +326,7 @@ func SpecGenToOCI(ctx context.Context, s *specgen.SpecGenerator, rt *libpod.Runt
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
g.Config.Linux.Resources = s.ResourceLimits
|
g.Config.Linux.Resources = s.ResourceLimits
|
||||||
} else {
|
default:
|
||||||
g.Config.Linux.Resources = compatibleOptions.InfraResources
|
g.Config.Linux.Resources = compatibleOptions.InfraResources
|
||||||
}
|
}
|
||||||
// Devices
|
// Devices
|
||||||
|
@ -47,12 +47,10 @@ func verifyContainerResourcesCgroupV1(s *specgen.SpecGenerator) ([]string, error
|
|||||||
if !sysInfo.MemorySwappiness {
|
if !sysInfo.MemorySwappiness {
|
||||||
warnings = append(warnings, "Your kernel does not support memory swappiness capabilities, or the cgroup is not mounted. Memory swappiness discarded.")
|
warnings = append(warnings, "Your kernel does not support memory swappiness capabilities, or the cgroup is not mounted. Memory swappiness discarded.")
|
||||||
memory.Swappiness = nil
|
memory.Swappiness = nil
|
||||||
} else {
|
} else if *memory.Swappiness > 100 {
|
||||||
if *memory.Swappiness > 100 {
|
|
||||||
return warnings, errors.Errorf("invalid value: %v, valid memory swappiness range is 0-100", *memory.Swappiness)
|
return warnings, errors.Errorf("invalid value: %v, valid memory swappiness range is 0-100", *memory.Swappiness)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if memory.Reservation != nil && !sysInfo.MemoryReservation {
|
if memory.Reservation != nil && !sysInfo.MemoryReservation {
|
||||||
warnings = append(warnings, "Your kernel does not support memory soft limit capabilities or the cgroup is not mounted. Limitation discarded.")
|
warnings = append(warnings, "Your kernel does not support memory soft limit capabilities or the cgroup is not mounted. Limitation discarded.")
|
||||||
memory.Reservation = nil
|
memory.Reservation = nil
|
||||||
|
@ -47,11 +47,12 @@ func ConvertWinMountPath(path string) (string, error) {
|
|||||||
path = strings.TrimPrefix(path, `\\?\`)
|
path = strings.TrimPrefix(path, `\\?\`)
|
||||||
|
|
||||||
// Drive installed via wsl --mount
|
// Drive installed via wsl --mount
|
||||||
if strings.HasPrefix(path, `\\.\`) {
|
switch {
|
||||||
|
case strings.HasPrefix(path, `\\.\`):
|
||||||
path = "/mnt/wsl/" + path[4:]
|
path = "/mnt/wsl/" + path[4:]
|
||||||
} else if len(path) > 1 && path[1] == ':' {
|
case len(path) > 1 && path[1] == ':':
|
||||||
path = "/mnt/" + strings.ToLower(path[0:1]) + path[2:]
|
path = "/mnt/" + strings.ToLower(path[0:1]) + path[2:]
|
||||||
} else {
|
default:
|
||||||
return path, errors.New("unsupported UNC path")
|
return path, errors.New("unsupported UNC path")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,11 +24,12 @@ func validate(c *entities.ContainerCreateOptions) error {
|
|||||||
"ignore": "",
|
"ignore": "",
|
||||||
}
|
}
|
||||||
if _, ok := imageVolType[c.ImageVolume]; !ok {
|
if _, ok := imageVolType[c.ImageVolume]; !ok {
|
||||||
if c.IsInfra {
|
switch {
|
||||||
|
case c.IsInfra:
|
||||||
c.ImageVolume = "bind"
|
c.ImageVolume = "bind"
|
||||||
} else if c.IsClone { // the image volume type will be deduced later from the container we are cloning
|
case c.IsClone: // the image volume type will be deduced later from the container we are cloning
|
||||||
return nil
|
return nil
|
||||||
} else {
|
default:
|
||||||
return errors.Errorf("invalid image-volume type %q. Pick one of bind, tmpfs, or ignore", c.ImageVolume)
|
return errors.Errorf("invalid image-volume type %q. Pick one of bind, tmpfs, or ignore", c.ImageVolume)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1098,9 +1098,9 @@ var cgroupDeviceType = map[string]bool{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var cgroupDeviceAccess = map[string]bool{
|
var cgroupDeviceAccess = map[string]bool{
|
||||||
"r": true, //read
|
"r": true, // read
|
||||||
"w": true, //write
|
"w": true, // write
|
||||||
"m": true, //mknod
|
"m": true, // mknod
|
||||||
}
|
}
|
||||||
|
|
||||||
// parseLinuxResourcesDeviceAccess parses the raw string passed with the --device-access-add flag
|
// parseLinuxResourcesDeviceAccess parses the raw string passed with the --device-access-add flag
|
||||||
|
@ -26,39 +26,39 @@ func IsSystemdSessionValid(uid int) bool {
|
|||||||
if rootless.IsRootless() {
|
if rootless.IsRootless() {
|
||||||
conn, err = GetLogindConnection(rootless.GetRootlessUID())
|
conn, err = GetLogindConnection(rootless.GetRootlessUID())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
//unable to fetch systemd object for logind
|
// unable to fetch systemd object for logind
|
||||||
logrus.Debugf("systemd-logind: %s", err)
|
logrus.Debugf("systemd-logind: %s", err)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
object = conn.Object(dbusDest, godbus.ObjectPath(dbusPath))
|
object = conn.Object(dbusDest, godbus.ObjectPath(dbusPath))
|
||||||
if err := object.Call(dbusInterface+".GetSeat", 0, "seat0").Store(&seat0Path); err != nil {
|
if err := object.Call(dbusInterface+".GetSeat", 0, "seat0").Store(&seat0Path); err != nil {
|
||||||
//unable to get seat0 path.
|
// unable to get seat0 path.
|
||||||
logrus.Debugf("systemd-logind: %s", err)
|
logrus.Debugf("systemd-logind: %s", err)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
seat0Obj := conn.Object(dbusDest, seat0Path)
|
seat0Obj := conn.Object(dbusDest, seat0Path)
|
||||||
activeSession, err := seat0Obj.GetProperty(dbusDest + ".Seat.ActiveSession")
|
activeSession, err := seat0Obj.GetProperty(dbusDest + ".Seat.ActiveSession")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
//unable to get active sessions.
|
// unable to get active sessions.
|
||||||
logrus.Debugf("systemd-logind: %s", err)
|
logrus.Debugf("systemd-logind: %s", err)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
activeSessionMap, ok := activeSession.Value().([]interface{})
|
activeSessionMap, ok := activeSession.Value().([]interface{})
|
||||||
if !ok || len(activeSessionMap) < 2 {
|
if !ok || len(activeSessionMap) < 2 {
|
||||||
//unable to get active session map.
|
// unable to get active session map.
|
||||||
logrus.Debugf("systemd-logind: %s", err)
|
logrus.Debugf("systemd-logind: %s", err)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
activeSessionPath, ok := activeSessionMap[1].(godbus.ObjectPath)
|
activeSessionPath, ok := activeSessionMap[1].(godbus.ObjectPath)
|
||||||
if !ok {
|
if !ok {
|
||||||
//unable to fetch active session path.
|
// unable to fetch active session path.
|
||||||
logrus.Debugf("systemd-logind: %s", err)
|
logrus.Debugf("systemd-logind: %s", err)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
activeSessionObj := conn.Object(dbusDest, activeSessionPath)
|
activeSessionObj := conn.Object(dbusDest, activeSessionPath)
|
||||||
sessionUser, err := activeSessionObj.GetProperty(dbusDest + ".Session.User")
|
sessionUser, err := activeSessionObj.GetProperty(dbusDest + ".Session.User")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
//unable to fetch session user from activeSession path.
|
// unable to fetch session user from activeSession path.
|
||||||
logrus.Debugf("systemd-logind: %s", err)
|
logrus.Debugf("systemd-logind: %s", err)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -75,7 +75,7 @@ func IsSystemdSessionValid(uid int) bool {
|
|||||||
if !ok {
|
if !ok {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
//active session found which belongs to following rootless user
|
// active session found which belongs to following rootless user
|
||||||
if activeUID == uint32(uid) {
|
if activeUID == uint32(uid) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -34,13 +34,14 @@ func GetTimestamp(value string, reference time.Time) (string, error) {
|
|||||||
// if the string has a Z or a + or three dashes use parse otherwise use parseinlocation
|
// if the string has a Z or a + or three dashes use parse otherwise use parseinlocation
|
||||||
parseInLocation := !(strings.ContainsAny(value, "zZ+") || strings.Count(value, "-") == 3)
|
parseInLocation := !(strings.ContainsAny(value, "zZ+") || strings.Count(value, "-") == 3)
|
||||||
|
|
||||||
if strings.Contains(value, ".") { // nolint(gocritic)
|
switch {
|
||||||
|
case strings.Contains(value, "."):
|
||||||
if parseInLocation {
|
if parseInLocation {
|
||||||
format = rFC3339NanoLocal
|
format = rFC3339NanoLocal
|
||||||
} else {
|
} else {
|
||||||
format = time.RFC3339Nano
|
format = time.RFC3339Nano
|
||||||
}
|
}
|
||||||
} else if strings.Contains(value, "T") {
|
case strings.Contains(value, "T"):
|
||||||
// we want the number of colons in the T portion of the timestamp
|
// we want the number of colons in the T portion of the timestamp
|
||||||
tcolons := strings.Count(value, ":")
|
tcolons := strings.Count(value, ":")
|
||||||
// if parseInLocation is off and we have a +/- zone offset (not Z) then
|
// if parseInLocation is off and we have a +/- zone offset (not Z) then
|
||||||
@ -68,9 +69,9 @@ func GetTimestamp(value string, reference time.Time) (string, error) {
|
|||||||
format = time.RFC3339
|
format = time.RFC3339
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if parseInLocation {
|
case parseInLocation:
|
||||||
format = dateLocal
|
format = dateLocal
|
||||||
} else {
|
default:
|
||||||
format = dateWithZone
|
format = dateWithZone
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,7 +212,7 @@ func PodmanTestCreateUtil(tempDir string, remote bool) *PodmanTestIntegration {
|
|||||||
podmanRemoteBinary = os.Getenv("PODMAN_REMOTE_BINARY")
|
podmanRemoteBinary = os.Getenv("PODMAN_REMOTE_BINARY")
|
||||||
}
|
}
|
||||||
|
|
||||||
conmonBinary := filepath.Join("/usr/libexec/podman/conmon")
|
conmonBinary := "/usr/libexec/podman/conmon"
|
||||||
altConmonBinary := "/usr/bin/conmon"
|
altConmonBinary := "/usr/bin/conmon"
|
||||||
if _, err := os.Stat(conmonBinary); os.IsNotExist(err) {
|
if _, err := os.Stat(conmonBinary); os.IsNotExist(err) {
|
||||||
conmonBinary = altConmonBinary
|
conmonBinary = altConmonBinary
|
||||||
@ -344,7 +344,7 @@ func imageTarPath(image string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// e.g., registry.com/fubar:latest -> registry.com-fubar-latest.tar
|
// e.g., registry.com/fubar:latest -> registry.com-fubar-latest.tar
|
||||||
imageCacheName := strings.Replace(strings.Replace(image, ":", "-", -1), "/", "-", -1) + ".tar"
|
imageCacheName := strings.ReplaceAll(strings.ReplaceAll(image, ":", "-"), "/", "-") + ".tar"
|
||||||
|
|
||||||
return filepath.Join(cacheDir, imageCacheName)
|
return filepath.Join(cacheDir, imageCacheName)
|
||||||
}
|
}
|
||||||
|
@ -184,7 +184,7 @@ var _ = Describe("Podman container clone", func() {
|
|||||||
Expect(checkCreate).Should(Exit(0))
|
Expect(checkCreate).Should(Exit(0))
|
||||||
createArray := checkCreate.OutputToStringArray()
|
createArray := checkCreate.OutputToStringArray()
|
||||||
|
|
||||||
Expect(cloneArray).To(ContainElements(createArray[:]))
|
Expect(cloneArray).To(ContainElements(createArray))
|
||||||
|
|
||||||
ctrInspect := podmanTest.Podman([]string{"inspect", clone.OutputToString()})
|
ctrInspect := podmanTest.Podman([]string{"inspect", clone.OutputToString()})
|
||||||
ctrInspect.WaitWithDefaultTimeout()
|
ctrInspect.WaitWithDefaultTimeout()
|
||||||
|
@ -75,7 +75,7 @@ var _ = Describe("Podman generate kube", func() {
|
|||||||
|
|
||||||
numContainers := 0
|
numContainers := 0
|
||||||
for range pod.Spec.Containers {
|
for range pod.Spec.Containers {
|
||||||
numContainers = numContainers + 1
|
numContainers++
|
||||||
}
|
}
|
||||||
Expect(numContainers).To(Equal(1))
|
Expect(numContainers).To(Equal(1))
|
||||||
})
|
})
|
||||||
@ -169,7 +169,7 @@ var _ = Describe("Podman generate kube", func() {
|
|||||||
|
|
||||||
numContainers := 0
|
numContainers := 0
|
||||||
for range pod.Spec.Containers {
|
for range pod.Spec.Containers {
|
||||||
numContainers = numContainers + 1
|
numContainers++
|
||||||
}
|
}
|
||||||
Expect(numContainers).To(Equal(1))
|
Expect(numContainers).To(Equal(1))
|
||||||
})
|
})
|
||||||
@ -478,11 +478,11 @@ var _ = Describe("Podman generate kube", func() {
|
|||||||
// for k8s
|
// for k8s
|
||||||
Expect(port.Protocol).To(BeEmpty())
|
Expect(port.Protocol).To(BeEmpty())
|
||||||
if port.HostPort == 4000 {
|
if port.HostPort == 4000 {
|
||||||
foundPort4000 = foundPort4000 + 1
|
foundPort4000++
|
||||||
} else if port.HostPort == 5000 {
|
} else if port.HostPort == 5000 {
|
||||||
foundPort5000 = foundPort5000 + 1
|
foundPort5000++
|
||||||
} else {
|
} else {
|
||||||
foundOtherPort = foundOtherPort + 1
|
foundOtherPort++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -438,7 +438,7 @@ RUN > file2
|
|||||||
Expect(result).Should(Exit(0))
|
Expect(result).Should(Exit(0))
|
||||||
Expect(result.OutputToStringArray()).To(HaveLen(1))
|
Expect(result.OutputToStringArray()).To(HaveLen(1))
|
||||||
|
|
||||||
//check if really abc is removed
|
// check if really abc is removed
|
||||||
result = podmanTest.Podman([]string{"image", "list", "--filter", "label=abc"})
|
result = podmanTest.Podman([]string{"image", "list", "--filter", "label=abc"})
|
||||||
Expect(result.OutputToStringArray()).To(BeEmpty())
|
Expect(result.OutputToStringArray()).To(BeEmpty())
|
||||||
|
|
||||||
@ -459,7 +459,7 @@ RUN > file2
|
|||||||
Expect(result).Should(Exit(0))
|
Expect(result).Should(Exit(0))
|
||||||
Expect(result.OutputToStringArray()).To(HaveLen(1))
|
Expect(result.OutputToStringArray()).To(HaveLen(1))
|
||||||
|
|
||||||
//check if really abc is removed
|
// check if really abc is removed
|
||||||
result = podmanTest.Podman([]string{"image", "list", "--filter", "label=abc"})
|
result = podmanTest.Podman([]string{"image", "list", "--filter", "label=abc"})
|
||||||
Expect(result.OutputToStringArray()).To(BeEmpty())
|
Expect(result.OutputToStringArray()).To(BeEmpty())
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ var _ = Describe("Podman load", func() {
|
|||||||
|
|
||||||
compress := SystemExec("gzip", []string{outfile})
|
compress := SystemExec("gzip", []string{outfile})
|
||||||
Expect(compress).Should(Exit(0))
|
Expect(compress).Should(Exit(0))
|
||||||
outfile = outfile + ".gz"
|
outfile += ".gz"
|
||||||
|
|
||||||
rmi := podmanTest.Podman([]string{"rmi", ALPINE})
|
rmi := podmanTest.Podman([]string{"rmi", ALPINE})
|
||||||
rmi.WaitWithDefaultTimeout()
|
rmi.WaitWithDefaultTimeout()
|
||||||
|
@ -51,7 +51,7 @@ var _ = Describe("Podman namespaces", func() {
|
|||||||
numCtrs := 0
|
numCtrs := 0
|
||||||
for _, outputLine := range output {
|
for _, outputLine := range output {
|
||||||
if outputLine != "" {
|
if outputLine != "" {
|
||||||
numCtrs = numCtrs + 1
|
numCtrs++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Expect(numCtrs).To(Equal(0))
|
Expect(numCtrs).To(Equal(0))
|
||||||
|
@ -114,7 +114,7 @@ var _ = Describe("Podman init containers", func() {
|
|||||||
check := podmanTest.Podman([]string{"container", "exists", initContainerID})
|
check := podmanTest.Podman([]string{"container", "exists", initContainerID})
|
||||||
check.WaitWithDefaultTimeout()
|
check.WaitWithDefaultTimeout()
|
||||||
// Container was rm'd
|
// Container was rm'd
|
||||||
//Expect(check).Should(Exit(1))
|
// Expect(check).Should(Exit(1))
|
||||||
Expect(check.ExitCode()).To(Equal(1), "I dont understand why the other way does not work")
|
Expect(check.ExitCode()).To(Equal(1), "I dont understand why the other way does not work")
|
||||||
// Lets double check with a stop and start
|
// Lets double check with a stop and start
|
||||||
stopPod := podmanTest.Podman([]string{"pod", "stop", "foobar"})
|
stopPod := podmanTest.Podman([]string{"pod", "stop", "foobar"})
|
||||||
|
@ -84,12 +84,12 @@ var _ = Describe("Podman run with --cgroup-parent", func() {
|
|||||||
exec.WaitWithDefaultTimeout()
|
exec.WaitWithDefaultTimeout()
|
||||||
Expect(exec).Should(Exit(0))
|
Expect(exec).Should(Exit(0))
|
||||||
|
|
||||||
containerCgroup := strings.TrimRight(strings.Replace(exec.OutputToString(), "0::", "", -1), "\n")
|
containerCgroup := strings.TrimRight(strings.ReplaceAll(exec.OutputToString(), "0::", ""), "\n")
|
||||||
|
|
||||||
// Move the container process to a sub cgroup
|
// Move the container process to a sub cgroup
|
||||||
content, err := ioutil.ReadFile(filepath.Join(cgroupRoot, containerCgroup, "cgroup.procs"))
|
content, err := ioutil.ReadFile(filepath.Join(cgroupRoot, containerCgroup, "cgroup.procs"))
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
oldSubCgroupPath := filepath.Join(filepath.Join(cgroupRoot, containerCgroup, "old-container"))
|
oldSubCgroupPath := filepath.Join(cgroupRoot, containerCgroup, "old-container")
|
||||||
err = os.MkdirAll(oldSubCgroupPath, 0755)
|
err = os.MkdirAll(oldSubCgroupPath, 0755)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
err = ioutil.WriteFile(filepath.Join(oldSubCgroupPath, "cgroup.procs"), content, 0644)
|
err = ioutil.WriteFile(filepath.Join(oldSubCgroupPath, "cgroup.procs"), content, 0644)
|
||||||
@ -102,7 +102,7 @@ var _ = Describe("Podman run with --cgroup-parent", func() {
|
|||||||
run = podmanTest.Podman([]string{"--cgroup-manager=cgroupfs", "run", "--rm", "--cgroupns=host", fmt.Sprintf("--cgroup-parent=%s", newCgroup), fedoraMinimal, "cat", "/proc/self/cgroup"})
|
run = podmanTest.Podman([]string{"--cgroup-manager=cgroupfs", "run", "--rm", "--cgroupns=host", fmt.Sprintf("--cgroup-parent=%s", newCgroup), fedoraMinimal, "cat", "/proc/self/cgroup"})
|
||||||
run.WaitWithDefaultTimeout()
|
run.WaitWithDefaultTimeout()
|
||||||
Expect(run).Should(Exit(0))
|
Expect(run).Should(Exit(0))
|
||||||
cgroupEffective := strings.TrimRight(strings.Replace(run.OutputToString(), "0::", "", -1), "\n")
|
cgroupEffective := strings.TrimRight(strings.ReplaceAll(run.OutputToString(), "0::", ""), "\n")
|
||||||
|
|
||||||
Expect(newCgroup).To(Equal(filepath.Dir(cgroupEffective)))
|
Expect(newCgroup).To(Equal(filepath.Dir(cgroupEffective)))
|
||||||
})
|
})
|
||||||
|
@ -66,7 +66,7 @@ var _ = Describe("Podman run with --sig-proxy", func() {
|
|||||||
counter := 0
|
counter := 0
|
||||||
for {
|
for {
|
||||||
buf := make([]byte, 1024)
|
buf := make([]byte, 1024)
|
||||||
n, err := uds.Read(buf[:])
|
n, err := uds.Read(buf)
|
||||||
if err != nil && err != io.EOF {
|
if err != nil && err != io.EOF {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
return
|
return
|
||||||
@ -92,7 +92,7 @@ var _ = Describe("Podman run with --sig-proxy", func() {
|
|||||||
counter = 0
|
counter = 0
|
||||||
for {
|
for {
|
||||||
buf := make([]byte, 1024)
|
buf := make([]byte, 1024)
|
||||||
n, err := uds.Read(buf[:])
|
n, err := uds.Read(buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
return
|
return
|
||||||
|
@ -226,7 +226,7 @@ var _ = Describe("Podman run with volumes", func() {
|
|||||||
mountPath := filepath.Join(podmanTest.TempDir, "secrets")
|
mountPath := filepath.Join(podmanTest.TempDir, "secrets")
|
||||||
os.Mkdir(mountPath, 0755)
|
os.Mkdir(mountPath, 0755)
|
||||||
|
|
||||||
//Container should be able to start with custom overlay volume
|
// Container should be able to start with custom overlay volume
|
||||||
session := podmanTest.Podman([]string{"run", "--rm", "-v", mountPath + ":/data:O", "--workdir=/data", ALPINE, "echo", "hello"})
|
session := podmanTest.Podman([]string{"run", "--rm", "-v", mountPath + ":/data:O", "--workdir=/data", ALPINE, "echo", "hello"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
@ -729,7 +729,7 @@ VOLUME /test/`, ALPINE)
|
|||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
Expect(session.OutputToString()).To(ContainSubstring("888:888"))
|
Expect(session.OutputToString()).To(ContainSubstring("888:888"))
|
||||||
|
|
||||||
vol = vol + ",O"
|
vol += ",O"
|
||||||
session = podmanTest.Podman([]string{"run", "--rm", "--user", "888:888", "--userns", "keep-id", "-v", vol, ALPINE, "stat", "-c", "%u:%g", dest})
|
session = podmanTest.Podman([]string{"run", "--rm", "--user", "888:888", "--userns", "keep-id", "-v", vol, ALPINE, "stat", "-c", "%u:%g", dest})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
|
@ -108,8 +108,8 @@ func (p *PodmanTest) PodmanAsUserBase(args []string, uid, gid uint32, cwd string
|
|||||||
timeCmd := append([]string{"/usr/bin/time"}, timeArgs...)
|
timeCmd := append([]string{"/usr/bin/time"}, timeArgs...)
|
||||||
wrapper = append(timeCmd, wrapper...)
|
wrapper = append(timeCmd, wrapper...)
|
||||||
}
|
}
|
||||||
|
runCmd := wrapper
|
||||||
runCmd := append(wrapper, podmanBinary)
|
runCmd = append(runCmd, podmanBinary)
|
||||||
if !p.RemoteTest && p.NetworkBackend == Netavark {
|
if !p.RemoteTest && p.NetworkBackend == Netavark {
|
||||||
runCmd = append(runCmd, []string{"--network-backend", "netavark"}...)
|
runCmd = append(runCmd, []string{"--network-backend", "netavark"}...)
|
||||||
}
|
}
|
||||||
@ -449,10 +449,10 @@ func GetHostDistributionInfo() HostOS {
|
|||||||
host.Arch = runtime.GOARCH
|
host.Arch = runtime.GOARCH
|
||||||
for l.Scan() {
|
for l.Scan() {
|
||||||
if strings.HasPrefix(l.Text(), "ID=") {
|
if strings.HasPrefix(l.Text(), "ID=") {
|
||||||
host.Distribution = strings.Replace(strings.TrimSpace(strings.Join(strings.Split(l.Text(), "=")[1:], "")), "\"", "", -1)
|
host.Distribution = strings.ReplaceAll(strings.TrimSpace(strings.Join(strings.Split(l.Text(), "=")[1:], "")), "\"", "")
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(l.Text(), "VERSION_ID=") {
|
if strings.HasPrefix(l.Text(), "VERSION_ID=") {
|
||||||
host.Version = strings.Replace(strings.TrimSpace(strings.Join(strings.Split(l.Text(), "=")[1:], "")), "\"", "", -1)
|
host.Version = strings.ReplaceAll(strings.TrimSpace(strings.Join(strings.Split(l.Text(), "=")[1:], "")), "\"", "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return host
|
return host
|
||||||
|
Reference in New Issue
Block a user