Skip to content

Commit

Permalink
Modify the update methods to accept no arguments, as the current argu…
Browse files Browse the repository at this point in the history
…ments are not utilized by the methods
  • Loading branch information
nikhilsbhat committed Apr 3, 2024
1 parent 5ecea85 commit 1fe7ba6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
6 changes: 3 additions & 3 deletions cmd/agent_profiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func updateAgentProfileCommand() *cobra.Command {
Use: "update",
Short: "Command to UPDATE a elastic agent profile with all specified configurations in GoCD [https://api.gocd.org/current/#update-an-elastic-agent-profile]",
Example: "gocd-cli elastic-agent-profile update sample_ec2 --from-file sample-ec2.yaml --log-level debug",
Args: cobra.RangeArgs(1, 1),
Args: cobra.NoArgs,
PreRunE: setCLIClient,
RunE: func(cmd *cobra.Command, args []string) error {
var commonCfg gocd.CommonConfig
Expand All @@ -184,7 +184,7 @@ func updateAgentProfileCommand() *cobra.Command {
return err
}

cliShellReadConfig.ShellMessage = fmt.Sprintf(updateMessage, "elastic-agent-profile", elasticAgentProfileFetched.Name)
cliShellReadConfig.ShellMessage = fmt.Sprintf(updateMessage, "elastic-agent-profile", elasticAgentProfileFetched.ID)

existing, err := diffCfg.String(elasticAgentProfileFetched)
if err != nil {
Expand All @@ -200,7 +200,7 @@ func updateAgentProfileCommand() *cobra.Command {
return err
}

if err = cliRenderer.Render(fmt.Sprintf("elastic agent profile %s updated successfully", commonCfg.Name)); err != nil {
if err = cliRenderer.Render(fmt.Sprintf("elastic agent profile %s updated successfully", commonCfg.ID)); err != nil {
return err
}

Expand Down
4 changes: 1 addition & 3 deletions cmd/agents.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func updateAgentCommand() *cobra.Command {
createAgentCmd := &cobra.Command{
Use: "update",
Short: "Command to UPDATE an agent with all specified configuration [https://api.gocd.org/current/#update-an-agent]",
Args: cobra.RangeArgs(1, 1),
Args: cobra.NoArgs,
PreRunE: setCLIClient,
RunE: func(cmd *cobra.Command, args []string) error {
var agent gocd.Agent
Expand All @@ -172,8 +172,6 @@ func updateAgentCommand() *cobra.Command {
return &errors.UnknownObjectTypeError{Name: objType}
}

agent.ID = args[0]

agentFetched, err := client.GetAgent(agent.ID)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion cmd/artifacts.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func updateArtifactStoreCommand() *cobra.Command {
updateArtifactsStoreCmd := &cobra.Command{
Use: "update-store",
Short: "Command to UPDATE an artifact store with all specified configurations in GoCD [https://api.gocd.org/current/#update-an-artifact-store]",
Args: cobra.RangeArgs(1, 1),
Args: cobra.NoArgs,
PreRunE: setCLIClient,
RunE: func(cmd *cobra.Command, args []string) error {
var commonCfg gocd.CommonConfig
Expand Down
6 changes: 3 additions & 3 deletions cmd/cluster_profiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func updateClusterProfileCommand() *cobra.Command {
updateClusterProfileCmd := &cobra.Command{
Use: "update",
Short: "Command to UPDATE a cluster profile with all specified configurations in GoCD [https://api.gocd.org/current/#update-a-cluster-profile]",
Args: cobra.RangeArgs(1, 1),
Args: cobra.NoArgs,
PreRunE: setCLIClient,
RunE: func(cmd *cobra.Command, args []string) error {
var commonCfg gocd.CommonConfig
Expand All @@ -178,7 +178,7 @@ func updateClusterProfileCommand() *cobra.Command {
return err
}

cliShellReadConfig.ShellMessage = fmt.Sprintf(updateMessage, "elastic-agent-profile", clusterProfileFetched.Name)
cliShellReadConfig.ShellMessage = fmt.Sprintf(updateMessage, "cluster-profile", clusterProfileFetched.ID)

existing, err := diffCfg.String(clusterProfileFetched)
if err != nil {
Expand All @@ -194,7 +194,7 @@ func updateClusterProfileCommand() *cobra.Command {
return err
}

if err = cliRenderer.Render(fmt.Sprintf("cluster profile %s updated successfully", commonCfg.Name)); err != nil {
if err = cliRenderer.Render(fmt.Sprintf("cluster profile %s updated successfully", commonCfg.ID)); err != nil {
return err
}

Expand Down

0 comments on commit 1fe7ba6

Please sign in to comment.