Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use an interface to abstract provider types #76

Open
johananl opened this issue Nov 20, 2018 · 0 comments
Open

Use an interface to abstract provider types #76

johananl opened this issue Nov 20, 2018 · 0 comments

Comments

@johananl
Copy link
Collaborator

clisso/cmd/get.go

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant