Skip creating swift container if already exists

Signed-off-by: Jack Griffin <jackpg14@gmail.com>
This commit is contained in:
Jack Griffin 2015-09-03 01:31:47 +00:00
parent 7c5a9ae96d
commit 2749bcdc28

View file

@ -165,8 +165,12 @@ func New(params Parameters) (*Driver, error) {
return nil, fmt.Errorf("Swift authentication failed: %s", err)
}
if err := ct.ContainerCreate(params.Container, nil); err != nil {
return nil, fmt.Errorf("Failed to create container %s (%s)", params.Container, err)
if _, _, err := ct.Container(params.Container); err == swift.ContainerNotFound {
if err := ct.ContainerCreate(params.Container, nil); err != nil {
return nil, fmt.Errorf("Failed to create container %s (%s)", params.Container, err)
}
} else if err != nil {
return nil, fmt.Errorf("Failed to retrieve info about container %s (%s)", params.Container, err)
}
d := &driver{