summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/images/build.go22
-rw-r--r--cmd/podman/secrets/inspect.go42
2 files changed, 60 insertions, 4 deletions
diff --git a/cmd/podman/images/build.go b/cmd/podman/images/build.go
index a4d6614e2..473048834 100644
--- a/cmd/podman/images/build.go
+++ b/cmd/podman/images/build.go
@@ -18,6 +18,7 @@ import (
"github.com/containers/common/pkg/completion"
"github.com/containers/common/pkg/config"
"github.com/containers/image/v5/docker/reference"
+ "github.com/containers/image/v5/types"
encconfig "github.com/containers/ocicrypt/config"
enchelpers "github.com/containers/ocicrypt/helpers"
"github.com/containers/podman/v4/cmd/podman/common"
@@ -205,6 +206,24 @@ func build(cmd *cobra.Command, args []string) error {
return errors.New("'--output' option is not supported in remote mode")
}
+ if buildOpts.Network == "none" {
+ if cmd.Flag("dns").Changed {
+ return errors.New("the --dns option cannot be used with --network=none")
+ }
+ if cmd.Flag("dns-option").Changed {
+ return errors.New("the --dns-option option cannot be used with --network=none")
+ }
+ if cmd.Flag("dns-search").Changed {
+ return errors.New("the --dns-search option cannot be used with --network=none")
+ }
+ }
+
+ if cmd.Flag("network").Changed {
+ if buildOpts.Network != "host" && buildOpts.Isolation == buildahDefine.IsolationChroot.String() {
+ return fmt.Errorf("cannot set --network other than host with --isolation %s", buildOpts.Isolation)
+ }
+ }
+
// Extract container files from the CLI (i.e., --file/-f) first.
var containerFiles []string
for _, f := range buildOpts.File {
@@ -613,6 +632,9 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
timestamp := time.Unix(flags.Timestamp, 0).UTC()
opts.Timestamp = &timestamp
}
+ if c.Flag("skip-unused-stages").Changed {
+ opts.SkipUnusedStages = types.NewOptionalBool(flags.SkipUnusedStages)
+ }
return &entities.BuildOptions{BuildOptions: opts}, nil
}
diff --git a/cmd/podman/secrets/inspect.go b/cmd/podman/secrets/inspect.go
index f4c395b0f..9054fc3b0 100644
--- a/cmd/podman/secrets/inspect.go
+++ b/cmd/podman/secrets/inspect.go
@@ -25,7 +25,23 @@ var (
}
)
-var format string
+var (
+ format string
+ pretty bool
+)
+
+const (
+ prettyTemplate = `ID: {{.ID}}
+Name: {{.Spec.Name}}
+{{- if .Spec.Labels }}
+Labels:
+{{- range $k, $v := .Spec.Labels }}
+ - {{ $k }}{{if $v }}={{ $v }}{{ end }}
+{{- end }}{{ end }}
+Driver: {{.Spec.Driver.Name}}
+Created at: {{.CreatedAt}}
+Updated at: {{.UpdatedAt}}`
+)
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
@@ -34,8 +50,11 @@ func init() {
})
flags := inspectCmd.Flags()
formatFlagName := "format"
- flags.StringVarP(&format, formatFlagName, "f", "", "Format volume output using Go template")
+ flags.StringVarP(&format, formatFlagName, "f", "", "Format inspect output using Go template")
_ = inspectCmd.RegisterFlagCompletionFunc(formatFlagName, common.AutocompleteFormat(&entities.SecretInfoReport{}))
+
+ prettyFlagName := "pretty"
+ flags.BoolVar(&pretty, prettyFlagName, false, "Print inspect output in human-readable format")
}
func inspect(cmd *cobra.Command, args []string) error {
@@ -46,7 +65,21 @@ func inspect(cmd *cobra.Command, args []string) error {
inspected = []*entities.SecretInfoReport{}
}
- if cmd.Flags().Changed("format") {
+ switch {
+ case cmd.Flags().Changed("pretty"):
+ rpt := report.New(os.Stdout, cmd.Name())
+ defer rpt.Flush()
+
+ rpt, err := rpt.Parse(report.OriginUser, prettyTemplate)
+ if err != nil {
+ return err
+ }
+
+ if err := rpt.Execute(inspected); err != nil {
+ return err
+ }
+
+ case cmd.Flags().Changed("format"):
rpt := report.New(os.Stdout, cmd.Name())
defer rpt.Flush()
@@ -58,7 +91,8 @@ func inspect(cmd *cobra.Command, args []string) error {
if err := rpt.Execute(inspected); err != nil {
return err
}
- } else {
+
+ default:
buf, err := json.MarshalIndent(inspected, "", " ")
if err != nil {
return err