From 72a3dc17eeb38a7048c9691df9ca0bf9ebfeb5c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Mon, 9 Jul 2018 20:51:00 +0200 Subject: [PATCH] Migrate --dest-ostree-tmp-dir to imageDestOptions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miloslav Trmač --- cmd/skopeo/copy.go | 5 ----- cmd/skopeo/utils.go | 15 +++++++++++++-- cmd/skopeo/utils_test.go | 2 -- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/cmd/skopeo/copy.go b/cmd/skopeo/copy.go index 604ddff1..e5d5b7d7 100644 --- a/cmd/skopeo/copy.go +++ b/cmd/skopeo/copy.go @@ -84,11 +84,6 @@ func copyCmd(global *globalOptions) cli.Command { Usage: "Sign the image using a GPG key with the specified `FINGERPRINT`", Destination: &opts.signByFingerprint, }, - cli.StringFlag{ - Name: "dest-ostree-tmp-dir", - Value: "", - Usage: "`DIRECTORY` to use for OSTree temporary files", - }, cli.GenericFlag{ Name: "format, f", Usage: "`MANIFEST TYPE` (oci, v2s1, or v2s2) to use when saving image to directory using the 'dir:' transport (default is manifest type of source)", diff --git a/cmd/skopeo/utils.go b/cmd/skopeo/utils.go index 8bddfb0d..26b16993 100644 --- a/cmd/skopeo/utils.go +++ b/cmd/skopeo/utils.go @@ -65,13 +65,14 @@ func imageFlags(global *globalOptions, flagPrefix, credsOptionAlias string) ([]c }, &opts } +// contextFromImageOptions returns a *types.SystemContext corresponding to opts. +// It is guaranteed to return a fresh instance, so it is safe to make additional updates to it. func contextFromImageOptions(c *cli.Context, opts *imageOptions) (*types.SystemContext, error) { ctx := &types.SystemContext{ RegistriesDirPath: opts.global.registriesDirPath, ArchitectureChoice: opts.global.overrideArch, OSChoice: opts.global.overrideOS, DockerCertPath: opts.dockerCertPath, - OSTreeTmpDirPath: c.String(opts.flagPrefix + "ostree-tmp-dir"), OCISharedBlobDirPath: opts.sharedBlobDir, DirForceCompress: c.Bool(opts.flagPrefix + "compress"), AuthFilePath: c.String("authfile"), @@ -101,6 +102,7 @@ func contextFromImageOptions(c *cli.Context, opts *imageOptions) (*types.SystemC // imageDestOptions is a superset of imageOptions specialized for iamge destinations. type imageDestOptions struct { *imageOptions + osTreeTmpDir string // A directory to use for OSTree temporary files } // imageDestFlags prepares a collection of CLI flags writing into imageDestOptions, and the managed imageDestOptions structure. @@ -108,15 +110,24 @@ func imageDestFlags(global *globalOptions, flagPrefix, credsOptionAlias string) genericFlags, genericOptions := imageFlags(global, flagPrefix, credsOptionAlias) opts := imageDestOptions{imageOptions: genericOptions} - return append(genericFlags, []cli.Flag{}...), &opts + return append(genericFlags, []cli.Flag{ + cli.StringFlag{ + Name: flagPrefix + "ostree-tmp-dir", + Usage: "`DIRECTORY` to use for OSTree temporary files", + Destination: &opts.osTreeTmpDir, + }, + }...), &opts } +// contextFromImageDestOptions returns a *types.SystemContext corresponding to opts. +// It is guaranteed to return a fresh instance, so it is safe to make additional updates to it. func contextFromImageDestOptions(c *cli.Context, opts *imageDestOptions) (*types.SystemContext, error) { ctx, err := contextFromImageOptions(c, opts.imageOptions) if err != nil { return nil, err } + ctx.OSTreeTmpDirPath = opts.osTreeTmpDir return ctx, err } diff --git a/cmd/skopeo/utils_test.go b/cmd/skopeo/utils_test.go index 2447f79c..3934c465 100644 --- a/cmd/skopeo/utils_test.go +++ b/cmd/skopeo/utils_test.go @@ -87,7 +87,6 @@ func TestContextFromImageOptions(t *testing.T) { }, []string{ "--authfile", "/srv/authfile", "--dest-cert-dir", "/srv/cert-dir", - "--dest-ostree-tmp-dir", "/srv/ostree-tmp-dir", "--dest-shared-blob-dir", "/srv/shared-blob-dir", "--dest-compress=true", "--dest-daemon-host", "daemon-host.example.com", @@ -105,7 +104,6 @@ func TestContextFromImageOptions(t *testing.T) { DockerCertPath: "/srv/cert-dir", DockerInsecureSkipTLSVerify: types.OptionalBoolTrue, DockerAuthConfig: &types.DockerAuthConfig{Username: "creds-user", Password: "creds-password"}, - OSTreeTmpDirPath: "/srv/ostree-tmp-dir", DockerDaemonCertPath: "/srv/cert-dir", DockerDaemonHost: "daemon-host.example.com", DockerDaemonInsecureSkipTLSVerify: true,