From fd65acede3d6148bae0419cec258512f1f293b81 Mon Sep 17 00:00:00 2001 From: Wojciech Trocki Date: Fri, 13 Aug 2021 10:52:31 +0100 Subject: [PATCH] fix: minor review suggestions --- pkg/cmd/registry/artifact/crud/delete/delete.go | 2 +- pkg/cmd/registry/artifact/crud/list/list.go | 16 +++++----------- pkg/cmd/registry/artifact/crud/update/update.go | 2 +- pkg/cmd/registry/artifact/download/download.go | 2 +- pkg/cmd/registry/artifact/util/constants.go | 2 +- 5 files changed, 9 insertions(+), 15 deletions(-) diff --git a/pkg/cmd/registry/artifact/crud/delete/delete.go b/pkg/cmd/registry/artifact/crud/delete/delete.go index f6df5fd3a..db40c01ae 100644 --- a/pkg/cmd/registry/artifact/crud/delete/delete.go +++ b/pkg/cmd/registry/artifact/crud/delete/delete.go @@ -180,7 +180,7 @@ func confirmDelete(opts *Options, message string) error { } if !shouldContinue { - return errors.New("") + return errors.New("command stopped by user") } } return nil diff --git a/pkg/cmd/registry/artifact/crud/list/list.go b/pkg/cmd/registry/artifact/crud/list/list.go index f71a632a9..e5d2a11e1 100644 --- a/pkg/cmd/registry/artifact/crud/list/list.go +++ b/pkg/cmd/registry/artifact/crud/list/list.go @@ -121,7 +121,7 @@ rhoas service-registry artifact list --page=2 --limit=10 cmd.Flags().Int32VarP(&opts.limit, "limit", "", 100, "Page limit") cmd.Flags().StringVarP(&opts.registryID, "instance-id", "", "", "Id of the registry to be used. By default uses currently selected registry") - cmd.Flags().StringVarP(&opts.outputFormat, "output", "o", "", "Output format (json, yaml, yml, table)") + cmd.Flags().StringVarP(&opts.outputFormat, "output", "o", "", "Output format (json, yaml, yml)") flagutil.EnableOutputFlagCompletion(cmd) @@ -162,12 +162,6 @@ func runList(opts *Options) error { return registryinstanceerror.TransformError(err) } - totalCount := opts.page * opts.limit - if len(response.Artifacts) != 0 && response.GetCount() < totalCount { - logger.Info("Provided limit and page arguments are larger than total count of elements on the server", response.GetCount()) - return nil - } - if len(response.Artifacts) == 0 && opts.outputFormat == "" { logger.Info("No artifacts available for " + opts.group + " group and registry id " + opts.registryID) return nil @@ -181,7 +175,7 @@ func runList(opts *Options) error { data, _ := yaml.Marshal(response) _ = dump.YAML(opts.IO.Out, data) default: - rows := mapResponseItemsToRows(&response.Artifacts) + rows := mapResponseItemsToRows(response.Artifacts) dump.Table(opts.IO.Out, rows) logger.Info("") } @@ -189,11 +183,11 @@ func runList(opts *Options) error { return nil } -func mapResponseItemsToRows(artifacts *[]registryinstanceclient.SearchedArtifact) []artifactRow { +func mapResponseItemsToRows(artifacts []registryinstanceclient.SearchedArtifact) []artifactRow { rows := []artifactRow{} - for i := range *artifacts { - k := (*artifacts)[i] + for i := range artifacts { + k := (artifacts)[i] row := artifactRow{ Id: k.GetId(), Name: k.GetName(), diff --git a/pkg/cmd/registry/artifact/crud/update/update.go b/pkg/cmd/registry/artifact/crud/update/update.go index 7f56057fb..8b6f50dc0 100644 --- a/pkg/cmd/registry/artifact/crud/update/update.go +++ b/pkg/cmd/registry/artifact/crud/update/update.go @@ -132,7 +132,7 @@ func runUpdate(opts *Options) error { } if opts.group == "" { - logger.Info("Group was not specified. Using " + util.DefaultArtifactGroup + " artifacts group.") + logger.Info("Group was not specified. Using", util.DefaultArtifactGroup, "artifacts group.") opts.group = util.DefaultArtifactGroup } diff --git a/pkg/cmd/registry/artifact/download/download.go b/pkg/cmd/registry/artifact/download/download.go index fc38b397c..9de94867c 100644 --- a/pkg/cmd/registry/artifact/download/download.go +++ b/pkg/cmd/registry/artifact/download/download.go @@ -147,7 +147,7 @@ func runGet(opts *Options) error { request := dataAPI.ArtifactsApi.GetContentByHash(ctx, opts.hash) dataFile, _, err = request.Execute() } else { - return errors.New("Please specify at least one flag: [contentId, globalId, hash]") + return errors.New("please specify at least one flag: [contentId, global-id, hash]") } if err != nil { diff --git a/pkg/cmd/registry/artifact/util/constants.go b/pkg/cmd/registry/artifact/util/constants.go index 53a3b1827..833236db8 100644 --- a/pkg/cmd/registry/artifact/util/constants.go +++ b/pkg/cmd/registry/artifact/util/constants.go @@ -4,7 +4,7 @@ import ( "strings" ) -var DefaultArtifactGroup = "default" +const DefaultArtifactGroup = "default" var AllowedArtifactTypeEnumValues = []string{ "AVRO",