aboutsummaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/containers/commit.go3
-rw-r--r--cmd/podman/containers/cp.go3
-rw-r--r--cmd/podman/containers/kill.go4
-rw-r--r--cmd/podman/containers/pause.go4
-rw-r--r--cmd/podman/containers/restart.go4
-rw-r--r--cmd/podman/containers/rm.go4
-rw-r--r--cmd/podman/containers/stop.go4
-rw-r--r--cmd/podman/containers/unpause.go4
-rw-r--r--cmd/podman/generate/spec.go4
-rw-r--r--cmd/podman/images/build.go3
-rw-r--r--cmd/podman/images/import.go3
-rw-r--r--cmd/podman/images/load.go3
-rw-r--r--cmd/podman/images/utils_linux.go3
-rw-r--r--cmd/podman/kube/generate.go5
-rw-r--r--cmd/podman/kube/play.go3
-rw-r--r--cmd/podman/manifest/push.go3
-rw-r--r--cmd/podman/parse/net_test.go3
-rw-r--r--cmd/podman/pods/create.go3
-rw-r--r--cmd/podman/secrets/create.go20
19 files changed, 41 insertions, 42 deletions
diff --git a/cmd/podman/containers/commit.go b/cmd/podman/containers/commit.go
index fb6dccad4..77f74395e 100644
--- a/cmd/podman/containers/commit.go
+++ b/cmd/podman/containers/commit.go
@@ -3,7 +3,6 @@ package containers
import (
"context"
"fmt"
- "io/ioutil"
"os"
"strings"
@@ -107,7 +106,7 @@ func commit(cmd *cobra.Command, args []string) error {
return err
}
if len(iidFile) > 0 {
- if err = ioutil.WriteFile(iidFile, []byte(response.Id), 0644); err != nil {
+ if err = os.WriteFile(iidFile, []byte(response.Id), 0644); err != nil {
return fmt.Errorf("failed to write image ID: %w", err)
}
}
diff --git a/cmd/podman/containers/cp.go b/cmd/podman/containers/cp.go
index 93477feb8..9e63169a0 100644
--- a/cmd/podman/containers/cp.go
+++ b/cmd/podman/containers/cp.go
@@ -3,7 +3,6 @@ package containers
import (
"fmt"
"io"
- "io/ioutil"
"os"
"os/user"
"path/filepath"
@@ -379,7 +378,7 @@ func copyToContainer(container string, containerPath string, hostPath string) er
// Copy from stdin to a temporary file *before* throwing it
// over the wire. This allows for proper client-side error
// reporting.
- tmpFile, err := ioutil.TempFile("", "")
+ tmpFile, err := os.CreateTemp("", "")
if err != nil {
return err
}
diff --git a/cmd/podman/containers/kill.go b/cmd/podman/containers/kill.go
index 86a7e3ff2..3c9bf6b71 100644
--- a/cmd/podman/containers/kill.go
+++ b/cmd/podman/containers/kill.go
@@ -4,7 +4,7 @@ import (
"context"
"errors"
"fmt"
- "io/ioutil"
+ "os"
"strings"
"github.com/containers/common/pkg/completion"
@@ -96,7 +96,7 @@ func kill(_ *cobra.Command, args []string) error {
return errors.New("valid signals are 1 through 64")
}
for _, cidFile := range killCidFiles {
- content, err := ioutil.ReadFile(cidFile)
+ content, err := os.ReadFile(cidFile)
if err != nil {
return fmt.Errorf("reading CIDFile: %w", err)
}
diff --git a/cmd/podman/containers/pause.go b/cmd/podman/containers/pause.go
index 591523cf9..ea5dd3a0c 100644
--- a/cmd/podman/containers/pause.go
+++ b/cmd/podman/containers/pause.go
@@ -3,7 +3,7 @@ package containers
import (
"context"
"fmt"
- "io/ioutil"
+ "os"
"strings"
"github.com/containers/common/pkg/completion"
@@ -92,7 +92,7 @@ func pause(cmd *cobra.Command, args []string) error {
)
for _, cidFile := range pauseCidFiles {
- content, err := ioutil.ReadFile(cidFile)
+ content, err := os.ReadFile(cidFile)
if err != nil {
return fmt.Errorf("reading CIDFile: %w", err)
}
diff --git a/cmd/podman/containers/restart.go b/cmd/podman/containers/restart.go
index 0cc7901f9..db2759f0b 100644
--- a/cmd/podman/containers/restart.go
+++ b/cmd/podman/containers/restart.go
@@ -3,7 +3,7 @@ package containers
import (
"context"
"fmt"
- "io/ioutil"
+ "os"
"strings"
"github.com/containers/common/pkg/completion"
@@ -105,7 +105,7 @@ func restart(cmd *cobra.Command, args []string) error {
}
for _, cidFile := range restartCidFiles {
- content, err := ioutil.ReadFile(cidFile)
+ content, err := os.ReadFile(cidFile)
if err != nil {
return fmt.Errorf("reading CIDFile: %w", err)
}
diff --git a/cmd/podman/containers/rm.go b/cmd/podman/containers/rm.go
index 44d03e9de..da5c24ab8 100644
--- a/cmd/podman/containers/rm.go
+++ b/cmd/podman/containers/rm.go
@@ -4,7 +4,7 @@ import (
"context"
"errors"
"fmt"
- "io/ioutil"
+ "os"
"strings"
"github.com/containers/common/pkg/completion"
@@ -108,7 +108,7 @@ func rm(cmd *cobra.Command, args []string) error {
rmOptions.Timeout = &stopTimeout
}
for _, cidFile := range rmCidFiles {
- content, err := ioutil.ReadFile(cidFile)
+ content, err := os.ReadFile(cidFile)
if err != nil {
return fmt.Errorf("reading CIDFile: %w", err)
}
diff --git a/cmd/podman/containers/stop.go b/cmd/podman/containers/stop.go
index 412c513e1..a1e3a0c46 100644
--- a/cmd/podman/containers/stop.go
+++ b/cmd/podman/containers/stop.go
@@ -3,7 +3,7 @@ package containers
import (
"context"
"fmt"
- "io/ioutil"
+ "os"
"strings"
"github.com/containers/common/pkg/completion"
@@ -105,7 +105,7 @@ func stop(cmd *cobra.Command, args []string) error {
stopOptions.Timeout = &stopTimeout
}
for _, cidFile := range stopCidFiles {
- content, err := ioutil.ReadFile(cidFile)
+ content, err := os.ReadFile(cidFile)
if err != nil {
return fmt.Errorf("reading CIDFile: %w", err)
}
diff --git a/cmd/podman/containers/unpause.go b/cmd/podman/containers/unpause.go
index 988964266..fea05ee22 100644
--- a/cmd/podman/containers/unpause.go
+++ b/cmd/podman/containers/unpause.go
@@ -4,7 +4,7 @@ import (
"context"
"errors"
"fmt"
- "io/ioutil"
+ "os"
"strings"
"github.com/containers/common/pkg/cgroups"
@@ -99,7 +99,7 @@ func unpause(cmd *cobra.Command, args []string) error {
}
for _, cidFile := range unpauseCidFiles {
- content, err := ioutil.ReadFile(cidFile)
+ content, err := os.ReadFile(cidFile)
if err != nil {
return fmt.Errorf("reading CIDFile: %w", err)
}
diff --git a/cmd/podman/generate/spec.go b/cmd/podman/generate/spec.go
index bf451ebc5..0c3d7884c 100644
--- a/cmd/podman/generate/spec.go
+++ b/cmd/podman/generate/spec.go
@@ -2,7 +2,7 @@ package generate
import (
"fmt"
- "io/ioutil"
+ "os"
"github.com/containers/common/pkg/completion"
"github.com/containers/podman/v4/cmd/podman/common"
@@ -59,7 +59,7 @@ func spec(cmd *cobra.Command, args []string) error {
// if we are looking to print the output, do not mess it up by printing the path
// if we are using -v the user probably expects to pipe the output somewhere else
if len(opts.FileName) > 0 {
- err = ioutil.WriteFile(opts.FileName, report.Data, 0644)
+ err = os.WriteFile(opts.FileName, report.Data, 0644)
if err != nil {
return err
}
diff --git a/cmd/podman/images/build.go b/cmd/podman/images/build.go
index 2b24c1cff..a4d6614e2 100644
--- a/cmd/podman/images/build.go
+++ b/cmd/podman/images/build.go
@@ -4,7 +4,6 @@ import (
"errors"
"fmt"
"io"
- "io/ioutil"
"os"
"os/exec"
"path/filepath"
@@ -635,7 +634,7 @@ func getDecryptConfig(decryptionKeys []string) (*encconfig.DecryptConfig, error)
func parseDockerignore(ignoreFile string) ([]string, error) {
excludes := []string{}
- ignore, err := ioutil.ReadFile(ignoreFile)
+ ignore, err := os.ReadFile(ignoreFile)
if err != nil {
return excludes, err
}
diff --git a/cmd/podman/images/import.go b/cmd/podman/images/import.go
index 8343a0bda..7532bf7a9 100644
--- a/cmd/podman/images/import.go
+++ b/cmd/podman/images/import.go
@@ -5,7 +5,6 @@ import (
"errors"
"fmt"
"io"
- "io/ioutil"
"os"
"strings"
@@ -116,7 +115,7 @@ func importCon(cmd *cobra.Command, args []string) error {
}
if source == "-" {
- outFile, err := ioutil.TempFile("", "podman")
+ outFile, err := os.CreateTemp("", "podman")
if err != nil {
return fmt.Errorf("creating file %v", err)
}
diff --git a/cmd/podman/images/load.go b/cmd/podman/images/load.go
index 367b628c7..4aae5217d 100644
--- a/cmd/podman/images/load.go
+++ b/cmd/podman/images/load.go
@@ -5,7 +5,6 @@ import (
"errors"
"fmt"
"io"
- "io/ioutil"
"os"
"strings"
@@ -93,7 +92,7 @@ func load(cmd *cobra.Command, args []string) error {
if term.IsTerminal(int(os.Stdin.Fd())) {
return errors.New("cannot read from terminal, use command-line redirection or the --input flag")
}
- outFile, err := ioutil.TempFile(util.Tmpdir(), "podman")
+ outFile, err := os.CreateTemp(util.Tmpdir(), "podman")
if err != nil {
return fmt.Errorf("creating file %v", err)
}
diff --git a/cmd/podman/images/utils_linux.go b/cmd/podman/images/utils_linux.go
index 935a45667..a2f471a48 100644
--- a/cmd/podman/images/utils_linux.go
+++ b/cmd/podman/images/utils_linux.go
@@ -3,7 +3,6 @@ package images
import (
"fmt"
"io"
- "io/ioutil"
"os"
"path/filepath"
@@ -16,7 +15,7 @@ import (
// the caller should use the returned function to clean up the pipeDir
func setupPipe() (string, func() <-chan error, error) {
errc := make(chan error)
- pipeDir, err := ioutil.TempDir(os.TempDir(), "pipeDir")
+ pipeDir, err := os.MkdirTemp(os.TempDir(), "pipeDir")
if err != nil {
return "", nil, err
}
diff --git a/cmd/podman/kube/generate.go b/cmd/podman/kube/generate.go
index ee2ea51ae..30b06b0c5 100644
--- a/cmd/podman/kube/generate.go
+++ b/cmd/podman/kube/generate.go
@@ -3,7 +3,6 @@ package kube
import (
"fmt"
"io"
- "io/ioutil"
"os"
"github.com/containers/common/pkg/completion"
@@ -77,7 +76,7 @@ func generateKube(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
- content, err := ioutil.ReadAll(report.Reader)
+ content, err := io.ReadAll(report.Reader)
if err != nil {
return err
}
@@ -89,7 +88,7 @@ func generateKube(cmd *cobra.Command, args []string) error {
if _, err := os.Stat(generateFile); err == nil {
return fmt.Errorf("cannot write to %q; file exists", generateFile)
}
- if err := ioutil.WriteFile(generateFile, content, 0644); err != nil {
+ if err := os.WriteFile(generateFile, content, 0644); err != nil {
return fmt.Errorf("cannot write to %q: %w", generateFile, err)
}
return nil
diff --git a/cmd/podman/kube/play.go b/cmd/podman/kube/play.go
index c846ec32c..1163a6ff6 100644
--- a/cmd/podman/kube/play.go
+++ b/cmd/podman/kube/play.go
@@ -5,7 +5,6 @@ import (
"errors"
"fmt"
"io"
- "io/ioutil"
"net"
"net/http"
"os"
@@ -284,7 +283,7 @@ func readerFromArg(fileName string) (*bytes.Reader, error) {
}
defer response.Body.Close()
- data, err := ioutil.ReadAll(response.Body)
+ data, err := io.ReadAll(response.Body)
if err != nil {
return nil, err
}
diff --git a/cmd/podman/manifest/push.go b/cmd/podman/manifest/push.go
index c8893ff2e..2b4c570a5 100644
--- a/cmd/podman/manifest/push.go
+++ b/cmd/podman/manifest/push.go
@@ -3,7 +3,6 @@ package manifest
import (
"errors"
"fmt"
- "io/ioutil"
"os"
"github.com/containers/common/pkg/auth"
@@ -149,7 +148,7 @@ func push(cmd *cobra.Command, args []string) error {
return err
}
if manifestPushOpts.DigestFile != "" {
- if err := ioutil.WriteFile(manifestPushOpts.DigestFile, []byte(digest), 0644); err != nil {
+ if err := os.WriteFile(manifestPushOpts.DigestFile, []byte(digest), 0644); err != nil {
return err
}
}
diff --git a/cmd/podman/parse/net_test.go b/cmd/podman/parse/net_test.go
index a11edc2ca..88bfaa894 100644
--- a/cmd/podman/parse/net_test.go
+++ b/cmd/podman/parse/net_test.go
@@ -3,7 +3,6 @@
package parse
import (
- "io/ioutil"
"os"
"testing"
@@ -15,7 +14,7 @@ var (
)
func createTmpFile(content []byte) (string, error) {
- tmpfile, err := ioutil.TempFile(os.TempDir(), "unittest")
+ tmpfile, err := os.CreateTemp(os.TempDir(), "unittest")
if err != nil {
return "", err
}
diff --git a/cmd/podman/pods/create.go b/cmd/podman/pods/create.go
index 1f8152f32..fc2e07894 100644
--- a/cmd/podman/pods/create.go
+++ b/cmd/podman/pods/create.go
@@ -4,7 +4,6 @@ import (
"context"
"errors"
"fmt"
- "io/ioutil"
"os"
"runtime"
"sort"
@@ -300,7 +299,7 @@ func create(cmd *cobra.Command, args []string) error {
}
if len(podIDFile) > 0 {
- if err = ioutil.WriteFile(podIDFile, []byte(response.Id), 0644); err != nil {
+ if err = os.WriteFile(podIDFile, []byte(response.Id), 0644); err != nil {
return fmt.Errorf("failed to write pod ID to file: %w", err)
}
}
diff --git a/cmd/podman/secrets/create.go b/cmd/podman/secrets/create.go
index 01775f563..293da2103 100644
--- a/cmd/podman/secrets/create.go
+++ b/cmd/podman/secrets/create.go
@@ -10,6 +10,7 @@ import (
"github.com/containers/common/pkg/completion"
"github.com/containers/podman/v4/cmd/podman/common"
+ "github.com/containers/podman/v4/cmd/podman/parse"
"github.com/containers/podman/v4/cmd/podman/registry"
"github.com/containers/podman/v4/pkg/domain/entities"
"github.com/spf13/cobra"
@@ -31,6 +32,7 @@ var (
var (
createOpts = entities.SecretCreateOptions{}
env = false
+ labels []string
)
func init() {
@@ -38,21 +40,24 @@ func init() {
Command: createCmd,
Parent: secretCmd,
})
+ cfg := registry.PodmanConfig()
flags := createCmd.Flags()
driverFlagName := "driver"
- optsFlagName := "driver-opts"
-
- cfg := registry.PodmanConfig()
-
flags.StringVarP(&createOpts.Driver, driverFlagName, "d", cfg.Secrets.Driver, "Specify secret driver")
- flags.StringToStringVar(&createOpts.DriverOpts, optsFlagName, cfg.Secrets.Opts, "Specify driver specific options")
_ = createCmd.RegisterFlagCompletionFunc(driverFlagName, completion.AutocompleteNone)
+
+ optsFlagName := "driver-opts"
+ flags.StringToStringVar(&createOpts.DriverOpts, optsFlagName, cfg.Secrets.Opts, "Specify driver specific options")
_ = createCmd.RegisterFlagCompletionFunc(optsFlagName, completion.AutocompleteNone)
envFlagName := "env"
flags.BoolVar(&env, envFlagName, false, "Read secret data from environment variable")
+
+ labelFlagName := "label"
+ flags.StringArrayVarP(&labels, labelFlagName, "l", nil, "Specify labels on the secret")
+ _ = createCmd.RegisterFlagCompletionFunc(labelFlagName, completion.AutocompleteNone)
}
func create(cmd *cobra.Command, args []string) error {
@@ -87,6 +92,11 @@ func create(cmd *cobra.Command, args []string) error {
reader = file
}
+ createOpts.Labels, err = parse.GetAllLabels([]string{}, labels)
+ if err != nil {
+ return fmt.Errorf("unable to process labels: %w", err)
+ }
+
report, err := registry.ContainerEngine().SecretCreate(context.Background(), name, reader, createOpts)
if err != nil {
return err