-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Install actually installs, added get and create commands
- Loading branch information
1 parent
c4e2c5d
commit d31fc0e
Showing
140 changed files
with
11,387 additions
and
43,706 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Development | ||
|
||
Always, always, always run `go fmt ./...` before committing! | ||
|
||
### Running the tests | ||
|
||
```bash | ||
go get golang.org/x/tools/cmd/cover | ||
|
||
make test | ||
``` | ||
|
||
See the html output of the coverage information | ||
|
||
```bash | ||
make test-cover | ||
``` | ||
|
||
### Updating dependencies | ||
|
||
```bash | ||
go get -u github.com/kardianos/govendor | ||
|
||
govendor add +external | ||
``` | ||
|
||
### Linting | ||
|
||
Perfect linting is not required, but it is helpful for new people coming to the code. | ||
|
||
``` | ||
go get -u github.com/golang/lint/golint | ||
golint ./ | ||
golint ./render | ||
``` |
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 |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package cmd | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"io/ioutil" | ||
|
||
"github.com/google/uuid" | ||
"github.com/skuid/helm-value-store/dynamo" | ||
"github.com/skuid/helm-value-store/store" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
type createCmdArgs struct { | ||
table string | ||
file string | ||
labels selectorSet | ||
name string | ||
chart string | ||
namespace string | ||
version string | ||
} | ||
|
||
var createArgs = &createCmdArgs{} | ||
|
||
var createCmd = &cobra.Command{ | ||
Use: "create", | ||
Short: "create a release in the relase store", | ||
Run: create, | ||
} | ||
|
||
func init() { | ||
RootCmd.AddCommand(createCmd) | ||
createCmd.Flags().StringVar(&createArgs.table, "table", "helm-charts", "Name of table") | ||
createCmd.Flags().StringVarP(&createArgs.file, "file", "f", "", "Name of values file") | ||
createCmd.Flags().VarP(&createArgs.labels, "labels", "l", `The labels to apply. Each label should have the format "k=v". | ||
Can be specified multiple times, or a comma-separated list.`) | ||
createCmd.Flags().StringVar(&createArgs.name, "name", "", "Name of the release") | ||
createCmd.Flags().StringVar(&createArgs.chart, "chart", "", "Chart of the release") | ||
createCmd.Flags().StringVar(&createArgs.namespace, "namespace", "default", "Namespace of the release") | ||
createCmd.Flags().StringVar(&createArgs.version, "version", "", "Version of the release") | ||
} | ||
|
||
func create(cmd *cobra.Command, args []string) { | ||
r := store.Release{ | ||
UniqueID: uuid.New().String(), | ||
Labels: createArgs.labels.ToMap(), | ||
Name: createArgs.name, | ||
Chart: createArgs.chart, | ||
Namespace: createArgs.namespace, | ||
Version: createArgs.version, | ||
} | ||
fmt.Printf("%#v\n", r) | ||
fmt.Println(r) | ||
|
||
if len(createArgs.file) > 0 { | ||
values, err := ioutil.ReadFile(createArgs.file) | ||
exitOnErr(err) | ||
r.Values = string(values) | ||
} | ||
if len(createArgs.chart) == 0 { | ||
exitOnErr(errors.New("No chart provided!")) | ||
} | ||
|
||
rs, err := dynamo.NewReleaseStore(createArgs.table) | ||
exitOnErr(err) | ||
|
||
err = rs.Put(r) | ||
exitOnErr(err) | ||
fmt.Println("Created release in dynamo!") | ||
} |
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package cmd | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
|
||
"github.com/skuid/helm-value-store/dynamo" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
type getCmdArgs struct { | ||
timeout int64 | ||
dryRun bool | ||
table string | ||
selector selectorSet | ||
|
||
uuid string | ||
name string | ||
} | ||
|
||
var getArgs = getCmdArgs{} | ||
|
||
var getCmd = &cobra.Command{ | ||
Use: "get-values", | ||
Short: "get the values of a release", | ||
Run: get, | ||
} | ||
|
||
func init() { | ||
RootCmd.AddCommand(getCmd) | ||
getCmd.Flags().StringVar(&getArgs.table, "table", "helm-charts", "Name of table") | ||
getCmd.Flags().StringVar(&getArgs.uuid, "uuid", "", "The UUID to get.") | ||
} | ||
|
||
func get(cmd *cobra.Command, args []string) { | ||
rs, err := dynamo.NewReleaseStore(getArgs.table) | ||
exitOnErr(err) | ||
|
||
if len(getArgs.uuid) == 0 { | ||
exitOnErr(errors.New("Must supply a UUID!")) | ||
} | ||
release, err := rs.Get(getArgs.uuid) | ||
exitOnErr(err) | ||
|
||
fmt.Print(release.Values) | ||
} |
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
Oops, something went wrong.