mirror of
https://github.com/pomerium/pomerium.git
synced 2025-07-16 16:26:16 +02:00
zero: bootstrap config
This commit is contained in:
parent
0affd9268b
commit
40efa26257
9 changed files with 638 additions and 30 deletions
33
internal/zero/bootstrap/cloud.go
Normal file
33
internal/zero/bootstrap/cloud.go
Normal file
|
@ -0,0 +1,33 @@
|
|||
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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue