Skip to content

Commit

Permalink
Changed the default behavior to not include the vault token in the en…
Browse files Browse the repository at this point in the history
…v by default
  • Loading branch information
Esteban Barrios committed Nov 30, 2018
1 parent 0c2a75c commit b16450c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
13 changes: 13 additions & 0 deletions command/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,13 @@ General Options:
can be changed using this flag so that Levant will exit cleanly ensuring CD
pipelines don't fail when no changes are detected.
-vault
This flag makes levant load the vault token from the current ENV.
It can not be used at the same time than -vault-token=<vault-token> flag
-vault-token=<vault-token>
The vault token used to deploy the application to nomad with vault support
This flag can not be used at the same time than -vault flag
-log-level=<level>
Specify the verbosity level of Levant's logs. Valid values include DEBUG,
Expand Down Expand Up @@ -115,6 +120,8 @@ func (c *DeployCommand) Run(args []string) int {
flags.StringVar(&level, "log-level", "INFO", "")
flags.StringVar(&format, "log-format", "HUMAN", "")
flags.StringVar(&config.Deploy.VaultToken, "vault-token", "", "")
flags.BoolVar(&config.Deploy.EnvVault, "vault", false, "")

flags.Var((*helper.FlagStringSlice)(&config.Template.VariableFiles), "var-file", "")

if err = flags.Parse(args); err != nil {
Expand All @@ -123,6 +130,12 @@ func (c *DeployCommand) Run(args []string) int {

args = flags.Args()

if config.Deploy.EnvVault == true && config.Deploy.VaultToken != "" {
c.UI.Error(c.Help())
c.UI.Error("\nERROR: Can not used -vault and -vault-token flag at the same time")
return 1
}

if err = logging.SetupLogger(level, format); err != nil {
c.UI.Error(err.Error())
return 1
Expand Down
2 changes: 1 addition & 1 deletion levant/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type DeployConfig struct {
func newLevantDeployment(config *DeployConfig, nomadClient *nomad.Client) (*levantDeployment, error) {

var err error
if config.Deploy.VaultToken == "" {
if config.Deploy.EnvVault == true {
config.Deploy.VaultToken = os.Getenv("VAULT_TOKEN")
}

Expand Down
6 changes: 5 additions & 1 deletion levant/structs/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@ type DeployConfig struct {
// and force the count based on the rendered job file.
ForceCount bool

// VaultToken is a string with the vault token
// VaultToken is a string with the vault token.
VaultToken string

// EnvVault is a boolean flag that can be used to enable reading the VAULT_TOKEN
// from the enviromment.
EnvVault bool
}

// ClientConfig is the config struct which houses all the information needed to connect
Expand Down

0 comments on commit b16450c

Please sign in to comment.