Skip to content

Commit

Permalink
make binary small (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
kindy authored Apr 11, 2024
1 parent ec8e57e commit 14c7da7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
13 changes: 4 additions & 9 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/fishi0x01/vsh/client"
"github.com/fishi0x01/vsh/completer"
"github.com/fishi0x01/vsh/log"
"github.com/hashicorp/vault/command/config"
)

var vaultClient *client.Client
Expand Down Expand Up @@ -110,15 +109,11 @@ func getCommand(args []string, commands *cli.Commands) (cmd cli.Command, err err
func getVaultToken() (token string, err error) {
token = os.Getenv("VAULT_TOKEN")
if token == "" {
helper, ve := config.DefaultTokenHelper()
if ve != nil {
err = ve
return token, err
}
token, ve = helper.Get()
if ve != nil {
err = ve
tok, err := getTokenFromHelper()
if err != nil {
return "", err
}
token = tok
}
return token, err
}
Expand Down
16 changes: 16 additions & 0 deletions tokenhelper.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//go:build !notokenhelper
// +build !notokenhelper

package main

import (
"github.com/hashicorp/vault/command/config"
)

func getTokenFromHelper() (string, error) {
helper, err := config.DefaultTokenHelper()
if err != nil {
return "", err
}
return helper.Get()
}
8 changes: 8 additions & 0 deletions tokenhelper_off.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//go:build notokenhelper
// +build notokenhelper

package main

func getTokenFromHelper() (string, error) {
return "", nil
}

0 comments on commit 14c7da7

Please # to comment.