Skip to content

Commit

Permalink
feat: adds ChainType to support non Cosmos chains
Browse files Browse the repository at this point in the history
  • Loading branch information
AntiTyping committed May 14, 2024
1 parent 46f6f2f commit e0bf776
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
15 changes: 15 additions & 0 deletions api/v1/cosmosfullnode_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ type FullNodeSpec struct {
// +optional
Type FullNodeType `json:"type"`

// Different kinds of chains supported by the operator
// 'Cosmos' configures the node using defaults for a Cosmos based chain
// 'Custom' configures the node with more flexible options that allow for support other chains
// If not set, defaults to Cosmos
// +kubebuilder:validation:Enum:=Cosmos;Custom
// +optional
ChainType ChainType `json:"chainType"`

// Blockchain-specific configuration.
ChainSpec ChainSpec `json:"chain"`

Expand Down Expand Up @@ -102,6 +110,13 @@ const (
Sentry FullNodeType = "Sentry"
)

type ChainType string

const (
Cosmos ChainType = "Cosmos"
Custom ChainType = "Custom"
)

// FullNodeStatus defines the observed state of CosmosFullNode
type FullNodeStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
Expand Down
9 changes: 9 additions & 0 deletions config/crd/bases/cosmos.strange.love_cosmosfullnodes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,15 @@ spec:
- chainID
- network
type: object
chainType:
description: Different kinds of chains supported by the operator 'Cosmos'
configures the node using defaults for a Cosmos based chain 'Custom'
configures the node with more flexible options that allow for support
other chains If not set, defaults to Cosmos
enum:
- Cosmos
- Custom
type: string
instanceOverrides:
additionalProperties:
description: InstanceOverridesSpec allows overriding an instance
Expand Down
6 changes: 3 additions & 3 deletions internal/fullnode/pod_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func NewPodBuilder(crd *cosmosv1.CosmosFullNode) PodBuilder {
},
}

if crd.Spec.ChainSpec.InitScript == nil && len(crd.Spec.ChainSpec.Versions) > 0 {
if crd.Spec.ChainType == cosmosv1.Cosmos && len(crd.Spec.ChainSpec.Versions) > 0 {
// version check sidecar, runs on inverval in case the instance is halting for upgrade.
pod.Spec.Containers = append(pod.Spec.Containers, corev1.Container{
Name: "version-check-interval",
Expand Down Expand Up @@ -361,7 +361,7 @@ func initContainers(crd *cosmosv1.CosmosFullNode, moniker string) []corev1.Conta
},
}

if crd.Spec.ChainSpec.InitScript == nil {
if crd.Spec.ChainType == cosmosv1.Cosmos {
mrg := []corev1.Container{
{
Name: "config-merge",
Expand Down Expand Up @@ -418,7 +418,7 @@ func initContainers(crd *cosmosv1.CosmosFullNode, moniker string) []corev1.Conta
// This initContainer will update the crd status with the current height for the pod,
// And then panic if the image version is not correct for the current height.
// After the status is patched, the pod will be restarted with the correct image.
if crd.Spec.ChainSpec.InitScript == nil {
if crd.Spec.ChainType == cosmosv1.Cosmos {
required = append(required, corev1.Container{
Name: "version-check",
Image: "ghcr.io/strangelove-ventures/cosmos-operator:" + version.DockerTag(),
Expand Down

0 comments on commit e0bf776

Please sign in to comment.