Skip to content

Commit

Permalink
Move command as sync-cloud-resources
Browse files Browse the repository at this point in the history
  • Loading branch information
tirthct committed Oct 4, 2024
1 parent 74d5a8c commit 49dc289
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 27 deletions.
18 changes: 0 additions & 18 deletions cmd/ocm-support/add/cmd.go

This file was deleted.

4 changes: 2 additions & 2 deletions cmd/ocm-support/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package main

import (
"github.com/openshift-online/ocm-support-cli/cmd/ocm-support/add"
"os"
"strings"

Expand All @@ -29,6 +28,7 @@ import (
"github.com/openshift-online/ocm-support-cli/cmd/ocm-support/delete"
"github.com/openshift-online/ocm-support-cli/cmd/ocm-support/get"
"github.com/openshift-online/ocm-support-cli/cmd/ocm-support/patch"
"github.com/openshift-online/ocm-support-cli/cmd/ocm-support/sync-cloud-resources"
"github.com/openshift-online/ocm-support-cli/cmd/ocm-support/version"
)

Expand Down Expand Up @@ -87,7 +87,7 @@ func init() {
rootCmd.AddCommand(get.Cmd)
rootCmd.AddCommand(delete.Cmd)
rootCmd.AddCommand(patch.Cmd)
rootCmd.AddCommand(add.Cmd)
rootCmd.AddCommand(sync_cloud_resources.Cmd)

// Set the log level before each command runs.
cobra.OnInitialize(initLogLevel)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package instances
package sync_cloud_resources

import (
"bytes"
Expand All @@ -12,9 +12,10 @@ import (
)

var Cmd = &cobra.Command{
Use: "instances [branch-name] [csv-path]",
Long: "Add new instances in AMS and generates quota rules for them",
RunE: addInstances,
Use: "sync-cloud-resources [branch-name] [csv-path]",
Short: "Syncs cloud resources in AMS and generates quota rules for them",
Long: "Syncs cloud resources in AMS and generates quota rules for them",
RunE: syncCloudResources,
SilenceUsage: true,
Args: cobra.ExactArgs(2),
}
Expand All @@ -28,7 +29,7 @@ func init() {
flags.BoolVar(&args.dryRun, "dry-run", true, "When true, don't actually take any actions, just print the actions that would be taken")
}

func addInstances(cmd *cobra.Command, argv []string) error {
func syncCloudResources(cmd *cobra.Command, argv []string) error {
branchName := argv[0]
csvPath := argv[1]
if branchName == "" {
Expand Down Expand Up @@ -74,7 +75,7 @@ func addInstances(cmd *cobra.Command, argv []string) error {
return fmt.Errorf("an error occurred while creating a new branch: %v", err)
}

fmt.Println("Replacing instances file")
fmt.Println("Replacing cloud resources file")
err = ReplaceFileContent(fmt.Sprintf("%s/config/quota-cloud-resources.csv", tempDir), csvPath)
if err != nil {
return fmt.Errorf("an error occurred while getting the head of the reference: %v", err)
Expand All @@ -93,7 +94,7 @@ func addInstances(cmd *cobra.Command, argv []string) error {
}

fmt.Println("Committing changes")
err = amsRepo.Commit(fmt.Sprintf("Adding instances and quota rules for %s", branchName))
err = amsRepo.Commit(fmt.Sprintf("Syncinc cloud resources and quota rules for %s", branchName))
if err != nil {
return fmt.Errorf("an error occurred committing the changes: %v", err)
}
Expand Down

0 comments on commit 49dc289

Please sign in to comment.