Skip to content

Commit

Permalink
Fixed bug where docker_container resource was not working properly wi…
Browse files Browse the repository at this point in the history
…th swarm
  • Loading branch information
jwthomp authored and josephholsten committed Sep 30, 2015
1 parent 0c3f2a9 commit f82a6c3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions builtin/providers/docker/resource_docker_container_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func resourceDockerContainerCreate(d *schema.ResourceData, meta interface{}) err
func resourceDockerContainerRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*dc.Client)

apiContainer, err := fetchDockerContainer(d.Get("name").(string), client)
apiContainer, err := fetchDockerContainer(d.Id(), client)
if err != nil {
return err
}
Expand Down Expand Up @@ -223,7 +223,7 @@ func stringSetToStringSlice(stringSet *schema.Set) []string {
return ret
}

func fetchDockerContainer(name string, client *dc.Client) (*dc.APIContainers, error) {
func fetchDockerContainer(ID string, client *dc.Client) (*dc.APIContainers, error) {
apiContainers, err := client.ListContainers(dc.ListContainersOptions{All: true})

if err != nil {
Expand All @@ -236,12 +236,12 @@ func fetchDockerContainer(name string, client *dc.Client) (*dc.APIContainers, er
// set name, it just uses the ID without a /...ugh.
switch len(apiContainer.Names) {
case 0:
if apiContainer.ID == name {
if apiContainer.ID == ID {
return &apiContainer, nil
}
default:
for _, containerName := range apiContainer.Names {
if strings.TrimLeft(containerName, "/") == name {
if strings.TrimLeft(containerName, "/") == ID {
return &apiContainer, nil
}
}
Expand Down

0 comments on commit f82a6c3

Please sign in to comment.