Skip to content
This repository has been archived by the owner on Jul 19, 2022. It is now read-only.

Commit

Permalink
layout add should use existing layout if there is one
Browse files Browse the repository at this point in the history
Fixes #25
  • Loading branch information
glyn committed Sep 10, 2019
1 parent bf33eda commit 936ace9
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions pkg/irel/layout_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ import (

func newCmdLayoutAdd() *cobra.Command {
return &cobra.Command{
Use: "add LAYOUT_PATH REF",
Short: "copy an image from a remote repository to an OCI image layout",
Args: cobra.ExactArgs(2),
Run: layoutAdd,
Use: "add LAYOUT_PATH REF",
Short: "copy an image from a remote repository to an OCI image layout",
Args: cobra.ExactArgs(2),
Run: layoutAdd,
}
}

Expand All @@ -41,9 +41,12 @@ func layoutAdd(cmd *cobra.Command, args []string) {
}

regClient := registry.NewRegistryClient()
layout, err := regClient.NewLayout(layoutPath)
layout, err := regClient.ReadLayout(layoutPath)
if err != nil {
log.Fatalf("failed to create OCI image layout: %v", err)
layout, err = regClient.NewLayout(layoutPath)
if err != nil {
log.Fatalf("failed to create OCI image layout: %v", err)
}
}

dig, err := layout.Add(ref)
Expand Down

0 comments on commit 936ace9

Please sign in to comment.