Skip to content

Commit

Permalink
Fix #5
Browse files Browse the repository at this point in the history
  • Loading branch information
nouney committed Mar 20, 2018
1 parent dfc9a31 commit 9090b94
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions helm-gcs/gcs/gcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"cloud.google.com/go/storage"
)

var ErrObjectNotExist = errors.New("gcs: " + storage.ErrObjectNotExist.Error())

func NewWriter(url string) (io.WriteCloser, error) {
makeError := makeErrorFunc("gcs.NewWriter")
bucket, fullname, err := splitURL(url)
Expand Down Expand Up @@ -43,6 +45,9 @@ func NewReader(url string) (io.ReadCloser, error) {
o := b.Object(fullname[1:])
r, err := o.NewReader(ctx)
if err != nil {
if err == storage.ErrObjectNotExist {
return nil, ErrObjectNotExist
}
return nil, makeError(err)
}
return r, nil
Expand Down
11 changes: 11 additions & 0 deletions helm-gcs/repo/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ func CreateRepo(path string) error {
if err != nil {
return makeError(err)
}
// Do not rewrite index.yaml if it already exists
_, err = gcs.NewReader(indexFileURL)
if err != nil {
if err != gcs.ErrObjectNotExist {
return makeError(err)
}
} else {
debug("repository already initialized")
return nil
}
// Create index.yaml
w, err := gcs.NewWriter(indexFileURL)
if err != nil {
return makeError(err)
Expand Down

0 comments on commit 9090b94

Please sign in to comment.