Skip to content
This repository has been archived by the owner on May 22, 2021. It is now read-only.

Commit

Permalink
Default to "latest" tag if tag is not specified
Browse files Browse the repository at this point in the history
Fixes #9
  • Loading branch information
jwilder committed Nov 5, 2014
1 parent 9b1925d commit 78e1901
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@ func main() {
fatal(err)
}

if tag != "" {
if !strings.Contains(tag, ":") {
fatalf("bad tag format: %s\n", tag)
}
if tag != "" && strings.Contains(tag, ":") {
parts := strings.Split(tag, ":")
if parts[0] == "" || parts[1] == "" {
fatalf("bad tag format: %s\n", tag)
Expand Down Expand Up @@ -181,13 +178,20 @@ func main() {
}

if tag != "" {
tagPart := "latest"
repoPart := tag
parts := strings.Split(tag, ":")
if len(parts) > 1 {
repoPart = parts[0]
tagPart = parts[1]
}
tagInfo := TagInfo{}
layer := export.LastChild()
tagInfo[parts[1]] = layer.LayerConfig.Id
export.Repositories[parts[0]] = &tagInfo

debugf("Tagging %s as %s\n", layer.LayerConfig.Id[0:12], tag)
tagInfo[tagPart] = layer.LayerConfig.Id
export.Repositories[repoPart] = &tagInfo

debugf("Tagging %s as %s:%s\n", layer.LayerConfig.Id[0:12], repoPart, tagPart)
err := export.WriteRepositoriesJson()
if err != nil {
fatal(err)
Expand Down

0 comments on commit 78e1901

Please sign in to comment.