Skip to content

Commit

Permalink
Add DUPLICITY_DOCKER_IMAGE parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
raphink committed Apr 5, 2016
1 parent 23ca3fb commit d1f6e24
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ $ docker run -v /var/run/docker.sock:/var/run/docker.sock:ro --rm -ti \

## Environment variables

### DUPLICITY_DOCKER_IMAGE

The image to use to launch duplicity. Default is `camptocamp/duplicity:latest`.

### DUPLICITY_TARGET_URL

Target URL passed to duplicity.
Expand Down
10 changes: 6 additions & 4 deletions conplicity.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
)

type Environment struct {
Image string
DuplicityTargetURL string
AWSAccessKeyID string
AWSSecretAccessKey string
Expand All @@ -23,7 +24,6 @@ type Conplicity struct {
*docker.Client
*Environment
Hostname string
Image string
}

func main() {
Expand All @@ -46,9 +46,6 @@ func main() {
vols, err := c.ListVolumes(docker.ListVolumesOptions{})
checkErr(err, "Failed to list Docker volumes: %v", 1)

// TODO: Make it variable
c.Image = "camptocamp/duplicity:latest"

err = c.pullImage()
checkErr(err, "Failed to pull image: %v", 1)

Expand All @@ -62,6 +59,7 @@ func main() {

func (c *Conplicity) getEnv() (err error) {
c.Environment = &Environment{
Image: os.Getenv("DUPLICITY_DOCKER_IMAGE"),
DuplicityTargetURL: os.Getenv("DUPLICITY_TARGET_URL"),
AWSAccessKeyID: os.Getenv("AWS_ACCESS_KEY_ID"),
AWSSecretAccessKey: os.Getenv("AWS_SECRET_ACCESS_KEY"),
Expand All @@ -72,6 +70,10 @@ func (c *Conplicity) getEnv() (err error) {
SwiftRegionName: os.Getenv("SWIFT_REGIONNAME"),
}

if c.Image == "" {
c.Image = "camptocamp/duplicity:latest"
}

return
}

Expand Down

0 comments on commit d1f6e24

Please sign in to comment.