Skip to content

Commit 053441e

Browse files
committed
run go fmt
Signed-off-by: Stephanie <[email protected]>
1 parent 621f915 commit 053441e

File tree

6 files changed

+33
-35
lines changed

6 files changed

+33
-35
lines changed

pkg/validation/components.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func ValidateComponents(components []v1alpha2.Component) error {
8282
}
8383
} else if component.Openshift != nil {
8484
if component.Openshift.Uri != "" {
85-
err:= ValidateURI(component.Openshift.Uri)
85+
err := ValidateURI(component.Openshift.Uri)
8686
if err != nil {
8787
return err
8888
}
@@ -95,7 +95,7 @@ func ValidateComponents(components []v1alpha2.Component) error {
9595

9696
} else if component.Kubernetes != nil {
9797
if component.Kubernetes.Uri != "" {
98-
err:= ValidateURI(component.Kubernetes.Uri)
98+
err := ValidateURI(component.Kubernetes.Uri)
9999
if err != nil {
100100
return err
101101
}

pkg/validation/components_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func generateDummyOpenshiftComponent(name string, endpoints []v1alpha2.Endpoint,
5252
K8sLikeComponentLocation: v1alpha2.K8sLikeComponentLocation{
5353
Uri: uri,
5454
},
55-
Endpoints : endpoints,
55+
Endpoints: endpoints,
5656
},
5757
},
5858
},
@@ -70,7 +70,7 @@ func generateDummyKubernetesComponent(name string, endpoints []v1alpha2.Endpoint
7070
K8sLikeComponentLocation: v1alpha2.K8sLikeComponentLocation{
7171
Uri: uri,
7272
},
73-
Endpoints : endpoints,
73+
Endpoints: endpoints,
7474
},
7575
},
7676
},

pkg/validation/endpoints.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
44

55
// validateEndpoints validates that the endpoints
66

7-
func validateEndpoints(endpoints []v1alpha2.Endpoint, processedEndPointPort map[int]bool, processedEndPointName map[string]bool) error {
7+
func validateEndpoints(endpoints []v1alpha2.Endpoint, processedEndPointPort map[int]bool, processedEndPointName map[string]bool) error {
88
currentComponentEndPointPort := make(map[int]bool)
99

1010
for _, endPoint := range endpoints {
@@ -19,7 +19,7 @@ func validateEndpoints(endpoints []v1alpha2.Endpoint, processedEndPointPort map[
1919
}
2020

2121
for targetPort := range currentComponentEndPointPort {
22-
if _, ok :=processedEndPointPort[targetPort]; ok {
22+
if _, ok := processedEndPointPort[targetPort]; ok {
2323
return &InvalidEndpointError{port: targetPort}
2424
}
2525
processedEndPointPort[targetPort] = true

pkg/validation/endpoints_test.go

+8-9
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import (
88
func TestValidateEndpoints(t *testing.T) {
99

1010
tests := []struct {
11-
name string
12-
endpoints []v1alpha2.Endpoint
11+
name string
12+
endpoints []v1alpha2.Endpoint
1313
processedEndpointName map[string]bool
1414
processedEndpointPort map[int]bool
15-
wantErr bool
15+
wantErr bool
1616
}{
1717
{
1818
name: "Case 1: Duplicate endpoint name within same component",
@@ -22,7 +22,7 @@ func TestValidateEndpoints(t *testing.T) {
2222
},
2323
processedEndpointName: map[string]bool{},
2424
processedEndpointPort: map[int]bool{},
25-
wantErr: true,
25+
wantErr: true,
2626
},
2727
{
2828
name: "Case 2: Duplicate endpoint name across components",
@@ -33,7 +33,7 @@ func TestValidateEndpoints(t *testing.T) {
3333
"url1": true,
3434
},
3535
processedEndpointPort: map[int]bool{},
36-
wantErr: true,
36+
wantErr: true,
3737
},
3838
{
3939
name: "Case 3: Duplicate endpoint port within same component",
@@ -43,7 +43,7 @@ func TestValidateEndpoints(t *testing.T) {
4343
},
4444
processedEndpointName: map[string]bool{},
4545
processedEndpointPort: map[int]bool{},
46-
wantErr: false,
46+
wantErr: false,
4747
},
4848
{
4949
name: "Case 4: Duplicate endpoint port across components",
@@ -64,9 +64,8 @@ func TestValidateEndpoints(t *testing.T) {
6464
},
6565
processedEndpointName: map[string]bool{},
6666
processedEndpointPort: map[int]bool{},
67-
wantErr: true,
67+
wantErr: true,
6868
},
69-
7069
}
7170
for _, tt := range tests {
7271
t.Run(tt.name, func(t *testing.T) {
@@ -87,4 +86,4 @@ func generateDummyEndpoint(name string, port int) v1alpha2.Endpoint {
8786
Name: name,
8887
TargetPort: port,
8988
}
90-
}
89+
}

pkg/validation/errors.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ func (e *InvalidComponentError) Error() string {
7979

8080
// InvalidNameOrIdError returns an error if the name or is is invalid
8181
type InvalidNameOrIdError struct {
82-
name string
83-
id string
82+
name string
83+
id string
8484
resourceType string
8585
}
8686

@@ -93,4 +93,3 @@ func (e *InvalidNameOrIdError) Error() string {
9393
}
9494
return errMsg
9595
}
96-

pkg/validation/utils_test.go

+17-17
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,23 @@ import (
77
func TestIsInt(t *testing.T) {
88

99
tests := []struct {
10-
name string
11-
arg string
10+
name string
11+
arg string
1212
wantResult bool
1313
}{
1414
{
15-
name: "Case 1: numeric string",
16-
arg: "1234",
15+
name: "Case 1: numeric string",
16+
arg: "1234",
1717
wantResult: true,
1818
},
1919
{
20-
name: "Case 2: alphanumeric string",
21-
arg: "1234abc",
20+
name: "Case 2: alphanumeric string",
21+
arg: "1234abc",
2222
wantResult: false,
2323
},
2424
{
25-
name: "Case 3: string with numbers and character",
26-
arg: "12_34",
25+
name: "Case 3: string with numbers and character",
26+
arg: "12_34",
2727
wantResult: false,
2828
},
2929
}
@@ -40,23 +40,23 @@ func TestIsInt(t *testing.T) {
4040
func TestValidateURI(t *testing.T) {
4141

4242
tests := []struct {
43-
name string
44-
uri string
43+
name string
44+
uri string
4545
wantErr bool
4646
}{
4747
{
48-
name: "Case 1: valid uri format starts with http",
49-
uri: "http://devfile.yaml",
48+
name: "Case 1: valid uri format starts with http",
49+
uri: "http://devfile.yaml",
5050
wantErr: false,
5151
},
5252
{
53-
name: "Case 2: invalid uri format starts with http",
54-
uri: "http//devfile.yaml",
53+
name: "Case 2: invalid uri format starts with http",
54+
uri: "http//devfile.yaml",
5555
wantErr: true,
5656
},
5757
{
58-
name: "Case 3: invalid uri format does not start with http",
59-
uri: "./devfile.yaml",
58+
name: "Case 3: invalid uri format does not start with http",
59+
uri: "./devfile.yaml",
6060
wantErr: false,
6161
},
6262
}
@@ -68,4 +68,4 @@ func TestValidateURI(t *testing.T) {
6868
}
6969
})
7070
}
71-
}
71+
}

0 commit comments

Comments
 (0)