Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

Commit

Permalink
Merge pull request #389 from docker/fix-single-container-tag
Browse files Browse the repository at this point in the history
Fix adding a tag to a container group
  • Loading branch information
chris-crone authored Jul 16, 2020
2 parents 45a7c7a + 4480d27 commit 9a4e937
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
8 changes: 4 additions & 4 deletions azure/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
17 changes: 10 additions & 7 deletions tests/aci-e2e/e2e-aci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ func (s *E2eACISuite) TestLoginLogoutCreateContextError() {
}

func (s *E2eACISuite) TestACIRunSingleContainer() {
var containerName string
resourceGroupName := s.setupTestResourceGroup()
defer deleteResourceGroup(resourceGroupName)

Expand All @@ -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))
Expand All @@ -127,18 +130,18 @@ 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"))
})

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() {
Expand All @@ -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() {
Expand Down

0 comments on commit 9a4e937

Please sign in to comment.