Skip to content

Commit

Permalink
fix: minor review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
wtrocki committed Aug 13, 2021
1 parent 7099367 commit fd65ace
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 15 deletions.
2 changes: 1 addition & 1 deletion pkg/cmd/registry/artifact/crud/delete/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 5 additions & 11 deletions pkg/cmd/registry/artifact/crud/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand All @@ -181,19 +175,19 @@ 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("")
}

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(),
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/registry/artifact/crud/update/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/registry/artifact/download/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/registry/artifact/util/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"strings"
)

var DefaultArtifactGroup = "default"
const DefaultArtifactGroup = "default"

var AllowedArtifactTypeEnumValues = []string{
"AVRO",
Expand Down

0 comments on commit fd65ace

Please sign in to comment.