Move alias CLI under a resource-alias command
Promote the trust-center alias subcommand to a top-level resource-alias command so aliases can be managed for any resource from the CLI. Signed-off-by: Bryan Frimin <bryan@probo.com>
This commit is contained in:
@@ -24,8 +24,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const removeMutation = `
|
const removeMutation = `
|
||||||
mutation($input: RemoveTrustCenterAliasInput!) {
|
mutation($input: RemoveResourceAliasInput!) {
|
||||||
removeTrustCenterAlias(input: $input) {
|
removeResourceAlias(input: $input) {
|
||||||
deletedResourceId
|
deletedResourceId
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -36,7 +36,7 @@ func NewCmdRemove(f *cmdutil.Factory) *cobra.Command {
|
|||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "remove <resource-id>",
|
Use: "remove <resource-id>",
|
||||||
Short: "Remove a trust center alias",
|
Short: "Remove a resource alias",
|
||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.ExactArgs(1),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
if !flagYes {
|
if !flagYes {
|
||||||
@@ -12,19 +12,20 @@
|
|||||||
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
// PERFORMANCE OF THIS SOFTWARE.
|
// PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
package alias
|
package resourcealias
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"go.probo.inc/probo/pkg/cmd/cmdutil"
|
"go.probo.inc/probo/pkg/cmd/cmdutil"
|
||||||
"go.probo.inc/probo/pkg/cmd/trust-center/alias/remove"
|
"go.probo.inc/probo/pkg/cmd/resource-alias/remove"
|
||||||
"go.probo.inc/probo/pkg/cmd/trust-center/alias/set"
|
"go.probo.inc/probo/pkg/cmd/resource-alias/set"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewCmdAlias(f *cmdutil.Factory) *cobra.Command {
|
func NewCmdResourceAlias(f *cmdutil.Factory) *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "alias <command>",
|
Use: "resource-alias <command>",
|
||||||
Short: "Manage trust center aliases",
|
Short: "Manage resource aliases",
|
||||||
|
Aliases: []string{"ra"},
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.AddCommand(set.NewCmdSet(f))
|
cmd.AddCommand(set.NewCmdSet(f))
|
||||||
@@ -25,9 +25,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const setMutation = `
|
const setMutation = `
|
||||||
mutation($input: SetTrustCenterAliasInput!) {
|
mutation($input: SetResourceAliasInput!) {
|
||||||
setTrustCenterAlias(input: $input) {
|
setResourceAlias(input: $input) {
|
||||||
alias {
|
resourceAlias {
|
||||||
resourceId
|
resourceId
|
||||||
alias
|
alias
|
||||||
}
|
}
|
||||||
@@ -36,12 +36,12 @@ mutation($input: SetTrustCenterAliasInput!) {
|
|||||||
`
|
`
|
||||||
|
|
||||||
type setResponse struct {
|
type setResponse struct {
|
||||||
SetTrustCenterAlias struct {
|
SetResourceAlias struct {
|
||||||
Alias struct {
|
ResourceAlias struct {
|
||||||
ResourceID string `json:"resourceId"`
|
ResourceID string `json:"resourceId"`
|
||||||
Alias string `json:"alias"`
|
Alias string `json:"alias"`
|
||||||
} `json:"alias"`
|
} `json:"resourceAlias"`
|
||||||
} `json:"setTrustCenterAlias"`
|
} `json:"setResourceAlias"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCmdSet(f *cmdutil.Factory) *cobra.Command {
|
func NewCmdSet(f *cmdutil.Factory) *cobra.Command {
|
||||||
@@ -52,12 +52,12 @@ func NewCmdSet(f *cmdutil.Factory) *cobra.Command {
|
|||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "set",
|
Use: "set",
|
||||||
Short: "Set a trust center alias",
|
Short: "Set a resource alias",
|
||||||
Example: ` # Set an alias interactively
|
Example: ` # Set an alias interactively
|
||||||
prb trust-center alias set --resource-id prbdoc_...
|
prb resource-alias set --resource-id prbdoc_...
|
||||||
|
|
||||||
# Set an alias non-interactively
|
# Set an alias non-interactively
|
||||||
prb trust-center alias set --resource-id prbdoc_... --alias privacy-policy`,
|
prb resource-alias set --resource-id prbdoc_... --alias privacy-policy`,
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
cfg, err := f.Config()
|
cfg, err := f.Config()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -80,7 +80,7 @@ func NewCmdSet(f *cmdutil.Factory) *cobra.Command {
|
|||||||
if f.IOStreams.IsInteractive() {
|
if f.IOStreams.IsInteractive() {
|
||||||
if flagResourceID == "" {
|
if flagResourceID == "" {
|
||||||
err := huh.NewInput().
|
err := huh.NewInput().
|
||||||
Title("Resource ID (document, file, or audit)").
|
Title("Resource ID").
|
||||||
Value(&flagResourceID).
|
Value(&flagResourceID).
|
||||||
Run()
|
Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -125,7 +125,7 @@ func NewCmdSet(f *cmdutil.Factory) *cobra.Command {
|
|||||||
return fmt.Errorf("cannot parse response: %w", err)
|
return fmt.Errorf("cannot parse response: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
a := resp.SetTrustCenterAlias.Alias
|
a := resp.SetResourceAlias.ResourceAlias
|
||||||
_, _ = fmt.Fprintf(
|
_, _ = fmt.Fprintf(
|
||||||
f.IOStreams.Out,
|
f.IOStreams.Out,
|
||||||
"Set alias %q for resource %s\n",
|
"Set alias %q for resource %s\n",
|
||||||
@@ -137,7 +137,7 @@ func NewCmdSet(f *cmdutil.Factory) *cobra.Command {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Flags().StringVar(&flagResourceID, "resource-id", "", "Document, trust center file, or audit ID")
|
cmd.Flags().StringVar(&flagResourceID, "resource-id", "", "ID of the resource to alias")
|
||||||
cmd.Flags().StringVar(&flagAlias, "alias", "", "Human-readable alias slug")
|
cmd.Flags().StringVar(&flagAlias, "alias", "", "Human-readable alias slug")
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
@@ -41,6 +41,7 @@ import (
|
|||||||
"go.probo.inc/probo/pkg/cmd/obligation"
|
"go.probo.inc/probo/pkg/cmd/obligation"
|
||||||
"go.probo.inc/probo/pkg/cmd/org"
|
"go.probo.inc/probo/pkg/cmd/org"
|
||||||
processingactivity "go.probo.inc/probo/pkg/cmd/processing-activity"
|
processingactivity "go.probo.inc/probo/pkg/cmd/processing-activity"
|
||||||
|
resourcealias "go.probo.inc/probo/pkg/cmd/resource-alias"
|
||||||
rightsrequest "go.probo.inc/probo/pkg/cmd/rights-request"
|
rightsrequest "go.probo.inc/probo/pkg/cmd/rights-request"
|
||||||
"go.probo.inc/probo/pkg/cmd/risk"
|
"go.probo.inc/probo/pkg/cmd/risk"
|
||||||
riskassessment "go.probo.inc/probo/pkg/cmd/risk-assessment"
|
riskassessment "go.probo.inc/probo/pkg/cmd/risk-assessment"
|
||||||
@@ -118,6 +119,7 @@ func NewCmdRoot(f *cmdutil.Factory) *cobra.Command {
|
|||||||
cmd.AddCommand(rightsrequest.NewCmdRightsRequest(f))
|
cmd.AddCommand(rightsrequest.NewCmdRightsRequest(f))
|
||||||
cmd.AddCommand(risk.NewCmdRisk(f))
|
cmd.AddCommand(risk.NewCmdRisk(f))
|
||||||
cmd.AddCommand(riskassessment.NewCmdRiskAssessment(f))
|
cmd.AddCommand(riskassessment.NewCmdRiskAssessment(f))
|
||||||
|
cmd.AddCommand(resourcealias.NewCmdResourceAlias(f))
|
||||||
cmd.AddCommand(scim.NewCmdScim(f))
|
cmd.AddCommand(scim.NewCmdScim(f))
|
||||||
cmd.AddCommand(soa.NewCmdSoa(f))
|
cmd.AddCommand(soa.NewCmdSoa(f))
|
||||||
cmd.AddCommand(task.NewCmdTask(f))
|
cmd.AddCommand(task.NewCmdTask(f))
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ package trustcenter
|
|||||||
import (
|
import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"go.probo.inc/probo/pkg/cmd/cmdutil"
|
"go.probo.inc/probo/pkg/cmd/cmdutil"
|
||||||
"go.probo.inc/probo/pkg/cmd/trust-center/alias"
|
|
||||||
"go.probo.inc/probo/pkg/cmd/trust-center/file"
|
"go.probo.inc/probo/pkg/cmd/trust-center/file"
|
||||||
"go.probo.inc/probo/pkg/cmd/trust-center/reference"
|
"go.probo.inc/probo/pkg/cmd/trust-center/reference"
|
||||||
"go.probo.inc/probo/pkg/cmd/trust-center/update"
|
"go.probo.inc/probo/pkg/cmd/trust-center/update"
|
||||||
@@ -34,7 +33,6 @@ func NewCmdTrustCenter(f *cmdutil.Factory) *cobra.Command {
|
|||||||
cmd.AddCommand(view.NewCmdView(f))
|
cmd.AddCommand(view.NewCmdView(f))
|
||||||
cmd.AddCommand(update.NewCmdUpdate(f))
|
cmd.AddCommand(update.NewCmdUpdate(f))
|
||||||
cmd.AddCommand(reference.NewCmdReference(f))
|
cmd.AddCommand(reference.NewCmdReference(f))
|
||||||
cmd.AddCommand(alias.NewCmdAlias(f))
|
|
||||||
cmd.AddCommand(file.NewCmdFile(f))
|
cmd.AddCommand(file.NewCmdFile(f))
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|||||||
Reference in New Issue
Block a user