mirror of
https://github.com/fluxcd/flux2.git
synced 2026-02-08 08:47:27 +00:00
Merge pull request #2998 from somtochiama/filter-artifact
Add `--filter-semver` and `--filter-regex` flags to `list artifacts`
This commit is contained in:
commit
81d2ad8245
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
|
||||
}
|
||||
|
|
|
|||
2
go.mod
2
go.mod
|
|
@ -14,7 +14,7 @@ require (
|
|||
github.com/fluxcd/notification-controller/api v0.25.1
|
||||
github.com/fluxcd/pkg/apis/meta v0.14.2
|
||||
github.com/fluxcd/pkg/kustomize v0.5.3
|
||||
github.com/fluxcd/pkg/oci v0.4.1
|
||||
github.com/fluxcd/pkg/oci v0.5.1
|
||||
github.com/fluxcd/pkg/runtime v0.16.2
|
||||
github.com/fluxcd/pkg/sourceignore v0.1.0
|
||||
github.com/fluxcd/pkg/ssa v0.17.0
|
||||
|
|
|
|||
4
go.sum
4
go.sum
|
|
@ -292,8 +292,8 @@ github.com/fluxcd/pkg/apis/meta v0.14.2 h1:/Hf7I/Vz01vv3m7Qx7DtQvrzAL1oVt0MJcLb/
|
|||
github.com/fluxcd/pkg/apis/meta v0.14.2/go.mod h1:ijZ61VG/8T3U17gj0aFL3fdtZL+mulD6V8VrLLUCAgM=
|
||||
github.com/fluxcd/pkg/kustomize v0.5.3 h1:WpxNOV/Yklp0p7Qv85VwBegq9fABuLR9qSWaAVa3+yc=
|
||||
github.com/fluxcd/pkg/kustomize v0.5.3/go.mod h1:zy1FLxkEDADUykCnrXqq6rVN48t3uMhAb3ao+zv0rFE=
|
||||
github.com/fluxcd/pkg/oci v0.4.1 h1:gx63SW9BymuJydDbu/8xzlMP85Tpc9FBnHZXsckgC7U=
|
||||
github.com/fluxcd/pkg/oci v0.4.1/go.mod h1:eOnW+Ce3Z8AmQ+X9tf1BCv+qxwro+rPM/VKca1E9Ka0=
|
||||
github.com/fluxcd/pkg/oci v0.5.1 h1:71Xt94AGUL5x3qBpHMS2KzIH3GnvxK22GIhA3KbBV0o=
|
||||
github.com/fluxcd/pkg/oci v0.5.1/go.mod h1:qEzBvOJvWKrIKIhCKw1Nlbgod9ClD8C6A7F2cylXpsA=
|
||||
github.com/fluxcd/pkg/runtime v0.16.2 h1:CexfMmJK+r12sHTvKWyAax0pcPomjd6VnaHXcxjUrRY=
|
||||
github.com/fluxcd/pkg/runtime v0.16.2/go.mod h1:OHSKsrO+T+Ym8WZRS2oidrnauWRARuE2nfm8ewevm7M=
|
||||
github.com/fluxcd/pkg/sourceignore v0.1.0 h1:v36Rqp6FDB7Ntjy7NakdwscOfxFPk14peKa+VMBNugo=
|
||||
|
|
|
|||
Loading…
Reference in a new issue