-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from hypnoglow/repo-index-rework
Repo index rework
- Loading branch information
Showing
2,511 changed files
with
206 additions
and
1,626,718 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
bin/* | ||
tmp | ||
releases | ||
vendor | ||
|
||
.env | ||
coverage.txt |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
pkg := github.com/hypnoglow/helm-s3 | ||
|
||
dep: | ||
@dep ensure -v -vendor-only | ||
|
||
build: | ||
@./sh/build.sh $(CURDIR) $(pkg) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,33 @@ | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
"context" | ||
"fmt" | ||
"log" | ||
"text/template" | ||
"time" | ||
|
||
"github.com/pkg/errors" | ||
|
||
"github.com/hypnoglow/helm-s3/pkg/awss3" | ||
"github.com/hypnoglow/helm-s3/pkg/awsutil" | ||
"github.com/hypnoglow/helm-s3/pkg/index" | ||
) | ||
|
||
const ( | ||
indexTemplate = `apiVersion: v1 | ||
entries: {} | ||
generated: {{ .Date }}` | ||
) | ||
|
||
func runInit(uri string) { | ||
tpl := template.New("index") | ||
tpl, err := tpl.Parse(indexTemplate) | ||
func runInit(uri string) error { | ||
r, err := index.New().Reader() | ||
if err != nil { | ||
log.Fatalf("failed to parse index.yaml template: %s", err) | ||
} | ||
|
||
buf := &bytes.Buffer{} | ||
if err := tpl.Execute(buf, map[string]interface{}{"Date": time.Now().Format(time.RFC3339Nano)}); err != nil { | ||
log.Fatalf("failed to execute index.yaml temlate: %s", err) | ||
return errors.WithMessage(err, "get index reader") | ||
} | ||
|
||
awsConfig, err := awsutil.Config() | ||
if err != nil { | ||
log.Fatalf("failed to get aws config: %s", err) | ||
return errors.WithMessage(err, "get aws config") | ||
} | ||
|
||
ctx, cancel := context.WithTimeout(context.Background(), defaultTimeout) | ||
defer cancel() | ||
|
||
if _, err := awss3.Upload(ctx, uri+"/index.yaml", buf, awsConfig); err != nil { | ||
log.Fatalf("failed to upload chart to s3: %s", err) | ||
if _, err := awss3.Upload(ctx, uri+"/index.yaml", r, awsConfig); err != nil { | ||
return errors.WithMessage(err, "upload index to s3") | ||
} | ||
|
||
fmt.Printf("Initialized empty repository at %s\n", uri) | ||
return nil | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.