aboutsummaryrefslogtreecommitdiff
path: root/cmd/podman/images/build.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/podman/images/build.go')
-rw-r--r--cmd/podman/images/build.go32
1 files changed, 28 insertions, 4 deletions
diff --git a/cmd/podman/images/build.go b/cmd/podman/images/build.go
index 9f1b86eb4..2b24c1cff 100644
--- a/cmd/podman/images/build.go
+++ b/cmd/podman/images/build.go
@@ -18,6 +18,7 @@ import (
"github.com/containers/common/pkg/auth"
"github.com/containers/common/pkg/completion"
"github.com/containers/common/pkg/config"
+ "github.com/containers/image/v5/docker/reference"
encconfig "github.com/containers/ocicrypt/config"
enchelpers "github.com/containers/ocicrypt/helpers"
"github.com/containers/podman/v4/cmd/podman/common"
@@ -184,7 +185,6 @@ func buildFlags(cmd *cobra.Command) {
flags.SetNormalizeFunc(buildahCLI.AliasFlags)
if registry.IsRemote() {
_ = flags.MarkHidden("disable-content-trust")
- _ = flags.MarkHidden("cache-from")
_ = flags.MarkHidden("sign-by")
_ = flags.MarkHidden("signature-policy")
_ = flags.MarkHidden("tls-verify")
@@ -222,7 +222,7 @@ func build(cmd *cobra.Command, args []string) error {
// The context directory could be a URL. Try to handle that.
tempDir, subDir, err := buildahDefine.TempDirForURL("", "buildah", args[0])
if err != nil {
- return fmt.Errorf("error prepping temporary context directory: %w", err)
+ return fmt.Errorf("prepping temporary context directory: %w", err)
}
if tempDir != "" {
// We had to download it to a temporary directory.
@@ -237,7 +237,7 @@ func build(cmd *cobra.Command, args []string) error {
// Nope, it was local. Use it as is.
absDir, err := filepath.Abs(args[0])
if err != nil {
- return fmt.Errorf("error determining path to directory %q: %w", args[0], err)
+ return fmt.Errorf("determining path to directory %q: %w", args[0], err)
}
contextDir = absDir
}
@@ -253,7 +253,7 @@ func build(cmd *cobra.Command, args []string) error {
}
absFile, err := filepath.Abs(containerFiles[i])
if err != nil {
- return fmt.Errorf("error determining path to file %q: %w", containerFiles[i], err)
+ return fmt.Errorf("determining path to file %q: %w", containerFiles[i], err)
}
contextDir = filepath.Dir(absFile)
containerFiles[i] = absFile
@@ -519,6 +519,27 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
}
}
}
+ var cacheTo reference.Named
+ var cacheFrom reference.Named
+ if c.Flag("cache-to").Changed {
+ cacheTo, err = parse.RepoNameToNamedReference(flags.CacheTo)
+ if err != nil {
+ return nil, fmt.Errorf("unable to parse value provided `%s` to --cache-to: %w", flags.CacheTo, err)
+ }
+ }
+ if c.Flag("cache-from").Changed {
+ cacheFrom, err = parse.RepoNameToNamedReference(flags.CacheFrom)
+ if err != nil {
+ return nil, fmt.Errorf("unable to parse value provided `%s` to --cache-from: %w", flags.CacheTo, err)
+ }
+ }
+ var cacheTTL time.Duration
+ if c.Flag("cache-ttl").Changed {
+ cacheTTL, err = time.ParseDuration(flags.CacheTTL)
+ if err != nil {
+ return nil, fmt.Errorf("unable to parse value provided %q as --cache-ttl: %w", flags.CacheTTL, err)
+ }
+ }
opts := buildahDefine.BuildOptions{
AddCapabilities: flags.CapAdd,
@@ -529,6 +550,9 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
Args: args,
BlobDirectory: flags.BlobCache,
BuildOutput: flags.BuildOutput,
+ CacheFrom: cacheFrom,
+ CacheTo: cacheTo,
+ CacheTTL: cacheTTL,
CommonBuildOpts: commonOpts,
Compression: compression,
ConfigureNetwork: networkPolicy,