Merge pull request #389 from docker/fix-single-container-tag

Fix adding a tag to a container group
This commit is contained in:
Chris Crone 2020-07-16 11:24:57 +02:00 committed by GitHub
commit 9a4e937c8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 11 deletions

View File

@ -196,16 +196,16 @@ func (cs *aciContainerService) Run(ctx context.Context, r containers.ContainerCo
if err != nil {
return err
}
addTag(groupDefinition, singleContainerTag)
addTag(&groupDefinition, singleContainerTag)
return createACIContainers(ctx, cs.ctx, groupDefinition)
}
func addTag(groupDefinition containerinstance.ContainerGroup, tagName string) {
func addTag(groupDefinition *containerinstance.ContainerGroup, tagName string) {
if groupDefinition.Tags == nil {
groupDefinition.Tags = make(map[string]*string, 1)
}
groupDefinition.Tags[tagName] = to.StringPtr("")
groupDefinition.Tags[tagName] = to.StringPtr(tagName)
}
func (cs *aciContainerService) Stop(ctx context.Context, containerName string, timeout *uint32) error {
@ -332,7 +332,7 @@ func (cs *aciComposeService) Up(ctx context.Context, opts cli.ProjectOptions) er
}
logrus.Debugf("Up on project with name %q\n", project.Name)
groupDefinition, err := convert.ToContainerGroup(cs.ctx, *project)
addTag(groupDefinition, composeContainerTag)
addTag(&groupDefinition, composeContainerTag)
if err != nil {
return err

View File

@ -81,6 +81,7 @@ func (s *E2eACISuite) TestLoginLogoutCreateContextError() {
}
func (s *E2eACISuite) TestACIRunSingleContainer() {
var containerName string
resourceGroupName := s.setupTestResourceGroup()
defer deleteResourceGroup(resourceGroupName)
@ -105,8 +106,10 @@ func (s *E2eACISuite) TestACIRunSingleContainer() {
"-v", fmt.Sprintf("%s:%s@%s:%s",
testStorageAccountName, firstKey, testShareName, mountTarget),
"-p", "80:80",
"--name", testContainerName).ExecOrDie()
Expect(output).To(ContainSubstring(testContainerName))
).ExecOrDie()
runOutput := Lines(output)
containerName = runOutput[len(runOutput)-1]
output = s.NewDockerCommand("ps").ExecOrDie()
lines := Lines(output)
Expect(len(lines)).To(Equal(2))
@ -127,10 +130,10 @@ func (s *E2eACISuite) TestACIRunSingleContainer() {
})
s.Step("exec command", func() {
output := s.NewDockerCommand("exec", testContainerName, "pwd").ExecOrDie()
output := s.NewDockerCommand("exec", containerName, "pwd").ExecOrDie()
Expect(output).To(ContainSubstring("/"))
_, err := s.NewDockerCommand("exec", testContainerName, "echo", "fail_with_argument").Exec()
_, err := s.NewDockerCommand("exec", containerName, "echo", "fail_with_argument").Exec()
Expect(err.Error()).To(ContainSubstring("ACI exec command does not accept arguments to the command. " +
"Only the binary should be specified"))
})
@ -138,7 +141,7 @@ func (s *E2eACISuite) TestACIRunSingleContainer() {
s.Step("follow logs from nginx", func() {
timeChan := make(chan time.Time)
ctx := s.NewDockerCommand("logs", "--follow", testContainerName).WithTimeout(timeChan)
ctx := s.NewDockerCommand("logs", "--follow", containerName).WithTimeout(timeChan)
outChan := make(chan string)
go func() {
@ -163,8 +166,8 @@ func (s *E2eACISuite) TestACIRunSingleContainer() {
})
s.Step("removes container nginx", func() {
output := s.NewDockerCommand("rm", testContainerName).ExecOrDie()
Expect(Lines(output)[0]).To(Equal(testContainerName))
output := s.NewDockerCommand("rm", containerName).ExecOrDie()
Expect(Lines(output)[0]).To(Equal(containerName))
})
s.Step("re-run nginx with modified cpu/mem, and without --detach and follow logs", func() {