scim/pkg/supplier/supplier.go
2022-06-10 13:51:19 +02:00

32 lines
568 B
Go

package supplier
import (
"context"
)
func Reconcile(ctx context.Context, sp ServiceProviderSupplier, kc KeycloakSupplier) error {
if err := sp.StartSession(ctx); err != nil {
return err
}
defer sp.CloseSession()
if err := sp.InstallOrUpdate(); err != nil {
return err
}
if err := sp.Enable(); err != nil {
return err
}
username, password, err := sp.GenerateCredentials()
if err != nil {
return err
}
return kc.Reconcile(ctx, ScimClient{
Name: sp.Name(),
Endpoint: sp.ScimEndpoint(),
Username: username,
Password: password,
})
}