directory: generate user/directory.User ID in a consistent way (#944)

This commit is contained in:
Caleb Doxsey 2020-06-22 07:42:57 -06:00 committed by GitHub
parent 84dde097c7
commit f7760c413e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 59 additions and 26 deletions

View file

@ -26,7 +26,7 @@ type Provider interface {
// GetProvider gets the provider for the given options.
func GetProvider(options *config.Options) Provider {
switch options.Provider {
case "azure":
case azure.Name:
serviceAccount, err := azure.ParseServiceAccount(options.ServiceAccount)
if err == nil {
return azure.New(azure.WithServiceAccount(serviceAccount))
@ -37,7 +37,7 @@ func GetProvider(options *config.Options) Provider {
Str("provider", options.Provider).
Err(err).
Msg("invalid service account for azure directory provider")
case "gitlab":
case gitlab.Name:
serviceAccount, err := gitlab.ParseServiceAccount(options.ServiceAccount)
if err == nil {
return gitlab.New(gitlab.WithServiceAccount(serviceAccount))
@ -47,11 +47,11 @@ func GetProvider(options *config.Options) Provider {
Str("provider", options.Provider).
Err(err).
Msg("invalid service account for gitlab directory provider")
case "google":
case google.Name:
if options.ServiceAccount != "" {
return google.New(google.WithServiceAccount(options.ServiceAccount))
}
case "okta":
case okta.Name:
providerURL, _ := url.Parse(options.ProviderURL)
serviceAccount, err := okta.ParseServiceAccount(options.ServiceAccount)
if err == nil {
@ -64,7 +64,7 @@ func GetProvider(options *config.Options) Provider {
Str("provider", options.Provider).
Err(err).
Msg("invalid service account for okta directory provider")
case "onelogin":
case onelogin.Name:
serviceAccount, err := onelogin.ParseServiceAccount(options.ServiceAccount)
if err == nil {
return onelogin.New(onelogin.WithServiceAccount(serviceAccount))