Skip to content
This repository was archived by the owner on Jun 27, 2025. It is now read-only.

Commit b16450c

Browse files
author
Esteban Barrios
committed
Changed the default behavior to not include the vault token in the env by default
1 parent 0c2a75c commit b16450c

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

command/deploy.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,13 @@ General Options:
6565
can be changed using this flag so that Levant will exit cleanly ensuring CD
6666
pipelines don't fail when no changes are detected.
6767
68+
-vault
69+
This flag makes levant load the vault token from the current ENV.
70+
It can not be used at the same time than -vault-token=<vault-token> flag
71+
6872
-vault-token=<vault-token>
6973
The vault token used to deploy the application to nomad with vault support
74+
This flag can not be used at the same time than -vault flag
7075
7176
-log-level=<level>
7277
Specify the verbosity level of Levant's logs. Valid values include DEBUG,
@@ -115,6 +120,8 @@ func (c *DeployCommand) Run(args []string) int {
115120
flags.StringVar(&level, "log-level", "INFO", "")
116121
flags.StringVar(&format, "log-format", "HUMAN", "")
117122
flags.StringVar(&config.Deploy.VaultToken, "vault-token", "", "")
123+
flags.BoolVar(&config.Deploy.EnvVault, "vault", false, "")
124+
118125
flags.Var((*helper.FlagStringSlice)(&config.Template.VariableFiles), "var-file", "")
119126

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

124131
args = flags.Args()
125132

133+
if config.Deploy.EnvVault == true && config.Deploy.VaultToken != "" {
134+
c.UI.Error(c.Help())
135+
c.UI.Error("\nERROR: Can not used -vault and -vault-token flag at the same time")
136+
return 1
137+
}
138+
126139
if err = logging.SetupLogger(level, format); err != nil {
127140
c.UI.Error(err.Error())
128141
return 1

levant/deploy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ type DeployConfig struct {
3333
func newLevantDeployment(config *DeployConfig, nomadClient *nomad.Client) (*levantDeployment, error) {
3434

3535
var err error
36-
if config.Deploy.VaultToken == "" {
36+
if config.Deploy.EnvVault == true {
3737
config.Deploy.VaultToken = os.Getenv("VAULT_TOKEN")
3838
}
3939

levant/structs/config.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,12 @@ type DeployConfig struct {
3535
// and force the count based on the rendered job file.
3636
ForceCount bool
3737

38-
// VaultToken is a string with the vault token
38+
// VaultToken is a string with the vault token.
3939
VaultToken string
40+
41+
// EnvVault is a boolean flag that can be used to enable reading the VAULT_TOKEN
42+
// from the enviromment.
43+
EnvVault bool
4044
}
4145

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

0 commit comments

Comments
 (0)