MCPcopy Index your code
hub / github.com/cloudfoundry/cli / getUsernamePassword

Method getUsernamePassword

command/v7/auth_command.go:126–165  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

124}
125
126func (cmd AuthCommand) getUsernamePassword() (string, string, error) {
127 var (
128 userMissing bool
129 passwordMissing bool
130 )
131
132 username := cmd.RequiredArgs.Username
133 if username == "" {
134 if envUser := cmd.Config.CFUsername(); envUser != "" {
135 username = envUser
136 } else {
137 userMissing = true
138 }
139 }
140
141 password := cmd.RequiredArgs.Password
142 if password == "" {
143 if envPassword := cmd.Config.CFPassword(); envPassword != "" {
144 password = envPassword
145 } else {
146 passwordMissing = true
147 }
148 }
149
150 if cmd.Config.IsCFOnK8s() {
151 if !passwordMissing {
152 cmd.UI.DisplayWarning("Warning: password is ignored when authenticating against Kubernetes.")
153 }
154 passwordMissing = false
155 }
156
157 if cmd.Assertion == "" && (userMissing || passwordMissing) {
158 return "", "", translatableerror.MissingCredentialsError{
159 MissingUsername: userMissing,
160 MissingPassword: passwordMissing,
161 }
162 }
163
164 return username, password, nil
165}

Callers 1

ExecuteMethod · 0.95

Calls 4

CFUsernameMethod · 0.65
CFPasswordMethod · 0.65
IsCFOnK8sMethod · 0.65
DisplayWarningMethod · 0.65

Tested by

no test coverage detected