mirror of
https://github.com/pomerium/pomerium.git
synced 2025-06-15 09:12:43 +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 additional metrics endpoints to scrape and provide part of metrics
|
||||||
MetricsScrapeEndpoints []MetricsScrapeEndpoint
|
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.
|
// 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 {
|
func (src *source) UpdateBootstrap(ctx context.Context, cfg cluster_api.BootstrapConfig) bool {
|
||||||
current := src.cfg.Load()
|
current := src.cfg.Load()
|
||||||
incoming := current.Clone()
|
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
|
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) {
|
func applyBootstrapConfig(dst *config.Config, src *cluster_api.BootstrapConfig) {
|
||||||
dst.SharedKey = base64.StdEncoding.EncodeToString(src.SharedSecret)
|
dst.Options.SharedKey = base64.StdEncoding.EncodeToString(src.SharedSecret)
|
||||||
if src.DatabrokerStorageConnection != nil {
|
if src.DatabrokerStorageConnection != nil {
|
||||||
dst.DataBrokerStorageType = config.StoragePostgresName
|
dst.Options.DataBrokerStorageType = config.StoragePostgresName
|
||||||
dst.DataBrokerStorageConnectionString = *src.DatabrokerStorageConnection
|
dst.Options.DataBrokerStorageConnectionString = *src.DatabrokerStorageConnection
|
||||||
} else {
|
} else {
|
||||||
dst.DataBrokerStorageType = config.StorageInMemoryName
|
dst.Options.DataBrokerStorageType = config.StorageInMemoryName
|
||||||
dst.DataBrokerStorageConnectionString = ""
|
dst.Options.DataBrokerStorageConnectionString = ""
|
||||||
}
|
}
|
||||||
|
dst.ZeroClusterID = src.ClusterId
|
||||||
|
dst.ZeroOrganizationID = src.OrganizationId
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,7 +95,7 @@ func TestSecretWriter(t *testing.T) {
|
||||||
"namespace": "pomerium",
|
"namespace": "pomerium",
|
||||||
},
|
},
|
||||||
"data": map[string]any{
|
"data": map[string]any{
|
||||||
"bootstrap.dat": `{"databrokerStorageConnection":"test","sharedSecret":null}`,
|
"bootstrap.dat": `{"clusterId":"","databrokerStorageConnection":"test","organizationId":"","sharedSecret":null}`,
|
||||||
},
|
},
|
||||||
}, unstructured)
|
}, unstructured)
|
||||||
})
|
})
|
||||||
|
|
|
@ -18,8 +18,11 @@ const (
|
||||||
|
|
||||||
// BootstrapConfig defines model for BootstrapConfig.
|
// BootstrapConfig defines model for BootstrapConfig.
|
||||||
type BootstrapConfig struct {
|
type BootstrapConfig struct {
|
||||||
|
ClusterId string `json:"clusterId"`
|
||||||
|
|
||||||
// DatabrokerStorageConnection databroker storage connection string
|
// DatabrokerStorageConnection databroker storage connection string
|
||||||
DatabrokerStorageConnection *string `json:"databrokerStorageConnection,omitempty"`
|
DatabrokerStorageConnection *string `json:"databrokerStorageConnection,omitempty"`
|
||||||
|
OrganizationId string `json:"organizationId"`
|
||||||
|
|
||||||
// SharedSecret shared secret
|
// SharedSecret shared secret
|
||||||
SharedSecret []byte `json:"sharedSecret"`
|
SharedSecret []byte `json:"sharedSecret"`
|
||||||
|
|
|
@ -163,14 +163,20 @@ components:
|
||||||
BootstrapConfig:
|
BootstrapConfig:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
|
clusterId:
|
||||||
|
type: string
|
||||||
databrokerStorageConnection:
|
databrokerStorageConnection:
|
||||||
type: string
|
type: string
|
||||||
description: databroker storage connection string
|
description: databroker storage connection string
|
||||||
|
organizationId:
|
||||||
|
type: string
|
||||||
sharedSecret:
|
sharedSecret:
|
||||||
type: string
|
type: string
|
||||||
format: byte
|
format: byte
|
||||||
description: shared secret
|
description: shared secret
|
||||||
required:
|
required:
|
||||||
|
- clusterId
|
||||||
|
- organizationId
|
||||||
- sharedSecret
|
- sharedSecret
|
||||||
|
|
||||||
Bundle:
|
Bundle:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue