Skip to content

Commit 60d92b8

Browse files
committed
fix authz
Signed-off-by: YaoZengzeng <[email protected]>
1 parent 88e54bf commit 60d92b8

File tree

1 file changed

+3
-25
lines changed

1 file changed

+3
-25
lines changed

ctl/authz/authz.go

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ func SetAuthzForPods(podNames []string, info string) {
160160
os.Exit(1)
161161
}
162162
for _, pod := range podList.Items {
163-
AuthzPerKmeshDaemon(cli, pod.GetName(), info)
163+
SetAuthzPerKmeshDaemon(cli, pod.GetName(), info)
164164
}
165165
} else {
166166
// Process for specified pods.
@@ -184,18 +184,9 @@ func SetAuthzPerKmeshDaemon(cli kube.CLIClient, podName, info string) {
184184
}
185185
defer fw.Close()
186186

187-
var url, method string
187+
url := fmt.Sprintf("http://%s%s?enable=%s", fw.Address(), patternAuthz, info)
188188

189-
switch info {
190-
case "true", "false":
191-
url = fmt.Sprintf("http://%s%s?enable=%s", fw.Address(), patternAuthz, info)
192-
method = http.MethodPost
193-
case "display":
194-
url = fmt.Sprintf("http://%s%s", fw.Address(), patternAuthz)
195-
method = http.MethodGet
196-
}
197-
198-
req, err := http.NewRequest(method, url, nil)
189+
req, err := http.NewRequest(http.MethodPost, url, nil)
199190
if err != nil {
200191
log.Errorf("Error creating request: %v", err)
201192
return
@@ -214,19 +205,6 @@ func SetAuthzPerKmeshDaemon(cli kube.CLIClient, podName, info string) {
214205
log.Errorf("Error: received status code %d", resp.StatusCode)
215206
return
216207
}
217-
218-
body, err := io.ReadAll(resp.Body)
219-
if err != nil {
220-
log.Errorf("failed to read from resp body: %v", err)
221-
return
222-
}
223-
224-
switch info {
225-
case "true", "false":
226-
fmt.Printf("%s\n", body)
227-
case "display":
228-
fmt.Printf("%s %s\n", podName, body)
229-
}
230208
}
231209

232210
// fetchAuthzStatus sends a GET request to a specific kmesh daemon pod

0 commit comments

Comments
 (0)