NewFetchConfig returns the default FetchConfig from cli flags
(ctx context.Context, cliContext *cli.Context)
| 117 | |
| 118 | // NewFetchConfig returns the default FetchConfig from cli flags |
| 119 | func NewFetchConfig(ctx context.Context, cliContext *cli.Context) (*FetchConfig, error) { |
| 120 | resolver, err := commands.GetResolver(ctx, cliContext) |
| 121 | if err != nil { |
| 122 | return nil, err |
| 123 | } |
| 124 | config := &FetchConfig{ |
| 125 | Resolver: resolver, |
| 126 | Labels: cliContext.StringSlice("label"), |
| 127 | TraceHTTP: cliContext.Bool("http-trace"), |
| 128 | } |
| 129 | if !cliContext.Bool("debug") { |
| 130 | config.ProgressOutput = os.Stdout |
| 131 | } |
| 132 | if !cliContext.Bool("all-platforms") { |
| 133 | p := cliContext.StringSlice("platform") |
| 134 | if len(p) == 0 { |
| 135 | p = append(p, platforms.DefaultString()) |
| 136 | } |
| 137 | config.Platforms = p |
| 138 | } |
| 139 | |
| 140 | if cliContext.Bool("metadata-only") { |
| 141 | config.AllMetadata = true |
| 142 | // Any with an empty set is None |
| 143 | config.PlatformMatcher = platforms.Any() |
| 144 | } else if !cliContext.Bool("skip-metadata") { |
| 145 | config.AllMetadata = true |
| 146 | } |
| 147 | |
| 148 | if cliContext.IsSet("max-concurrent-uploaded-layers") { |
| 149 | mcu := cliContext.Int("max-concurrent-uploaded-layers") |
| 150 | config.RemoteOpts = append(config.RemoteOpts, containerd.WithMaxConcurrentUploadedLayers(mcu)) |
| 151 | } |
| 152 | |
| 153 | return config, nil |
| 154 | } |
| 155 | |
| 156 | // Fetch loads all resources into the content store and returns the image |
| 157 | func Fetch(ctx context.Context, client *containerd.Client, ref string, config *FetchConfig) (images.Image, error) { |
no test coverage detected
searching dependent graphs…