func NewGCPServiceAccount()

in cmd/checker/gcp.go [124:153]


func NewGCPServiceAccount(account string) (gerrit.Authenticator, error) {
	tc := tokenCache{
		account: account,
	}

	scopes, err := tc.fetchScopes()
	if err != nil {
		return nil, err
	}

	found := false
	for _, s := range scopes {
		if s == gerritScope {
			found = true
			break
		}
	}
	if !found {
		return nil, fmt.Errorf("missing scope %q, got %q", gerritScope, scopes)
	}

	tc.current, err = tc.fetchToken()
	if err != nil {
		return nil, err
	}

	go tc.loop()

	return &tc, nil
}