Skip to content

Commit

Permalink
feat(service-registry): added --all-groups flag in artifact list comm…
Browse files Browse the repository at this point in the history
…and (#1667)
  • Loading branch information
SafarMirek authored Jul 21, 2022
1 parent d6e8ef6 commit 211f739
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
4 changes: 4 additions & 0 deletions docs/commands/rhoas_service-registry_artifact_list.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions pkg/cmd/registry/artifact/crud/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ type artifactRow struct {
}

type options struct {
group string
group string
allGroups bool

registryID string
outputFormat string
Expand Down Expand Up @@ -95,6 +96,7 @@ func NewListCommand(f *factory.Factory) *cobra.Command {
}

cmd.Flags().StringVarP(&opts.group, "group", "g", registrycmdutil.DefaultArtifactGroup, opts.localizer.MustLocalize("artifact.common.group"))
cmd.Flags().BoolVarP(&opts.allGroups, "all-groups", "a", false, opts.localizer.MustLocalize("artifact.cmd.list.flag.allgroups.description"))
cmd.Flags().Int32VarP(&opts.page, "page", "", 1, opts.localizer.MustLocalize("artifact.common.page.number"))
cmd.Flags().Int32VarP(&opts.limit, "limit", "", 100, opts.localizer.MustLocalize("artifact.common.page.limit"))

Expand All @@ -112,7 +114,7 @@ func NewListCommand(f *factory.Factory) *cobra.Command {
}

func runList(opts *options) error {
if opts.group == registrycmdutil.DefaultArtifactGroup {
if opts.group == registrycmdutil.DefaultArtifactGroup && !opts.allGroups {
opts.Logger.Info(opts.localizer.MustLocalize("registry.artifact.common.message.no.group", localize.NewEntry("DefaultArtifactGroup", registrycmdutil.DefaultArtifactGroup)))
}

Expand All @@ -129,12 +131,15 @@ func runList(opts *options) error {
}
request := a.SearchApi.SearchArtifacts(opts.Context)

request = request.Group(opts.group)
request = request.Offset((opts.page - 1) * opts.limit)
request = request.Limit(opts.limit)
request = request.Orderby(registryinstanceclient.SORTBY_CREATED_ON)
request = request.Order(registryinstanceclient.SORTORDER_ASC)

if !opts.allGroups {
request = request.Group(opts.group)
}

if opts.name != "" {
request = request.Name(opts.name)
}
Expand Down
6 changes: 6 additions & 0 deletions pkg/core/localize/locales/en/cmd/artifact.en.toml
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,9 @@ one = '''
## List all artifacts for the "default" artifact group
rhoas service-registry artifact list
## List all artifacts in all groups
rhoas service-registry artifact list --all-groups
## List all artifacts with "my-group" group
rhoas service-registry artifact list --group=my-group
Expand Down Expand Up @@ -486,6 +489,9 @@ one = 'Successfully updated artifact state'
[artifact.cmd.state.error.invalidArtifactState]
one = 'invalid artifact state. Please use one of following values: {{.AllowedTypes}}'

[artifact.cmd.list.flag.allgroups.description]
one= 'List artifacts in all groups'

[artifact.cmd.list.flag.name.description]
one = 'Text search to filter artifacts by name'

Expand Down

0 comments on commit 211f739

Please sign in to comment.