Skip to content

Commit 211f739

Browse files
authored
feat(service-registry): added --all-groups flag in artifact list command (#1667)
1 parent d6e8ef6 commit 211f739

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

docs/commands/rhoas_service-registry_artifact_list.md

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/cmd/registry/artifact/crud/list/list.go

+8-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ type artifactRow struct {
3535
}
3636

3737
type options struct {
38-
group string
38+
group string
39+
allGroups bool
3940

4041
registryID string
4142
outputFormat string
@@ -95,6 +96,7 @@ func NewListCommand(f *factory.Factory) *cobra.Command {
9596
}
9697

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

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

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

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

132-
request = request.Group(opts.group)
133134
request = request.Offset((opts.page - 1) * opts.limit)
134135
request = request.Limit(opts.limit)
135136
request = request.Orderby(registryinstanceclient.SORTBY_CREATED_ON)
136137
request = request.Order(registryinstanceclient.SORTORDER_ASC)
137138

139+
if !opts.allGroups {
140+
request = request.Group(opts.group)
141+
}
142+
138143
if opts.name != "" {
139144
request = request.Name(opts.name)
140145
}

pkg/core/localize/locales/en/cmd/artifact.en.toml

+6
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,9 @@ one = '''
293293
## List all artifacts for the "default" artifact group
294294
rhoas service-registry artifact list
295295
296+
## List all artifacts in all groups
297+
rhoas service-registry artifact list --all-groups
298+
296299
## List all artifacts with "my-group" group
297300
rhoas service-registry artifact list --group=my-group
298301
@@ -486,6 +489,9 @@ one = 'Successfully updated artifact state'
486489
[artifact.cmd.state.error.invalidArtifactState]
487490
one = 'invalid artifact state. Please use one of following values: {{.AllowedTypes}}'
488491

492+
[artifact.cmd.list.flag.allgroups.description]
493+
one= 'List artifacts in all groups'
494+
489495
[artifact.cmd.list.flag.name.description]
490496
one = 'Text search to filter artifacts by name'
491497

0 commit comments

Comments
 (0)