Skopeo should support for BigFilesTemporaryDir (SystemContext)

Enhancement request: https://github.com/containers/skopeo/issues/805

Also sorted commands and options on skopeo man page and skopeo --help

Originally submitted by  Michel Belleau <michel.belleau@malaiwah.com>
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
Daniel J Walsh 2020-03-28 07:09:22 -04:00
parent a6f5ef18c5
commit aa20fbfdf5
No known key found for this signature in database
GPG Key ID: A2DF901DABE2C028
5 changed files with 43 additions and 29 deletions

View File

@ -28,6 +28,7 @@ type globalOptions struct {
overrideVariant string // Architecture variant to use for choosing images, instead of the runtime one overrideVariant string // Architecture variant to use for choosing images, instead of the runtime one
commandTimeout time.Duration // Timeout for the command execution commandTimeout time.Duration // Timeout for the command execution
registriesConfPath string // Path to the "registries.conf" file registriesConfPath string // Path to the "registries.conf" file
tmpDir string // Path to use for big temporary files
} }
// createApp returns a cli.App, and the underlying globalOptions object, to be run or tested. // createApp returns a cli.App, and the underlying globalOptions object, to be run or tested.
@ -44,32 +45,21 @@ func createApp() (*cli.App, *globalOptions) {
} }
app.Usage = "Various operations with container images and container image registries" app.Usage = "Various operations with container images and container image registries"
app.Flags = []cli.Flag{ app.Flags = []cli.Flag{
cli.DurationFlag{
Name: "command-timeout",
Usage: "timeout for the command execution",
Destination: &opts.commandTimeout,
},
cli.BoolFlag{ cli.BoolFlag{
Name: "debug", Name: "debug",
Usage: "enable debug output", Usage: "enable debug output",
Destination: &opts.debug, Destination: &opts.debug,
}, },
cli.GenericFlag{
Name: "tls-verify",
Usage: "require HTTPS and verify certificates when talking to container registries (defaults to true)",
Hidden: true,
Value: newOptionalBoolValue(&opts.tlsVerify),
},
cli.StringFlag{
Name: "policy",
Usage: "Path to a trust policy file",
Destination: &opts.policyPath,
},
cli.BoolFlag{ cli.BoolFlag{
Name: "insecure-policy", Name: "insecure-policy",
Usage: "run the tool without any policy check", Usage: "run the tool without any policy check",
Destination: &opts.insecurePolicy, Destination: &opts.insecurePolicy,
}, },
cli.StringFlag{
Name: "registries.d",
Usage: "use registry configuration files in `DIR` (e.g. for container signature storage)",
Destination: &opts.registriesDirPath,
},
cli.StringFlag{ cli.StringFlag{
Name: "override-arch", Name: "override-arch",
Usage: "use `ARCH` instead of the architecture of the machine for choosing images", Usage: "use `ARCH` instead of the architecture of the machine for choosing images",
@ -85,10 +75,10 @@ func createApp() (*cli.App, *globalOptions) {
Usage: "use `VARIANT` instead of the running architecture variant for choosing images", Usage: "use `VARIANT` instead of the running architecture variant for choosing images",
Destination: &opts.overrideVariant, Destination: &opts.overrideVariant,
}, },
cli.DurationFlag{ cli.StringFlag{
Name: "command-timeout", Name: "policy",
Usage: "timeout for the command execution", Usage: "Path to a trust policy file",
Destination: &opts.commandTimeout, Destination: &opts.policyPath,
}, },
cli.StringFlag{ cli.StringFlag{
Name: "registries-conf", Name: "registries-conf",
@ -96,19 +86,35 @@ func createApp() (*cli.App, *globalOptions) {
Destination: &opts.registriesConfPath, Destination: &opts.registriesConfPath,
Hidden: true, Hidden: true,
}, },
cli.StringFlag{
Name: "registries.d",
Usage: "use registry configuration files in `DIR` (e.g. for container signature storage)",
Destination: &opts.registriesDirPath,
},
cli.GenericFlag{
Name: "tls-verify",
Usage: "require HTTPS and verify certificates when talking to container registries (defaults to true)",
Hidden: true,
Value: newOptionalBoolValue(&opts.tlsVerify),
},
cli.StringFlag{
Name: "tmpdir",
Usage: "directory used to store temporary files",
Destination: &opts.tmpDir,
},
} }
app.Before = opts.before app.Before = opts.before
app.Commands = []cli.Command{ app.Commands = []cli.Command{
copyCmd(&opts), copyCmd(&opts),
deleteCmd(&opts),
inspectCmd(&opts), inspectCmd(&opts),
layersCmd(&opts), layersCmd(&opts),
deleteCmd(&opts), tagsCmd(&opts),
manifestDigestCmd(), manifestDigestCmd(),
syncCmd(&opts),
standaloneSignCmd(), standaloneSignCmd(),
standaloneVerifyCmd(), standaloneVerifyCmd(),
syncCmd(&opts),
untrustedSignatureDumpCmd(), untrustedSignatureDumpCmd(),
tagsCmd(&opts),
} }
return app, &opts return app, &opts
} }

View File

@ -158,6 +158,7 @@ func (opts *imageOptions) newSystemContext() (*types.SystemContext, error) {
DockerDaemonHost: opts.dockerDaemonHost, DockerDaemonHost: opts.dockerDaemonHost,
DockerDaemonCertPath: opts.dockerCertPath, DockerDaemonCertPath: opts.dockerCertPath,
SystemRegistriesConfPath: opts.global.registriesConfPath, SystemRegistriesConfPath: opts.global.registriesConfPath,
BigFilesTemporaryDir: opts.global.tmpDir,
} }
if opts.dockerImageOptions.authFilePath.present { if opts.dockerImageOptions.authFilePath.present {
ctx.AuthFilePath = opts.dockerImageOptions.authFilePath.value ctx.AuthFilePath = opts.dockerImageOptions.authFilePath.value

View File

@ -54,6 +54,7 @@ func TestImageOptionsNewSystemContext(t *testing.T) {
"--override-arch", "overridden-arch", "--override-arch", "overridden-arch",
"--override-os", "overridden-os", "--override-os", "overridden-os",
"--override-variant", "overridden-variant", "--override-variant", "overridden-variant",
"--tmpdir", "/srv",
}, []string{ }, []string{
"--authfile", "/srv/authfile", "--authfile", "/srv/authfile",
"--dest-authfile", "/srv/dest-authfile", "--dest-authfile", "/srv/dest-authfile",
@ -78,6 +79,7 @@ func TestImageOptionsNewSystemContext(t *testing.T) {
DockerDaemonCertPath: "/srv/cert-dir", DockerDaemonCertPath: "/srv/cert-dir",
DockerDaemonHost: "daemon-host.example.com", DockerDaemonHost: "daemon-host.example.com",
DockerDaemonInsecureSkipTLSVerify: true, DockerDaemonInsecureSkipTLSVerify: true,
BigFilesTemporaryDir: "/srv",
}, res) }, res)
// Global/per-command tlsVerify behavior // Global/per-command tlsVerify behavior
@ -166,6 +168,7 @@ func TestImageDestOptionsNewSystemContext(t *testing.T) {
"--override-arch", "overridden-arch", "--override-arch", "overridden-arch",
"--override-os", "overridden-os", "--override-os", "overridden-os",
"--override-variant", "overridden-variant", "--override-variant", "overridden-variant",
"--tmpdir", "/srv",
}, []string{ }, []string{
"--authfile", "/srv/authfile", "--authfile", "/srv/authfile",
"--dest-cert-dir", "/srv/cert-dir", "--dest-cert-dir", "/srv/cert-dir",
@ -191,6 +194,7 @@ func TestImageDestOptionsNewSystemContext(t *testing.T) {
DockerDaemonHost: "daemon-host.example.com", DockerDaemonHost: "daemon-host.example.com",
DockerDaemonInsecureSkipTLSVerify: true, DockerDaemonInsecureSkipTLSVerify: true,
DirForceCompress: true, DirForceCompress: true,
BigFilesTemporaryDir: "/srv",
}, res) }, res)
// Invalid option values in imageOptions // Invalid option values in imageOptions

View File

@ -168,6 +168,7 @@ _skopeo_skopeo() {
--override-os --override-os
--override-variant --override-variant
--command-timeout --command-timeout
--tmpdir
" "
local boolean_options=" local boolean_options="
--insecure-policy --insecure-policy

View File

@ -46,23 +46,25 @@ Most commands refer to container images, using a _transport_`:`_details_ format.
## OPTIONS ## OPTIONS
**--command-timeout** _duration_ Timeout for the command execution.
**--debug** enable debug output **--debug** enable debug output
**--policy** _path-to-policy_ Path to a policy.json file to use for verifying signatures and deciding whether an image is trusted, overriding the default trust policy file. **--help**|**-h** Show help
**--insecure-policy** Adopt an insecure, permissive policy that allows anything. This obviates the need for a policy file. **--insecure-policy** Adopt an insecure, permissive policy that allows anything. This obviates the need for a policy file.
**--registries.d** _dir_ use registry configuration files in _dir_ (e.g. for container signature storage), overriding the default path.
**--override-arch** _arch_ Use _arch_ instead of the architecture of the machine for choosing images. **--override-arch** _arch_ Use _arch_ instead of the architecture of the machine for choosing images.
**--override-os** _OS_ Use _OS_ instead of the running OS for choosing images. **--override-os** _OS_ Use _OS_ instead of the running OS for choosing images.
**--override-variant** _VARIANT_ Use _VARIANT_ instead of the running architecture variant for choosing images. **--override-variant** _VARIANT_ Use _VARIANT_ instead of the running architecture variant for choosing images.
**--command-timeout** _duration_ Timeout for the command execution. **--policy** _path-to-policy_ Path to a policy.json file to use for verifying signatures and deciding whether an image is trusted, overriding the default trust policy file.
**--help**|**-h** Show help **--registries.d** _dir_ use registry configuration files in _dir_ (e.g. for container signature storage), overriding the default path.
**--tmpdir:**_dir_ _dir_ used to store temporary files. Defaults to /var/tmp.
**--version**|**-v** print the version number **--version**|**-v** print the version number
@ -73,11 +75,11 @@ Most commands refer to container images, using a _transport_`:`_details_ format.
| [skopeo-copy(1)](skopeo-copy.1.md) | Copy an image (manifest, filesystem layers, signatures) from one location to another. | | [skopeo-copy(1)](skopeo-copy.1.md) | Copy an image (manifest, filesystem layers, signatures) from one location to another. |
| [skopeo-delete(1)](skopeo-delete.1.md) | Mark image-name for deletion. | | [skopeo-delete(1)](skopeo-delete.1.md) | Mark image-name for deletion. |
| [skopeo-inspect(1)](skopeo-inspect.1.md) | Return low-level information about image-name in a registry. | | [skopeo-inspect(1)](skopeo-inspect.1.md) | Return low-level information about image-name in a registry. |
| [skopeo-list-tags(1)](skopeo-list-tags.1.md) | List the tags for the given transport/repository. |
| [skopeo-manifest-digest(1)](skopeo-manifest-digest.1.md) | Compute a manifest digest of manifest-file and write it to standard output.| | [skopeo-manifest-digest(1)](skopeo-manifest-digest.1.md) | Compute a manifest digest of manifest-file and write it to standard output.|
| [skopeo-standalone-sign(1)](skopeo-standalone-sign.1.md) | Sign an image. | | [skopeo-standalone-sign(1)](skopeo-standalone-sign.1.md) | Sign an image. |
| [skopeo-standalone-verify(1)](skopeo-standalone-verify.1.md)| Verify an image. | | [skopeo-standalone-verify(1)](skopeo-standalone-verify.1.md)| Verify an image. |
| [skopeo-sync(1)](skopeo-sync.1.md)| Copy images from one or more repositories to a user specified destination. | | [skopeo-sync(1)](skopeo-sync.1.md)| Copy images from one or more repositories to a user specified destination. |
| [skopeo-list-tags(1)](skopeo-list-tags.1.md) | List the tags for the given transport/repository. |
## FILES ## FILES
**/etc/containers/policy.json** **/etc/containers/policy.json**