Browse Source

add comments to exported functions

Anish Mukherjee 2 years ago
parent
commit
d999f7b86e

+ 1 - 0
cli/cmd/acl/root.go

@@ -14,6 +14,7 @@ var rootCmd = &cobra.Command{
 	// Run: func(cmd *cobra.Command, args []string) { },
 	// Run: func(cmd *cobra.Command, args []string) { },
 }
 }
 
 
+// GetRoot returns the root subcommand
 func GetRoot() *cobra.Command {
 func GetRoot() *cobra.Command {
 	return rootCmd
 	return rootCmd
 }
 }

+ 0 - 1
cli/cmd/context/delete.go

@@ -5,7 +5,6 @@ import (
 	"github.com/spf13/cobra"
 	"github.com/spf13/cobra"
 )
 )
 
 
-// contextDeleteCmd deletes a contex
 var contextDeleteCmd = &cobra.Command{
 var contextDeleteCmd = &cobra.Command{
 	Use:   "delete [NAME]",
 	Use:   "delete [NAME]",
 	Args:  cobra.ExactArgs(1),
 	Args:  cobra.ExactArgs(1),

+ 0 - 1
cli/cmd/context/list.go

@@ -5,7 +5,6 @@ import (
 	"github.com/spf13/cobra"
 	"github.com/spf13/cobra"
 )
 )
 
 
-// contextListCmd lists all contexts
 var contextListCmd = &cobra.Command{
 var contextListCmd = &cobra.Command{
 	Use:   "list",
 	Use:   "list",
 	Args:  cobra.NoArgs,
 	Args:  cobra.NoArgs,

+ 1 - 0
cli/cmd/context/root.go

@@ -14,6 +14,7 @@ var rootCmd = &cobra.Command{
 	// Run: func(cmd *cobra.Command, args []string) { },
 	// Run: func(cmd *cobra.Command, args []string) { },
 }
 }
 
 
+// GetRoot returns the root subcommand
 func GetRoot() *cobra.Command {
 func GetRoot() *cobra.Command {
 	return rootCmd
 	return rootCmd
 }
 }

+ 0 - 2
cli/cmd/context/set.go

@@ -14,7 +14,6 @@ var (
 	masterKey string
 	masterKey string
 )
 )
 
 
-// contextSetCmd creates/updates a context
 var contextSetCmd = &cobra.Command{
 var contextSetCmd = &cobra.Command{
 	Use:   "set [NAME]",
 	Use:   "set [NAME]",
 	Args:  cobra.ExactArgs(1),
 	Args:  cobra.ExactArgs(1),
@@ -41,6 +40,5 @@ func init() {
 	contextSetCmd.Flags().StringVar(&password, "password", "", "Password")
 	contextSetCmd.Flags().StringVar(&password, "password", "", "Password")
 	contextSetCmd.MarkFlagsRequiredTogether("username", "password")
 	contextSetCmd.MarkFlagsRequiredTogether("username", "password")
 	contextSetCmd.Flags().StringVar(&masterKey, "master_key", "", "Master Key")
 	contextSetCmd.Flags().StringVar(&masterKey, "master_key", "", "Master Key")
-
 	rootCmd.AddCommand(contextSetCmd)
 	rootCmd.AddCommand(contextSetCmd)
 }
 }

+ 0 - 1
cli/cmd/context/use.go

@@ -5,7 +5,6 @@ import (
 	"github.com/spf13/cobra"
 	"github.com/spf13/cobra"
 )
 )
 
 
-// contextUseCmd sets the current context
 var contextUseCmd = &cobra.Command{
 var contextUseCmd = &cobra.Command{
 	Use:   "use [NAME]",
 	Use:   "use [NAME]",
 	Args:  cobra.ExactArgs(1),
 	Args:  cobra.ExactArgs(1),

+ 1 - 0
cli/cmd/dns/root.go

@@ -14,6 +14,7 @@ var rootCmd = &cobra.Command{
 	// Run: func(cmd *cobra.Command, args []string) { },
 	// Run: func(cmd *cobra.Command, args []string) { },
 }
 }
 
 
+// GetRoot returns the root subcommand
 func GetRoot() *cobra.Command {
 func GetRoot() *cobra.Command {
 	return rootCmd
 	return rootCmd
 }
 }

+ 1 - 0
cli/cmd/ext_client/root.go

@@ -14,6 +14,7 @@ var rootCmd = &cobra.Command{
 	// Run: func(cmd *cobra.Command, args []string) { },
 	// Run: func(cmd *cobra.Command, args []string) { },
 }
 }
 
 
+// GetRoot returns the root subcommand
 func GetRoot() *cobra.Command {
 func GetRoot() *cobra.Command {
 	return rootCmd
 	return rootCmd
 }
 }

+ 1 - 0
cli/cmd/keys/root.go

@@ -14,6 +14,7 @@ var rootCmd = &cobra.Command{
 	// Run: func(cmd *cobra.Command, args []string) { },
 	// Run: func(cmd *cobra.Command, args []string) { },
 }
 }
 
 
+// GetRoot returns the root subcommand
 func GetRoot() *cobra.Command {
 func GetRoot() *cobra.Command {
 	return rootCmd
 	return rootCmd
 }
 }

+ 1 - 0
cli/cmd/network/root.go

@@ -16,6 +16,7 @@ var rootCmd = &cobra.Command{
 	// Run: func(cmd *cobra.Command, args []string) { },
 	// Run: func(cmd *cobra.Command, args []string) { },
 }
 }
 
 
+// GetRoot returns the root subcommand
 func GetRoot() *cobra.Command {
 func GetRoot() *cobra.Command {
 	return rootCmd
 	return rootCmd
 }
 }

+ 1 - 0
cli/cmd/node/root.go

@@ -14,6 +14,7 @@ var rootCmd = &cobra.Command{
 	// Run: func(cmd *cobra.Command, args []string) { },
 	// Run: func(cmd *cobra.Command, args []string) { },
 }
 }
 
 
+// GetRoot returns the root subcommand
 func GetRoot() *cobra.Command {
 func GetRoot() *cobra.Command {
 	return rootCmd
 	return rootCmd
 }
 }

+ 1 - 0
cli/cmd/server/root.go

@@ -14,6 +14,7 @@ var rootCmd = &cobra.Command{
 	// Run: func(cmd *cobra.Command, args []string) { },
 	// Run: func(cmd *cobra.Command, args []string) { },
 }
 }
 
 
+// GetRoot returns the root subcommand
 func GetRoot() *cobra.Command {
 func GetRoot() *cobra.Command {
 	return rootCmd
 	return rootCmd
 }
 }

+ 1 - 0
cli/cmd/user/root.go

@@ -14,6 +14,7 @@ var rootCmd = &cobra.Command{
 	// Run: func(cmd *cobra.Command, args []string) { },
 	// Run: func(cmd *cobra.Command, args []string) { },
 }
 }
 
 
+// GetRoot returns the root subcommand
 func GetRoot() *cobra.Command {
 func GetRoot() *cobra.Command {
 	return rootCmd
 	return rootCmd
 }
 }

+ 21 - 15
cli/config/config.go

@@ -9,6 +9,7 @@ import (
 	"gopkg.in/yaml.v3"
 	"gopkg.in/yaml.v3"
 )
 )
 
 
+// Context maintains configuration for interaction with Netmaker API
 type Context struct {
 type Context struct {
 	Endpoint  string `yaml:"endpoint"`
 	Endpoint  string `yaml:"endpoint"`
 	Username  string `yaml:"username,omitempty"`
 	Username  string `yaml:"username,omitempty"`
@@ -56,18 +57,7 @@ func loadConfig() {
 	}
 	}
 }
 }
 
 
-func GetCurrentContext() (ret Context) {
-	for _, ctx := range contextMap {
-		if ctx.Current {
-			ret = ctx
-			return
-		}
-	}
-	log.Fatalf("No current context set, do so via `netmaker context use <name>`")
-	return
-}
-
-func SaveContext() {
+func saveContext() {
 	bodyBytes, err := yaml.Marshal(&contextMap)
 	bodyBytes, err := yaml.Marshal(&contextMap)
 	if err != nil {
 	if err != nil {
 		log.Fatalf("Error marshalling into YAML %s", err)
 		log.Fatalf("Error marshalling into YAML %s", err)
@@ -84,6 +74,19 @@ func SaveContext() {
 	}
 	}
 }
 }
 
 
+// GetCurrentContext - returns current set context
+func GetCurrentContext() (ret Context) {
+	for _, ctx := range contextMap {
+		if ctx.Current {
+			ret = ctx
+			return
+		}
+	}
+	log.Fatalf("No current context set, do so via `netmaker context use <name>`")
+	return
+}
+
+// SetCurrentContext - sets a given context as current context
 func SetCurrentContext(ctxName string) {
 func SetCurrentContext(ctxName string) {
 	if _, ok := contextMap[ctxName]; !ok {
 	if _, ok := contextMap[ctxName]; !ok {
 		log.Fatalf("No such context %s", ctxName)
 		log.Fatalf("No such context %s", ctxName)
@@ -92,26 +95,29 @@ func SetCurrentContext(ctxName string) {
 		ctx.Current = key == ctxName
 		ctx.Current = key == ctxName
 		contextMap[key] = ctx
 		contextMap[key] = ctx
 	}
 	}
-	SaveContext()
+	saveContext()
 }
 }
 
 
+// SetContext - updates an existing context or creates a new one
 func SetContext(ctxName string, ctx Context) {
 func SetContext(ctxName string, ctx Context) {
 	if oldCtx, ok := contextMap[ctxName]; ok && oldCtx.Current {
 	if oldCtx, ok := contextMap[ctxName]; ok && oldCtx.Current {
 		ctx.Current = true
 		ctx.Current = true
 	}
 	}
 	contextMap[ctxName] = ctx
 	contextMap[ctxName] = ctx
-	SaveContext()
+	saveContext()
 }
 }
 
 
+// DeleteContext - deletes a context
 func DeleteContext(ctxName string) {
 func DeleteContext(ctxName string) {
 	if _, ok := contextMap[ctxName]; ok {
 	if _, ok := contextMap[ctxName]; ok {
 		delete(contextMap, ctxName)
 		delete(contextMap, ctxName)
-		SaveContext()
+		saveContext()
 	} else {
 	} else {
 		log.Fatalf("No such context %s", ctxName)
 		log.Fatalf("No such context %s", ctxName)
 	}
 	}
 }
 }
 
 
+// ListAll - lists all contexts
 func ListAll() {
 func ListAll() {
 	for key, ctx := range contextMap {
 	for key, ctx := range contextMap {
 		fmt.Print("\n", key, " -> ", ctx.Endpoint)
 		fmt.Print("\n", key, " -> ", ctx.Endpoint)

+ 2 - 0
cli/functions/acl.go

@@ -7,10 +7,12 @@ import (
 	"github.com/gravitl/netmaker/logic/acls"
 	"github.com/gravitl/netmaker/logic/acls"
 )
 )
 
 
+// GetACL - fetch all ACLs associated with a network
 func GetACL(networkName string) *acls.ACLContainer {
 func GetACL(networkName string) *acls.ACLContainer {
 	return request[acls.ACLContainer](http.MethodGet, fmt.Sprintf("/api/networks/%s/acls", networkName), nil)
 	return request[acls.ACLContainer](http.MethodGet, fmt.Sprintf("/api/networks/%s/acls", networkName), nil)
 }
 }
 
 
+// UpdateACL - update an ACL
 func UpdateACL(networkName string, payload *acls.ACLContainer) *acls.ACLContainer {
 func UpdateACL(networkName string, payload *acls.ACLContainer) *acls.ACLContainer {
 	return request[acls.ACLContainer](http.MethodPut, fmt.Sprintf("/api/networks/%s/acls", networkName), payload)
 	return request[acls.ACLContainer](http.MethodPut, fmt.Sprintf("/api/networks/%s/acls", networkName), payload)
 }
 }

+ 7 - 0
cli/functions/dns.go

@@ -7,30 +7,37 @@ import (
 	"github.com/gravitl/netmaker/models"
 	"github.com/gravitl/netmaker/models"
 )
 )
 
 
+// GetDNS - fetch all DNS entries
 func GetDNS() *[]models.DNSEntry {
 func GetDNS() *[]models.DNSEntry {
 	return request[[]models.DNSEntry](http.MethodGet, "/api/dns", nil)
 	return request[[]models.DNSEntry](http.MethodGet, "/api/dns", nil)
 }
 }
 
 
+// GetNodeDNS - fetch all Node DNS entires
 func GetNodeDNS(networkName string) *[]models.DNSEntry {
 func GetNodeDNS(networkName string) *[]models.DNSEntry {
 	return request[[]models.DNSEntry](http.MethodGet, fmt.Sprintf("/api/dns/adm/%s/nodes", networkName), nil)
 	return request[[]models.DNSEntry](http.MethodGet, fmt.Sprintf("/api/dns/adm/%s/nodes", networkName), nil)
 }
 }
 
 
+// GetCustomDNS - fetch user defined DNS entriees
 func GetCustomDNS(networkName string) *[]models.DNSEntry {
 func GetCustomDNS(networkName string) *[]models.DNSEntry {
 	return request[[]models.DNSEntry](http.MethodGet, fmt.Sprintf("/api/dns/adm/%s/custom", networkName), nil)
 	return request[[]models.DNSEntry](http.MethodGet, fmt.Sprintf("/api/dns/adm/%s/custom", networkName), nil)
 }
 }
 
 
+// GetNetworkDNS - fetch DNS entries associated with a network
 func GetNetworkDNS(networkName string) *[]models.DNSEntry {
 func GetNetworkDNS(networkName string) *[]models.DNSEntry {
 	return request[[]models.DNSEntry](http.MethodGet, "/api/dns/adm/"+networkName, nil)
 	return request[[]models.DNSEntry](http.MethodGet, "/api/dns/adm/"+networkName, nil)
 }
 }
 
 
+// CreateDNS - create a DNS entry
 func CreateDNS(networkName string, payload *models.DNSEntry) *models.DNSEntry {
 func CreateDNS(networkName string, payload *models.DNSEntry) *models.DNSEntry {
 	return request[models.DNSEntry](http.MethodPost, "/api/dns/"+networkName, payload)
 	return request[models.DNSEntry](http.MethodPost, "/api/dns/"+networkName, payload)
 }
 }
 
 
+// PushDNS - push a DNS entry to CoreDNS
 func PushDNS() *string {
 func PushDNS() *string {
 	return request[string](http.MethodPost, "/api/dns/adm/pushdns", nil)
 	return request[string](http.MethodPost, "/api/dns/adm/pushdns", nil)
 }
 }
 
 
+// DeleteDNS - delete a DNS entry
 func DeleteDNS(networkName, domainName string) *string {
 func DeleteDNS(networkName, domainName string) *string {
 	return request[string](http.MethodDelete, fmt.Sprintf("/api/dns/%s/%s", networkName, domainName), nil)
 	return request[string](http.MethodDelete, fmt.Sprintf("/api/dns/%s/%s", networkName, domainName), nil)
 }
 }

+ 7 - 0
cli/functions/ext_client.go

@@ -10,18 +10,22 @@ import (
 	"github.com/gravitl/netmaker/models"
 	"github.com/gravitl/netmaker/models"
 )
 )
 
 
+// GetAllExtClients - fetch all external clients
 func GetAllExtClients() *[]models.ExtClient {
 func GetAllExtClients() *[]models.ExtClient {
 	return request[[]models.ExtClient](http.MethodGet, "/api/extclients", nil)
 	return request[[]models.ExtClient](http.MethodGet, "/api/extclients", nil)
 }
 }
 
 
+// GetNetworkExtClients - fetch external clients associated with a network
 func GetNetworkExtClients(networkName string) *[]models.ExtClient {
 func GetNetworkExtClients(networkName string) *[]models.ExtClient {
 	return request[[]models.ExtClient](http.MethodGet, "/api/extclients/"+networkName, nil)
 	return request[[]models.ExtClient](http.MethodGet, "/api/extclients/"+networkName, nil)
 }
 }
 
 
+// GetExtClient - fetch a single external client
 func GetExtClient(networkName, clientID string) *models.ExtClient {
 func GetExtClient(networkName, clientID string) *models.ExtClient {
 	return request[models.ExtClient](http.MethodGet, fmt.Sprintf("/api/extclients/%s/%s", networkName, clientID), nil)
 	return request[models.ExtClient](http.MethodGet, fmt.Sprintf("/api/extclients/%s/%s", networkName, clientID), nil)
 }
 }
 
 
+// GetExtClientConfig - fetch a wireguard config of an external client
 func GetExtClientConfig(networkName, clientID string) string {
 func GetExtClientConfig(networkName, clientID string) string {
 	ctx := config.GetCurrentContext()
 	ctx := config.GetCurrentContext()
 	req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("%s/api/extclients/%s/%s/file", ctx.Endpoint, networkName, clientID), nil)
 	req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("%s/api/extclients/%s/%s/file", ctx.Endpoint, networkName, clientID), nil)
@@ -44,6 +48,7 @@ func GetExtClientConfig(networkName, clientID string) string {
 	return string(bodyBytes)
 	return string(bodyBytes)
 }
 }
 
 
+// CreateExtClient - create an external client
 func CreateExtClient(networkName, nodeID, extClientID string) {
 func CreateExtClient(networkName, nodeID, extClientID string) {
 	if extClientID != "" {
 	if extClientID != "" {
 		request[any](http.MethodPost, fmt.Sprintf("/api/extclients/%s/%s", networkName, nodeID), &models.CustomExtClient{
 		request[any](http.MethodPost, fmt.Sprintf("/api/extclients/%s/%s", networkName, nodeID), &models.CustomExtClient{
@@ -54,10 +59,12 @@ func CreateExtClient(networkName, nodeID, extClientID string) {
 	}
 	}
 }
 }
 
 
+// DeleteExtClient - delete an external client
 func DeleteExtClient(networkName, clientID string) *models.SuccessResponse {
 func DeleteExtClient(networkName, clientID string) *models.SuccessResponse {
 	return request[models.SuccessResponse](http.MethodDelete, fmt.Sprintf("/api/extclients/%s/%s", networkName, clientID), nil)
 	return request[models.SuccessResponse](http.MethodDelete, fmt.Sprintf("/api/extclients/%s/%s", networkName, clientID), nil)
 }
 }
 
 
+// UpdateExtClient - update an external client
 func UpdateExtClient(networkName, clientID string, payload *models.ExtClient) *models.ExtClient {
 func UpdateExtClient(networkName, clientID string, payload *models.ExtClient) *models.ExtClient {
 	return request[models.ExtClient](http.MethodPut, fmt.Sprintf("/api/extclients/%s/%s", networkName, clientID), payload)
 	return request[models.ExtClient](http.MethodPut, fmt.Sprintf("/api/extclients/%s/%s", networkName, clientID), payload)
 }
 }

+ 11 - 0
cli/functions/node.go

@@ -7,6 +7,7 @@ import (
 	"github.com/gravitl/netmaker/models"
 	"github.com/gravitl/netmaker/models"
 )
 )
 
 
+// GetNodes - fetch all nodes
 func GetNodes(networkName ...string) *[]models.Node {
 func GetNodes(networkName ...string) *[]models.Node {
 	if len(networkName) == 1 {
 	if len(networkName) == 1 {
 		return request[[]models.Node](http.MethodGet, "/api/nodes/"+networkName[0], nil)
 		return request[[]models.Node](http.MethodGet, "/api/nodes/"+networkName[0], nil)
@@ -15,18 +16,22 @@ func GetNodes(networkName ...string) *[]models.Node {
 	}
 	}
 }
 }
 
 
+// GetNodeByID - fetch a single node by ID
 func GetNodeByID(networkName, nodeID string) *models.NodeGet {
 func GetNodeByID(networkName, nodeID string) *models.NodeGet {
 	return request[models.NodeGet](http.MethodGet, fmt.Sprintf("/api/nodes/%s/%s", networkName, nodeID), nil)
 	return request[models.NodeGet](http.MethodGet, fmt.Sprintf("/api/nodes/%s/%s", networkName, nodeID), nil)
 }
 }
 
 
+// UpdateNode - update a single node
 func UpdateNode(networkName, nodeID string, node *models.Node) *models.Node {
 func UpdateNode(networkName, nodeID string, node *models.Node) *models.Node {
 	return request[models.Node](http.MethodPut, fmt.Sprintf("/api/nodes/%s/%s", networkName, nodeID), node)
 	return request[models.Node](http.MethodPut, fmt.Sprintf("/api/nodes/%s/%s", networkName, nodeID), node)
 }
 }
 
 
+// DeleteNode - delete a node
 func DeleteNode(networkName, nodeID string) *models.SuccessResponse {
 func DeleteNode(networkName, nodeID string) *models.SuccessResponse {
 	return request[models.SuccessResponse](http.MethodDelete, fmt.Sprintf("/api/nodes/%s/%s", networkName, nodeID), nil)
 	return request[models.SuccessResponse](http.MethodDelete, fmt.Sprintf("/api/nodes/%s/%s", networkName, nodeID), nil)
 }
 }
 
 
+// CreateRelay - turn a node into a relay
 func CreateRelay(networkName, nodeID string, relayAddresses []string) *models.Node {
 func CreateRelay(networkName, nodeID string, relayAddresses []string) *models.Node {
 	return request[models.Node](http.MethodPost, fmt.Sprintf("/api/nodes/%s/%s/createrelay", networkName, nodeID), &models.RelayRequest{
 	return request[models.Node](http.MethodPost, fmt.Sprintf("/api/nodes/%s/%s/createrelay", networkName, nodeID), &models.RelayRequest{
 		NetID:      networkName,
 		NetID:      networkName,
@@ -35,28 +40,34 @@ func CreateRelay(networkName, nodeID string, relayAddresses []string) *models.No
 	})
 	})
 }
 }
 
 
+// DeleteRelay - remove relay role from a node
 func DeleteRelay(networkName, nodeID string) *models.Node {
 func DeleteRelay(networkName, nodeID string) *models.Node {
 	return request[models.Node](http.MethodDelete, fmt.Sprintf("/api/nodes/%s/%s/deleterelay", networkName, nodeID), nil)
 	return request[models.Node](http.MethodDelete, fmt.Sprintf("/api/nodes/%s/%s/deleterelay", networkName, nodeID), nil)
 }
 }
 
 
+// CreateEgress - turn a node into an egress
 func CreateEgress(networkName, nodeID string, payload *models.EgressGatewayRequest) *models.Node {
 func CreateEgress(networkName, nodeID string, payload *models.EgressGatewayRequest) *models.Node {
 	return request[models.Node](http.MethodPost, fmt.Sprintf("/api/nodes/%s/%s/creategateway", networkName, nodeID), payload)
 	return request[models.Node](http.MethodPost, fmt.Sprintf("/api/nodes/%s/%s/creategateway", networkName, nodeID), payload)
 }
 }
 
 
+// DeleteEgress - remove egress role from a node
 func DeleteEgress(networkName, nodeID string) *models.Node {
 func DeleteEgress(networkName, nodeID string) *models.Node {
 	return request[models.Node](http.MethodDelete, fmt.Sprintf("/api/nodes/%s/%s/deletegateway", networkName, nodeID), nil)
 	return request[models.Node](http.MethodDelete, fmt.Sprintf("/api/nodes/%s/%s/deletegateway", networkName, nodeID), nil)
 }
 }
 
 
+// CreateIngress - turn a node into an ingress
 func CreateIngress(networkName, nodeID string, failover bool) *models.Node {
 func CreateIngress(networkName, nodeID string, failover bool) *models.Node {
 	return request[models.Node](http.MethodPost, fmt.Sprintf("/api/nodes/%s/%s/createingress", networkName, nodeID), &struct {
 	return request[models.Node](http.MethodPost, fmt.Sprintf("/api/nodes/%s/%s/createingress", networkName, nodeID), &struct {
 		Failover bool `json:"failover"`
 		Failover bool `json:"failover"`
 	}{Failover: failover})
 	}{Failover: failover})
 }
 }
 
 
+// DeleteIngress - remove ingress role from a node
 func DeleteIngress(networkName, nodeID string) *models.Node {
 func DeleteIngress(networkName, nodeID string) *models.Node {
 	return request[models.Node](http.MethodDelete, fmt.Sprintf("/api/nodes/%s/%s/deleteingress", networkName, nodeID), nil)
 	return request[models.Node](http.MethodDelete, fmt.Sprintf("/api/nodes/%s/%s/deleteingress", networkName, nodeID), nil)
 }
 }
 
 
+// UncordonNode - uncordon a node
 func UncordonNode(networkName, nodeID string) *string {
 func UncordonNode(networkName, nodeID string) *string {
 	return request[string](http.MethodPost, fmt.Sprintf("/api/nodes/%s/%s/approve", networkName, nodeID), nil)
 	return request[string](http.MethodPost, fmt.Sprintf("/api/nodes/%s/%s/approve", networkName, nodeID), nil)
 }
 }

+ 4 - 0
cli/functions/server.go

@@ -10,6 +10,7 @@ import (
 	"github.com/gravitl/netmaker/models"
 	"github.com/gravitl/netmaker/models"
 )
 )
 
 
+// GetLogs - fetch Netmaker server logs
 func GetLogs() string {
 func GetLogs() string {
 	ctx := config.GetCurrentContext()
 	ctx := config.GetCurrentContext()
 	req, err := http.NewRequest(http.MethodGet, ctx.Endpoint+"/api/logs", nil)
 	req, err := http.NewRequest(http.MethodGet, ctx.Endpoint+"/api/logs", nil)
@@ -32,14 +33,17 @@ func GetLogs() string {
 	return string(bodyBytes)
 	return string(bodyBytes)
 }
 }
 
 
+// GetServerInfo - fetch minimal server info
 func GetServerInfo() *models.ServerConfig {
 func GetServerInfo() *models.ServerConfig {
 	return request[models.ServerConfig](http.MethodGet, "/api/server/getserverinfo", nil)
 	return request[models.ServerConfig](http.MethodGet, "/api/server/getserverinfo", nil)
 }
 }
 
 
+// GetServerConfig - fetch entire server config including secrets
 func GetServerConfig() *cfg.ServerConfig {
 func GetServerConfig() *cfg.ServerConfig {
 	return request[cfg.ServerConfig](http.MethodGet, "/api/server/getconfig", nil)
 	return request[cfg.ServerConfig](http.MethodGet, "/api/server/getconfig", nil)
 }
 }
 
 
+// GetServerHealth - fetch server current health status
 func GetServerHealth() string {
 func GetServerHealth() string {
 	ctx := config.GetCurrentContext()
 	ctx := config.GetCurrentContext()
 	req, err := http.NewRequest(http.MethodGet, ctx.Endpoint+"/api/server/health", nil)
 	req, err := http.NewRequest(http.MethodGet, ctx.Endpoint+"/api/server/health", nil)

+ 6 - 0
cli/functions/user.go

@@ -6,26 +6,32 @@ import (
 	"github.com/gravitl/netmaker/models"
 	"github.com/gravitl/netmaker/models"
 )
 )
 
 
+// HasAdmin - check if server has an admin user
 func HasAdmin() *bool {
 func HasAdmin() *bool {
 	return request[bool](http.MethodGet, "/api/users/adm/hasadmin", nil)
 	return request[bool](http.MethodGet, "/api/users/adm/hasadmin", nil)
 }
 }
 
 
+// CreateUser - create a user
 func CreateUser(payload *models.User) *models.User {
 func CreateUser(payload *models.User) *models.User {
 	return request[models.User](http.MethodPost, "/api/users/"+payload.UserName, payload)
 	return request[models.User](http.MethodPost, "/api/users/"+payload.UserName, payload)
 }
 }
 
 
+// UpdateUser - update a user
 func UpdateUser(payload *models.User) *models.User {
 func UpdateUser(payload *models.User) *models.User {
 	return request[models.User](http.MethodPut, "/api/users/networks/"+payload.UserName, payload)
 	return request[models.User](http.MethodPut, "/api/users/networks/"+payload.UserName, payload)
 }
 }
 
 
+// DeleteUser - delete a user
 func DeleteUser(username string) *string {
 func DeleteUser(username string) *string {
 	return request[string](http.MethodDelete, "/api/users/"+username, nil)
 	return request[string](http.MethodDelete, "/api/users/"+username, nil)
 }
 }
 
 
+// GetUser - fetch a single user
 func GetUser(username string) *models.User {
 func GetUser(username string) *models.User {
 	return request[models.User](http.MethodGet, "/api/users/"+username, nil)
 	return request[models.User](http.MethodGet, "/api/users/"+username, nil)
 }
 }
 
 
+// ListUsers - fetch all users
 func ListUsers() *[]models.ReturnUser {
 func ListUsers() *[]models.ReturnUser {
 	return request[[]models.ReturnUser](http.MethodGet, "/api/users", nil)
 	return request[[]models.ReturnUser](http.MethodGet, "/api/users", nil)
 }
 }