Skip to content

Commit

Permalink
fix for the issues reported by the Go Report Card
Browse files Browse the repository at this point in the history
Signed-off-by: Rahul krishnan R A <[email protected]>
  • Loading branch information
rahulkrishnanfs authored and kmova committed Mar 5, 2021
1 parent 14eaa27 commit 07b28b3
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion pkg/kubernetes/api/apps/v1/deployment/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func (b *Builder) WithNodeSelector(selector map[string]string) *Builder {
return b
}

// WithNodeSelector Sets the node selector with the provided argument.
// WithNodeSelectorNew Sets the node selector with the provided argument.
func (b *Builder) WithNodeSelectorNew(selector map[string]string) *Builder {
if len(selector) == 0 {
b.errors = append(
Expand Down
1 change: 1 addition & 0 deletions pkg/kubernetes/api/apps/v1/deployment/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package deployment

import (
Expand Down
6 changes: 3 additions & 3 deletions pkg/kubernetes/api/core/v1/container/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ func TestBuilderWithEnvsNew(t *testing.T) {
}{
"Test Builder with envList": {
envList: []corev1.EnvVar{
corev1.EnvVar{},
{},
},
builder: &Builder{con: &container{
corev1.Container{},
Expand Down Expand Up @@ -324,7 +324,7 @@ func TestBuilderWithPortsNew(t *testing.T) {
}{
"Test Builder with portList": {
portList: []corev1.ContainerPort{
corev1.ContainerPort{},
{},
},
builder: &Builder{con: &container{
corev1.Container{},
Expand Down Expand Up @@ -396,7 +396,7 @@ func TestBuilderWithVolumeMountsNew(t *testing.T) {
}{
"Test Builder with volume mounts": {
mounts: []corev1.VolumeMount{
corev1.VolumeMount{},
{},
},
builder: &Builder{con: &container{
corev1.Container{},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ func (b *Builder) WithNodeSelectorNew(nodeselectors map[string]string) *Builder
return b
}

//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
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ func TestBuilderWithTolerations(t *testing.T) {
}{
"Test Builder with tolerations": {
tolerations: []corev1.Toleration{
corev1.Toleration{},
{},
},
builder: &Builder{podtemplatespec: &PodTemplateSpec{
Object: &corev1.PodTemplateSpec{},
Expand Down Expand Up @@ -391,7 +391,7 @@ func TestBuilderWithTolerationsNew(t *testing.T) {
}{
"Test Builder with tolerations": {
tolerations: []corev1.Toleration{
corev1.Toleration{},
{},
},
builder: &Builder{podtemplatespec: &PodTemplateSpec{
Object: &corev1.PodTemplateSpec{},
Expand Down
22 changes: 11 additions & 11 deletions provisioner/helper_kernel_nfs_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ const (
// NFSPVFinalizer represents finalizer string used by NFSPV
NFSPVFinalizer = "nfs.openebs.io/finalizer"

//NFS Server Port
//NFSServerPort set the NFS Server Port
NFSServerPort = 2049

//RPC Bind Port
//RPCBindPort set the RPC Bind Port
RPCBindPort = 111
)

Expand Down Expand Up @@ -80,7 +80,7 @@ func (p *Provisioner) createBackendPVC(nfsServerOpts *KernelNFSServerOptions) er
klog.V(4).Infof("Verifying if PVC(%v) for NFS storage was already created.", pvcName)

//Check if the PVC is already created. This can happen
//if the previous reconcilation of PVC-PV, resulted in
//if the previous reconciliation of PVC-PV, resulted in
//creating a PVC, but was not yet available for 60+ seconds
_, err := persistentvolumeclaim.NewKubeClient().
WithNamespace(p.namespace).
Expand Down Expand Up @@ -172,7 +172,7 @@ func (p *Provisioner) createDeployment(nfsServerOpts *KernelNFSServerOptions) er
klog.V(4).Infof("Verifying if Deployment(%v) for NFS storage was already created.", deployName)

//Check if the Deployment is already created. This can happen
//if the previous reconcilation of PVC-PV, resulted in
//if the previous reconciliation of PVC-PV, resulted in
//creating a Deployment, but was not yet available for 60+ seconds
_, err := deployment.NewKubeClient().
WithNamespace(p.namespace).
Expand Down Expand Up @@ -207,19 +207,19 @@ func (p *Provisioner) createDeployment(nfsServerOpts *KernelNFSServerOptions) er
WithImage("itsthenetwork/nfs-server-alpine").
WithEnvsNew(
[]corev1.EnvVar{
corev1.EnvVar{
{
Name: "SHARED_DIRECTORY",
Value: "/nfsshare",
},
},
).
WithPortsNew(
[]corev1.ContainerPort{
corev1.ContainerPort{
{
Name: "nfs",
ContainerPort: NFSServerPort,
},
corev1.ContainerPort{
{
Name: "rpcbind",
ContainerPort: RPCBindPort,
},
Expand All @@ -228,7 +228,7 @@ func (p *Provisioner) createDeployment(nfsServerOpts *KernelNFSServerOptions) er
WithPrivilegedSecurityContext(&secContext).
WithVolumeMountsNew(
[]corev1.VolumeMount{
corev1.VolumeMount{
{
Name: "exports-dir",
MountPath: "/nfsshare",
},
Expand Down Expand Up @@ -313,7 +313,7 @@ func (p *Provisioner) createService(nfsServerOpts *KernelNFSServerOptions) error
klog.V(4).Infof("Verifying if Service(%v) for NFS storage was already created.", svcName)

//Check if the Service is already created. This can happen
//if the previous reconcilation of PVC-PV, resulted in
//if the previous reconciliation of PVC-PV, resulted in
//creating a Service, but was not yet available for 60+ seconds
_, err := service.NewKubeClient().
WithNamespace(p.namespace).
Expand All @@ -336,11 +336,11 @@ func (p *Provisioner) createService(nfsServerOpts *KernelNFSServerOptions) error
WithName(svcName).
WithPorts(
[]corev1.ServicePort{
corev1.ServicePort{
{
Name: "nfs",
Port: NFSServerPort,
},
corev1.ServicePort{
{
Name: "rpcbind",
Port: RPCBindPort,
},
Expand Down
4 changes: 2 additions & 2 deletions tests/sanity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ var _ = Describe("TEST NFS PV", func() {
).
WithVolumeMountsNew(
[]corev1.VolumeMount{
corev1.VolumeMount{
{
Name: "demo-vol1",
MountPath: "/mnt/store1",
},
Expand All @@ -114,7 +114,7 @@ var _ = Describe("TEST NFS PV", func() {
Build()
Expect(err).ShouldNot(
HaveOccurred(),
"while building delpoyment {%s} in namespace {%s}",
"while building deployment {%s} in namespace {%s}",
deployName,
namespaceObj.Name,
)
Expand Down

0 comments on commit 07b28b3

Please sign in to comment.