restructure

This commit is contained in:
Denis Mishin 2023-08-08 14:47:32 -04:00
parent 40efa26257
commit c7fd5a4752
7 changed files with 86 additions and 122 deletions

View file

@ -4,30 +4,21 @@ 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 {
) (*cluster_api.BootstrapConfig, error) {
resp, err := client.GetClusterBootstrapConfigWithResponse(ctx)
if err != nil {
return fmt.Errorf("get: %w", err)
return nil, fmt.Errorf("get: %w", err)
}
if resp.JSON200 == nil {
return fmt.Errorf("unexpected response: %d/%v", resp.StatusCode(), resp.Status())
return nil, 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
return resp.JSON200, nil
}