-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some cloudflare tools (like wrangler) expect variables prefixed with `CF_` rather than `CLOUDFLARE_`. Add the matching variables. Fixes issue 37
- Loading branch information
Showing
2 changed files
with
11 additions
and
0 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 |
---|---|---|
|
@@ -112,6 +112,8 @@ $ cf-vault exec work -- env | grep -i cloudflare | |
CLOUDFLARE_VAULT_SESSION=work | ||
[email protected] | ||
CLOUDFLARE_API_KEY=s3cr3t | ||
[email protected] | ||
CF_API_KEY=s3cr3t | ||
``` | ||
|
||
If you don't provide a command, you will be dropped into a new shell with the | ||
|
@@ -123,6 +125,8 @@ $ env | grep -i cloudflare | |
CLOUDFLARE_VAULT_SESSION=work | ||
[email protected] | ||
CLOUDFLARE_API_KEY=s3cr3t | ||
[email protected] | ||
CF_API_KEY=s3cr3t | ||
|
||
$ exit | ||
$ env | grep -i cloudflare | ||
|
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 |
---|---|---|
|
@@ -31,6 +31,8 @@ var execCmd = &cobra.Command{ | |
CLOUDFLARE_VAULT_SESSION=example-profile | ||
[email protected] | ||
CLOUDFLARE_API_KEY=s3cr3t | ||
[email protected] | ||
CF_API_KEY=s3cr3t | ||
Spawn a new shell with credentials populated | ||
|
@@ -39,6 +41,8 @@ var execCmd = &cobra.Command{ | |
CLOUDFLARE_VAULT_SESSION=example-profile | ||
[email protected] | ||
CLOUDFLARE_API_KEY=s3cr3t | ||
[email protected] | ||
CF_API_KEY=s3cr3t | ||
`, | ||
Args: func(cmd *cobra.Command, args []string) error { | ||
if len(args) < 1 { | ||
|
@@ -105,8 +109,10 @@ var execCmd = &cobra.Command{ | |
if profile.SessionDuration == "" { | ||
if profile.AuthType == "api_key" { | ||
env.Set("CLOUDFLARE_EMAIL", profile.Email) | ||
env.Set("CF_EMAIL", profile.Email) | ||
} | ||
env.Set(fmt.Sprintf("CLOUDFLARE_%s", strings.ToUpper(profile.AuthType)), string(keychain.Data)) | ||
env.Set(fmt.Sprintf("CF_%s", strings.ToUpper(profile.AuthType)), string(keychain.Data)) | ||
} else { | ||
var api *cloudflare.API | ||
if profile.AuthType == "api_token" { | ||
|
@@ -160,6 +166,7 @@ var execCmd = &cobra.Command{ | |
|
||
if shortLivedToken.Value != "" { | ||
env.Set("CLOUDFLARE_API_TOKEN", shortLivedToken.Value) | ||
env.Set("CF_API_TOKEN", shortLivedToken.Value) | ||
} | ||
|
||
env.Set("CLOUDFLARE_SESSION_EXPIRY", strconv.Itoa(int(tokenExpiry.Unix()))) | ||
|