mirror of
https://github.com/pomerium/pomerium.git
synced 2025-06-14 00:33:09 +02:00
core/zero: add organization id and cluster id to bootstrap config (#5275)
This commit is contained in:
parent
a2f98c8743
commit
aa816dc2a8
5 changed files with 25 additions and 9 deletions
|
@ -49,6 +49,11 @@ type Config struct {
|
|||
|
||||
// MetricsScrapeEndpoints additional metrics endpoints to scrape and provide part of metrics
|
||||
MetricsScrapeEndpoints []MetricsScrapeEndpoint
|
||||
|
||||
// ZeroClusterID is the zero cluster id, only set when in zero mode.
|
||||
ZeroClusterID string
|
||||
// ZeroOrganizationID is the zero organization id, only set when in zero mode.
|
||||
ZeroOrganizationID string
|
||||
}
|
||||
|
||||
// Clone creates a clone of the config.
|
||||
|
|
|
@ -55,9 +55,9 @@ func (src *source) OnConfigChange(_ context.Context, l config.ChangeListener) {
|
|||
func (src *source) UpdateBootstrap(ctx context.Context, cfg cluster_api.BootstrapConfig) bool {
|
||||
current := src.cfg.Load()
|
||||
incoming := current.Clone()
|
||||
applyBootstrapConfig(incoming.Options, &cfg)
|
||||
applyBootstrapConfig(incoming, &cfg)
|
||||
|
||||
if cmp.Equal(incoming.Options, current.Options, cmpOpts...) {
|
||||
if cmp.Equal(incoming, current, cmpOpts...) {
|
||||
return false
|
||||
}
|
||||
|
||||
|
@ -81,13 +81,15 @@ func (src *source) notifyListeners(ctx context.Context, cfg *config.Config) {
|
|||
}
|
||||
}
|
||||
|
||||
func applyBootstrapConfig(dst *config.Options, src *cluster_api.BootstrapConfig) {
|
||||
dst.SharedKey = base64.StdEncoding.EncodeToString(src.SharedSecret)
|
||||
func applyBootstrapConfig(dst *config.Config, src *cluster_api.BootstrapConfig) {
|
||||
dst.Options.SharedKey = base64.StdEncoding.EncodeToString(src.SharedSecret)
|
||||
if src.DatabrokerStorageConnection != nil {
|
||||
dst.DataBrokerStorageType = config.StoragePostgresName
|
||||
dst.DataBrokerStorageConnectionString = *src.DatabrokerStorageConnection
|
||||
dst.Options.DataBrokerStorageType = config.StoragePostgresName
|
||||
dst.Options.DataBrokerStorageConnectionString = *src.DatabrokerStorageConnection
|
||||
} else {
|
||||
dst.DataBrokerStorageType = config.StorageInMemoryName
|
||||
dst.DataBrokerStorageConnectionString = ""
|
||||
dst.Options.DataBrokerStorageType = config.StorageInMemoryName
|
||||
dst.Options.DataBrokerStorageConnectionString = ""
|
||||
}
|
||||
dst.ZeroClusterID = src.ClusterId
|
||||
dst.ZeroOrganizationID = src.OrganizationId
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ func TestSecretWriter(t *testing.T) {
|
|||
"namespace": "pomerium",
|
||||
},
|
||||
"data": map[string]any{
|
||||
"bootstrap.dat": `{"databrokerStorageConnection":"test","sharedSecret":null}`,
|
||||
"bootstrap.dat": `{"clusterId":"","databrokerStorageConnection":"test","organizationId":"","sharedSecret":null}`,
|
||||
},
|
||||
}, unstructured)
|
||||
})
|
||||
|
|
|
@ -18,8 +18,11 @@ const (
|
|||
|
||||
// BootstrapConfig defines model for BootstrapConfig.
|
||||
type BootstrapConfig struct {
|
||||
ClusterId string `json:"clusterId"`
|
||||
|
||||
// DatabrokerStorageConnection databroker storage connection string
|
||||
DatabrokerStorageConnection *string `json:"databrokerStorageConnection,omitempty"`
|
||||
OrganizationId string `json:"organizationId"`
|
||||
|
||||
// SharedSecret shared secret
|
||||
SharedSecret []byte `json:"sharedSecret"`
|
||||
|
|
|
@ -163,14 +163,20 @@ components:
|
|||
BootstrapConfig:
|
||||
type: object
|
||||
properties:
|
||||
clusterId:
|
||||
type: string
|
||||
databrokerStorageConnection:
|
||||
type: string
|
||||
description: databroker storage connection string
|
||||
organizationId:
|
||||
type: string
|
||||
sharedSecret:
|
||||
type: string
|
||||
format: byte
|
||||
description: shared secret
|
||||
required:
|
||||
- clusterId
|
||||
- organizationId
|
||||
- sharedSecret
|
||||
|
||||
Bundle:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue