Skip to content

Commit

Permalink
cmd/kernels: Replace --ci with --repo
Browse files Browse the repository at this point in the history
Allow the user to provide the repo and provide examples for the CI
repository, rather than hardcoding lvh org OCI repos and CI flag.

Signed-off-by: Joe Stringer <[email protected]>
  • Loading branch information
joestringer committed Apr 16, 2024
1 parent 8a969ea commit 7cec9c2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
20 changes: 10 additions & 10 deletions cmd/lvh/kernels/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ const (

kernelTagRegex = `^(.+)-([0-9]+\.[0-9]+|main)$`

ciCommand = "ci"
ciHelp = "use CI repositories instead of main ones"
repoCommand = "repo"
repoHelp = "specify the OCI repository to pull the image from"
)

func catalogCommand() *cobra.Command {
var ci bool
var (
repo string
)

cmd := &cobra.Command{
Use: "catalog [version]",
Expand All @@ -36,15 +38,13 @@ Examples:
lvh kernels catalog 6.6
# Retrieve the latest tags available for version bpf-next
lvh kernels catalog bpf-next | tail -n 2`,
lvh kernels catalog bpf-next | tail -n 2
# Retrieve the latest CI-generated images for version bpf-next
lvh kernels catalog bpf-next --repo quay.io/lvh-images/kernel-images-ci`,
RunE: func(cmd *cobra.Command, args []string) error {
re := regexp.MustCompile(kernelTagRegex)

repo := kernelImageRepository
if ci {
repo = fmt.Sprintf("%s-ci", repo)
}

rawTagList, err := crane.ListTags(repo)
if err != nil {
return err
Expand Down Expand Up @@ -97,7 +97,7 @@ Examples:
},
}

cmd.Flags().BoolVar(&ci, ciCommand, false, ciHelp)
cmd.Flags().StringVar(&repo, repoCommand, kernelImageRepository, repoHelp)

return cmd
}
18 changes: 9 additions & 9 deletions cmd/lvh/kernels/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ import (
)

func pullCommand() *cobra.Command {
var platform string
var ci bool
var (
platform string
repo string
)

cmd := &cobra.Command{
Use: "pull <tag>",
Expand All @@ -38,7 +40,10 @@ Examples:
lvh kernels pull 5.10-main --dir mykernels
# Pull the latest tags available for version 5.15 without using 5.15-main
lvh kernels pull $(lvh kernels catalog 5.15 | tail -n 2 | head -n 1)`,
lvh kernels pull $(lvh kernels catalog 5.15 | tail -n 2 | head -n 1)
# Pull the latest CI-generated images for version bpf-next
lvh kernels pull bpf-next-main --repo quay.io/lvh-images/kernel-images-ci`,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
re := regexp.MustCompile(kernelTagRegex)
Expand All @@ -52,11 +57,6 @@ Examples:
return fmt.Errorf("platform is malformed, it must be <os>/<arch>: %s", platform)
}

repo := kernelImageRepository
if ci {
repo = fmt.Sprintf("%s-ci", repo)
}

srcImage := fmt.Sprintf("%s:%s", repo, args[0])
dstTarFile := fmt.Sprintf("%s.tar", args[0])

Expand All @@ -78,7 +78,7 @@ Examples:

cmd.Flags().StringVarP(&platform, "platform", "p", runtime.GOOS+"/"+runtime.GOARCH, "platform for the kernel image <os>/<arch>")
cmd.Flags().StringVarP(&dirName, dirNameCommand, "d", ".", dirNameHelp)
cmd.Flags().BoolVar(&ci, ciCommand, false, ciHelp)
cmd.Flags().StringVar(&repo, repoCommand, kernelImageRepository, repoHelp)

return cmd
}
Expand Down

0 comments on commit 7cec9c2

Please sign in to comment.