mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-06 13:56:04 +02:00
33 lines
823 B
Go
33 lines
823 B
Go
package bootstrap
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/pomerium/pomerium/config"
|
|
cluster_api "github.com/pomerium/zero-sdk/cluster"
|
|
)
|
|
|
|
// LoadBootstrapConfigFromAPI loads the bootstrap configuration from the cluster API.
|
|
func LoadBootstrapConfigFromAPI(
|
|
ctx context.Context,
|
|
dst *config.Options,
|
|
client cluster_api.ClientWithResponsesInterface,
|
|
) error {
|
|
resp, err := client.GetClusterBootstrapConfigWithResponse(ctx)
|
|
if err != nil {
|
|
return fmt.Errorf("get: %w", err)
|
|
}
|
|
if resp.JSON200 == nil {
|
|
return fmt.Errorf("unexpected response: %d/%v", resp.StatusCode(), resp.Status())
|
|
}
|
|
|
|
v := cluster_api.BootstrapConfig(*resp.JSON200)
|
|
|
|
if v.DatabrokerStorageConnection != nil {
|
|
dst.DataBrokerStorageType = "postgres"
|
|
dst.DataBrokerStorageConnectionString = *v.DatabrokerStorageConnection
|
|
}
|
|
|
|
return nil
|
|
}
|