Skip to content

Commit 02ce7c7

Browse files
author
Gal Topper
authored
Use V3IO_API and V3IO_ACCESS_KEY. (#2)
1 parent 9989f37 commit 02ce7c7

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

pkg/v3ctl/v3ctl.go

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func NewRootCommandeer() *RootCommandeer {
4747
SilenceErrors: true,
4848
}
4949

50-
defaultV3ioServer := os.Getenv("V3IO_SERVICE_URL")
50+
defaultV3ioServer := os.Getenv("V3IO_API")
5151

5252
cmd.PersistentFlags().StringVarP(&commandeer.logLevel, "log-level", "v", "debug",
5353
`Verbose output. Add "=<level>" to set the log level -
@@ -101,10 +101,25 @@ func (rc *RootCommandeer) initialize() error {
101101
return errors.New("Container must be specified (use --container)")
102102
}
103103

104+
var username string
105+
var password string
106+
var accessKey = rc.accessKey
107+
108+
// Only use username and password from cli if access key was not also provided on cli.
109+
if accessKey == "" {
110+
username = rc.username
111+
password = rc.password
112+
113+
// Only use V3IO_ACCESS_KEY if no credentials were provided on cli.
114+
if password == "" {
115+
accessKey = os.Getenv("V3IO_ACCESS_KEY")
116+
}
117+
}
118+
104119
session, err := rc.dataPlaneContext.NewSessionSync(&v3io.NewSessionInput{
105-
Username: rc.username,
106-
Password: rc.password,
107-
AccessKey: rc.accessKey,
120+
Username: username,
121+
Password: password,
122+
AccessKey: accessKey,
108123
})
109124

110125
if err != nil {

0 commit comments

Comments
 (0)