|
@@ -29,9 +29,9 @@ func TestServiceContextWrite(t *testing.T) {
|
|
// Table format
|
|
// Table format
|
|
{
|
|
{
|
|
Context{Format: NewServiceListFormat("table", false)},
|
|
Context{Format: NewServiceListFormat("table", false)},
|
|
- `ID NAME MODE REPLICAS IMAGE
|
|
|
|
-id_baz baz global 2/4
|
|
|
|
-id_bar bar replicated 2/4
|
|
|
|
|
|
+ `ID NAME MODE REPLICAS IMAGE PORTS
|
|
|
|
+id_baz baz global 2/4 *:80->8080/tcp
|
|
|
|
+id_bar bar replicated 2/4 *:80->8080/tcp
|
|
`,
|
|
`,
|
|
},
|
|
},
|
|
{
|
|
{
|
|
@@ -62,12 +62,14 @@ name: baz
|
|
mode: global
|
|
mode: global
|
|
replicas: 2/4
|
|
replicas: 2/4
|
|
image:
|
|
image:
|
|
|
|
+ports: *:80->8080/tcp
|
|
|
|
|
|
id: id_bar
|
|
id: id_bar
|
|
name: bar
|
|
name: bar
|
|
mode: replicated
|
|
mode: replicated
|
|
replicas: 2/4
|
|
replicas: 2/4
|
|
image:
|
|
image:
|
|
|
|
+ports: *:80->8080/tcp
|
|
|
|
|
|
`,
|
|
`,
|
|
},
|
|
},
|
|
@@ -88,8 +90,38 @@ bar
|
|
|
|
|
|
for _, testcase := range cases {
|
|
for _, testcase := range cases {
|
|
services := []swarm.Service{
|
|
services := []swarm.Service{
|
|
- {ID: "id_baz", Spec: swarm.ServiceSpec{Annotations: swarm.Annotations{Name: "baz"}}},
|
|
|
|
- {ID: "id_bar", Spec: swarm.ServiceSpec{Annotations: swarm.Annotations{Name: "bar"}}},
|
|
|
|
|
|
+ {
|
|
|
|
+ ID: "id_baz",
|
|
|
|
+ Spec: swarm.ServiceSpec{
|
|
|
|
+ Annotations: swarm.Annotations{Name: "baz"},
|
|
|
|
+ EndpointSpec: &swarm.EndpointSpec{
|
|
|
|
+ Ports: []swarm.PortConfig{
|
|
|
|
+ {
|
|
|
|
+ PublishMode: "ingress",
|
|
|
|
+ PublishedPort: 80,
|
|
|
|
+ TargetPort: 8080,
|
|
|
|
+ Protocol: "tcp",
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ ID: "id_bar",
|
|
|
|
+ Spec: swarm.ServiceSpec{
|
|
|
|
+ Annotations: swarm.Annotations{Name: "bar"},
|
|
|
|
+ EndpointSpec: &swarm.EndpointSpec{
|
|
|
|
+ Ports: []swarm.PortConfig{
|
|
|
|
+ {
|
|
|
|
+ PublishMode: "ingress",
|
|
|
|
+ PublishedPort: 80,
|
|
|
|
+ TargetPort: 8080,
|
|
|
|
+ Protocol: "tcp",
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ },
|
|
}
|
|
}
|
|
info := map[string]ServiceListInfo{
|
|
info := map[string]ServiceListInfo{
|
|
"id_baz": {
|
|
"id_baz": {
|
|
@@ -114,8 +146,38 @@ bar
|
|
|
|
|
|
func TestServiceContextWriteJSON(t *testing.T) {
|
|
func TestServiceContextWriteJSON(t *testing.T) {
|
|
services := []swarm.Service{
|
|
services := []swarm.Service{
|
|
- {ID: "id_baz", Spec: swarm.ServiceSpec{Annotations: swarm.Annotations{Name: "baz"}}},
|
|
|
|
- {ID: "id_bar", Spec: swarm.ServiceSpec{Annotations: swarm.Annotations{Name: "bar"}}},
|
|
|
|
|
|
+ {
|
|
|
|
+ ID: "id_baz",
|
|
|
|
+ Spec: swarm.ServiceSpec{
|
|
|
|
+ Annotations: swarm.Annotations{Name: "baz"},
|
|
|
|
+ EndpointSpec: &swarm.EndpointSpec{
|
|
|
|
+ Ports: []swarm.PortConfig{
|
|
|
|
+ {
|
|
|
|
+ PublishMode: "ingress",
|
|
|
|
+ PublishedPort: 80,
|
|
|
|
+ TargetPort: 8080,
|
|
|
|
+ Protocol: "tcp",
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ ID: "id_bar",
|
|
|
|
+ Spec: swarm.ServiceSpec{
|
|
|
|
+ Annotations: swarm.Annotations{Name: "bar"},
|
|
|
|
+ EndpointSpec: &swarm.EndpointSpec{
|
|
|
|
+ Ports: []swarm.PortConfig{
|
|
|
|
+ {
|
|
|
|
+ PublishMode: "ingress",
|
|
|
|
+ PublishedPort: 80,
|
|
|
|
+ TargetPort: 8080,
|
|
|
|
+ Protocol: "tcp",
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ },
|
|
}
|
|
}
|
|
info := map[string]ServiceListInfo{
|
|
info := map[string]ServiceListInfo{
|
|
"id_baz": {
|
|
"id_baz": {
|
|
@@ -128,8 +190,8 @@ func TestServiceContextWriteJSON(t *testing.T) {
|
|
},
|
|
},
|
|
}
|
|
}
|
|
expectedJSONs := []map[string]interface{}{
|
|
expectedJSONs := []map[string]interface{}{
|
|
- {"ID": "id_baz", "Name": "baz", "Mode": "global", "Replicas": "2/4", "Image": ""},
|
|
|
|
- {"ID": "id_bar", "Name": "bar", "Mode": "replicated", "Replicas": "2/4", "Image": ""},
|
|
|
|
|
|
+ {"ID": "id_baz", "Name": "baz", "Mode": "global", "Replicas": "2/4", "Image": "", "Ports": "*:80->8080/tcp"},
|
|
|
|
+ {"ID": "id_bar", "Name": "bar", "Mode": "replicated", "Replicas": "2/4", "Image": "", "Ports": "*:80->8080/tcp"},
|
|
}
|
|
}
|
|
|
|
|
|
out := bytes.NewBufferString("")
|
|
out := bytes.NewBufferString("")
|