Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support extra init args #390

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading