Fix Lint warnings: Missing comments for functions

* Added comments wherever missing for exported functions/constants

Change-Id: I3757fcf7b9ad24753e2803abaaad84bba7e84fd0
Relates-To: #148
This commit is contained in:
Yasin, Siraj (SY495P) 2020-04-30 17:22:03 -05:00
parent 9530e88c97
commit 972dcf93a9
5 changed files with 19 additions and 0 deletions

View File

@ -21,6 +21,7 @@ import (
"sigs.k8s.io/yaml" "sigs.k8s.io/yaml"
) )
// AuthInfo contains kubeConfig AuthInfo Object
type AuthInfo struct { type AuthInfo struct {
// KubeConfig AuthInfo Object // KubeConfig AuthInfo Object
authInfo *api.AuthInfo authInfo *api.AuthInfo
@ -36,9 +37,12 @@ func (c *AuthInfo) String() string {
return string(kyaml) return string(kyaml)
} }
// KubeAuthInfo returns kubeConfig AuthInfo Object
func (c *AuthInfo) KubeAuthInfo() *api.AuthInfo { func (c *AuthInfo) KubeAuthInfo() *api.AuthInfo {
return c.authInfo return c.authInfo
} }
// SetKubeAuthInfo sets kubeConfig in AuthInfo
func (c *AuthInfo) SetKubeAuthInfo(kc *api.AuthInfo) { func (c *AuthInfo) SetKubeAuthInfo(kc *api.AuthInfo) {
c.authInfo = kc c.authInfo = kc
} }

View File

@ -66,22 +66,29 @@ func (c *Cluster) String() string {
return fmt.Sprintf("%s\n%s", string(cyaml), string(kyaml)) return fmt.Sprintf("%s\n%s", string(cyaml), string(kyaml))
} }
// PrettyString returns cluster information in a formatted string
func (c *Cluster) PrettyString() string { func (c *Cluster) PrettyString() string {
clusterName := NewClusterComplexNameFromKubeClusterName(c.NameInKubeconf) clusterName := NewClusterComplexNameFromKubeClusterName(c.NameInKubeconf)
return fmt.Sprintf("Cluster: %s\n%s:\n%s", clusterName.Name, clusterName.Type, c) return fmt.Sprintf("Cluster: %s\n%s:\n%s", clusterName.Name, clusterName.Type, c)
} }
// KubeCluster returns KubeConfig Cluster Object
func (c *Cluster) KubeCluster() *api.Cluster { func (c *Cluster) KubeCluster() *api.Cluster {
return c.cluster return c.cluster
} }
// SetKubeCluster sets cluster in KubeConfig
func (c *Cluster) SetKubeCluster(kc *api.Cluster) { func (c *Cluster) SetKubeCluster(kc *api.Cluster) {
c.cluster = kc c.cluster = kc
} }
// String returns cluster's complex name, formed by combining name and type with a delimiter('_')
func (c *ClusterComplexName) String() string { func (c *ClusterComplexName) String() string {
return strings.Join([]string{c.Name, c.Type}, AirshipClusterNameSeparator) return strings.Join([]string{c.Name, c.Type}, AirshipClusterNameSeparator)
} }
// ValidClusterType checks for the possible options for cluster type
// Returns error when invalid cluster type is given
func ValidClusterType(clusterType string) error { func ValidClusterType(clusterType string) error {
for _, validType := range AllClusterTypes { for _, validType := range AllClusterTypes {
if clusterType == validType { if clusterType == validType {

View File

@ -684,6 +684,7 @@ func (c *Config) CurrentContextTargetPath() (string, error) {
return ccm.TargetPath, nil return ccm.TargetPath, nil
} }
// CurrentContextClusterType returns cluster type of current context
func (c *Config) CurrentContextClusterType() (string, error) { func (c *Config) CurrentContextClusterType() (string, error) {
context, err := c.GetCurrentContext() context, err := c.GetCurrentContext()
if err != nil { if err != nil {
@ -692,6 +693,7 @@ func (c *Config) CurrentContextClusterType() (string, error) {
return context.ClusterType(), nil return context.ClusterType(), nil
} }
// CurrentContextClusterName returns cluster name of current context
func (c *Config) CurrentContextClusterName() (string, error) { func (c *Config) CurrentContextClusterName() (string, error) {
context, err := c.GetCurrentContext() context, err := c.GetCurrentContext()
if err != nil { if err != nil {

View File

@ -20,6 +20,7 @@ import (
"errors" "errors"
) )
// RunSetAuthInfo validates the given command line options and invokes AddAuthInfo/ModifyAuthInfo
func RunSetAuthInfo(o *AuthInfoOptions, airconfig *Config, writeToStorage bool) (bool, error) { func RunSetAuthInfo(o *AuthInfoOptions, airconfig *Config, writeToStorage bool) (bool, error) {
modified := false modified := false
err := o.Validate() err := o.Validate()
@ -54,6 +55,7 @@ func RunSetAuthInfo(o *AuthInfoOptions, airconfig *Config, writeToStorage bool)
return modified, nil return modified, nil
} }
// RunSetCluster validates the given command line options and invokes AddCluster/ModifyCluster
func RunSetCluster(o *ClusterOptions, airconfig *Config, writeToStorage bool) (bool, error) { func RunSetCluster(o *ClusterOptions, airconfig *Config, writeToStorage bool) (bool, error) {
modified := false modified := false
err := o.Validate() err := o.Validate()
@ -98,6 +100,7 @@ func RunSetCluster(o *ClusterOptions, airconfig *Config, writeToStorage bool) (b
return modified, nil return modified, nil
} }
// RunSetContext validates the given command line options and invokes AddContext/ModifyContext
func RunSetContext(o *ContextOptions, airconfig *Config, writeToStorage bool) (bool, error) { func RunSetContext(o *ContextOptions, airconfig *Config, writeToStorage bool) (bool, error) {
modified := false modified := false
err := o.Validate() err := o.Validate()
@ -148,6 +151,7 @@ func RunSetContext(o *ContextOptions, airconfig *Config, writeToStorage bool) (b
return modified, nil return modified, nil
} }
// RunUseContext validates the given context name and updates it as current context
func RunUseContext(desiredContext string, airconfig *Config) error { func RunUseContext(desiredContext string, airconfig *Config) error {
if _, err := airconfig.GetContext(desiredContext); err != nil { if _, err := airconfig.GetContext(desiredContext); err != nil {
return err return err

View File

@ -72,6 +72,8 @@ func (c *Context) ClusterType() string {
return NewClusterComplexNameFromKubeClusterName(c.NameInKubeconf).Type return NewClusterComplexNameFromKubeClusterName(c.NameInKubeconf).Type
} }
// ClusterName returns cluster name by extracting the name portion from
// the complex cluster name
func (c *Context) ClusterName() string { func (c *Context) ClusterName() string {
return NewClusterComplexNameFromKubeClusterName(c.NameInKubeconf).Name return NewClusterComplexNameFromKubeClusterName(c.NameInKubeconf).Name
} }