Fix Repository attribute in docker client PullOptions for private registries.
This commit is contained in:
parent
03dc6c4879
commit
09e336a80a
|
@ -83,7 +83,7 @@ func pullImage(data *Data, client *dc.Client, image string) error {
|
||||||
splitPortRepo := strings.Split(splitImageName[1], "/")
|
splitPortRepo := strings.Split(splitImageName[1], "/")
|
||||||
pullOpts.Registry = splitImageName[0] + ":" + splitPortRepo[0]
|
pullOpts.Registry = splitImageName[0] + ":" + splitPortRepo[0]
|
||||||
pullOpts.Tag = splitImageName[2]
|
pullOpts.Tag = splitImageName[2]
|
||||||
pullOpts.Repository = strings.Join(splitPortRepo[1:], "/")
|
pullOpts.Repository = pullOpts.Registry + "/" + strings.Join(splitPortRepo[1:], "/")
|
||||||
|
|
||||||
// It's either registry:port/username/repo, registry:port/repo,
|
// It's either registry:port/username/repo, registry:port/repo,
|
||||||
// or repo:tag with default registry
|
// or repo:tag with default registry
|
||||||
|
@ -98,7 +98,7 @@ func pullImage(data *Data, client *dc.Client, image string) error {
|
||||||
// registry:port/username/repo or registry:port/repo
|
// registry:port/username/repo or registry:port/repo
|
||||||
default:
|
default:
|
||||||
pullOpts.Registry = splitImageName[0] + ":" + splitPortRepo[0]
|
pullOpts.Registry = splitImageName[0] + ":" + splitPortRepo[0]
|
||||||
pullOpts.Repository = strings.Join(splitPortRepo[1:], "/")
|
pullOpts.Repository = pullOpts.Registry + "/" + strings.Join(splitPortRepo[1:], "/")
|
||||||
pullOpts.Tag = "latest"
|
pullOpts.Tag = "latest"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
package docker
|
package docker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/hashicorp/terraform/helper/resource"
|
"github.com/hashicorp/terraform/helper/resource"
|
||||||
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAccDockerImage_basic(t *testing.T) {
|
func TestAccDockerImage_basic(t *testing.T) {
|
||||||
|
@ -24,9 +23,34 @@ func TestAccDockerImage_basic(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAddDockerImage_private(t *testing.T) {
|
||||||
|
resource.Test(t, resource.TestCase{
|
||||||
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
Providers: testAccProviders,
|
||||||
|
Steps: []resource.TestStep{
|
||||||
|
resource.TestStep{
|
||||||
|
Config: testAddDockerPrivateImageConfig,
|
||||||
|
Check: resource.ComposeTestCheckFunc(
|
||||||
|
resource.TestCheckResourceAttr(
|
||||||
|
"docker_image.foobar",
|
||||||
|
"latest",
|
||||||
|
"2c40b0526b6358710fd09e7b8c022429268cc61703b4777e528ac9d469a07ca1"),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const testAccDockerImageConfig = `
|
const testAccDockerImageConfig = `
|
||||||
resource "docker_image" "foo" {
|
resource "docker_image" "foo" {
|
||||||
name = "ubuntu:trusty-20150320"
|
name = "ubuntu:trusty-20150320"
|
||||||
keep_updated = true
|
keep_updated = true
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
|
const testAddDockerPrivateImageConfig = `
|
||||||
|
resource "docker_image" "foobar" {
|
||||||
|
name = "gcr.io:443/google_containers/pause:0.8.0"
|
||||||
|
keep_updated = true
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
Loading…
Reference in New Issue