mirror of
https://github.com/containers/podman.git
synced 2025-08-06 19:44:14 +08:00
Fix problems reported by staticcheck
`staticcheck` is a golang code analysis tool. https://staticcheck.io/ This commit fixes a lot of problems found in our code. Common problems are: - unnecessary use of fmt.Sprintf - duplicated imports with different names - unnecessary check that a key exists before a delete call There are still a lot of reported problems in the test files but I have not looked at those. Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/containers/common/pkg/auth"
|
||||
@ -181,7 +180,7 @@ func DefineCreateFlags(cmd *cobra.Command, cf *ContainerCLIOpts) {
|
||||
createFlags.StringSliceVar(
|
||||
&cf.Devices,
|
||||
deviceFlagName, devices(),
|
||||
fmt.Sprintf("Add a host device to the container"),
|
||||
"Add a host device to the container",
|
||||
)
|
||||
_ = cmd.RegisterFlagCompletionFunc(deviceFlagName, completion.AutocompleteDefault)
|
||||
|
||||
@ -359,7 +358,7 @@ func DefineCreateFlags(cmd *cobra.Command, cf *ContainerCLIOpts) {
|
||||
&cf.InitPath,
|
||||
initPathFlagName, initPath(),
|
||||
// Do not use the Value field for setting the default value to determine user input (i.e., non-empty string)
|
||||
fmt.Sprintf("Path to the container-init binary"),
|
||||
"Path to the container-init binary",
|
||||
)
|
||||
_ = cmd.RegisterFlagCompletionFunc(initPathFlagName, completion.AutocompleteDefault)
|
||||
|
||||
|
@ -18,9 +18,9 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
pruneDescription = fmt.Sprintf(`podman container prune
|
||||
pruneDescription = `podman container prune
|
||||
|
||||
Removes all non running containers`)
|
||||
Removes all non running containers`
|
||||
pruneCommand = &cobra.Command{
|
||||
Use: "prune [options]",
|
||||
Short: "Remove all non running containers",
|
||||
|
@ -127,23 +127,23 @@ func kube(cmd *cobra.Command, args []string) error {
|
||||
|
||||
for _, pod := range report.Pods {
|
||||
for _, l := range pod.Logs {
|
||||
fmt.Fprintf(os.Stderr, l)
|
||||
fmt.Fprint(os.Stderr, l)
|
||||
}
|
||||
}
|
||||
|
||||
ctrsFailed := 0
|
||||
|
||||
for _, pod := range report.Pods {
|
||||
fmt.Printf("Pod:\n")
|
||||
fmt.Println("Pod:")
|
||||
fmt.Println(pod.ID)
|
||||
|
||||
switch len(pod.Containers) {
|
||||
case 0:
|
||||
continue
|
||||
case 1:
|
||||
fmt.Printf("Container:\n")
|
||||
fmt.Println("Container:")
|
||||
default:
|
||||
fmt.Printf("Containers:\n")
|
||||
fmt.Println("Containers:")
|
||||
}
|
||||
for _, ctr := range pod.Containers {
|
||||
fmt.Println(ctr)
|
||||
@ -154,7 +154,7 @@ func kube(cmd *cobra.Command, args []string) error {
|
||||
fmt.Println()
|
||||
}
|
||||
for _, err := range pod.ContainerErrors {
|
||||
fmt.Fprintf(os.Stderr, err+"\n")
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
}
|
||||
// Empty line for space for next block
|
||||
fmt.Println()
|
||||
|
@ -2,7 +2,6 @@ package pods
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"text/tabwriter"
|
||||
"text/template"
|
||||
@ -21,9 +20,9 @@ var (
|
||||
)
|
||||
|
||||
var (
|
||||
inspectDescription = fmt.Sprintf(`Display the configuration for a pod by name or id
|
||||
inspectDescription = `Display the configuration for a pod by name or id
|
||||
|
||||
By default, this will render all results in a JSON array.`)
|
||||
By default, this will render all results in a JSON array.`
|
||||
|
||||
inspectCmd = &cobra.Command{
|
||||
Use: "inspect [options] POD [POD...]",
|
||||
|
@ -20,7 +20,7 @@ var (
|
||||
)
|
||||
|
||||
var (
|
||||
pruneDescription = fmt.Sprintf(`podman pod prune Removes all exited pods`)
|
||||
pruneDescription = `podman pod prune Removes all exited pods`
|
||||
|
||||
pruneCommand = &cobra.Command{
|
||||
Use: "prune [options]",
|
||||
|
@ -25,9 +25,9 @@ type podRmOptionsWrapper struct {
|
||||
|
||||
var (
|
||||
rmOptions = podRmOptionsWrapper{}
|
||||
podRmDescription = fmt.Sprintf(`podman rm will remove one or more stopped pods and their containers from the host.
|
||||
podRmDescription = `podman rm will remove one or more stopped pods and their containers from the host.
|
||||
|
||||
The pod name or ID can be used. A pod with containers will not be removed without --force. If --force is specified, all containers will be stopped, then removed.`)
|
||||
The pod name or ID can be used. A pod with containers will not be removed without --force. If --force is specified, all containers will be stopped, then removed.`
|
||||
rmCommand = &cobra.Command{
|
||||
Use: "rm [options] POD [POD...]",
|
||||
Short: "Remove one or more pods",
|
||||
|
@ -20,11 +20,11 @@ import (
|
||||
var (
|
||||
pruneOptions = entities.SystemPruneOptions{}
|
||||
filters []string
|
||||
pruneDescription = fmt.Sprintf(`
|
||||
pruneDescription = `
|
||||
podman system prune
|
||||
|
||||
Remove unused data
|
||||
`)
|
||||
`
|
||||
|
||||
pruneCommand = &cobra.Command{
|
||||
Use: "prune [options]",
|
||||
|
@ -80,7 +80,7 @@ func service(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
// socket activation uses a unix:// socket in the shipped unit files but apiURI is coded as "" at this layer.
|
||||
if "unix" == uri.Scheme && !registry.IsRemote() {
|
||||
if uri.Scheme == "unix" && !registry.IsRemote() {
|
||||
if err := syscall.Unlink(uri.Path); err != nil && !os.IsNotExist(err) {
|
||||
return err
|
||||
}
|
||||
|
@ -40,7 +40,6 @@ import (
|
||||
"github.com/containers/storage/pkg/idtools"
|
||||
securejoin "github.com/cyphar/filepath-securejoin"
|
||||
runcuser "github.com/opencontainers/runc/libcontainer/user"
|
||||
"github.com/opencontainers/runtime-spec/specs-go"
|
||||
spec "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/opencontainers/runtime-tools/generate"
|
||||
"github.com/opencontainers/selinux/go-selinux/label"
|
||||
@ -284,7 +283,7 @@ func (c *Container) generateSpec(ctx context.Context) (*spec.Spec, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
g := generate.NewFromSpec(c.config.Spec)
|
||||
g := generate.Generator{Config: c.config.Spec}
|
||||
|
||||
// If network namespace was requested, add it now
|
||||
if c.config.CreateNetNS {
|
||||
@ -400,7 +399,7 @@ func (c *Container) generateSpec(ctx context.Context) (*spec.Spec, error) {
|
||||
return nil, errors.Wrapf(err, "failed to create TempDir in the %s directory", c.config.StaticDir)
|
||||
}
|
||||
|
||||
var overlayMount specs.Mount
|
||||
var overlayMount spec.Mount
|
||||
if volume.ReadWrite {
|
||||
overlayMount, err = overlay.Mount(contentDir, mountPoint, volume.Dest, c.RootUID(), c.RootGID(), c.runtime.store.GraphOptions())
|
||||
} else {
|
||||
@ -1482,18 +1481,14 @@ func (c *Container) makeBindMounts() error {
|
||||
}
|
||||
if newPasswd != "" {
|
||||
// Make /etc/passwd
|
||||
if _, ok := c.state.BindMounts["/etc/passwd"]; ok {
|
||||
// If it already exists, delete so we can recreate
|
||||
delete(c.state.BindMounts, "/etc/passwd")
|
||||
}
|
||||
c.state.BindMounts["/etc/passwd"] = newPasswd
|
||||
}
|
||||
if newGroup != "" {
|
||||
// Make /etc/group
|
||||
if _, ok := c.state.BindMounts["/etc/group"]; ok {
|
||||
// If it already exists, delete so we can recreate
|
||||
delete(c.state.BindMounts, "/etc/group")
|
||||
}
|
||||
c.state.BindMounts["/etc/group"] = newGroup
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,6 @@ import (
|
||||
"github.com/containers/common/pkg/retry"
|
||||
cp "github.com/containers/image/v5/copy"
|
||||
"github.com/containers/image/v5/directory"
|
||||
"github.com/containers/image/v5/docker/archive"
|
||||
dockerarchive "github.com/containers/image/v5/docker/archive"
|
||||
"github.com/containers/image/v5/docker/reference"
|
||||
"github.com/containers/image/v5/image"
|
||||
@ -37,7 +36,6 @@ import (
|
||||
"github.com/containers/podman/v2/pkg/util"
|
||||
"github.com/containers/storage"
|
||||
digest "github.com/opencontainers/go-digest"
|
||||
imgspecv1 "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
ociv1 "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
opentracing "github.com/opentracing/opentracing-go"
|
||||
"github.com/pkg/errors"
|
||||
@ -185,7 +183,7 @@ func (ir *Runtime) SaveImages(ctx context.Context, namesOrIDs []string, format s
|
||||
|
||||
sys := GetSystemContext("", "", false)
|
||||
|
||||
archWriter, err := archive.NewWriter(sys, outputFile)
|
||||
archWriter, err := dockerarchive.NewWriter(sys, outputFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -291,7 +289,7 @@ func (ir *Runtime) LoadAllImagesFromDockerArchive(ctx context.Context, fileName
|
||||
}
|
||||
|
||||
sc := GetSystemContext(signaturePolicyPath, "", false)
|
||||
reader, err := archive.NewReader(sc, fileName)
|
||||
reader, err := dockerarchive.NewReader(sc, fileName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -1148,7 +1146,7 @@ func (i *Image) GetLabel(ctx context.Context, label string) (string, error) {
|
||||
}
|
||||
|
||||
for k, v := range labels {
|
||||
if strings.ToLower(k) == strings.ToLower(label) {
|
||||
if strings.EqualFold(k, label) {
|
||||
return v, nil
|
||||
}
|
||||
}
|
||||
@ -1326,7 +1324,7 @@ func (ir *Runtime) Import(ctx context.Context, path, reference string, writer io
|
||||
|
||||
annotations := make(map[string]string)
|
||||
|
||||
// config imgspecv1.Image
|
||||
// config ociv1.Image
|
||||
err = updater.ConfigUpdate(imageConfig, annotations)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "error updating image config")
|
||||
@ -1435,7 +1433,7 @@ func (i *Image) IsParent(ctx context.Context) (bool, error) {
|
||||
|
||||
// historiesMatch returns the number of entries in the histories which have the
|
||||
// same contents
|
||||
func historiesMatch(a, b []imgspecv1.History) int {
|
||||
func historiesMatch(a, b []ociv1.History) int {
|
||||
i := 0
|
||||
for i < len(a) && i < len(b) {
|
||||
if a[i].Created != nil && b[i].Created == nil {
|
||||
@ -1468,7 +1466,7 @@ func historiesMatch(a, b []imgspecv1.History) int {
|
||||
|
||||
// areParentAndChild checks diff ID and history in the two images and return
|
||||
// true if the second should be considered to be directly based on the first
|
||||
func areParentAndChild(parent, child *imgspecv1.Image) bool {
|
||||
func areParentAndChild(parent, child *ociv1.Image) bool {
|
||||
// the child and candidate parent should share all of the
|
||||
// candidate parent's diff IDs, which together would have
|
||||
// controlled which layers were used
|
||||
@ -1621,7 +1619,7 @@ func (i *Image) Save(ctx context.Context, source, format, output string, moreTag
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "error getting the OCI directory ImageReference for (%q, %q)", output, destImageName)
|
||||
}
|
||||
manifestType = imgspecv1.MediaTypeImageManifest
|
||||
manifestType = ociv1.MediaTypeImageManifest
|
||||
case "docker-dir":
|
||||
destRef, err = directory.NewReference(output)
|
||||
if err != nil {
|
||||
|
@ -29,7 +29,7 @@ func generatePruneFilterFuncs(filter, filterValue string) (ImageFilter, error) {
|
||||
return false
|
||||
}
|
||||
for labelKey, labelValue := range labels {
|
||||
if labelKey == filterKey && ("" == filterValue || labelValue == filterValue) {
|
||||
if labelKey == filterKey && (filterValue == "" || labelValue == filterValue) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ import (
|
||||
cp "github.com/containers/image/v5/copy"
|
||||
"github.com/containers/image/v5/directory"
|
||||
"github.com/containers/image/v5/docker"
|
||||
"github.com/containers/image/v5/docker/archive"
|
||||
dockerarchive "github.com/containers/image/v5/docker/archive"
|
||||
ociarchive "github.com/containers/image/v5/oci/archive"
|
||||
oci "github.com/containers/image/v5/oci/layout"
|
||||
@ -130,7 +129,7 @@ func (ir *Runtime) getSinglePullRefPairGoal(srcRef types.ImageReference, destNam
|
||||
|
||||
// getPullRefPairsFromDockerArchiveReference returns a slice of pullRefPairs
|
||||
// for the specified docker reference and the corresponding archive.Reader.
|
||||
func (ir *Runtime) getPullRefPairsFromDockerArchiveReference(ctx context.Context, reader *archive.Reader, ref types.ImageReference, sc *types.SystemContext) ([]pullRefPair, error) {
|
||||
func (ir *Runtime) getPullRefPairsFromDockerArchiveReference(ctx context.Context, reader *dockerarchive.Reader, ref types.ImageReference, sc *types.SystemContext) ([]pullRefPair, error) {
|
||||
destNames, err := reader.ManifestTagsForReference(ref)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -178,7 +177,7 @@ func (ir *Runtime) pullGoalFromImageReference(ctx context.Context, srcRef types.
|
||||
// supports pulling from docker-archive, oci, and registries
|
||||
switch srcRef.Transport().Name() {
|
||||
case DockerArchive:
|
||||
reader, readerRef, err := archive.NewReaderForReference(sc, srcRef)
|
||||
reader, readerRef, err := dockerarchive.NewReaderForReference(sc, srcRef)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -432,7 +431,7 @@ func checkRemoteImageForLabel(ctx context.Context, label string, imageInfo pullR
|
||||
}
|
||||
// Labels are case insensitive; so we iterate instead of simple lookup
|
||||
for k := range remoteInspect.Labels {
|
||||
if strings.ToLower(label) == strings.ToLower(k) {
|
||||
if strings.EqualFold(label, k) {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
@ -437,12 +437,8 @@ func (s *InMemoryState) RemoveContainer(ctr *Container) error {
|
||||
}
|
||||
|
||||
// Remove our network aliases
|
||||
if _, ok := s.ctrNetworkAliases[ctr.ID()]; ok {
|
||||
delete(s.ctrNetworkAliases, ctr.ID())
|
||||
}
|
||||
if _, ok := s.ctrNetworks[ctr.ID()]; ok {
|
||||
delete(s.ctrNetworks, ctr.ID())
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@ -680,9 +676,7 @@ func (s *InMemoryState) NetworkDisconnect(ctr *Container, network string) error
|
||||
ctrAliases = make(map[string][]string)
|
||||
s.ctrNetworkAliases[ctr.ID()] = ctrAliases
|
||||
}
|
||||
if _, ok := ctrAliases[network]; ok {
|
||||
delete(ctrAliases, network)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@ -1523,12 +1517,8 @@ func (s *InMemoryState) RemoveContainerFromPod(pod *Pod, ctr *Container) error {
|
||||
}
|
||||
|
||||
// Remove our network aliases
|
||||
if _, ok := s.ctrNetworkAliases[ctr.ID()]; ok {
|
||||
delete(s.ctrNetworkAliases, ctr.ID())
|
||||
}
|
||||
if _, ok := s.ctrNetworks[ctr.ID()]; ok {
|
||||
delete(s.ctrNetworks, ctr.ID())
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ func IfPassesFilter(netconf *libcni.NetworkConfigList, filters map[string][]stri
|
||||
filterValue = ""
|
||||
}
|
||||
for labelKey, labelValue := range labels {
|
||||
if labelKey == filterKey && ("" == filterValue || labelValue == filterValue) {
|
||||
if labelKey == filterKey && (filterValue == "" || labelValue == filterValue) {
|
||||
result = true
|
||||
continue outer
|
||||
}
|
||||
|
@ -1374,6 +1374,7 @@ func (r *ConmonOCIRuntime) sharedConmonArgs(ctr *Container, cuuid, bundlePath, p
|
||||
logDriverArg = define.NoLogging
|
||||
case define.JSONLogging:
|
||||
fallthrough
|
||||
//lint:ignore ST1015 the default case has to be here
|
||||
default: //nolint-stylecheck
|
||||
// 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())
|
||||
|
@ -910,7 +910,7 @@ func WithUserNSFrom(nsCtr *Container) CtrCreateOption {
|
||||
ctr.config.UserNsCtr = nsCtr.ID()
|
||||
ctr.config.IDMappings = nsCtr.config.IDMappings
|
||||
|
||||
g := generate.NewFromSpec(ctr.config.Spec)
|
||||
g := generate.Generator{Config: ctr.config.Spec}
|
||||
|
||||
g.ClearLinuxUIDMappings()
|
||||
for _, uidmap := range nsCtr.config.IDMappings.UIDMap {
|
||||
|
@ -16,7 +16,6 @@ import (
|
||||
"github.com/containers/podman/v2/libpod"
|
||||
"github.com/containers/podman/v2/libpod/define"
|
||||
"github.com/containers/podman/v2/libpod/image"
|
||||
image2 "github.com/containers/podman/v2/libpod/image"
|
||||
"github.com/containers/podman/v2/pkg/api/handlers"
|
||||
"github.com/containers/podman/v2/pkg/api/handlers/utils"
|
||||
"github.com/containers/podman/v2/pkg/auth"
|
||||
@ -524,7 +523,7 @@ func CommitContainer(w http.ResponseWriter, r *http.Request) {
|
||||
utils.Error(w, "failed to get runtime config", http.StatusInternalServerError, errors.Wrap(err, "failed to get runtime config"))
|
||||
return
|
||||
}
|
||||
sc := image2.GetSystemContext(rtc.Engine.SignaturePolicyPath, "", false)
|
||||
sc := image.GetSystemContext(rtc.Engine.SignaturePolicyPath, "", false)
|
||||
tag := "latest"
|
||||
options := libpod.ContainerCommitOptions{
|
||||
Pause: true,
|
||||
|
@ -35,7 +35,7 @@ func GenerateContainerFilterFuncs(filter string, filterValues []string, r *libpo
|
||||
filterValue = ""
|
||||
}
|
||||
for labelKey, labelValue := range labels {
|
||||
if labelKey == filterKey && ("" == filterValue || labelValue == filterValue) {
|
||||
if labelKey == filterKey && (filterValue == "" || labelValue == filterValue) {
|
||||
matched = true
|
||||
break
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ func GeneratePodFilterFunc(filter string, filterValues []string) (
|
||||
filterValue = ""
|
||||
}
|
||||
for labelKey, labelValue := range labels {
|
||||
if labelKey == filterKey && ("" == filterValue || labelValue == filterValue) {
|
||||
if labelKey == filterKey && (filterValue == "" || labelValue == filterValue) {
|
||||
matched = true
|
||||
break
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ func GenerateVolumeFilters(filters url.Values) ([]libpod.VolumeFilter, error) {
|
||||
}
|
||||
vf = append(vf, func(v *libpod.Volume) bool {
|
||||
for labelKey, labelValue := range v.Labels() {
|
||||
if labelKey == filterKey && ("" == filterVal || labelValue == filterVal) {
|
||||
if labelKey == filterKey && (filterVal == "" || labelValue == filterVal) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
@ -56,7 +56,7 @@ func GenerateVolumeFilters(filters url.Values) ([]libpod.VolumeFilter, error) {
|
||||
}
|
||||
vf = append(vf, func(v *libpod.Volume) bool {
|
||||
for labelKey, labelValue := range v.Options() {
|
||||
if labelKey == filterKey && ("" == filterVal || labelValue == filterVal) {
|
||||
if labelKey == filterKey && (filterVal == "" || labelValue == filterVal) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
@ -113,15 +113,7 @@ func (ic *ContainerEngine) ContainerWait(ctx context.Context, namesOrIds []strin
|
||||
}
|
||||
|
||||
func (ic *ContainerEngine) ContainerPause(ctx context.Context, namesOrIds []string, options entities.PauseUnPauseOptions) ([]*entities.PauseUnpauseReport, error) {
|
||||
var (
|
||||
err error
|
||||
)
|
||||
ctrs := []*libpod.Container{} //nolint
|
||||
if options.All {
|
||||
ctrs, err = ic.Libpod.GetAllContainers()
|
||||
} else {
|
||||
ctrs, err = getContainersByContext(false, false, namesOrIds, ic.Libpod)
|
||||
}
|
||||
ctrs, err := getContainersByContext(options.All, false, namesOrIds, ic.Libpod)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -134,15 +126,7 @@ func (ic *ContainerEngine) ContainerPause(ctx context.Context, namesOrIds []stri
|
||||
}
|
||||
|
||||
func (ic *ContainerEngine) ContainerUnpause(ctx context.Context, namesOrIds []string, options entities.PauseUnPauseOptions) ([]*entities.PauseUnpauseReport, error) {
|
||||
var (
|
||||
err error
|
||||
)
|
||||
ctrs := []*libpod.Container{} //nolint
|
||||
if options.All {
|
||||
ctrs, err = ic.Libpod.GetAllContainers()
|
||||
} else {
|
||||
ctrs, err = getContainersByContext(false, false, namesOrIds, ic.Libpod)
|
||||
}
|
||||
ctrs, err := getContainersByContext(options.All, false, namesOrIds, ic.Libpod)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ import (
|
||||
"github.com/containers/image/v5/types"
|
||||
"github.com/containers/podman/v2/libpod/define"
|
||||
"github.com/containers/podman/v2/libpod/image"
|
||||
libpodImage "github.com/containers/podman/v2/libpod/image"
|
||||
"github.com/containers/podman/v2/pkg/domain/entities"
|
||||
"github.com/containers/podman/v2/pkg/domain/entities/reports"
|
||||
domainUtils "github.com/containers/podman/v2/pkg/domain/utils"
|
||||
@ -206,7 +205,7 @@ func (ir *ImageEngine) Unmount(ctx context.Context, nameOrIDs []string, options
|
||||
return reports, nil
|
||||
}
|
||||
|
||||
func ToDomainHistoryLayer(layer *libpodImage.History) entities.ImageHistoryLayer {
|
||||
func ToDomainHistoryLayer(layer *image.History) entities.ImageHistoryLayer {
|
||||
l := entities.ImageHistoryLayer{}
|
||||
l.ID = layer.ID
|
||||
l.Created = *layer.Created
|
||||
|
@ -13,7 +13,6 @@ import (
|
||||
|
||||
"github.com/containers/buildah/manifests"
|
||||
buildahManifests "github.com/containers/buildah/pkg/manifests"
|
||||
"github.com/containers/buildah/util"
|
||||
buildahUtil "github.com/containers/buildah/util"
|
||||
cp "github.com/containers/image/v5/copy"
|
||||
"github.com/containers/image/v5/docker"
|
||||
@ -60,7 +59,7 @@ func (ir *ImageEngine) ManifestInspect(ctx context.Context, name string) ([]byte
|
||||
}
|
||||
}
|
||||
sc := ir.Libpod.SystemContext()
|
||||
refs, err := util.ResolveNameToReferences(ir.Libpod.GetStore(), sc, name)
|
||||
refs, err := buildahUtil.ResolveNameToReferences(ir.Libpod.GetStore(), sc, name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -162,11 +162,6 @@ func movePauseProcessToScope(r *libpod.Runtime) error {
|
||||
return utils.RunUnderSystemdScope(int(pid), "user.slice", "podman-pause.scope")
|
||||
}
|
||||
|
||||
// checkInput can be used to verify any of the globalopt values
|
||||
func checkInput() error { // nolint:deadcode,unused
|
||||
return nil
|
||||
}
|
||||
|
||||
// SystemPrune removes unused data from the system. Pruning pods, containers, volumes and images.
|
||||
func (ic *ContainerEngine) SystemPrune(ctx context.Context, options entities.SystemPruneOptions) (*entities.SystemPruneReport, error) {
|
||||
var systemPruneReport = new(entities.SystemPruneReport)
|
||||
|
@ -21,9 +21,6 @@ var (
|
||||
errNotADevice = errors.New("not a device node")
|
||||
)
|
||||
|
||||
func u32Ptr(i int64) *uint32 { u := uint32(i); return &u }
|
||||
func fmPtr(i int64) *os.FileMode { fm := os.FileMode(i); return &fm }
|
||||
|
||||
func addPrivilegedDevices(g *generate.Generator) error {
|
||||
hostDevices, err := getDevices("/dev")
|
||||
if err != nil {
|
||||
|
@ -110,7 +110,7 @@ func makeCommand(ctx context.Context, s *specgen.SpecGenerator, img *image.Image
|
||||
// Only use image command if the user did not manually set an
|
||||
// entrypoint.
|
||||
command := s.Command
|
||||
if (command == nil || len(command) == 0) && img != nil && (s.Entrypoint == nil || len(s.Entrypoint) == 0) {
|
||||
if len(command) == 0 && img != nil && len(s.Entrypoint) == 0 {
|
||||
newCmd, err := img.Cmd(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -124,15 +124,11 @@ func finalizeMounts(ctx context.Context, s *specgen.SpecGenerator, rt *libpod.Ru
|
||||
// named volumes, and vice versa.
|
||||
// We'll delete the conflicts here as we supersede.
|
||||
for dest := range unifiedMounts {
|
||||
if _, ok := baseVolumes[dest]; ok {
|
||||
delete(baseVolumes, dest)
|
||||
}
|
||||
}
|
||||
for dest := range unifiedVolumes {
|
||||
if _, ok := baseMounts[dest]; ok {
|
||||
delete(baseMounts, dest)
|
||||
}
|
||||
}
|
||||
|
||||
// Supersede volumes-from/image volumes with unified volumes from above.
|
||||
// This is an unconditional replacement.
|
||||
|
@ -48,7 +48,7 @@ func verifyContainerResourcesCgroupV1(s *specgen.SpecGenerator) ([]string, error
|
||||
warnings = append(warnings, "Your kernel does not support memory swappiness capabilities, or the cgroup is not mounted. Memory swappiness discarded.")
|
||||
memory.Swappiness = nil
|
||||
} else {
|
||||
if *memory.Swappiness < 0 || *memory.Swappiness > 100 {
|
||||
if *memory.Swappiness > 100 {
|
||||
return warnings, errors.Errorf("invalid value: %v, valid memory swappiness range is 0-100", *memory.Swappiness)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user