Migrate --dest-ostree-tmp-dir to imageDestOptions

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
Miloslav Trmač 2018-07-09 20:51:00 +02:00
parent 88c748f47a
commit 72a3dc17ee
3 changed files with 13 additions and 9 deletions

View File

@ -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)",

View File

@ -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
}

View File

@ -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,