Skip to content

Commit

Permalink
Simplify composite literals
Browse files Browse the repository at this point in the history
Utility "gopls" used to analyse Go source did not support code
simplifications as of writing "sslendpoints" tool [1].

Simplifying composite literals is now supported [2].

[1] golang/go#37221
[2] golang/tools@e428a8e

Issue-ID: SECCOM-261
Change-Id: I757ff8aefed4c7653f3992f9c1b7b0f3e6c10ea3
Signed-off-by: Pawel Wieczorek <p.wieczorek2@samsung.com>
(cherry picked from commit 8ff725b)
  • Loading branch information
pawiecz authored and morganrOL committed Nov 26, 2020
1 parent b338e25 commit 8eda063
Showing 1 changed file with 50 additions and 50 deletions.
100 changes: 50 additions & 50 deletions test/security/sslendpoints/ports/ports_test.go
Expand Up @@ -55,126 +55,126 @@ var _ = Describe("Ports", func() {

BeforeEach(func() {
csvSomeUnparsable = [][]string{
[]string{serviceR, strconv.Itoa(nodePortO)},
[]string{serviceL, strconv.Itoa(nodePortN)},
[]string{serviceZ, notParsablePort1},
{serviceR, strconv.Itoa(nodePortO)},
{serviceL, strconv.Itoa(nodePortN)},
{serviceZ, notParsablePort1},
}
csvAllUnparsable = [][]string{
[]string{serviceR, notParsablePort1},
[]string{serviceL, notParsablePort2},
[]string{serviceZ, notParsablePort3},
{serviceR, notParsablePort1},
{serviceL, notParsablePort2},
{serviceZ, notParsablePort3},
}

servicesEmpty = &v1.ServiceList{}
servicesSingleWithNodePort = &v1.ServiceList{
Items: []v1.Service{
v1.Service{
{
ObjectMeta: metav1.ObjectMeta{Name: serviceR},
Spec: v1.ServiceSpec{
Ports: []v1.ServicePort{
v1.ServicePort{NodePort: nodePortO},
{NodePort: nodePortO},
},
},
},
},
}
servicesSingleWithMultipleNodePorts = &v1.ServiceList{
Items: []v1.Service{
v1.Service{
{
ObjectMeta: metav1.ObjectMeta{Name: serviceR},
Spec: v1.ServiceSpec{
Ports: []v1.ServicePort{
v1.ServicePort{NodePort: nodePortO},
v1.ServicePort{NodePort: nodePortN},
{NodePort: nodePortO},
{NodePort: nodePortN},
},
},
},
},
}
servicesManyWithoutNodePorts = &v1.ServiceList{
Items: []v1.Service{
v1.Service{
{
Spec: v1.ServiceSpec{
Ports: []v1.ServicePort{
v1.ServicePort{NodePort: notNodePort},
{NodePort: notNodePort},
},
},
},
v1.Service{
{
Spec: v1.ServiceSpec{
Ports: []v1.ServicePort{
v1.ServicePort{NodePort: notNodePort},
{NodePort: notNodePort},
},
},
},
},
}
servicesManyWithNodePort = &v1.ServiceList{
Items: []v1.Service{
v1.Service{
{
ObjectMeta: metav1.ObjectMeta{Name: serviceR},
Spec: v1.ServiceSpec{
Ports: []v1.ServicePort{
v1.ServicePort{NodePort: nodePortO},
{NodePort: nodePortO},
},
},
},
v1.Service{
{
ObjectMeta: metav1.ObjectMeta{Name: serviceL},
Spec: v1.ServiceSpec{
Ports: []v1.ServicePort{
v1.ServicePort{NodePort: nodePortN},
{NodePort: nodePortN},
},
},
},
},
}
servicesManyWithMultipleNodePorts = &v1.ServiceList{
Items: []v1.Service{
v1.Service{
{
ObjectMeta: metav1.ObjectMeta{Name: serviceR},
Spec: v1.ServiceSpec{
Ports: []v1.ServicePort{
v1.ServicePort{NodePort: nodePortO},
v1.ServicePort{NodePort: nodePortN},
{NodePort: nodePortO},
{NodePort: nodePortN},
},
},
},
v1.Service{
{
ObjectMeta: metav1.ObjectMeta{Name: serviceL},
Spec: v1.ServiceSpec{
Ports: []v1.ServicePort{
v1.ServicePort{NodePort: nodePortA},
v1.ServicePort{NodePort: nodePortP},
{NodePort: nodePortA},
{NodePort: nodePortP},
},
},
},
},
}
servicesManyMixedNodePorts = &v1.ServiceList{
Items: []v1.Service{
v1.Service{
{
ObjectMeta: metav1.ObjectMeta{Name: serviceR},
Spec: v1.ServiceSpec{
Ports: []v1.ServicePort{
v1.ServicePort{NodePort: notNodePort},
{NodePort: notNodePort},
},
},
},
v1.Service{
{
ObjectMeta: metav1.ObjectMeta{Name: serviceL},
Spec: v1.ServiceSpec{
Ports: []v1.ServicePort{
v1.ServicePort{NodePort: nodePortO},
{NodePort: nodePortO},
},
},
},
v1.Service{
{
ObjectMeta: metav1.ObjectMeta{Name: serviceZ},
Spec: v1.ServiceSpec{
Ports: []v1.ServicePort{
v1.ServicePort{NodePort: nodePortN},
v1.ServicePort{NodePort: nodePortA},
{NodePort: nodePortN},
{NodePort: nodePortA},
},
},
},
Expand All @@ -184,63 +184,63 @@ var _ = Describe("Ports", func() {
nodesEmpty = &v1.NodeList{}
nodesSingleWithIP = &v1.NodeList{
Items: []v1.Node{
v1.Node{
{
Status: v1.NodeStatus{
Addresses: []v1.NodeAddress{
v1.NodeAddress{Type: "InternalIP", Address: internalIpControl},
v1.NodeAddress{Type: "Hostname", Address: hostnameControl},
{Type: "InternalIP", Address: internalIpControl},
{Type: "Hostname", Address: hostnameControl},
},
},
},
},
}
nodesSingleWithBothIPs = &v1.NodeList{
Items: []v1.Node{
v1.Node{
{
Status: v1.NodeStatus{
Addresses: []v1.NodeAddress{
v1.NodeAddress{Type: "ExternalIP", Address: externalIpControl},
v1.NodeAddress{Type: "InternalIP", Address: internalIpControl},
v1.NodeAddress{Type: "Hostname", Address: hostnameControl},
{Type: "ExternalIP", Address: externalIpControl},
{Type: "InternalIP", Address: internalIpControl},
{Type: "Hostname", Address: hostnameControl},
},
},
},
},
}
nodesManyWithHostnames = &v1.NodeList{
Items: []v1.Node{
v1.Node{
{
Status: v1.NodeStatus{
Addresses: []v1.NodeAddress{
v1.NodeAddress{Type: "Hostname", Address: hostnameControl},
{Type: "Hostname", Address: hostnameControl},
},
},
},
v1.Node{
{
Status: v1.NodeStatus{
Addresses: []v1.NodeAddress{
v1.NodeAddress{Type: "Hostname", Address: hostnameWorker},
{Type: "Hostname", Address: hostnameWorker},
},
},
},
},
}
nodesManyWithMixedIPs = &v1.NodeList{
Items: []v1.Node{
v1.Node{
{
Status: v1.NodeStatus{
Addresses: []v1.NodeAddress{
v1.NodeAddress{Type: "ExternalIP", Address: externalIpControl},
v1.NodeAddress{Type: "InternalIP", Address: internalIpControl},
v1.NodeAddress{Type: "Hostname", Address: hostnameControl},
{Type: "ExternalIP", Address: externalIpControl},
{Type: "InternalIP", Address: internalIpControl},
{Type: "Hostname", Address: hostnameControl},
},
},
},
v1.Node{
{
Status: v1.NodeStatus{
Addresses: []v1.NodeAddress{
v1.NodeAddress{Type: "InternalIP", Address: internalIpWorker},
v1.NodeAddress{Type: "Hostname", Address: hostnameWorker},
{Type: "InternalIP", Address: internalIpWorker},
{Type: "Hostname", Address: hostnameWorker},
},
},
},
Expand Down

0 comments on commit 8eda063

Please sign in to comment.