@@ -19,6 +19,7 @@ import (
19
19
"context"
20
20
"fmt"
21
21
"os"
22
+ "strings"
22
23
23
24
"github.com/litmuschaos/litmusctl/pkg/apis"
24
25
"github.com/litmuschaos/litmusctl/pkg/completion"
@@ -27,9 +28,9 @@ import (
27
28
)
28
29
29
30
// createCmd represents the create command
30
- var agentCmd = & cobra.Command {
31
- Use : "chaos-delegate " ,
32
- Short : `Upgrades the LitmusChaos agent plane.` ,
31
+ var infraCmd = & cobra.Command {
32
+ Use : "chaos-infra " ,
33
+ Short : `Upgrades the LitmusChaos Execution plane.` ,
33
34
Run : func (cmd * cobra.Command , args []string ) {
34
35
credentials , err := utils .GetCredentials (cmd )
35
36
utils .PrintError (err )
@@ -42,32 +43,36 @@ var agentCmd = &cobra.Command{
42
43
fmt .Scanln (& projectID )
43
44
}
44
45
45
- cluster_id , err := cmd .Flags ().GetString ("chaos-delegate -id" )
46
+ infraID , err := cmd .Flags ().GetString ("chaos-infra -id" )
46
47
utils .PrintError (err )
47
48
48
- if cluster_id == "" {
49
- utils .White_B .Print ("\n Enter the Chaos Delegate ID: " )
50
- fmt .Scanln (& cluster_id )
49
+ if infraID == "" {
50
+ utils .White_B .Print ("\n Enter the Chaos Infra ID: " )
51
+ fmt .Scanln (& infraID )
51
52
}
52
53
53
54
kubeconfig , err := cmd .Flags ().GetString ("kubeconfig" )
54
55
utils .PrintError (err )
55
56
56
- output , err := apis .UpgradeInfra (context .Background (), credentials , projectID , cluster_id , kubeconfig )
57
+ output , err := apis .UpgradeInfra (context .Background (), credentials , projectID , infraID , kubeconfig )
57
58
if err != nil {
58
- utils .Red .Print ("\n ❌ Failed upgrading Chaos Delegate: \n " + err .Error () + "\n " )
59
+ if strings .Contains (err .Error (), "no documents in result" ) {
60
+ utils .Red .Println ("❌ The specified Project ID or Chaos Infrastructure ID doesn't exist." )
61
+ os .Exit (1 )
62
+ }
63
+ utils .Red .Print ("\n ❌ Failed upgrading Chaos Infrastructure: \n " + err .Error () + "\n " )
59
64
os .Exit (1 )
60
65
}
61
66
utils .White_B .Print ("\n " , output )
62
67
},
63
68
}
64
69
65
70
func init () {
66
- UpgradeCmd .AddCommand (agentCmd )
67
- agentCmd .Flags ().String ("project-id" , "" , "Enter the project ID" )
68
- agentCmd .Flags ().String ("kubeconfig" , "" , "Enter the kubeconfig path(default: $HOME/.kube/config))" )
69
- agentCmd .Flags ().String ("chaos-delegate-id" , "" , "Enter the Chaos Delegate ID" )
70
-
71
- agentCmd .RegisterFlagCompletionFunc ("project-id" , completion .ProjectIDFlagCompletion )
71
+ UpgradeCmd .AddCommand (infraCmd )
72
+ infraCmd .Flags ().String ("project-id" , "" , "Enter the project ID" )
73
+ infraCmd .Flags ().String ("kubeconfig" , "" , "Enter the kubeconfig path(default: $HOME/.kube/config))" )
74
+ infraCmd .Flags ().String ("chaos-infra-id" , "" , "Enter the Chaos Infrastructure ID" )
72
75
76
+ infraCmd .RegisterFlagCompletionFunc ("project-id" , completion .ProjectIDFlagCompletion )
77
+ infraCmd .RegisterFlagCompletionFunc ("chaos-infra-id" , completion .ChaosInfraFlagCompletion )
73
78
}
0 commit comments