Skip to content

Commit

Permalink
Plumb offline flags around more
Browse files Browse the repository at this point in the history
Also drop show-packages printing arch to stdout so I can use it.

Signed-off-by: Jon Johnson <jon.johnson@chainguard.dev>
  • Loading branch information
jonjohnsonjr committed Jan 30, 2024
1 parent c8eac4d commit 9986652
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions internal/cli/dot.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ func dotcmd() *cobra.Command {
var extraRepos []string
var archstrs []string
var web, span bool
var cacheDir string
var offline bool

cmd := &cobra.Command{
Use: "dot",
Expand All @@ -66,6 +68,7 @@ apko dot --web -S example.yaml
build.WithConfig(args[0]),
build.WithExtraKeys(extraKeys),
build.WithExtraRepos(extraRepos),
build.WithCacheDir(cacheDir, offline),
)
},
}
Expand All @@ -75,6 +78,8 @@ apko dot --web -S example.yaml
cmd.Flags().StringSliceVar(&archstrs, "arch", nil, "architectures to build for (e.g., x86_64,ppc64le,arm64) -- default is all, unless specified in config. Can also use 'host' to indicate arch of host this is running on")
cmd.Flags().BoolVarP(&span, "spanning-tree", "S", false, "does something like a spanning tree to avoid a huge number of edges")
cmd.Flags().BoolVar(&web, "web", false, "launch a browser")
cmd.Flags().StringVar(&cacheDir, "cache-dir", "", "directory to use for caching apk packages and indexes (default '' means to use system-defined cache directory)")
cmd.Flags().BoolVar(&offline, "offline", false, "do not use network to fetch packages (cache must be pre-populated)")

return cmd
}
Expand Down
5 changes: 5 additions & 0 deletions internal/cli/show-config.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import (
func showConfig() *cobra.Command {
var extraKeys []string
var extraRepos []string
var cacheDir string
var offline bool

cmd := &cobra.Command{
Use: "show-config",
Expand All @@ -46,12 +48,15 @@ The derived configuration is rendered in YAML.
build.WithAssertions(build.RequireGroupFile(true), build.RequirePasswdFile(true)),
build.WithExtraKeys(extraKeys),
build.WithExtraRepos(extraRepos),
build.WithCacheDir(cacheDir, offline),
)
},
}

cmd.Flags().StringSliceVarP(&extraKeys, "keyring-append", "k", []string{}, "path to extra keys to include in the keyring")
cmd.Flags().StringSliceVarP(&extraRepos, "repository-append", "r", []string{}, "path to extra repositories to include")
cmd.Flags().StringVar(&cacheDir, "cache-dir", "", "directory to use for caching apk packages and indexes (default '' means to use system-defined cache directory)")
cmd.Flags().BoolVar(&offline, "offline", false, "do not use network to fetch packages (cache must be pre-populated)")

return cmd
}
Expand Down
6 changes: 5 additions & 1 deletion internal/cli/show-packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ func showPackages() *cobra.Command {
var archstrs []string
var format string
var tmpl string
var cacheDir string
var offline bool

cmd := &cobra.Command{
Use: "show-packages",
Expand Down Expand Up @@ -107,6 +109,7 @@ packagelock and packagelock-source are particularly useful for inserting back in
build.WithConfig(args[0]),
build.WithExtraKeys(extraKeys),
build.WithExtraRepos(extraRepos),
build.WithCacheDir(cacheDir, offline),
)
},
}
Expand All @@ -115,6 +118,8 @@ packagelock and packagelock-source are particularly useful for inserting back in
cmd.Flags().StringSliceVarP(&extraRepos, "repository-append", "r", []string{}, "path to extra repositories to include")
cmd.Flags().StringSliceVar(&archstrs, "arch", nil, "architectures to build for (e.g., x86_64,ppc64le,arm64) -- default is all, unless specified in config. Can also use 'host' to indicate arch of host this is running on")
cmd.Flags().StringVar(&format, "format", showPkgsFormatDefault, "format for showing packages; if pre-defined from list, will use that, else go template. See https://pkg.go.dev/text/template for more information. Available vars are `.Name`, `.Version`, `.Source`")
cmd.Flags().StringVar(&cacheDir, "cache-dir", "", "directory to use for caching apk packages and indexes (default '' means to use system-defined cache directory)")
cmd.Flags().BoolVar(&offline, "offline", false, "do not use network to fetch packages (cache must be pre-populated)")

return cmd
}
Expand Down Expand Up @@ -177,7 +182,6 @@ func ShowPackagesCmd(ctx context.Context, format string, archs []types.Architect
if err != nil {
return fmt.Errorf("failed to get package list for image: %w", err)
}
fmt.Println(arch)
var p pkgInfo
for _, pkg := range pkgs {
p.Name = pkg.Name
Expand Down

0 comments on commit 9986652

Please sign in to comment.