Skip to content

Commit

Permalink
minor fixes, add readme and installer scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
C123R committed Apr 9, 2020
1 parent 03a47fa commit c9b3126
Show file tree
Hide file tree
Showing 14 changed files with 704 additions and 66 deletions.
34 changes: 34 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
before:
hooks:
- go mod download
builds:
- main: main.go
binary: helm-blob
env:
- CGO_ENABLED=0
goos:
- windows
- linux
- darwin
goarch:
- amd64
- arm64
archive:
format: tar.gz
files:
- README.md
- LICENSE
- plugin.yaml
- scripts/install_plugin.sh
- scripts/helm-blob.sh
name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}_{{ .Tag }}"
checksum:
name_template: "checksums.txt"
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
30 changes: 30 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
language: go
go:
- "1.13"

env:
- GO111MODULE=on

before_install:
- sudo apt-get update
- sudo apt-get install -y libpcap-dev gcc

install:
- go mod download

after_success:
# Set up git user name and tag this commit
- git config --global user.email "[email protected]"
- git config --global user.name "Travis CI"
- export TRAVIS_TAG=${TRAVIS_TAG:-$(cat VERSION)}
- git tag -a $TRAVIS_TAG $(git log --format=%h -1) -m "Generated tag from Travis CI based on VERSION file"
- test -n "$TRAVIS_TAG" && curl -s https://raw.githubusercontent.com/goreleaser/get/master/latest | bash

deploy:
- provider: script
github_token: $GITHUB_TOKEN
skip_cleanup: true
script: curl -sL https://git.io/goreleaser | bash

notifications:
email: false
100 changes: 98 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,98 @@
# helm-blob
Helm Plugin that allows you to manage private helm repositories on blob storage(Azure Blob, GCS, S3)
# helm-blob [![Build Status](https://travis-ci.org/C123R/helm-blob.svg?branch=master)](https://travis-ci.org/C123R/helm-blob)

`helm-blob` plugin allows you to manage helm repositories on the blob storage like Azure Blob, GCS, S3, etc.

This plugin supports operations like uploading or deletion of charts from remote Helm Repository hosted on Blob Storage. It could be used to initialize the new Helm Repository.

`helm-blob` was inspired by [Alex Khaerov's](https://github.com/hayorov) [helm-gcs](https://github.com/hayorov/helm-gcs) plugin with extending support for Azure Blob storage and S3, which makes helm-blob to support Azure Blob, GCS, S3 storage.

This plugin uses Go Cloud's [Blob](https://gocloud.dev/howto/blob/) package.

## Installation

```sh
helm plugin install https://github.com/C123R/helm-blob
```

## Usage

- ### Initialize a new chart repository

```sh
helm blob init azblob://helmrepo
```

Note: This command will not create new blob storage, moreover
it will just add empty index.yaml file.

- ### Add your repository to Helm

```sh
helm repo add azurehelm azblob://helmrepo
```

- ### Push a new chart to your repository

```sh
helm blob push mychart.tar.gz azurehelm
```

- ### Updating Helm cache (Required after pushing new chart)

```sh
helm repo update
```

- ### Fetch the chart

```sh
helm fetch azurehelm/mychart
```

- ### Delete a chart

```sh
helm blob delete mychart azurehelm
```

Note: This will delete all chart versions from remote repository. To delete a specific chart:

```sh
helm blob delete mychart -v 0.3.0 azurehelm
```

## Authentication

Helm blob's plugin authentication varies depending upon the blob provider as mentioned below:

- ### S3

S3 provider support AWS [default credential provider](https://docs.aws.amazon.com/sdk-for-go/v1/developer-guide/configuring-sdk.html#specifying-credentials) chain in the following order:

- Environment variables.

- Shared credentials file.

- If your application is running on an Amazon EC2 instance, IAM role for Amazon EC2.

- ### Azure Blob

Currently it supports authentication only with [environment variables](https://docs.microsoft.com/en-us/azure/storage/common/storage-azure-cli#set-default-azure-storage-account-environment-variables):

- AZURE_STORAGE_ACCOUNT
- AZURE_STORAGE_KEY or AZURE_STORAGE_SAS_TOKEN

- ### [GCS](https://cloud.google.com/docs/authentication/production)

GCS provider uses [Application Default Credentials](https://cloud.google.com/docs/authentication/production) in the following order:

- Environment Variable (GOOGLE_APPLICATION_CREDENTIALS)
- Default Service Account from the compute instance(Compute Engine, Kubernetes Engine, Cloud function etc).

To authenticate against GCS you can:

- Use the [application default credentials](https://cloud.google.com/sdk/gcloud/reference/auth/application-default/)

- Use a service account via the global flag `--service-account`

See [the GCP documentation](https://cloud.google.com/docs/authentication/production#providing_credentials_to_your_application) for more information.
2 changes: 1 addition & 1 deletion cmd/helm-blob/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var version string
// deleteCmd represents the delete command
var deleteCmd = &cobra.Command{
Use: "delete <chart-name> <repo-name>",
Short: "deletes a chart from repository",
Short: "Deletes a chart from repository",
Args: cobra.MinimumNArgs(2),
Long: `
Delete command deletes a chart from a remote repository.
Expand Down
11 changes: 6 additions & 5 deletions cmd/helm-blob/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,22 @@ import (
// fetchCmd represents the fetch command
var fetchCmd = &cobra.Command{
Use: "fetch <blob-url>",
Short: "fetches file from blob",
Short: "Fetches file from blob",
Args: cobra.MinimumNArgs(1),
Long: `
Fetch command fetches file from remote chart and prints it on standard output.
`,
RunE: func(cmd *cobra.Command, args []string) error {

// workaround: "helm repo add" commands sends url
// with index.yaml path appended in it
repoUrl := strings.TrimRight(args[0], "index.yaml")
urlParts := strings.Split(args[0], "/")
file2download := urlParts[len(urlParts)-1]
repoUrl := strings.TrimRight(args[0], file2download)

r, err := repo.NewRepoByUrl(repoUrl)
if err != nil {
return err
}
if err = r.Fetch(); err != nil {
if err = r.Fetch(file2download); err != nil {
return err
}
return nil
Expand Down
8 changes: 7 additions & 1 deletion cmd/helm-blob/init.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package cmd

import (
"fmt"

"github.com/C123R/helm-blob/pkg/repo"
"github.com/spf13/cobra"
)

// initCmd represents the init command
var initCmd = &cobra.Command{
Use: "init <blob-url>",
Short: "initialize new repository",
Short: "Initialize new repository",
Args: cobra.ExactValidArgs(1),
Long: `
Init command will initialize a new helm repository on provided blob url.
Expand All @@ -25,6 +27,10 @@ it will just add empty index.yaml file.
if err = r.Init(); err != nil {
return err
}
fmt.Printf(`Successfully initialized %s.
Now you can add this repo using 'helm repo add <repo-name> %s'`, repoUrl, repoUrl)
fmt.Println()
return nil
},
}
Expand Down
5 changes: 3 additions & 2 deletions cmd/helm-blob/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ var force bool
// pushCmd represents the push command
var pushCmd = &cobra.Command{
Use: "push <chart-name> <repo-name>",
Short: "uploads a chart into a repository",
Short: "Uploads a chart into a repository",
Args: cobra.ExactValidArgs(2),
Long: `
Push command uploads a chart into a remote repository.
Push command uploads a chart into a remote repository and merge
with remote index file.
`,
Example: `helm blob push sample-chart.tgz sample-repository`,
RunE: func(cmd *cobra.Command, args []string) error {
Expand Down
2 changes: 1 addition & 1 deletion cmd/helm-blob/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
// versionCmd represents the version command
var versionCmd = &cobra.Command{
Use: "version",
Short: "print the current helm-blob version",
Short: "Print the current helm-blob version",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
byte, err := ioutil.ReadFile("VERSION")
Expand Down
16 changes: 8 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ module github.com/C123R/helm-blob
go 1.13

require (
github.com/Masterminds/semver v1.5.0 // indirect
github.com/Azure/go-autorest/autorest/azure/auth v0.4.2 // indirect
github.com/aws/aws-sdk-go v1.20.6 // indirect
github.com/spf13/cobra v0.0.6
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/cobra v0.0.7
gocloud.dev v0.19.0
golang.org/x/net v0.0.0-20191004110552-13f9640d40b9 // indirect
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b // indirect
golang.org/x/sys v0.0.0-20191022100944-742c48ecaeb7 // indirect
gopkg.in/yaml.v2 v2.2.8
helm.sh/helm v3.0.0-beta.3+incompatible
k8s.io/client-go v11.0.0+incompatible // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
helm.sh/helm/v3 v3.1.0
sigs.k8s.io/yaml v1.2.0
)

replace github.com/Azure/go-autorest => github.com/Azure/go-autorest v12.2.0+incompatible
Loading

0 comments on commit c9b3126

Please sign in to comment.