Skip to content

Commit

Permalink
Allow adding additional start args (#381)
Browse files Browse the repository at this point in the history
  • Loading branch information
agouin authored Oct 27, 2023
1 parent 41a210e commit ff3610b
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 0 deletions.
4 changes: 4 additions & 0 deletions api/v1/cosmosfullnode_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,10 @@ type ChainSpec struct {
// If not provided, the operator will not upgrade the chain, and will use the image specified in the pod spec.
// +optional
Versions []ChainVersion `json:"versions"`

// Additional arguments to pass to the chain start command.
// +optional
AdditionalStartArgs []string `json:"additionalStartArgs"`
}

type ChainVersion struct {
Expand Down
5 changes: 5 additions & 0 deletions api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions config/crd/bases/cosmos.strange.love_cosmosfullnodes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ spec:
chain:
description: Blockchain-specific configuration.
properties:
additionalStartArgs:
description: Additional arguments to pass to the chain start command.
items:
type: string
type: array
addrbookScript:
description: 'Specify shell (sh) script commands to properly download
and save the address book file. Prefer AddrbookURL if the file
Expand Down
3 changes: 3 additions & 0 deletions internal/fullnode/pod_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,9 @@ func startCommandArgs(crd *cosmosv1.CosmosFullNode) []string {
if format := cfg.LogFormat; format != nil {
args = append(args, "--log_format", *format)
}
if len(crd.Spec.ChainSpec.AdditionalStartArgs) > 0 {
args = append(args, crd.Spec.ChainSpec.AdditionalStartArgs...)
}
return args
}

Expand Down
14 changes: 14 additions & 0 deletions internal/fullnode/pod_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,20 @@ func TestPodBuilder(t *testing.T) {
test.RequireValidMetadata(t, pod)
})

t.Run("additional args", func(t *testing.T) {
crd := defaultCRD()

crd.Spec.ChainSpec.AdditionalStartArgs = []string{"--foo", "bar"}

builder := NewPodBuilder(&crd)
pod, err := builder.WithOrdinal(0).Build()
require.NoError(t, err)

test.RequireValidMetadata(t, pod)

require.Equal(t, []string{"start", "--home", "/home/operator/cosmos", "--foo", "bar"}, pod.Spec.Containers[0].Args)
})

t.Run("containers", func(t *testing.T) {
crd := defaultCRD()
const wantWrkDir = "/home/operator"
Expand Down

0 comments on commit ff3610b

Please sign in to comment.