Skip to content

Commit

Permalink
litmusctl version fix (#20)
Browse files Browse the repository at this point in the history
Signed-off-by: Raj Babu Das <[email protected]>
  • Loading branch information
imrajdas authored Jul 21, 2021
1 parent a58bc76 commit ea4c62c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
5 changes: 2 additions & 3 deletions pkg/agent/ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,9 @@ AGENT_NAME:

if strings.ToLower(nodeSelectorDescision) == "y" {
utils.White_B.Print("\nEnter the NodeSelector (Format: key1=value1,key2=value2): ")
nodeSelector := utils.Scanner()
newAgent.NodeSelector = &nodeSelector
newAgent.NodeSelector = utils.Scanner()

if ok := utils.CheckKeyValueFormat(*newAgent.NodeSelector); !ok {
if ok := utils.CheckKeyValueFormat(newAgent.NodeSelector); !ok {
os.Exit(1)
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ type UserAgentReg struct {
// ConnectAgent connects the agent with the given details
func ConnectAgent(agent types.Agent, cred types.Credentials) (AgentConnectionData, error) {
query := `{"query":"mutation {\n userClusterReg(clusterInput: \n { \n cluster_name: \"` + agent.AgentName + `\", \n description: \"` + agent.Description + `\",\n \tplatform_name: \"` + agent.PlatformName + `\",\n project_id: \"` + agent.ProjectId + `\",\n cluster_type: \"` + agent.ClusterType + `\",\n agent_scope: \"` + agent.Mode + `\",\n agent_namespace: \"` + agent.Namespace + `\",\n serviceaccount: \"` + agent.ServiceAccount + `\",\n agent_ns_exists: ` + fmt.Sprintf("%t", agent.NsExists) + `,\n agent_sa_exists: ` + fmt.Sprintf("%t", agent.SAExists) + `,\n }){\n cluster_id\n cluster_name\n token\n }\n}"}`
if *agent.NodeSelector != "" {
query = `{"query":"mutation {\n userClusterReg(clusterInput: \n { \n cluster_name: \"` + agent.AgentName + `\", \n description: \"` + agent.Description + `\",\n node_selector: \"` + *agent.NodeSelector + `\",\n \tplatform_name: \"` + agent.PlatformName + `\",\n project_id: \"` + agent.ProjectId + `\",\n cluster_type: \"` + agent.ClusterType + `\",\n agent_scope: \"` + agent.Mode + `\",\n agent_namespace: \"` + agent.Namespace + `\",\n serviceaccount: \"` + agent.ServiceAccount + `\",\n agent_ns_exists: ` + fmt.Sprintf("%t", agent.NsExists) + `,\n agent_sa_exists: ` + fmt.Sprintf("%t", agent.SAExists) + `,\n }){\n cluster_id\n cluster_name\n token\n }\n}"}`
if agent.NodeSelector != "" {
query = `{"query":"mutation {\n userClusterReg(clusterInput: \n { \n cluster_name: \"` + agent.AgentName + `\", \n description: \"` + agent.Description + `\",\n node_selector: \"` + agent.NodeSelector + `\",\n \tplatform_name: \"` + agent.PlatformName + `\",\n project_id: \"` + agent.ProjectId + `\",\n cluster_type: \"` + agent.ClusterType + `\",\n agent_scope: \"` + agent.Mode + `\",\n agent_namespace: \"` + agent.Namespace + `\",\n serviceaccount: \"` + agent.ServiceAccount + `\",\n agent_ns_exists: ` + fmt.Sprintf("%t", agent.NsExists) + `,\n agent_sa_exists: ` + fmt.Sprintf("%t", agent.SAExists) + `,\n }){\n cluster_id\n cluster_name\n token\n }\n}"}`
}

resp, err := SendRequest(SendRequestParams{Endpoint: cred.Endpoint + utils.GQLAPIPath, Token: cred.Token}, []byte(query))
Expand Down
7 changes: 3 additions & 4 deletions pkg/cmd/create/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,10 @@ var agentCmd = &cobra.Command{
os.Exit(1)
}

nodeSelector, err := cmd.Flags().GetString("node-selector")
newAgent.NodeSelector = &nodeSelector
newAgent.NodeSelector, err = cmd.Flags().GetString("node-selector")
utils.PrintError(err)
if *newAgent.NodeSelector != "" {
if ok := utils.CheckKeyValueFormat(*newAgent.NodeSelector); !ok {
if newAgent.NodeSelector != "" {
if ok := utils.CheckKeyValueFormat(newAgent.NodeSelector); !ok {
os.Exit(1)
}
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/types/agent_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ package types
type Agent struct {
AgentName string `json:"cluster_name"`
Mode string
Description string `json:"description,omitempty"`
PlatformName string `json:"platform_name"`
ProjectId string `json:"project_id"`
ClusterType string `json:"cluster_type"`
NodeSelector *string `json:"node_selector"`
Description string `json:"description,omitempty"`
PlatformName string `json:"platform_name"`
ProjectId string `json:"project_id"`
ClusterType string `json:"cluster_type"`
NodeSelector string `json:"node_selector"`
Namespace string
ServiceAccount string
NsExists bool
Expand Down

0 comments on commit ea4c62c

Please sign in to comment.