-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
358 additions
and
356 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,68 @@ | ||
# team-env | ||
# team | ||
|
||
Save your project environment variables in a remote store and easily share them with your team, instead of having to store them in your project repository. | ||
Save your project configuration (environment variables, configuration files, etc) in a remote store and easily share it with your team, instead of having to store it inside your project repository. | ||
|
||
This allows you to share the source code of your project without sharing secrets, API keys, etc. | ||
This allows you to securely share the source code of your project without including secrets, API keys, service account files, etc. | ||
|
||
Currently only the `ssm` remote store is supported, but the package can be easily extended for adding more stores in the future. | ||
Currently only the `aws` remote store is supported, but the package can be easily extended for adding more stores in the future. | ||
|
||
- `ssm`: Store variables in your AWS account, using the [SSM Parameters Store](https://docs.aws.amazon.com/es_es/systems-manager/latest/userguide/systems-manager-paramstore.html). | ||
- `aws`: Stores project configuration in your AWS account. Environment variables are stored in the [SSM Parameters Store](https://docs.aws.amazon.com/es_es/systems-manager/latest/userguide/systems-manager-paramstore.html), and files are stored in [S3](https://docs.aws.amazon.com/s3/index.html#lang/es_es). | ||
|
||
## Installation: | ||
|
||
```bash | ||
go get -u github.com/andybar2/team-env | ||
go get -u github.com/andybar2/team | ||
``` | ||
|
||
## Configuration: | ||
|
||
Create the `team-env.json` file in your project folder, and set your configuration parameters there. Here is an example using the `ssm` store on AWS. | ||
Create the `team.json` file in your project folder, and set your configuration parameters there. | ||
|
||
```json | ||
{ | ||
"store": "ssm", | ||
"project": "example", | ||
"store": "aws", | ||
"aws_profile": "myaccount", | ||
"aws_region": "us-east-2" | ||
} | ||
``` | ||
|
||
The value of `aws_profile` is a reference to your `~/.aws/credentials` file. The keys for the given profile will be used by `team-env` to connect to your AWS account: | ||
The value of `aws_profile` is a reference to your `~/.aws/credentials` file. The keys for the given profile will be used by `team` to connect to your AWS account: | ||
|
||
``` | ||
[myaccount] | ||
aws_access_key_id = xxxxxxxx | ||
aws_secret_access_key = xxxxxxxxxxxxxxxxxxxxxxxx | ||
``` | ||
|
||
## Usage: | ||
## Manage environment variables: | ||
|
||
### Set variable: | ||
|
||
```bash | ||
team-env set --env=development --var=DEBUG --val=1 | ||
team env set -s "development" -n "STRIPE_API_KEY" -v "1234567890" | ||
``` | ||
|
||
### Get variable: | ||
|
||
```bash | ||
team-env get --env=development --var=DEBUG | ||
team env get -s "development" -n "STRIPE_API_KEY" | ||
``` | ||
|
||
### Delete variable: | ||
|
||
```bash | ||
team-env del --env=development --var=DEBUG | ||
team env del -s "development" -n "STRIPE_API_KEY" | ||
``` | ||
|
||
### Print all variables for an environment: | ||
|
||
```bash | ||
team-env print --env=development | ||
team env print -s "development" | ||
``` | ||
|
||
### Configure your local environment with the values of the variables in the remote store: | ||
|
||
```bash | ||
export $(team-env print --env=development) | ||
export $(team env print -s "development") | ||
``` |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package env | ||
|
||
import ( | ||
"errors" | ||
|
||
"github.com/andybar2/team/store" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var delParams struct { | ||
Stage string | ||
Name string | ||
} | ||
|
||
var delCmd = &cobra.Command{ | ||
Use: "del", | ||
Short: "Delete an environment variable", | ||
RunE: runDelCmd, | ||
} | ||
|
||
func init() { | ||
delCmd.Flags().StringVarP(&delParams.Stage, "stage", "s", "", "Stage name") | ||
delCmd.Flags().StringVarP(&delParams.Name, "name", "n", "", "Variable name") | ||
|
||
EnvCmd.AddCommand(delCmd) | ||
} | ||
|
||
func runDelCmd(cmd *cobra.Command, args []string) error { | ||
if delParams.Stage == "" { | ||
return errors.New("invalid stage name") | ||
} | ||
|
||
if delParams.Name == "" { | ||
return errors.New("invalid variable name") | ||
} | ||
|
||
s, err := store.New() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return s.EnvDel(delParams.Stage, delParams.Name) | ||
} |
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,11 @@ | ||
package env | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// EnvCmd is the sub-command to manage environment veriables | ||
var EnvCmd = &cobra.Command{ | ||
Use: "env [command]", | ||
Short: "Manage environment variables", | ||
} |
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,51 @@ | ||
package env | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
|
||
"github.com/andybar2/team/store" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var getParams struct { | ||
Stage string | ||
Name string | ||
} | ||
|
||
var getCmd = &cobra.Command{ | ||
Use: "get", | ||
Short: "Get an environment variable", | ||
RunE: runGetCmd, | ||
} | ||
|
||
func init() { | ||
getCmd.Flags().StringVarP(&getParams.Stage, "stage", "s", "", "Stage name") | ||
getCmd.Flags().StringVarP(&getParams.Name, "name", "n", "", "Variable name") | ||
|
||
EnvCmd.AddCommand(getCmd) | ||
} | ||
|
||
func runGetCmd(cmd *cobra.Command, args []string) error { | ||
if getParams.Stage == "" { | ||
return errors.New("invalid stage name") | ||
} | ||
|
||
if getParams.Name == "" { | ||
return errors.New("invalid variable name") | ||
} | ||
|
||
s, err := store.New() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
value, err := s.EnvGet(getParams.Stage, getParams.Name) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
fmt.Printf("%s=%s\n", getParams.Name, value) | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package env | ||
|
||
import ( | ||
"errors" | ||
|
||
"github.com/andybar2/team/store" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var printParams struct { | ||
Stage string | ||
} | ||
|
||
var printCmd = &cobra.Command{ | ||
Use: "print", | ||
Short: "Print all the environment variables for a stage", | ||
RunE: runPrintCmd, | ||
} | ||
|
||
func init() { | ||
printCmd.Flags().StringVarP(&printParams.Stage, "stage", "s", "", "Stage name") | ||
|
||
EnvCmd.AddCommand(printCmd) | ||
} | ||
|
||
func runPrintCmd(cmd *cobra.Command, args []string) error { | ||
if printParams.Stage == "" { | ||
return errors.New("invalid stage name") | ||
} | ||
|
||
s, err := store.New() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return s.EnvPrint(printParams.Stage) | ||
} |
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,45 @@ | ||
package env | ||
|
||
import ( | ||
"errors" | ||
|
||
"github.com/andybar2/team/store" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var setParams struct { | ||
Stage string | ||
Name string | ||
Value string | ||
} | ||
|
||
var setCmd = &cobra.Command{ | ||
Use: "set", | ||
Short: "Set an environment variable", | ||
RunE: runSetCmd, | ||
} | ||
|
||
func init() { | ||
setCmd.Flags().StringVarP(&setParams.Stage, "stage", "s", "", "Stage name") | ||
setCmd.Flags().StringVarP(&setParams.Name, "name", "n", "", "Variable name") | ||
setCmd.Flags().StringVarP(&setParams.Value, "value", "v", "", "Variable value") | ||
|
||
EnvCmd.AddCommand(setCmd) | ||
} | ||
|
||
func runSetCmd(cmd *cobra.Command, args []string) error { | ||
if setParams.Stage == "" { | ||
return errors.New("invalid stage name") | ||
} | ||
|
||
if setParams.Name == "" { | ||
return errors.New("invalid variable name") | ||
} | ||
|
||
s, err := store.New() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return s.EnvSet(setParams.Stage, setParams.Name, setParams.Value) | ||
} |
Oops, something went wrong.