LoginRequest -> CredentialRequest

- We want to follow the <noun>Request convention.
- The actual operation does not login a user, but it does retrieve a
  credential with which they can login.

- This commit includes changes to all LoginRequest-related symbols and
  constants to try to update their names to follow the new
  CredentialRequest type.

Signed-off-by: Andrew Keesler <akeesler@vmware.com>
This commit is contained in:
Andrew Keesler
2020-08-14 10:11:14 -04:00
parent dd8ce677ba
commit df1a1cf1bd
40 changed files with 2539 additions and 808 deletions

View File

@@ -31,7 +31,7 @@ func main() {
type envGetter func(string) (string, bool)
type tokenExchanger func(ctx context.Context, token, caBundle, apiEndpoint string) (*client.Credential, error)
const ErrMissingEnvVar = constable.Error("failed to login: environment variable not set")
const ErrMissingEnvVar = constable.Error("failed to get credential: environment variable not set")
func run(envGetter envGetter, tokenExchanger tokenExchanger, outputWriter io.Writer, timeout time.Duration) error {
ctx, cancel := context.WithTimeout(context.Background(), timeout)
@@ -54,7 +54,7 @@ func run(envGetter envGetter, tokenExchanger tokenExchanger, outputWriter io.Wri
cred, err := tokenExchanger(ctx, token, caBundle, apiEndpoint)
if err != nil {
return fmt.Errorf("failed to login: %w", err)
return fmt.Errorf("failed to get credential: %w", err)
}
var expiration *metav1.Time

View File

@@ -50,19 +50,19 @@ func TestRun(t *testing.T) {
it("returns an error when PLACEHOLDER_NAME_TOKEN is missing", func() {
delete(fakeEnv, "PLACEHOLDER_NAME_TOKEN")
err := run(envGetter, tokenExchanger, buffer, 30*time.Second)
r.EqualError(err, "failed to login: environment variable not set: PLACEHOLDER_NAME_TOKEN")
r.EqualError(err, "failed to get credential: environment variable not set: PLACEHOLDER_NAME_TOKEN")
})
it("returns an error when PLACEHOLDER_NAME_CA_BUNDLE is missing", func() {
delete(fakeEnv, "PLACEHOLDER_NAME_CA_BUNDLE")
err := run(envGetter, tokenExchanger, buffer, 30*time.Second)
r.EqualError(err, "failed to login: environment variable not set: PLACEHOLDER_NAME_CA_BUNDLE")
r.EqualError(err, "failed to get credential: environment variable not set: PLACEHOLDER_NAME_CA_BUNDLE")
})
it("returns an error when PLACEHOLDER_NAME_K8S_API_ENDPOINT is missing", func() {
delete(fakeEnv, "PLACEHOLDER_NAME_K8S_API_ENDPOINT")
err := run(envGetter, tokenExchanger, buffer, 30*time.Second)
r.EqualError(err, "failed to login: environment variable not set: PLACEHOLDER_NAME_K8S_API_ENDPOINT")
r.EqualError(err, "failed to get credential: environment variable not set: PLACEHOLDER_NAME_K8S_API_ENDPOINT")
})
})
@@ -75,7 +75,7 @@ func TestRun(t *testing.T) {
it("returns an error", func() {
err := run(envGetter, tokenExchanger, buffer, 30*time.Second)
r.EqualError(err, "failed to login: some error")
r.EqualError(err, "failed to get credential: some error")
})
})
@@ -106,7 +106,7 @@ func TestRun(t *testing.T) {
it("returns an error", func() {
err := run(envGetter, tokenExchanger, buffer, 1*time.Millisecond)
r.EqualError(err, "failed to login: context deadline exceeded")
r.EqualError(err, "failed to get credential: context deadline exceeded")
})
})