Skip to content

Commit

Permalink
Support extra init args (#390)
Browse files Browse the repository at this point in the history
  • Loading branch information
agouin authored Nov 16, 2023
1 parent 3e03ae9 commit 573d4ec
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
4 changes: 4 additions & 0 deletions api/v1/cosmosfullnode_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,10 @@ type ChainSpec struct {
// +optional
Versions []ChainVersion `json:"versions"`

// Additional arguments to pass to the chain init command.
// +optional
AdditionalInitArgs []string `json:"additionalInitArgs"`

// Additional arguments to pass to the chain start command.
// +optional
AdditionalStartArgs []string `json:"additionalStartArgs"`
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:
additionalInitArgs:
description: Additional arguments to pass to the chain init command.
items:
type: string
type: array
additionalStartArgs:
description: Additional arguments to pass to the chain start command.
items:
Expand Down
5 changes: 4 additions & 1 deletion internal/fullnode/pod_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,10 @@ func initContainers(crd *cosmosv1.CosmosFullNode, moniker string) []corev1.Conta
addrbookCmd, addrbookArgs := DownloadAddrbookCommand(crd.Spec.ChainSpec)
env := envVars(crd)

initCmd := fmt.Sprintf("%s init %s --chain-id %s", binary, moniker, crd.Spec.ChainSpec.ChainID)
initCmd := fmt.Sprintf("%s --chain-id %s init %s", binary, crd.Spec.ChainSpec.ChainID, moniker)
if len(crd.Spec.ChainSpec.AdditionalInitArgs) > 0 {
initCmd += " " + strings.Join(crd.Spec.ChainSpec.AdditionalInitArgs, " ")
}
required := []corev1.Container{
{
Name: "clean-init",
Expand Down
4 changes: 2 additions & 2 deletions internal/fullnode/pod_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ func TestPodBuilder(t *testing.T) {
require.Contains(t, freshCont.Args[1], `rm -rf "$HOME/.tmp/*"`)

initCont := pod.Spec.InitContainers[1]
require.Contains(t, initCont.Args[1], `osmosisd init osmosis-6 --chain-id osmosis-123 --home "$CHAIN_HOME"`)
require.Contains(t, initCont.Args[1], `osmosisd init osmosis-6 --chain-id osmosis-123 --home "$HOME/.tmp"`)
require.Contains(t, initCont.Args[1], `osmosisd --chain-id osmosis-123 init osmosis-6 --home "$CHAIN_HOME"`)
require.Contains(t, initCont.Args[1], `osmosisd --chain-id osmosis-123 init osmosis-6 --home "$HOME/.tmp"`)

mergeConfig1 := pod.Spec.InitContainers[3]
// The order of config-merge arguments is important. Rightmost takes precedence.
Expand Down

0 comments on commit 573d4ec

Please sign in to comment.