@@ -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
8890func 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