Skip to content

Use an interface to abstract provider types #76

@johananl

Description

@johananl

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions