Skip to content

Commit

Permalink
restrict cluster and environment flags to cloud (#1193)
Browse files Browse the repository at this point in the history
  • Loading branch information
brianstrauch committed Feb 16, 2022
1 parent cde0fd2 commit 5de0b4a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 15 deletions.
7 changes: 4 additions & 3 deletions internal/cmd/kafka/command_link_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,14 @@ func (c *linkCommand) newCreateCommand() *cobra.Command {
cmd.Flags().Bool(dryrunFlagName, false, "DEPRECATED: Validate a link, but do not create it (this flag is no longer active).")
cmd.Flags().Bool(noValidateFlagName, false, "DEPRECATED: Create a link even if the source cluster cannot be reached (this flag is no longer active).")

if c.cfg.IsOnPremLogin() {
if c.cfg.IsCloudLogin() {
pcmd.AddClusterFlag(cmd, c.AuthenticatedCLICommand)
pcmd.AddEnvironmentFlag(cmd, c.AuthenticatedCLICommand)
} else {
cmd.Flags().AddFlagSet(pcmd.OnPremKafkaRestSet())
}

pcmd.AddClusterFlag(cmd, c.AuthenticatedCLICommand)
pcmd.AddContextFlag(cmd, c.CLICommand)
pcmd.AddEnvironmentFlag(cmd, c.AuthenticatedCLICommand)

if c.cfg.IsCloudLogin() {
_ = cmd.MarkFlagRequired(sourceBootstrapServerFlagName)
Expand Down
7 changes: 4 additions & 3 deletions internal/cmd/kafka/command_link_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ func (c *linkCommand) newDeleteCommand() *cobra.Command {
RunE: c.delete,
}

if c.cfg.IsOnPremLogin() {
if c.cfg.IsCloudLogin() {
pcmd.AddClusterFlag(cmd, c.AuthenticatedCLICommand)
pcmd.AddEnvironmentFlag(cmd, c.AuthenticatedCLICommand)
} else {
cmd.Flags().AddFlagSet(pcmd.OnPremKafkaRestSet())
}

pcmd.AddClusterFlag(cmd, c.AuthenticatedCLICommand)
pcmd.AddContextFlag(cmd, c.CLICommand)
pcmd.AddEnvironmentFlag(cmd, c.AuthenticatedCLICommand)

return cmd
}
Expand Down
7 changes: 4 additions & 3 deletions internal/cmd/kafka/command_link_describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ func (c *linkCommand) newDescribeCommand() *cobra.Command {
RunE: c.describe,
}

if c.cfg.IsOnPremLogin() {
if c.cfg.IsCloudLogin() {
pcmd.AddClusterFlag(cmd, c.AuthenticatedCLICommand)
pcmd.AddEnvironmentFlag(cmd, c.AuthenticatedCLICommand)
} else {
cmd.Flags().AddFlagSet(pcmd.OnPremKafkaRestSet())
}

pcmd.AddClusterFlag(cmd, c.AuthenticatedCLICommand)
pcmd.AddContextFlag(cmd, c.CLICommand)
pcmd.AddEnvironmentFlag(cmd, c.AuthenticatedCLICommand)
pcmd.AddOutputFlag(cmd)

return cmd
Expand Down
7 changes: 4 additions & 3 deletions internal/cmd/kafka/command_link_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,14 @@ func (c *linkCommand) newListCommand() *cobra.Command {

cmd.Flags().Bool(includeTopicsFlagName, false, "If set, will list mirrored topics for the links returned.")

if c.cfg.IsOnPremLogin() {
if c.cfg.IsCloudLogin() {
pcmd.AddClusterFlag(cmd, c.AuthenticatedCLICommand)
pcmd.AddEnvironmentFlag(cmd, c.AuthenticatedCLICommand)
} else {
cmd.Flags().AddFlagSet(pcmd.OnPremKafkaRestSet())
}

pcmd.AddClusterFlag(cmd, c.AuthenticatedCLICommand)
pcmd.AddContextFlag(cmd, c.CLICommand)
pcmd.AddEnvironmentFlag(cmd, c.AuthenticatedCLICommand)
pcmd.AddOutputFlag(cmd)

return cmd
Expand Down
7 changes: 4 additions & 3 deletions internal/cmd/kafka/command_link_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ func (c *linkCommand) newUpdateCommand() *cobra.Command {
cmd.Flags().String(configFileFlagName, "", "Name of the file containing link config overrides. "+
"Each property key-value pair should have the format of key=value. Properties are separated by new-line characters.")

if c.cfg.IsOnPremLogin() {
if c.cfg.IsCloudLogin() {
pcmd.AddClusterFlag(cmd, c.AuthenticatedCLICommand)
pcmd.AddEnvironmentFlag(cmd, c.AuthenticatedCLICommand)
} else {
cmd.Flags().AddFlagSet(pcmd.OnPremKafkaRestSet())
}

pcmd.AddClusterFlag(cmd, c.AuthenticatedCLICommand)
pcmd.AddContextFlag(cmd, c.CLICommand)
pcmd.AddEnvironmentFlag(cmd, c.AuthenticatedCLICommand)

_ = cmd.MarkFlagRequired(configFileFlagName)

Expand Down

0 comments on commit 5de0b4a

Please sign in to comment.