mirror of
https://github.com/kreuzwerker/terraform-provider-docker.git
synced 2026-01-28 17:37:34 -05:00
#250 no errors if auth config incomplete
This commit is contained in:
parent
5d0f0fb806
commit
937136e154
2 changed files with 33 additions and 4 deletions
|
|
@ -238,13 +238,13 @@ func providerSetToRegistryAuth(authSet *schema.Set) (*AuthConfigs, error) {
|
|||
|
||||
r, err := os.Open(filePath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Error opening docker registry config file: %v", err)
|
||||
continue
|
||||
}
|
||||
|
||||
// Parse and set the auth
|
||||
auths, err := newAuthConfigurations(r)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Error parsing docker registry config json: %v", err)
|
||||
continue
|
||||
}
|
||||
|
||||
foundRegistry := false
|
||||
|
|
@ -257,8 +257,7 @@ func providerSetToRegistryAuth(authSet *schema.Set) (*AuthConfigs, error) {
|
|||
}
|
||||
|
||||
if !foundRegistry {
|
||||
return nil, fmt.Errorf("Couldn't find registry config for '%s' in file: %s",
|
||||
authConfig.ServerAddress, filePath)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,10 @@ package docker
|
|||
|
||||
import (
|
||||
"os/exec"
|
||||
"regexp"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/terraform"
|
||||
)
|
||||
|
|
@ -24,6 +26,19 @@ func TestProvider(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestAccDockerProvider_WithIncompleteRegistryAuth(t *testing.T) {
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccDockerProviderWithIncompleteAuthConfig,
|
||||
ExpectError: regexp.MustCompile(`401 Unauthorized`),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestProvider_impl(t *testing.T) {
|
||||
var _ terraform.ResourceProvider = Provider()
|
||||
}
|
||||
|
|
@ -47,3 +62,18 @@ func testAccPreCheck(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
const testAccDockerProviderWithIncompleteAuthConfig = `
|
||||
provider "docker" {
|
||||
alias = "private"
|
||||
registry_auth {
|
||||
address = ""
|
||||
username = ""
|
||||
password = ""
|
||||
}
|
||||
}
|
||||
data "docker_registry_image" "foobar" {
|
||||
provider = "docker.private"
|
||||
name = "localhost:15000/helloworld:1.0"
|
||||
}
|
||||
`
|
||||
|
|
|
|||
Loading…
Reference in a new issue