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