Skip to content

Commit 1cbe7f8

Browse files
0.1.0-2408071551.dev
1 parent c71a91c commit 1cbe7f8

6 files changed

Lines changed: 328 additions & 97 deletions

File tree

Taskfile.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ tasks:
5353
- task: build
5454

5555
build:
56+
aliases: [b]
5657
desc: build ops locally
5758
cmds:
5859
- echo building {{.VERSION}}
@@ -66,13 +67,15 @@ tasks:
6667
- ops
6768

6869
debug:
70+
aliases: [d]
6971
cmds:
7072
- task: build
7173
vars:
7274
DEBUG: "-gcflags '-l -N'"
7375
- dlv exec ./ops -- {{.CLI_ARGS}}
7476

7577
install:
78+
aliases: [i]
7679
desc: install ops in ~./local/bin
7780
deps:
7881
- build
@@ -96,6 +99,7 @@ tasks:
9699
- task: itest
97100

98101
utest:
102+
aliases: [ut]
99103
desc: unit test (use F=-v to verbose)
100104
cmds:
101105
- rm -Rf ~/.ops
@@ -116,6 +120,7 @@ tasks:
116120
- test -d bats
117121

118122
itest:
123+
aliases: [it]
119124
desc: integration tests for ops (T=<test-name> without .bats, empty run all, pass flags with F=)
120125
dir: tests
121126
cmds:

auth/login.go

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import (
3030
"path/filepath"
3131

3232
"github.com/apache/openserverless-cli/config"
33-
"github.com/mitchellh/go-homedir"
3433
"github.com/zalando/go-keyring"
3534
)
3635

@@ -41,7 +40,7 @@ type LoginResult struct {
4140
}
4241

4342
const usage = `Usage:
44-
ops login <apihost> [<user>]
43+
ops -login <apihost> [<user>]
4544
4645
Login to an OpenServerless instance. If no user is specified, the default user "nuvolaris" is used.
4746
You can set the environment variables OPS_APIHOST and OPS_USER to avoid specifying them on the command line.
@@ -50,12 +49,18 @@ You can set OPS_PASSWORD to avoid entering the password interactively.
5049
Options:
5150
-h, --help Show usage`
5251

53-
const whiskLoginPath = "/api/v1/web/whisk-system/ops/login"
52+
const whiskLoginPath = "/api/v1/web/whisk-system/nuv/login"
5453
const defaultUser = "nuvolaris"
5554
const opsSecretServiceName = "nuvolaris"
5655

5756
func LoginCmd() (*LoginResult, error) {
58-
flag := flag.NewFlagSet("login", flag.ExitOnError)
57+
58+
// enable log output if requested
59+
if os.Getenv("DEBUG")+os.Getenv("TRACE") != "" {
60+
log.SetOutput(os.Stdout)
61+
}
62+
63+
flag := flag.NewFlagSet("-login", flag.ExitOnError)
5964
flag.Usage = func() {
6065
fmt.Println(usage)
6166
}
@@ -80,17 +85,6 @@ func LoginCmd() (*LoginResult, error) {
8085
return nil, errors.New("missing apihost")
8186
}
8287

83-
password := os.Getenv("OPS_PASSWORD")
84-
if password == "" {
85-
fmt.Print("Enter Password: ")
86-
pwd, err := AskPassword()
87-
if err != nil {
88-
return nil, err
89-
}
90-
password = pwd
91-
fmt.Println()
92-
}
93-
9488
apihost := os.Getenv("OPS_APIHOST")
9589
if apihost == "" {
9690
apihost = args[0]
@@ -116,11 +110,22 @@ func LoginCmd() (*LoginResult, error) {
116110

117111
// if still not set, use the default user
118112
if user == "" {
119-
log.Println("Using the default user:", defaultUser)
113+
fmt.Println("Using the default user:", defaultUser)
120114
user = defaultUser
121115
}
122116

123-
log.Println("Logging in as", user, "to", apihost)
117+
fmt.Println("Logging in", apihost, "as", user)
118+
119+
password := os.Getenv("OPS_PASSWORD")
120+
if password == "" {
121+
fmt.Print("Enter Password: ")
122+
pwd, err := AskPassword()
123+
if err != nil {
124+
return nil, err
125+
}
126+
password = pwd
127+
fmt.Println()
128+
}
124129

125130
creds, err := doLogin(url, user, password)
126131
if err != nil {
@@ -131,9 +136,9 @@ func LoginCmd() (*LoginResult, error) {
131136
return nil, errors.New("missing AUTH token from login response")
132137
}
133138

134-
opsHome, err := homedir.Expand("~/.ops")
135-
if err != nil {
136-
return nil, err
139+
opsHome := os.Getenv("OPS_HOME")
140+
if opsHome == "" {
141+
return nil, fmt.Errorf("OPS_HOME not defined")
137142
}
138143

139144
configMap, err := config.NewConfigMapBuilder().

0 commit comments

Comments
 (0)