mirror of
https://github.com/docker/compose.git
synced 2025-07-23 13:45:00 +02:00
Add ACI public ip
This commit is contained in:
parent
d8a38afecc
commit
5effbdc31f
@ -133,11 +133,12 @@ func (cs *aciContainerService) List(ctx context.Context) ([]containers.Container
|
|||||||
if container.InstanceView != nil && container.InstanceView.CurrentState != nil {
|
if container.InstanceView != nil && container.InstanceView.CurrentState != nil {
|
||||||
status = *container.InstanceView.CurrentState.State
|
status = *container.InstanceView.CurrentState.State
|
||||||
}
|
}
|
||||||
|
|
||||||
res = append(res, containers.Container{
|
res = append(res, containers.Container{
|
||||||
ID: containerID,
|
ID: containerID,
|
||||||
Image: *container.Image,
|
Image: *container.Image,
|
||||||
Status: status,
|
Status: status,
|
||||||
Ports: convert.ToPorts(*container.Ports),
|
Ports: convert.ToPorts(group.IPAddress, *container.Ports),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,22 +1,35 @@
|
|||||||
package convert
|
package convert
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-10-01/containerinstance"
|
"github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-10-01/containerinstance"
|
||||||
|
|
||||||
"github.com/docker/api/containers"
|
"github.com/docker/api/containers"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ToPorts converts Azure container ports to api ports
|
// ToPorts converts Azure container ports to api ports
|
||||||
func ToPorts(ports []containerinstance.ContainerPort) []containers.Port {
|
func ToPorts(ipAddr *containerinstance.IPAddress, ports []containerinstance.ContainerPort) []containers.Port {
|
||||||
var result []containers.Port
|
var result []containers.Port
|
||||||
|
|
||||||
for _, port := range ports {
|
for _, port := range ports {
|
||||||
if port.Port == nil {
|
if port.Port == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
protocol := "tcp"
|
||||||
|
if port.Protocol != "" {
|
||||||
|
protocol = string(port.Protocol)
|
||||||
|
}
|
||||||
|
ip := ""
|
||||||
|
if ipAddr != nil {
|
||||||
|
ip = *ipAddr.IP
|
||||||
|
}
|
||||||
|
|
||||||
result = append(result, containers.Port{
|
result = append(result, containers.Port{
|
||||||
|
HostPort: uint32(*port.Port),
|
||||||
ContainerPort: uint32(*port.Port),
|
ContainerPort: uint32(*port.Port),
|
||||||
Protocol: "tcp",
|
HostIP: ip,
|
||||||
|
Protocol: strings.ToLower(protocol),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/Azure/azure-sdk-for-go/profiles/2019-03-01/resources/mgmt/resources"
|
"github.com/Azure/azure-sdk-for-go/profiles/2019-03-01/resources/mgmt/resources"
|
||||||
"github.com/Azure/go-autorest/autorest/to"
|
"github.com/Azure/go-autorest/autorest/to"
|
||||||
@ -66,8 +67,7 @@ func main() {
|
|||||||
Expect(len(Lines(output))).To(Equal(1))
|
Expect(len(Lines(output))).To(Equal(1))
|
||||||
})
|
})
|
||||||
|
|
||||||
var nginxID string
|
It("runs nginx on port 80", func() {
|
||||||
It("runs nginx on port 80 (PORT NOT CHECKED YET!!! REMOVE THAT WHEN IMPLEMENTED)", func() {
|
|
||||||
output := NewDockerCommand("run", "nginx", "-p", "80:80", "--name", testContainerName).ExecOrDie()
|
output := NewDockerCommand("run", "nginx", "-p", "80:80", "--name", testContainerName).ExecOrDie()
|
||||||
Expect(output).To(Equal(testContainerName + "\n"))
|
Expect(output).To(Equal(testContainerName + "\n"))
|
||||||
output = NewDockerCommand("ps").ExecOrDie()
|
output = NewDockerCommand("ps").ExecOrDie()
|
||||||
@ -75,20 +75,19 @@ func main() {
|
|||||||
Expect(len(lines)).To(Equal(2))
|
Expect(len(lines)).To(Equal(2))
|
||||||
|
|
||||||
containerFields := Columns(lines[1])
|
containerFields := Columns(lines[1])
|
||||||
nginxID = containerFields[0]
|
|
||||||
Expect(containerFields[1]).To(Equal("nginx"))
|
Expect(containerFields[1]).To(Equal("nginx"))
|
||||||
Expect(containerFields[2]).To(Equal("Running"))
|
Expect(containerFields[2]).To(Equal("Running"))
|
||||||
// exposedIP := containerFields[3]
|
exposedIP := containerFields[3]
|
||||||
// Expect(exposedIP).To(ContainSubstring(":80->80/TCP"))
|
Expect(exposedIP).To(ContainSubstring(":80->80/tcp"))
|
||||||
|
|
||||||
// url := strings.ReplaceAll(exposedIP, "->80/TCP", "")
|
url := strings.ReplaceAll(exposedIP, "->80/tcp", "")
|
||||||
// output = NewCommand("curl", url).ExecOrDie()
|
output = NewCommand("curl", url).ExecOrDie()
|
||||||
// Expect(output).To(ContainSubstring("Welcome to nginx!"))
|
Expect(output).To(ContainSubstring("Welcome to nginx!"))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("removes container nginx", func() {
|
It("removes container nginx", func() {
|
||||||
output := NewDockerCommand("rm", nginxID).ExecOrDie()
|
output := NewDockerCommand("rm", testContainerName).ExecOrDie()
|
||||||
Expect(Lines(output)[0]).To(Equal(nginxID))
|
Expect(Lines(output)[0]).To(Equal(testContainerName))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("deploys a compose app", func() {
|
It("deploys a compose app", func() {
|
||||||
@ -97,25 +96,25 @@ func main() {
|
|||||||
output := NewDockerCommand("ps").ExecOrDie()
|
output := NewDockerCommand("ps").ExecOrDie()
|
||||||
Lines := Lines(output)
|
Lines := Lines(output)
|
||||||
Expect(len(Lines)).To(Equal(4))
|
Expect(len(Lines)).To(Equal(4))
|
||||||
|
webChecked := false
|
||||||
|
|
||||||
for _, line := range Lines[1:] {
|
for _, line := range Lines[1:] {
|
||||||
Expect(line).To(ContainSubstring("Running"))
|
Expect(line).To(ContainSubstring("Running"))
|
||||||
}
|
if strings.Contains(line, "acidemo_web") {
|
||||||
/*
|
|
||||||
if strings.Contains(line, "acicompose_web") {
|
|
||||||
webChecked = true
|
webChecked = true
|
||||||
containerFields := Columns(line)
|
containerFields := Columns(line)
|
||||||
exposedIP := containerFields[3]
|
exposedIP := containerFields[3]
|
||||||
Expect(exposedIP).To(ContainSubstring(":80->80/TCP"))
|
Expect(exposedIP).To(ContainSubstring(":80->80/tcp"))
|
||||||
|
|
||||||
url := strings.ReplaceAll(exposedIP, "->80/TCP", "")
|
url := strings.ReplaceAll(exposedIP, "->80/tcp", "")
|
||||||
output = NewCommand("curl", url).ExecOrDie()
|
output = NewCommand("curl", url).ExecOrDie()
|
||||||
Expect(output).To(ContainSubstring("Docker Compose demo"))
|
Expect(output).To(ContainSubstring("Docker Compose demo"))
|
||||||
output = NewCommand("curl", url+"/words/noun").ExecOrDie()
|
output = NewCommand("curl", url+"/words/noun").ExecOrDie()
|
||||||
Expect(output).To(ContainSubstring("\"word\":"))
|
Expect(output).To(ContainSubstring("\"word\":"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Expect(webChecked).To(BeTrue())
|
Expect(webChecked).To(BeTrue())
|
||||||
*/
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("get logs from web service", func() {
|
It("get logs from web service", func() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user