Skip to content

Commit

Permalink
chore(code formatting): format the code with 1.19 version
Browse files Browse the repository at this point in the history
Signed-off-by: Abhinandan Purkait <[email protected]>
  • Loading branch information
Abhinandan-Purkait committed Nov 23, 2023
1 parent d1f9d76 commit 9b767a1
Show file tree
Hide file tree
Showing 14 changed files with 190 additions and 161 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
uses: actions/checkout@v4

- name: Set up Go 1.19
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: 1.19.13

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-charts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Install Helm
- name: Install Helm
uses: azure/setup-helm@v3
with:
version: v3.12.1
Expand Down
6 changes: 3 additions & 3 deletions pkg/kubernetes/api/apps/v1/deployment/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ func (b *Builder) WithReplicas(replicas *int32) *Builder {
return b
}

//WithStrategyType sets the strategy field of the deployment
// WithStrategyType sets the strategy field of the deployment
func (b *Builder) WithStrategyType(
strategytype appsv1.DeploymentStrategyType,
) *Builder {
Expand All @@ -323,7 +323,7 @@ func (b *Builder) WithStrategyType(
return b
}

//WithStrategyTypeRecreate sets the strategy field of the deployment as Recreate
// WithStrategyTypeRecreate sets the strategy field of the deployment as Recreate
func (b *Builder) WithStrategyTypeRecreate() *Builder {
return b.WithStrategyType(appsv1.RecreateDeploymentStrategyType)
}
Expand Down Expand Up @@ -519,7 +519,7 @@ func (d *Deploy) IsTerminationInProgress() bool {

// IsUpdateInProgress Checks if all the replicas are updated or not.
// If Status.AvailableReplicas < Status.UpdatedReplicas then all the
//older replicas are not there but there are less number of availableReplicas
// older replicas are not there but there are less number of availableReplicas
func IsUpdateInProgress() Predicate {
return func(d *Deploy) bool {
return d.IsUpdateInProgress()
Expand Down
16 changes: 8 additions & 8 deletions pkg/kubernetes/api/core/v1/persistentvolume/persistentvolume.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ func (p *PV) GetPath() string {
// This method expects only a single hostname to be set.
//
// The PV object will have the node's hostname specified as follows:
// nodeAffinity:
// required:
// nodeSelectorTerms:
// - matchExpressions:
// - key: kubernetes.io/hostname
// operator: In
// values:
// - hostname
//
// nodeAffinity:
// required:
// nodeSelectorTerms:
// - matchExpressions:
// - key: kubernetes.io/hostname
// operator: In
// values:
// - hostname
func (p *PV) GetAffinitedNodeHostname() string {
nodeAffinity := p.object.Spec.NodeAffinity
if nodeAffinity == nil {
Expand Down
9 changes: 6 additions & 3 deletions pkg/kubernetes/api/core/v1/podtemplatespec/podtemplatespec.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func (b *Builder) WithNodeSelectorNew(nodeselectors map[string]string) *Builder
return b
}

//WithNodeSelectorByValue overrides the NodeSelector with new values
// WithNodeSelectorByValue overrides the NodeSelector with new values
func (b *Builder) WithNodeSelectorByValue(nodeselectors map[string]string) *Builder {
// copy of original map
newnodeselectors := map[string]string{}
Expand Down Expand Up @@ -290,9 +290,12 @@ func (b *Builder) WithAffinity(affinity *corev1.Affinity) *Builder {
// WithNodeAffinityMatchExpressions sets matchexpressions under
// nodeAffinity
// NOTE: If nil is passed then match expressions will not be
// propogated to node affinity.
//
// propogated to node affinity.
//
// CAUTION: Don't invoke WithAffinity func after calling this function
// It will overwrite MatchExpression
//
// It will overwrite MatchExpression
func (b *Builder) WithNodeAffinityMatchExpressions(
mExpressions []corev1.NodeSelectorRequirement) *Builder {
if len(mExpressions) == 0 {
Expand Down
4 changes: 2 additions & 2 deletions pkg/kubernetes/api/core/v1/volume/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (b *Builder) WithHostDirectory(path string) *Builder {
return b
}

//WithSecret sets the VolumeSource field of Volume with provided Secret
// WithSecret sets the VolumeSource field of Volume with provided Secret
func (b *Builder) WithSecret(secret *corev1.Secret, defaultMode int32) *Builder {
dM := defaultMode
if secret == nil {
Expand All @@ -92,7 +92,7 @@ func (b *Builder) WithSecret(secret *corev1.Secret, defaultMode int32) *Builder
return b
}

//WithConfigMap sets the VolumeSource field of Volume with provided ConfigMap
// WithConfigMap sets the VolumeSource field of Volume with provided ConfigMap
func (b *Builder) WithConfigMap(configMap *corev1.ConfigMap, defaultMode int32) *Builder {
dM := defaultMode
if configMap == nil {
Expand Down
22 changes: 15 additions & 7 deletions pkg/kubernetes/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,45 +42,51 @@ const (
// to abstract getting kubernetes incluster config
//
// NOTE:
// typed function makes it simple to mock
//
// typed function makes it simple to mock
type getInClusterConfigFn func() (*rest.Config, error)

// buildConfigFromFlagsFn is a typed function
// to abstract getting a kubernetes config from
// provided flags
//
// NOTE:
// typed function makes it simple to mock
//
// typed function makes it simple to mock
type buildConfigFromFlagsFn func(string, string) (*rest.Config, error)

// getKubeMasterIPFromENVFn is a typed function
// to abstract getting kubernetes master IP
// address from environment variable
//
// NOTE:
// typed function makes it simple to mock
//
// typed function makes it simple to mock
type getKubeMasterIPFromENVFn func(env.ENVKey) string

// getKubeConfigPathFromENVFn is a typed function to
// abstract getting kubernetes config path from
// environment variable
//
// NOTE:
// typed function makes it simple to mock
//
// typed function makes it simple to mock
type getKubeConfigPathFromENVFn func(env.ENVKey) string

// getKubeDynamicClientFn is a typed function to
// abstract getting dynamic kubernetes clientset
//
// NOTE:
// typed function makes it simple to mock
//
// typed function makes it simple to mock
type getKubeDynamicClientFn func(*rest.Config) (dynamic.Interface, error)

// getKubeClientsetFn is a typed function
// to abstract getting kubernetes clientset
//
// NOTE:
// typed function makes it simple to mock
//
// typed function makes it simple to mock
type getKubeClientsetFn func(*rest.Config) (*kubernetes.Clientset, error)

// Client provides Kubernetes client operations
Expand Down Expand Up @@ -119,7 +125,9 @@ type Client struct {
// instance
//
// NOTE:
// This is the basic building block to create
//
// This is the basic building block to create
//
// functional operations against the client
// instance
type OptionFn func(*Client)
Expand Down
74 changes: 41 additions & 33 deletions provisioner/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const (
betaStorageClassAnnotation = "volume.beta.kubernetes.io/storage-class"
)

//GetVolumeConfig creates a new VolumeConfig struct by
// GetVolumeConfig creates a new VolumeConfig struct by
// parsing and merging the configuration provided in the PVC
// annotation - cas.openebs.io/config with the
// default configuration of the provisioner.
Expand Down Expand Up @@ -177,7 +177,7 @@ func (p *Provisioner) GetVolumeConfig(pvName string, pvc *v1.PersistentVolumeCla
return c, nil
}

//GetNFSServerTypeFromConfig returns the NFSServerType value configured
// GetNFSServerTypeFromConfig returns the NFSServerType value configured
// in StorageClass. Default is kernel
func (c *VolumeConfig) GetNFSServerTypeFromConfig() string {
serverType := c.getValue(KeyPVNFSServerType)
Expand All @@ -187,7 +187,7 @@ func (c *VolumeConfig) GetNFSServerTypeFromConfig() string {
return serverType
}

//GetBackendStorageClassFromConfig returns the Storage Class
// GetBackendStorageClassFromConfig returns the Storage Class
// value configured in StorageClass. Default is ""
func (c *VolumeConfig) GetBackendStorageClassFromConfig() string {
backingSC := c.getValue(KeyPVBackendStorageClass)
Expand Down Expand Up @@ -241,14 +241,16 @@ func (c *VolumeConfig) GetNFServerGraceTime() (int, error) {
// StorageClass if specified
// -----------------------------------------------------
// NOTE: This feature has been deprecated
// Alternative: Use FilePermission 'cas.openebs.io/config' annotation
// key on the backend volume PVC. Sample FilePermissions
// for FSGID-like configuration --
//
// name: FilePermissions
// data:
// GID: <group-ID>
// mode: "g+s"
// Alternative: Use FilePermission 'cas.openebs.io/config' annotation
// key on the backend volume PVC. Sample FilePermissions
// for FSGID-like configuration --
//
// name: FilePermissions
// data:
// GID: <group-ID>
// mode: "g+s"
//
// -----------------------------------------------------
func (c *VolumeConfig) GetFSGroupID() (*int64, error) {
fsGroupIDStr := c.getValue(FSGroupID)
Expand Down Expand Up @@ -371,18 +373,21 @@ func (c *VolumeConfig) getResourceList(key string) (v1.ResourceList, error) {
return resourceList, nil
}

//getValue is a utility function to extract the value
// getValue is a utility function to extract the value
// of the `key` from the ConfigMap object - which is
// map[string]interface{map[string][string]}
// Example:
// {
// key1: {
// value: value1
// enabled: true
// }
// }
//
// {
// key1: {
// value: value1
// enabled: true
// }
// }
//
// In the above example, if `key1` is passed as input,
// `value1` will be returned.
//
// `value1` will be returned.
func (c *VolumeConfig) getValue(key string) string {
if configObj, ok := util.GetNestedField(c.options, key).(map[string]string); ok {
if val, p := configObj[string(mconfig.ValuePTP)]; p {
Expand All @@ -392,20 +397,23 @@ func (c *VolumeConfig) getValue(key string) string {
return ""
}

//getData is a utility function to extract the value
// getData is a utility function to extract the value
// of the `key` from the ConfigMap object - which is
// map[string]interface{map[string]interface{map[string]string}}
// Example:
// {
// key1: {
// value: value1
// data: {
// dataKey1: dataValue1
// }
// }
// }
//
// {
// key1: {
// value: value1
// data: {
// dataKey1: dataValue1
// }
// }
// }
//
// In the above example, if `key1` and `dataKey1` are passed as input,
// `dataValue1` will be returned.
//
// `dataValue1` will be returned.
func (c *VolumeConfig) getData(key string, dataKey string) string {
if configData, ok := util.GetNestedField(c.configData, key).(map[string]string); ok {
if val, p := configData[dataKey]; p {
Expand Down Expand Up @@ -449,11 +457,11 @@ func hookConfigFileExist() (bool, error) {

// initializeHook read the hook config file and update the given hook variable
// return value:
// - nil
// - If hook config file doesn't exists
// - If hook config file is parsed and given hook variable is updated
// - error
// - If hook config is invalid
// - nil
// - If hook config file doesn't exists
// - If hook config file is parsed and given hook variable is updated
// - error
// - If hook config is invalid
func initializeHook(hook **nfshook.Hook) error {
hookFileExists, err := hookConfigFileExist()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion provisioner/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
Loading

0 comments on commit 9b767a1

Please sign in to comment.