Skip to content

Commit

Permalink
feat(service-registry rule): add disable and update command (#1444)
Browse files Browse the repository at this point in the history
  • Loading branch information
rkpattnaik780 committed Feb 21, 2022
1 parent 93feb7b commit 22c2689
Show file tree
Hide file tree
Showing 26 changed files with 665 additions and 59 deletions.
2 changes: 2 additions & 0 deletions docs/commands/rhoas_service-registry_rule.md

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

47 changes: 47 additions & 0 deletions docs/commands/rhoas_service-registry_rule_disable.md

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

47 changes: 47 additions & 0 deletions docs/commands/rhoas_service-registry_rule_update.md

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

7 changes: 3 additions & 4 deletions pkg/cmd/registry/artifact/crud/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func NewCreateCommand(f *factory.Factory) *cobra.Command {
cmd.Flags().StringVar(&opts.file, "file", "", opts.localizer.MustLocalize("artifact.common.file.location"))

cmd.Flags().StringVar(&opts.artifact, "artifact-id", "", opts.localizer.MustLocalize("artifact.common.id"))
cmd.Flags().StringVarP(&opts.group, "group", "g", util.DefaultArtifactGroup, opts.localizer.MustLocalize("artifact.common.group"))
cmd.Flags().StringVarP(&opts.group, "group", "g", registrycmdutil.DefaultArtifactGroup, opts.localizer.MustLocalize("artifact.common.group"))

cmd.Flags().StringVar(&opts.version, "version", "", opts.localizer.MustLocalize("artifact.common.custom.version"))
cmd.Flags().StringVar(&opts.name, "name", "", opts.localizer.MustLocalize("artifact.common.custom.name"))
Expand Down Expand Up @@ -133,9 +133,8 @@ func runCreate(opts *options) error {
return err
}

if opts.group == util.DefaultArtifactGroup {
opts.Logger.Info(opts.localizer.MustLocalize("artifact.common.message.no.group", localize.NewEntry("DefaultArtifactGroup", util.DefaultArtifactGroup)))
opts.group = util.DefaultArtifactGroup
if opts.group == registrycmdutil.DefaultArtifactGroup {
opts.Logger.Info(opts.localizer.MustLocalize("registry.artifact.common.message.no.group", localize.NewEntry("DefaultArtifactGroup", registrycmdutil.DefaultArtifactGroup)))
}

var specifiedFile *os.File
Expand Down
8 changes: 3 additions & 5 deletions pkg/cmd/registry/artifact/crud/delete/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"errors"

"github.com/AlecAivazis/survey/v2"
"github.com/redhat-developer/app-services-cli/pkg/cmd/registry/artifact/util"
"github.com/redhat-developer/app-services-cli/pkg/cmd/registry/registrycmdutil"
"github.com/redhat-developer/app-services-cli/pkg/core/cmdutil/flagutil"
"github.com/redhat-developer/app-services-cli/pkg/core/config"
Expand Down Expand Up @@ -74,7 +73,7 @@ func NewDeleteCommand(f *factory.Factory) *cobra.Command {

cmd.Flags().BoolVarP(&opts.force, "yes", "y", false, opts.localizer.MustLocalize("artifact.common.delete.without.prompt"))
cmd.Flags().StringVar(&opts.artifact, "artifact-id", "", opts.localizer.MustLocalize("artifact.common.id"))
cmd.Flags().StringVarP(&opts.group, "group", "g", util.DefaultArtifactGroup, opts.localizer.MustLocalize("artifact.common.group"))
cmd.Flags().StringVarP(&opts.group, "group", "g", registrycmdutil.DefaultArtifactGroup, opts.localizer.MustLocalize("artifact.common.group"))
cmd.Flags().StringVar(&opts.registryID, "instance-id", "", opts.localizer.MustLocalize("artifact.common.registryIdToUse"))
flagutil.EnableOutputFlagCompletion(cmd)

Expand All @@ -92,9 +91,8 @@ func runDelete(opts *options) error {
return err
}

if opts.group == util.DefaultArtifactGroup {
opts.Logger.Info(opts.localizer.MustLocalize("artifact.common.message.no.group", localize.NewEntry("DefaultArtifactGroup", util.DefaultArtifactGroup)))
opts.group = util.DefaultArtifactGroup
if opts.group == registrycmdutil.DefaultArtifactGroup {
opts.Logger.Info(opts.localizer.MustLocalize("registry.artifact.common.message.no.group", localize.NewEntry("DefaultArtifactGroup", registrycmdutil.DefaultArtifactGroup)))
}

if opts.artifact == "" {
Expand Down
8 changes: 3 additions & 5 deletions pkg/cmd/registry/artifact/crud/get/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"io/ioutil"
"os"

"github.com/redhat-developer/app-services-cli/pkg/cmd/registry/artifact/util"
"github.com/redhat-developer/app-services-cli/pkg/cmd/registry/registrycmdutil"
"github.com/redhat-developer/app-services-cli/pkg/core/cmdutil/flagutil"
"github.com/redhat-developer/app-services-cli/pkg/core/config"
Expand Down Expand Up @@ -77,7 +76,7 @@ func NewGetCommand(f *factory.Factory) *cobra.Command {
}

cmd.Flags().StringVar(&opts.artifact, "artifact-id", "", opts.localizer.MustLocalize("artifact.common.id"))
cmd.Flags().StringVarP(&opts.group, "group", "g", util.DefaultArtifactGroup, opts.localizer.MustLocalize("artifact.common.group"))
cmd.Flags().StringVarP(&opts.group, "group", "g", registrycmdutil.DefaultArtifactGroup, opts.localizer.MustLocalize("artifact.common.group"))
cmd.Flags().StringVar(&opts.registryID, "instance-id", "", opts.localizer.MustLocalize("registry.common.flag.instance.id"))
cmd.Flags().StringVar(&opts.outputFile, "output-file", "", opts.localizer.MustLocalize("artifact.common.message.file.location"))
cmd.Flags().StringVar(&opts.version, "version", "", opts.localizer.MustLocalize("artifact.common.version"))
Expand All @@ -98,9 +97,8 @@ func runGet(opts *options) error {
return err
}

if opts.group == util.DefaultArtifactGroup {
opts.Logger.Info(opts.localizer.MustLocalize("artifact.common.message.no.group", localize.NewEntry("DefaultArtifactGroup", util.DefaultArtifactGroup)))
opts.group = util.DefaultArtifactGroup
if opts.group == registrycmdutil.DefaultArtifactGroup {
opts.Logger.Info(opts.localizer.MustLocalize("registry.artifact.common.message.no.group", localize.NewEntry("DefaultArtifactGroup", registrycmdutil.DefaultArtifactGroup)))
}

var dataFile *os.File
Expand Down
8 changes: 3 additions & 5 deletions pkg/cmd/registry/artifact/crud/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package list
import (
"context"

"github.com/redhat-developer/app-services-cli/pkg/cmd/registry/artifact/util"
"github.com/redhat-developer/app-services-cli/pkg/cmd/registry/registrycmdutil"

"github.com/redhat-developer/app-services-cli/pkg/core/cmdutil/flagutil"
Expand Down Expand Up @@ -102,7 +101,7 @@ func NewListCommand(f *factory.Factory) *cobra.Command {
},
}

cmd.Flags().StringVarP(&opts.group, "group", "g", util.DefaultArtifactGroup, opts.localizer.MustLocalize("artifact.common.group"))
cmd.Flags().StringVarP(&opts.group, "group", "g", registrycmdutil.DefaultArtifactGroup, opts.localizer.MustLocalize("artifact.common.group"))
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 @@ -120,9 +119,8 @@ func NewListCommand(f *factory.Factory) *cobra.Command {
}

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

conn, err := opts.Connection(connection.DefaultConfigRequireMasAuth)
Expand Down
8 changes: 4 additions & 4 deletions pkg/cmd/registry/artifact/crud/update/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"os"

"github.com/redhat-developer/app-services-cli/pkg/cmd/registry/artifact/util"
"github.com/redhat-developer/app-services-cli/pkg/cmd/registry/registrycmdutil"
"github.com/redhat-developer/app-services-cli/pkg/core/cmdutil/flagutil"
"github.com/redhat-developer/app-services-cli/pkg/core/config"
"github.com/redhat-developer/app-services-cli/pkg/core/ioutil/iostreams"
Expand Down Expand Up @@ -84,7 +85,7 @@ func NewUpdateCommand(f *factory.Factory) *cobra.Command {
cmd.Flags().StringVarP(&opts.file, "file", "f", "", opts.localizer.MustLocalize("artifact.common.file.location"))

cmd.Flags().StringVar(&opts.artifact, "artifact-id", "", opts.localizer.MustLocalize("artifact.common.id"))
cmd.Flags().StringVarP(&opts.group, "group", "g", util.DefaultArtifactGroup, opts.localizer.MustLocalize("artifact.common.group"))
cmd.Flags().StringVarP(&opts.group, "group", "g", registrycmdutil.DefaultArtifactGroup, opts.localizer.MustLocalize("artifact.common.group"))
cmd.Flags().StringVar(&opts.registryID, "instance-id", "", opts.localizer.MustLocalize("registry.common.flag.instance.id"))

cmd.Flags().StringVar(&opts.version, "version", "", opts.localizer.MustLocalize("artifact.common.custom.version"))
Expand All @@ -107,9 +108,8 @@ func runUpdate(opts *options) error {
return err
}

if opts.group == util.DefaultArtifactGroup {
opts.Logger.Info(opts.localizer.MustLocalize("artifact.common.message.no.group", localize.NewEntry("DefaultArtifactGroup", util.DefaultArtifactGroup)))
opts.group = util.DefaultArtifactGroup
if opts.group == registrycmdutil.DefaultArtifactGroup {
opts.Logger.Info(opts.localizer.MustLocalize("registry.artifact.common.message.no.group", localize.NewEntry("DefaultArtifactGroup", registrycmdutil.DefaultArtifactGroup)))
}

var specifiedFile *os.File
Expand Down
8 changes: 3 additions & 5 deletions pkg/cmd/registry/artifact/download/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"io/ioutil"
"os"

"github.com/redhat-developer/app-services-cli/pkg/cmd/registry/artifact/util"
"github.com/redhat-developer/app-services-cli/pkg/cmd/registry/registrycmdutil"
"github.com/redhat-developer/app-services-cli/pkg/core/cmdutil/flagutil"
"github.com/redhat-developer/app-services-cli/pkg/core/config"
Expand Down Expand Up @@ -77,7 +76,7 @@ func NewDownloadCommand(f *factory.Factory) *cobra.Command {
},
}

cmd.Flags().StringVarP(&opts.group, "group", "g", util.DefaultArtifactGroup, opts.localizer.MustLocalize("artifact.common.group"))
cmd.Flags().StringVarP(&opts.group, "group", "g", registrycmdutil.DefaultArtifactGroup, opts.localizer.MustLocalize("artifact.common.group"))
cmd.Flags().StringVar(&opts.hash, "hash", "", opts.localizer.MustLocalize("artifact.common.sha"))
cmd.Flags().Int64VarP(&opts.globalId, "global-id", "", unusedFlagIdValue, opts.localizer.MustLocalize("artifact.common.global.id"))
cmd.Flags().Int64VarP(&opts.contentId, "content-id", "", unusedFlagIdValue, opts.localizer.MustLocalize("artifact.common.content.id"))
Expand All @@ -101,9 +100,8 @@ func runGet(opts *options) error {
return err
}

if opts.group == util.DefaultArtifactGroup {
opts.Logger.Info(opts.localizer.MustLocalize("artifact.common.message.no.group", localize.NewEntry("DefaultArtifactGroup", util.DefaultArtifactGroup)))
opts.group = util.DefaultArtifactGroup
if opts.group == registrycmdutil.DefaultArtifactGroup {
opts.Logger.Info(opts.localizer.MustLocalize("registry.artifact.common.message.no.group", localize.NewEntry("DefaultArtifactGroup", registrycmdutil.DefaultArtifactGroup)))
}

opts.Logger.Info(opts.localizer.MustLocalize("artifact.common.message.fetching.artifact"))
Expand Down
7 changes: 3 additions & 4 deletions pkg/cmd/registry/artifact/metadata/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func NewGetMetadataCommand(f *factory.Factory) *cobra.Command {
}

cmd.Flags().StringVar(&opts.artifact, "artifact-id", "", opts.localizer.MustLocalize("artifact.common.id"))
cmd.Flags().StringVarP(&opts.group, "group", "g", util.DefaultArtifactGroup, opts.localizer.MustLocalize("artifact.common.group"))
cmd.Flags().StringVarP(&opts.group, "group", "g", registrycmdutil.DefaultArtifactGroup, opts.localizer.MustLocalize("artifact.common.group"))
cmd.Flags().StringVar(&opts.registryID, "instance-id", "", opts.localizer.MustLocalize("registry.common.flag.instance.id"))
cmd.Flags().StringVarP(&opts.outputFormat, "output", "o", "", opts.localizer.MustLocalize("artifact.common.message.output.format"))

Expand All @@ -101,9 +101,8 @@ func runGet(opts *GetOptions) error {
return err
}

if opts.group == util.DefaultArtifactGroup {
opts.Logger.Info(opts.localizer.MustLocalize("artifact.common.message.no.group", localize.NewEntry("DefaultArtifactGroup", util.DefaultArtifactGroup)))
opts.group = util.DefaultArtifactGroup
if opts.group == registrycmdutil.DefaultArtifactGroup {
opts.Logger.Info(opts.localizer.MustLocalize("registry.artifact.common.message.no.group", localize.NewEntry("DefaultArtifactGroup", registrycmdutil.DefaultArtifactGroup)))
}

opts.Logger.Info(opts.localizer.MustLocalize("artifact.common.message.artifact.metadata.fetching"))
Expand Down
8 changes: 3 additions & 5 deletions pkg/cmd/registry/artifact/metadata/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"encoding/json"

"github.com/redhat-developer/app-services-cli/pkg/cmd/registry/artifact/util"
"github.com/redhat-developer/app-services-cli/pkg/cmd/registry/registrycmdutil"
"github.com/redhat-developer/app-services-cli/pkg/core/cmdutil/flagutil"
"github.com/redhat-developer/app-services-cli/pkg/core/config"
Expand Down Expand Up @@ -84,7 +83,7 @@ func NewSetMetadataCommand(f *factory.Factory) *cobra.Command {
}

cmd.Flags().StringVar(&opts.artifact, "artifact-id", "", opts.localizer.MustLocalize("artifact.common.id"))
cmd.Flags().StringVarP(&opts.group, "group", "g", util.DefaultArtifactGroup, opts.localizer.MustLocalize("artifact.common.group"))
cmd.Flags().StringVarP(&opts.group, "group", "g", registrycmdutil.DefaultArtifactGroup, opts.localizer.MustLocalize("artifact.common.group"))
cmd.Flags().StringVar(&opts.registryID, "instance-id", "", opts.localizer.MustLocalize("registry.common.flag.instance.id"))
cmd.Flags().StringVarP(&opts.outputFormat, "output", "o", "", opts.localizer.MustLocalize("artifact.common.message.output.format"))

Expand All @@ -107,9 +106,8 @@ func runSet(opts *SetOptions) error {
return err
}

if opts.group == util.DefaultArtifactGroup {
opts.Logger.Info(opts.localizer.MustLocalize("artifact.common.message.no.group", localize.NewEntry("DefaultArtifactGroup", util.DefaultArtifactGroup)))
opts.group = util.DefaultArtifactGroup
if opts.group == registrycmdutil.DefaultArtifactGroup {
opts.Logger.Info(opts.localizer.MustLocalize("registry.artifact.common.message.no.group", localize.NewEntry("DefaultArtifactGroup", registrycmdutil.DefaultArtifactGroup)))
}

opts.Logger.Info(opts.localizer.MustLocalize("artifact.common.message.artifact.metadata.fetching"))
Expand Down
7 changes: 3 additions & 4 deletions pkg/cmd/registry/artifact/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func NewSetStateCommand(f *factory.Factory) *cobra.Command {
}

cmd.Flags().StringVar(&opts.artifact, "artifact-id", "", opts.localizer.MustLocalize("artifact.common.id"))
cmd.Flags().StringVarP(&opts.group, "group", "g", util.DefaultArtifactGroup, opts.localizer.MustLocalize("artifact.common.group"))
cmd.Flags().StringVarP(&opts.group, "group", "g", registrycmdutil.DefaultArtifactGroup, opts.localizer.MustLocalize("artifact.common.group"))
cmd.Flags().StringVar(&opts.registryID, "instance-id", "", opts.localizer.MustLocalize("registry.common.flag.instance.id"))
cmd.Flags().StringVar(&opts.state, "state", "", opts.localizer.MustLocalize("artifact.flag.state.description"))

Expand All @@ -99,9 +99,8 @@ func runSet(opts *options) error {
return err
}

if opts.group == util.DefaultArtifactGroup {
opts.Logger.Info(opts.localizer.MustLocalize("artifact.common.message.no.group", localize.NewEntry("DefaultArtifactGroup", util.DefaultArtifactGroup)))
opts.group = util.DefaultArtifactGroup
if opts.group == registrycmdutil.DefaultArtifactGroup {
opts.Logger.Info(opts.localizer.MustLocalize("registry.artifact.common.message.no.group", localize.NewEntry("DefaultArtifactGroup", registrycmdutil.DefaultArtifactGroup)))
}

updateState, err := registryinstanceclient.NewArtifactStateFromValue(opts.state)
Expand Down
2 changes: 0 additions & 2 deletions pkg/cmd/registry/artifact/util/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"strings"
)

const DefaultArtifactGroup = "default"

var AllowedArtifactTypeEnumValues = []string{
"AVRO",
"PROTOBUF",
Expand Down
3 changes: 2 additions & 1 deletion pkg/cmd/registry/artifact/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package util
import (
"fmt"

"github.com/redhat-developer/app-services-cli/pkg/cmd/registry/registrycmdutil"
registryinstanceclient "github.com/redhat-developer/app-services-sdk-go/registryinstance/apiv1internal/client"
registrymgmtclient "github.com/redhat-developer/app-services-sdk-go/registrymgmt/apiv1/client"
)
Expand All @@ -13,7 +14,7 @@ func GetArtifactURL(registry *registrymgmtclient.Registry, metadata *registryins
group := metadata.GetGroupId()

if group == "" {
group = DefaultArtifactGroup
group = registrycmdutil.DefaultArtifactGroup
}

homeURL, ok := registry.GetBrowserUrlOk()
Expand Down
Loading

0 comments on commit 22c2689

Please sign in to comment.