Skip to content

Commit 4c50b90

Browse files
authored
Add CF-prefixed variables (#38)
Some cloudflare tools (like wrangler) expect variables prefixed with `CF_` rather than `CLOUDFLARE_`. Add the matching variables. Fixes issue 37
1 parent ad1468e commit 4c50b90

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ $ cf-vault exec work -- env | grep -i cloudflare
112112
CLOUDFLARE_VAULT_SESSION=work
113113
114114
CLOUDFLARE_API_KEY=s3cr3t
115+
116+
CF_API_KEY=s3cr3t
115117
```
116118

117119
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
123125
CLOUDFLARE_VAULT_SESSION=work
124126
125127
CLOUDFLARE_API_KEY=s3cr3t
128+
129+
CF_API_KEY=s3cr3t
126130

127131
$ exit
128132
$ env | grep -i cloudflare

cmd/exec.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ var execCmd = &cobra.Command{
3131
CLOUDFLARE_VAULT_SESSION=example-profile
3232
3333
CLOUDFLARE_API_KEY=s3cr3t
34+
35+
CF_API_KEY=s3cr3t
3436
3537
Spawn a new shell with credentials populated
3638
@@ -39,6 +41,8 @@ var execCmd = &cobra.Command{
3941
CLOUDFLARE_VAULT_SESSION=example-profile
4042
4143
CLOUDFLARE_API_KEY=s3cr3t
44+
45+
CF_API_KEY=s3cr3t
4246
`,
4347
Args: func(cmd *cobra.Command, args []string) error {
4448
if len(args) < 1 {
@@ -105,8 +109,10 @@ var execCmd = &cobra.Command{
105109
if profile.SessionDuration == "" {
106110
if profile.AuthType == "api_key" {
107111
env.Set("CLOUDFLARE_EMAIL", profile.Email)
112+
env.Set("CF_EMAIL", profile.Email)
108113
}
109114
env.Set(fmt.Sprintf("CLOUDFLARE_%s", strings.ToUpper(profile.AuthType)), string(keychain.Data))
115+
env.Set(fmt.Sprintf("CF_%s", strings.ToUpper(profile.AuthType)), string(keychain.Data))
110116
} else {
111117
var api *cloudflare.API
112118
if profile.AuthType == "api_token" {
@@ -160,6 +166,7 @@ var execCmd = &cobra.Command{
160166

161167
if shortLivedToken.Value != "" {
162168
env.Set("CLOUDFLARE_API_TOKEN", shortLivedToken.Value)
169+
env.Set("CF_API_TOKEN", shortLivedToken.Value)
163170
}
164171

165172
env.Set("CLOUDFLARE_SESSION_EXPIRY", strconv.Itoa(int(tokenExpiry.Unix())))

0 commit comments

Comments
 (0)