Skip to content

Commit

Permalink
Add golangci config
Browse files Browse the repository at this point in the history
Signed-off-by: Ashok Pon Kumar <[email protected]>
  • Loading branch information
ashokponkumar committed Oct 2, 2020
1 parent 584a35d commit c9b5d0f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 15 deletions.
11 changes: 11 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
issues:
exclude-use-default: false

linters:
disable-all: true
enable:
- golint

linters-settings:
golint:
min-confidence: 0.85
9 changes: 3 additions & 6 deletions internal/apiresource/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,8 @@ func (d *Deployment) ConvertToClusterSupportedKinds(obj runtime.Object, supporte
} else if d1, ok := obj.(*corev1.Pod); ok {
var replicas int32 = 2
return []runtime.Object{d.toDeployment(d1.ObjectMeta, d1.Spec, replicas)}, true
} else {
return []runtime.Object{obj}, true
}
return []runtime.Object{obj}, true
}
if common.IsStringPresent(supportedKinds, replicationControllerKind) {
if d1, ok := obj.(*okdappsv1.DeploymentConfig); ok {
Expand All @@ -149,9 +148,8 @@ func (d *Deployment) ConvertToClusterSupportedKinds(obj runtime.Object, supporte
} else if d1, ok := obj.(*corev1.Pod); ok {
var replicas int32 = 2
return []runtime.Object{d.toReplicationController(d1.ObjectMeta, d1.Spec, replicas)}, true
} else {
return []runtime.Object{obj}, true
}
return []runtime.Object{obj}, true
}
if common.IsStringPresent(supportedKinds, podKind) {
if d1, ok := obj.(*okdappsv1.DeploymentConfig); ok {
Expand All @@ -160,9 +158,8 @@ func (d *Deployment) ConvertToClusterSupportedKinds(obj runtime.Object, supporte
return []runtime.Object{d.toPod(d1.ObjectMeta, d1.Spec.Template.Spec, corev1.RestartPolicyAlways)}, true
} else if d1, ok := obj.(*corev1.ReplicationController); ok {
return []runtime.Object{d.toPod(d1.ObjectMeta, d1.Spec.Template.Spec, corev1.RestartPolicyAlways)}, true
} else {
return []runtime.Object{obj}, true
}
return []runtime.Object{obj}, true
}
return nil, false
}
Expand Down
4 changes: 2 additions & 2 deletions internal/common/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func TestGetImageNameAndTag(t *testing.T) {

type givesYamlError struct{}

func (_ *givesYamlError) MarshalYAML() (interface{}, error) {
func (*givesYamlError) MarshalYAML() (interface{}, error) {
return nil, fmt.Errorf("Can't marshal this type to yaml.")
}

Expand Down Expand Up @@ -325,7 +325,7 @@ func TestReadYaml(t *testing.T) {

type givesJSONError struct{}

func (_ *givesJSONError) MarshalJSON() ([]byte, error) {
func (*givesJSONError) MarshalJSON() ([]byte, error) {
return nil, fmt.Errorf("Can't marshal this type to json.")
}

Expand Down
3 changes: 1 addition & 2 deletions internal/qaengine/cliengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ func (c *CliEngine) FetchAnswer(prob qatypes.Problem) (answer qatypes.Problem, e
}

func (c *CliEngine) fetchSelectAnswer(prob qatypes.Problem) (answer qatypes.Problem, err error) {
var ans string = ""
d := ""
var ans, d string
if len(prob.Solution.Default) > 0 {
d = prob.Solution.Default[0]
} else {
Expand Down
10 changes: 5 additions & 5 deletions types/plan/plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,11 +432,11 @@ func TestNewPlan(t *testing.T) {
}

func TestNewService(t *testing.T) {
svc_name := "foo"
var trans_type plan.TranslationTypeValue = "bar"
s := plan.NewService(svc_name, trans_type)
if s.ServiceName != svc_name || s.TranslationType != trans_type {
t.Error("Service name and translation type have not been set correctly. Expected:", svc_name, trans_type, "Actual:", s.ServiceName, s.TranslationType)
svcName := "foo"
var transType plan.TranslationTypeValue = "bar"
s := plan.NewService(svcName, transType)
if s.ServiceName != svcName || s.TranslationType != transType {
t.Error("Service name and translation type have not been set correctly. Expected:", svcName, transType, "Actual:", s.ServiceName, s.TranslationType)
}
if s.SourceTypes == nil || s.BuildArtifacts == nil || s.SourceArtifacts == nil {
t.Error("Failed to instantiate the service fields properly. Actual:", s)
Expand Down

0 comments on commit c9b5d0f

Please sign in to comment.