mirror of
https://github.com/gravitl/netmaker.git
synced 2024-09-20 15:26:04 +08:00
Merge pull request #2205 from gravitl/GRA-1529n-key-update
Gra 1529n key update
This commit is contained in:
commit
249cf5f474
21
cli/cmd/host/refresh_keys.go
Normal file
21
cli/cmd/host/refresh_keys.go
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
package host
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gravitl/netmaker/cli/functions"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
var hostRefreshKeysCmd = &cobra.Command{
|
||||||
|
Use: "refresh_keys [HOST ID] ",
|
||||||
|
Args: cobra.MaximumNArgs(1),
|
||||||
|
Short: "Refresh wireguard keys on host",
|
||||||
|
Long: `Refresh wireguard keys on specified or all hosts
|
||||||
|
If HOSTID is not specified, all hosts will be updated`,
|
||||||
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
functions.PrettyPrint(functions.RefreshKeys(args[0]))
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
rootCmd.AddCommand(hostRefreshKeysCmd)
|
||||||
|
}
|
|
@ -1,20 +0,0 @@
|
||||||
package network
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/gravitl/netmaker/cli/functions"
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
)
|
|
||||||
|
|
||||||
var networkRefreshKeysCmd = &cobra.Command{
|
|
||||||
Use: "refresh_keys [NETWORK NAME]",
|
|
||||||
Short: "Refresh public and private key pairs of a network",
|
|
||||||
Long: `Refresh public and private key pairs of a network`,
|
|
||||||
Args: cobra.ExactArgs(1),
|
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
|
||||||
functions.PrettyPrint(functions.RefreshKeys(args[0]))
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
rootCmd.AddCommand(networkRefreshKeysCmd)
|
|
||||||
}
|
|
|
@ -48,3 +48,12 @@ func CreateRelay(hostID string, relayedHosts []string) *models.ApiHost {
|
||||||
func DeleteRelay(hostID string) *models.ApiHost {
|
func DeleteRelay(hostID string) *models.ApiHost {
|
||||||
return request[models.ApiHost](http.MethodDelete, fmt.Sprintf("/api/hosts/%s/relay", hostID), nil)
|
return request[models.ApiHost](http.MethodDelete, fmt.Sprintf("/api/hosts/%s/relay", hostID), nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RefreshKeys - refresh wireguard keys
|
||||||
|
func RefreshKeys(hostID string) any {
|
||||||
|
if hostID == "" {
|
||||||
|
return request[any](http.MethodPut, "/api/hosts/keys", nil)
|
||||||
|
}
|
||||||
|
return request[any](http.MethodPut, fmt.Sprintf("/api/hosts/%s/keys", hostID), nil)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -38,8 +38,3 @@ func GetNetwork(name string) *models.Network {
|
||||||
func DeleteNetwork(name string) *string {
|
func DeleteNetwork(name string) *string {
|
||||||
return request[string](http.MethodDelete, "/api/networks/"+name, nil)
|
return request[string](http.MethodDelete, "/api/networks/"+name, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RefreshKeys - refresh public and private key pairs for a network
|
|
||||||
func RefreshKeys(networkName string) *models.Network {
|
|
||||||
return request[models.Network](http.MethodPost, fmt.Sprintf("/api/networks/%s/keyupdate", networkName), nil)
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue