diff options
author | Aditya R <arajan@redhat.com> | 2022-08-09 09:10:55 +0530 |
---|---|---|
committer | Aditya R <arajan@redhat.com> | 2022-08-09 09:10:58 +0530 |
commit | 59cb410fe29d18d2e908762d80f3caf1cd5a41a4 (patch) | |
tree | f14728908cc5638ff5b7d50d838a3c38b496778d /cmd | |
parent | 7bd886480066ceb097ab5ab101738d6b4fca718f (diff) | |
download | podman-59cb410fe29d18d2e908762d80f3caf1cd5a41a4.tar.gz podman-59cb410fe29d18d2e908762d80f3caf1cd5a41a4.tar.bz2 podman-59cb410fe29d18d2e908762d80f3caf1cd5a41a4.zip |
build: implement --cache-to,--cache-from and --cache-ttl
[NO NEW TESTS NEEDED]
[NO TESTS NEEDED]
Signed-off-by: Aditya R <arajan@redhat.com>
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/podman/images/build.go | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/cmd/podman/images/build.go b/cmd/podman/images/build.go index 9f1b86eb4..837b233f4 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") @@ -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, |