Skip to content

Commit

Permalink
Fix merge conflicts
Browse files Browse the repository at this point in the history
Signed-off-by: Rémi ZIOLKOWSKI <[email protected]>
  • Loading branch information
Vr00mm committed Oct 17, 2023
1 parent 14452c2 commit 85aa426
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
5 changes: 3 additions & 2 deletions pkg/cmd/create/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ package create

import (
"fmt"

"os"

models "github.com/litmuschaos/litmus/chaoscenter/graphql/server/graph/model"
"github.com/litmuschaos/litmusctl/pkg/apis"
"github.com/litmuschaos/litmusctl/pkg/apis/environment"
"github.com/litmuschaos/litmusctl/pkg/completion"
"github.com/litmuschaos/litmusctl/pkg/ops"
"github.com/litmuschaos/litmusctl/pkg/infra_ops"
"github.com/litmuschaos/litmusctl/pkg/utils"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -111,7 +112,7 @@ var environmentCmd = &cobra.Command{
}
if isEnvExist {
utils.Red.Println("\nChaos Environment with the given ID already exists, try with a different name")
ops.PrintExistingEnvironments(envs)
infra_ops.PrintExistingEnvironments(envs)
os.Exit(1)
}

Expand Down
35 changes: 20 additions & 15 deletions pkg/cmd/upgrade/agent.go → pkg/cmd/upgrade/infra.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"context"
"fmt"
"os"
"strings"

"github.com/litmuschaos/litmusctl/pkg/apis"
"github.com/litmuschaos/litmusctl/pkg/completion"
Expand All @@ -27,9 +28,9 @@ import (
)

// createCmd represents the create command
var agentCmd = &cobra.Command{
Use: "chaos-delegate",
Short: `Upgrades the LitmusChaos agent plane.`,
var infraCmd = &cobra.Command{
Use: "chaos-infra",
Short: `Upgrades the LitmusChaos Execution plane.`,
Run: func(cmd *cobra.Command, args []string) {
credentials, err := utils.GetCredentials(cmd)
utils.PrintError(err)
Expand All @@ -42,32 +43,36 @@ var agentCmd = &cobra.Command{
fmt.Scanln(&projectID)
}

cluster_id, err := cmd.Flags().GetString("chaos-delegate-id")
infraID, err := cmd.Flags().GetString("chaos-infra-id")
utils.PrintError(err)

if cluster_id == "" {
utils.White_B.Print("\nEnter the Chaos Delegate ID: ")
fmt.Scanln(&cluster_id)
if infraID == "" {
utils.White_B.Print("\nEnter the Chaos Infra ID: ")
fmt.Scanln(&infraID)
}

kubeconfig, err := cmd.Flags().GetString("kubeconfig")
utils.PrintError(err)

output, err := apis.UpgradeInfra(context.Background(), credentials, projectID, cluster_id, kubeconfig)
output, err := apis.UpgradeInfra(context.Background(), credentials, projectID, infraID, kubeconfig)
if err != nil {
utils.Red.Print("\n❌ Failed upgrading Chaos Delegate: \n" + err.Error() + "\n")
if strings.Contains(err.Error(), "no documents in result") {
utils.Red.Println("❌ The specified Project ID or Chaos Infrastructure ID doesn't exist.")
os.Exit(1)
}
utils.Red.Print("\n❌ Failed upgrading Chaos Infrastructure: \n" + err.Error() + "\n")
os.Exit(1)
}
utils.White_B.Print("\n", output)
},
}

func init() {
UpgradeCmd.AddCommand(agentCmd)
agentCmd.Flags().String("project-id", "", "Enter the project ID")
agentCmd.Flags().String("kubeconfig", "", "Enter the kubeconfig path(default: $HOME/.kube/config))")
agentCmd.Flags().String("chaos-delegate-id", "", "Enter the Chaos Delegate ID")

agentCmd.RegisterFlagCompletionFunc("project-id", completion.ProjectIDFlagCompletion)
UpgradeCmd.AddCommand(infraCmd)
infraCmd.Flags().String("project-id", "", "Enter the project ID")
infraCmd.Flags().String("kubeconfig", "", "Enter the kubeconfig path(default: $HOME/.kube/config))")
infraCmd.Flags().String("chaos-infra-id", "", "Enter the Chaos Infrastructure ID")

infraCmd.RegisterFlagCompletionFunc("project-id", completion.ProjectIDFlagCompletion)
infraCmd.RegisterFlagCompletionFunc("chaos-infra-id", completion.ChaosInfraFlagCompletion)
}

0 comments on commit 85aa426

Please sign in to comment.