-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Labels
Description
Lines 87 to 109 in baae940
if pType == "onelogin" { | |
creds, err := onelogin.Get(app, provider) | |
if err != nil { | |
log.Fatal(color.RedString("Could not get temporary credentials: "), err) | |
} | |
// Process credentials | |
err = processCredentials(creds, app) | |
if err != nil { | |
log.Fatalf(color.RedString("Error processing credentials: %v"), err) | |
} | |
} else if pType == "okta" { | |
creds, err := okta.Get(app, provider) | |
if err != nil { | |
log.Fatal(color.RedString("Could not get temporary credentials: "), err) | |
} | |
// Process credentials | |
err = processCredentials(creds, app) | |
if err != nil { | |
log.Fatalf(color.RedString("Error processing credentials: %v"), err) | |
} | |
} else { | |
log.Fatalf(color.RedString("Unsupported identity provider type '%s' for app '%s'"), pType, app) | |
} |
We could use an interface to eliminate the code duplication above and have something like the following:
p := NewProvider(pType)
creds, err := p.Get()
...
The concrete provider type would be constructed based on the invoked command.