Skip to content

Commit

Permalink
Expose methods to create a cluster based on the generated spec (#1716)
Browse files Browse the repository at this point in the history
  • Loading branch information
johscheuer authored Jun 30, 2023
1 parent 99ce5d0 commit 001f200
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
22 changes: 11 additions & 11 deletions e2e/fixtures/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,18 +155,18 @@ func (factory *Factory) CreateFdbCluster(
config *ClusterConfig,
options ...ClusterOption,
) *FdbCluster {
config.SetDefaults(factory)

mainOverrides, sidecarOverrides := factory.getContainerOverrides(config.DebugSymbols)
spec := factory.createFDBClusterSpec(
config.Name,
config.Namespace,
factory.createProcesses(config),
config.CreateDatabaseConfiguration(),
config.StorageServerPerPod,
mainOverrides,
sidecarOverrides)
spec := factory.GenerateFDBClusterSpec(config)
return factory.CreateFdbClusterFromSpec(spec, config, options...)
}

// CreateFdbClusterFromSpec creates a FDB cluster. This method can be used in combination with the GenerateFDBClusterSpec method.
// In general this should only be used for special cases that are not covered by changing the ClusterOptions or the ClusterConfig.
func (factory *Factory) CreateFdbClusterFromSpec(
spec *fdbv1beta2.FoundationDBCluster,
config *ClusterConfig,
options ...ClusterOption,
) *FdbCluster {
config.SetDefaults(factory)
log.Printf("create cluster: %s", ToJSON(spec))

return factory.startFDBFromClusterSpec(spec, config, options...)
Expand Down
15 changes: 15 additions & 0 deletions e2e/fixtures/fdb_cluster_specs.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@ import (
"k8s.io/utils/pointer"
)

// GenerateFDBClusterSpec will generate a *fdbv1beta2.FoundationDBCluster based on the input ClusterConfig.
func (factory *Factory) GenerateFDBClusterSpec(config *ClusterConfig) *fdbv1beta2.FoundationDBCluster {
config.SetDefaults(factory)

mainOverrides, sidecarOverrides := factory.getContainerOverrides(config.DebugSymbols)
return factory.createFDBClusterSpec(
config.Name,
config.Namespace,
factory.createProcesses(config),
config.CreateDatabaseConfiguration(),
config.StorageServerPerPod,
mainOverrides,
sidecarOverrides)
}

// High Level Cluster Spec Supplied by Operator.
func (factory *Factory) createFDBClusterSpec(
clusterName string,
Expand Down

0 comments on commit 001f200

Please sign in to comment.