mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-27 10:50:50 +08:00
fix delete key endpoint
This commit is contained in:
@@ -13,9 +13,8 @@ var keysDeleteCmd = &cobra.Command{
|
||||
Short: "Delete a key",
|
||||
Long: `Delete a key`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
if functions.DeleteKey(args[0], args[1]) == nil {
|
||||
functions.DeleteKey(args[0], args[1])
|
||||
fmt.Println("Success")
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -74,9 +74,10 @@ func request[T any](method, route string, payload any) *T {
|
||||
log.Fatalf("Error response: %s", string(resBodyBytes))
|
||||
}
|
||||
body := new(T)
|
||||
if len(resBodyBytes) > 0 {
|
||||
if err := json.Unmarshal(resBodyBytes, body); err != nil {
|
||||
// log.Printf("Error unmarshalling JSON: %s", err)
|
||||
return nil
|
||||
log.Printf("Error unmarshalling JSON: %s", err)
|
||||
}
|
||||
}
|
||||
return body
|
||||
}
|
||||
|
||||
@@ -18,6 +18,6 @@ func CreateKey(networkName string, key *models.AccessKey) *models.AccessKey {
|
||||
}
|
||||
|
||||
// DeleteKey - delete an access key
|
||||
func DeleteKey(networkName, keyName string) *string {
|
||||
return request[string](http.MethodDelete, fmt.Sprintf("/api/networks/%s/keys/%s", networkName, keyName), nil)
|
||||
func DeleteKey(networkName, keyName string) {
|
||||
request[string](http.MethodDelete, fmt.Sprintf("/api/networks/%s/keys/%s", networkName, keyName), nil)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user