Skip to content

Commit 019f272

Browse files
aljesusgmanusa
andcommitted
Address Marc comments
Signed-off-by: Alberto Gutierrez <[email protected]> Co-authored-by: Marc Nuri <[email protected]>
1 parent bbc1144 commit 019f272

File tree

3 files changed

+52
-26
lines changed

3 files changed

+52
-26
lines changed

pkg/kiali/get_mesh_graph.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ func (k *Kiali) GetMeshGraph(ctx context.Context, namespaces []string, queryPara
3434
Errors: make(map[string]string),
3535
}
3636

37+
var errorsMu sync.Mutex
3738
var wg sync.WaitGroup
3839
wg.Add(4)
3940

@@ -42,7 +43,9 @@ func (k *Kiali) GetMeshGraph(ctx context.Context, namespaces []string, queryPara
4243
defer wg.Done()
4344
data, err := k.getGraph(ctx, cleaned, queryParams)
4445
if err != nil {
46+
errorsMu.Lock()
4547
resp.Errors["graph"] = err.Error()
48+
errorsMu.Unlock()
4649
return
4750
}
4851
resp.Graph = data
@@ -53,7 +56,9 @@ func (k *Kiali) GetMeshGraph(ctx context.Context, namespaces []string, queryPara
5356
defer wg.Done()
5457
data, err := k.getHealth(ctx, cleaned, queryParams)
5558
if err != nil {
59+
errorsMu.Lock()
5660
resp.Errors["health"] = err.Error()
61+
errorsMu.Unlock()
5762
return
5863
}
5964
resp.Health = data
@@ -64,7 +69,9 @@ func (k *Kiali) GetMeshGraph(ctx context.Context, namespaces []string, queryPara
6469
defer wg.Done()
6570
data, err := k.getMeshStatus(ctx)
6671
if err != nil {
72+
errorsMu.Lock()
6773
resp.Errors["mesh_status"] = err.Error()
74+
errorsMu.Unlock()
6875
return
6976
}
7077
resp.MeshStatus = data
@@ -75,7 +82,9 @@ func (k *Kiali) GetMeshGraph(ctx context.Context, namespaces []string, queryPara
7582
defer wg.Done()
7683
data, err := k.getNamespaces(ctx)
7784
if err != nil {
85+
errorsMu.Lock()
7886
resp.Errors["namespaces"] = err.Error()
87+
errorsMu.Unlock()
7988
return
8089
}
8190
resp.Namespaces = data

pkg/toolsets/kiali/get_mesh_graph.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func getMeshGraphHandler(params api.ToolHandlerParams) (*api.ToolCallResult, err
9191
if rateInterval, ok := params.GetArguments()["rateInterval"].(string); ok && rateInterval != "" {
9292
queryParams["rateInterval"] = rateInterval
9393
}
94-
if graphType, ok := params.GetArguments()["graph_type"].(string); ok && graphType != "" {
94+
if graphType, ok := params.GetArguments()["graphType"].(string); ok && graphType != "" {
9595
queryParams["graphType"] = graphType
9696
}
9797
k := params.NewKiali()

pkg/toolsets/kiali/manage_istio_config.go

Lines changed: 42 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ func initManageIstioConfig() []api.ServerTool {
5151
},
5252
Annotations: api.ToolAnnotations{
5353
Title: "Manage Istio Config: List, Get, Create, Patch, Delete",
54-
ReadOnlyHint: ptr.To(true),
55-
DestructiveHint: ptr.To(false),
54+
ReadOnlyHint: ptr.To(false),
55+
DestructiveHint: ptr.To(true),
5656
IdempotentHint: ptr.To(true),
5757
OpenWorldHint: ptr.To(true),
5858
},
@@ -83,35 +83,52 @@ func istioConfigHandler(params api.ToolHandlerParams) (*api.ToolCallResult, erro
8383
// validateIstioConfigInput centralizes validation rules for manage istio config tool.
8484
// Rules:
8585
// - If action is not "list": namespace, group, version, kind are required
86-
// - If action is "create": name and json_data are required
87-
// - If action is "patch": json_data is required
86+
// - If action is "create": json_data are required
87+
// - If action is "patch": name and json_data is required
88+
// - If action is "get": name is required
89+
// - If action is "patch": name is required
8890
func validateIstioConfigInput(action, namespace, group, version, kind, name, jsonData string) error {
89-
if action != "list" {
90-
if namespace == "" {
91-
return fmt.Errorf("namespace is required for action %q", action)
91+
switch action {
92+
case "list", "create", "patch", "get", "delete":
93+
if action != "list" {
94+
if namespace == "" {
95+
return fmt.Errorf("namespace is required for action %q", action)
96+
}
97+
if group == "" {
98+
return fmt.Errorf("group is required for action %q", action)
99+
}
100+
if version == "" {
101+
return fmt.Errorf("version is required for action %q", action)
102+
}
103+
if kind == "" {
104+
return fmt.Errorf("kind is required for action %q", action)
105+
}
92106
}
93-
if group == "" {
94-
return fmt.Errorf("group is required for action %q", action)
107+
if action == "create" {
108+
if jsonData == "" {
109+
return fmt.Errorf("json_data is required for action %q", action)
110+
}
95111
}
96-
if version == "" {
97-
return fmt.Errorf("version is required for action %q", action)
112+
if action == "patch" {
113+
if name == "" {
114+
return fmt.Errorf("name is required for action %q", action)
115+
}
116+
if jsonData == "" {
117+
return fmt.Errorf("json_data is required for action %q", action)
118+
}
98119
}
99-
if kind == "" {
100-
return fmt.Errorf("kind is required for action %q", action)
120+
if action == "get" {
121+
if name == "" {
122+
return fmt.Errorf("name is required for action %q", action)
123+
}
101124
}
102-
}
103-
if action == "create" {
104-
if name == "" {
105-
return fmt.Errorf("name is required for action %q", action)
106-
}
107-
if jsonData == "" {
108-
return fmt.Errorf("json_data is required for action %q", action)
109-
}
110-
}
111-
if action == "patch" {
112-
if jsonData == "" {
113-
return fmt.Errorf("json_data is required for action %q", action)
125+
if action == "delete" {
126+
if name == "" {
127+
return fmt.Errorf("name is required for action %q", action)
128+
}
114129
}
130+
default:
131+
return fmt.Errorf("invalid action %q: must be one of list, create, patch, get, delete", action)
115132
}
116133
return nil
117134
}

0 commit comments

Comments
 (0)