mirror of
https://github.com/fluxcd/flux2.git
synced 2026-04-11 14:40:04 +00:00
Add --filter-semver and regex flags to list artifact
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
This commit is contained in:
parent
545949c67f
commit
96d1c1b2bd
3 changed files with 19 additions and 4 deletions
|
|
@ -27,6 +27,13 @@ import (
|
|||
"github.com/fluxcd/flux2/pkg/printers"
|
||||
)
|
||||
|
||||
type listArtifactFlags struct {
|
||||
semverFilter string
|
||||
regexFilter string
|
||||
}
|
||||
|
||||
var listArtifactArgs listArtifactFlags
|
||||
|
||||
var listArtifactsCmd = &cobra.Command{
|
||||
Use: "artifacts",
|
||||
Short: "list artifacts",
|
||||
|
|
@ -39,6 +46,9 @@ The command uses the credentials from '~/.docker/config.json'.`,
|
|||
}
|
||||
|
||||
func init() {
|
||||
listArtifactsCmd.Flags().StringVar(&listArtifactArgs.semverFilter, "filter-semver", "", "filter tags returned from the oci repository using semver")
|
||||
listArtifactsCmd.Flags().StringVar(&listArtifactArgs.regexFilter, "filter-regex", "", "filter tags returned from the oci repository using regex")
|
||||
|
||||
listCmd.AddCommand(listArtifactsCmd)
|
||||
}
|
||||
|
||||
|
|
@ -57,7 +67,12 @@ func listArtifactsCmdRun(cmd *cobra.Command, args []string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
metas, err := ociClient.List(ctx, url)
|
||||
opts := oci.ListOptions{
|
||||
RegexFilter: listArtifactArgs.regexFilter,
|
||||
SemverFilter: listArtifactArgs.semverFilter,
|
||||
}
|
||||
|
||||
metas, err := ociClient.List(ctx, url, opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue