Skip to content

Commit

Permalink
Update urfave cli to use v2
Browse files Browse the repository at this point in the history
Signed-off-by: Derek McGowan <[email protected]>
  • Loading branch information
dmcgowan committed Apr 24, 2024
1 parent 92fff08 commit 06db6c6
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 77 deletions.
34 changes: 17 additions & 17 deletions cmd/ctr-remote/commands/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ import (
"github.com/klauspost/compress/zstd"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
"github.com/urfave/cli/v2"
)

// ConvertCommand converts an image
var ConvertCommand = cli.Command{
var ConvertCommand = &cli.Command{
Name: "convert",
Usage: "convert an image",
ArgsUsage: "[flags] <source_ref> <target_ref>...",
Expand All @@ -56,72 +56,72 @@ When '--all-platforms' is given all images in a manifest list must be available.
`,
Flags: []cli.Flag{
// estargz flags
cli.BoolFlag{
&cli.BoolFlag{
Name: "estargz",
Usage: "convert legacy tar(.gz) layers to eStargz for lazy pulling. Should be used in conjunction with '--oci'",
},
cli.StringFlag{
&cli.StringFlag{
Name: "estargz-record-in",
Usage: "Read 'ctr-remote optimize --record-out=<FILE>' record file",
},
cli.IntFlag{
&cli.IntFlag{
Name: "estargz-compression-level",
Usage: "eStargz compression level",
Value: gzip.BestCompression,
},
cli.IntFlag{
&cli.IntFlag{
Name: "estargz-chunk-size",
Usage: "eStargz chunk size",
Value: 0,
},
cli.IntFlag{
&cli.IntFlag{
Name: "estargz-min-chunk-size",
Usage: "The minimal number of bytes of data must be written in one gzip stream. Note that this adds a TOC property that old reader doesn't understand.",
Value: 0,
},
cli.BoolFlag{
&cli.BoolFlag{
Name: "estargz-external-toc",
Usage: "Separate TOC JSON into another image (called \"TOC image\"). The name of TOC image is the original + \"-esgztoc\" suffix. Both eStargz and the TOC image should be pushed to the same registry. stargz-snapshotter refers to the TOC image when it pulls the result eStargz image.",
},
cli.BoolFlag{
&cli.BoolFlag{
Name: "estargz-keep-diff-id",
Usage: "convert to esgz without changing diffID (cannot be used in conjunction with '--estargz-record-in'. must be specified with '--estargz-external-toc')",
},
// zstd:chunked flags
cli.BoolFlag{
&cli.BoolFlag{
Name: "zstdchunked",
Usage: "use zstd compression instead of gzip (a.k.a zstd:chunked). Must be used in conjunction with '--oci'.",
},
cli.StringFlag{
&cli.StringFlag{
Name: "zstdchunked-record-in",
Usage: "Read 'ctr-remote optimize --record-out=<FILE>' record file",
},
cli.IntFlag{
&cli.IntFlag{
Name: "zstdchunked-compression-level",
Usage: "zstd:chunked compression level",
Value: 3, // SpeedDefault; see also https://pkg.go.dev/github.com/klauspost/compress/zstd#EncoderLevel
},
cli.IntFlag{
&cli.IntFlag{
Name: "zstdchunked-chunk-size",
Usage: "zstd:chunked chunk size",
Value: 0,
},
// generic flags
cli.BoolFlag{
&cli.BoolFlag{
Name: "uncompress",
Usage: "convert tar.gz layers to uncompressed tar layers",
},
cli.BoolFlag{
&cli.BoolFlag{
Name: "oci",
Usage: "convert Docker media types to OCI media types",
},
// platform flags
cli.StringSliceFlag{
&cli.StringSliceFlag{
Name: "platform",
Usage: "Convert content for a specific platform",
Value: &cli.StringSlice{},
},
cli.BoolFlag{
&cli.BoolFlag{
Name: "all-platforms",
Usage: "Convert content for all platforms",
},
Expand Down
40 changes: 20 additions & 20 deletions cmd/ctr-remote/commands/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,87 +40,87 @@ import (
runtimespec "github.com/opencontainers/runtime-spec/specs-go"
"github.com/rs/xid"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
"github.com/urfave/cli/v2"
)

const netnsMountDir = "/var/run/netns"

var samplerFlags = []cli.Flag{
cli.BoolFlag{
&cli.BoolFlag{
Name: "terminal,t",
Usage: "enable terminal for sample container. must be specified with i option",
},
cli.BoolFlag{
&cli.BoolFlag{
Name: "i",
Usage: "attach stdin to the container",
},
cli.IntFlag{
&cli.IntFlag{
Name: "period",
Usage: "time period to monitor access log",
Value: defaultPeriod,
},
cli.StringFlag{
&cli.StringFlag{
Name: "user",
Usage: "user/group name to override image's default config(user[:group])",
},
cli.StringFlag{
&cli.StringFlag{
Name: "cwd",
Usage: "working dir to override image's default config",
},
cli.StringFlag{
&cli.StringFlag{
Name: "args",
Usage: "command arguments to override image's default config(in JSON array)",
},
cli.StringFlag{
&cli.StringFlag{
Name: "entrypoint",
Usage: "entrypoint to override image's default config(in JSON array)",
},
cli.StringSliceFlag{
&cli.StringSliceFlag{
Name: "env",
Usage: "environment valulable to add or override to the image's default config",
},
cli.StringFlag{
&cli.StringFlag{
Name: "env-file",
Usage: "specify additional container environment variables in a file(i.e. FOO=bar, one per line)",
},
cli.StringSliceFlag{
&cli.StringSliceFlag{
Name: "mount",
Usage: "additional mounts for the container (e.g. type=foo,source=/path,destination=/target,options=bind)",
},
cli.StringFlag{
&cli.StringFlag{
Name: "dns-nameservers",
Usage: "comma-separated nameservers added to the container's /etc/resolv.conf",
Value: "8.8.8.8",
},
cli.StringFlag{
&cli.StringFlag{
Name: "dns-search-domains",
Usage: "comma-separated search domains added to the container's /etc/resolv.conf",
},
cli.StringFlag{
&cli.StringFlag{
Name: "dns-options",
Usage: "comma-separated options added to the container's /etc/resolv.conf",
},
cli.StringFlag{
&cli.StringFlag{
Name: "add-hosts",
Usage: "comma-separated hosts configuration (host:IP) added to container's /etc/hosts",
},
cli.BoolFlag{
&cli.BoolFlag{
Name: "cni",
Usage: "enable CNI-based networking",
},
cli.StringFlag{
&cli.StringFlag{
Name: "cni-plugin-conf-dir",
Usage: "path to the CNI plugins configuration directory",
},
cli.StringFlag{
&cli.StringFlag{
Name: "cni-plugin-dir",
Usage: "path to the CNI plugins binary directory",
},
cli.IntSliceFlag{
&cli.IntSliceFlag{
Name: "gpus",
Usage: "add gpus to the container",
},
cli.BoolFlag{
&cli.BoolFlag{
Name: "net-host",
Usage: "enable host networking in the container",
},
Expand Down
8 changes: 4 additions & 4 deletions cmd/ctr-remote/commands/get-toc-digest.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@ import (
"github.com/containerd/stargz-snapshotter/estargz/zstdchunked"
digest "github.com/opencontainers/go-digest"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/urfave/cli"
"github.com/urfave/cli/v2"
)

// GetTOCDigestCommand outputs TOC info of a layer
var GetTOCDigestCommand = cli.Command{
var GetTOCDigestCommand = &cli.Command{
Name: "get-toc-digest",
Usage: "get the digest of TOC of a layer",
ArgsUsage: "<layer digest>",
Flags: []cli.Flag{
// zstd:chunked flags
cli.BoolFlag{
&cli.BoolFlag{
Name: "zstdchunked",
Usage: "parse layer as zstd:chunked",
},
// other flags for debugging
cli.BoolFlag{
&cli.BoolFlag{
Name: "dump-toc",
Usage: "dump TOC instead of digest. Note that the dumped TOC might be formatted with indents so may have different digest against the original in the layer",
},
Expand Down
11 changes: 6 additions & 5 deletions cmd/ctr-remote/commands/ipfs-push.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,28 @@ import (
estargzconvert "github.com/containerd/stargz-snapshotter/nativeconverter/estargz"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
"github.com/urfave/cli/v2"
)

// IPFSPushCommand pushes an image to IPFS
var IPFSPushCommand = cli.Command{
var IPFSPushCommand = &cli.Command{
Name: "ipfs-push",
Usage: "push an image to IPFS (experimental)",
ArgsUsage: "[flags] <image_ref>",
Flags: []cli.Flag{
// platform flags
cli.StringSliceFlag{
&cli.StringSliceFlag{
Name: "platform",
Usage: "Add content for a specific platform",
Value: &cli.StringSlice{},
},
cli.BoolFlag{
&cli.BoolFlag{
Name: "all-platforms",
Usage: "Add content for all platforms",
},
cli.BoolTFlag{
&cli.BoolFlag{
Name: "estargz",
Value: true,
Usage: "Convert the image into eStargz",
},
},
Expand Down
4 changes: 2 additions & 2 deletions cmd/ctr-remote/commands/notify.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ import (
"os"

"github.com/containerd/stargz-snapshotter/analyzer/fanotify/service"
"github.com/urfave/cli"
"github.com/urfave/cli/v2"
)

// FanotifyCommand notifies filesystem event under the specified directory.
var FanotifyCommand = cli.Command{
var FanotifyCommand = &cli.Command{
Name: "fanotify",
Hidden: true,
Action: func(context *cli.Context) error {
Expand Down
32 changes: 16 additions & 16 deletions cmd/ctr-remote/commands/optimize.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,74 +45,74 @@ import (
"github.com/opencontainers/go-digest"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
"github.com/urfave/cli/v2"
)

const defaultPeriod = 10

// OptimizeCommand converts and optimizes an image
var OptimizeCommand = cli.Command{
var OptimizeCommand = &cli.Command{
Name: "optimize",
Usage: "optimize an image with user-specified workload",
ArgsUsage: "[flags] <source_ref> <target_ref>...",
Flags: append([]cli.Flag{
cli.BoolFlag{
&cli.BoolFlag{
Name: "reuse",
Usage: "reuse eStargz (already optimized) layers without further conversion",
},
cli.StringSliceFlag{
&cli.StringSliceFlag{
Name: "platform",
Usage: "Pull content from a specific platform",
Value: &cli.StringSlice{},
},
cli.BoolFlag{
&cli.BoolFlag{
Name: "all-platforms",
Usage: "targeting all platform of the source image",
},
cli.BoolFlag{
&cli.BoolFlag{
Name: "wait-on-signal",
Usage: "ignore context cancel and keep the container running until it receives SIGINT (Ctrl + C) sent manually",
},
cli.StringFlag{
&cli.StringFlag{
Name: "wait-on-line",
Usage: "Substring of a stdout line to be waited. When this string is detected, the container will be killed.",
},
cli.BoolFlag{
&cli.BoolFlag{
Name: "no-optimize",
Usage: "convert image without optimization",
},
cli.StringFlag{
&cli.StringFlag{
Name: "record-out",
Usage: "record the monitor log to the specified file",
},
cli.BoolFlag{
&cli.BoolFlag{
Name: "oci",
Usage: "convert Docker media types to OCI media types",
},
cli.IntFlag{
&cli.IntFlag{
Name: "estargz-compression-level",
Usage: "eStargz compression level",
Value: gzip.BestCompression,
},
cli.BoolFlag{
&cli.BoolFlag{
Name: "estargz-external-toc",
Usage: "Separate TOC JSON into another image (called \"TOC image\"). The name of TOC image is the original + \"-esgztoc\" suffix. Both eStargz and the TOC image should be pushed to the same registry. stargz-snapshotter refers to the TOC image when it pulls the result eStargz image.",
},
cli.IntFlag{
&cli.IntFlag{
Name: "estargz-chunk-size",
Usage: "eStargz chunk size (not applied to zstd:chunked)",
Value: 0,
},
cli.IntFlag{
&cli.IntFlag{
Name: "estargz-min-chunk-size",
Usage: "The minimal number of bytes of data must be written in one gzip stream. Note that this adds a TOC property that old reader doesn't understand (not applied to zstd:chunked)",
Value: 0,
},
cli.BoolFlag{
&cli.BoolFlag{
Name: "zstdchunked",
Usage: "use zstd compression instead of gzip (a.k.a zstd:chunked)",
},
cli.IntFlag{
&cli.IntFlag{
Name: "zstdchunked-compression-level",
Usage: "zstd:chunked compression level",
Value: 3, // SpeedDefault; see also https://pkg.go.dev/github.com/klauspost/compress/zstd#EncoderLevel
Expand Down
Loading

0 comments on commit 06db6c6

Please sign in to comment.