Skip to content

Commit 6a9b558

Browse files
authored
feat: add args for custom volume mount paths (#44)
1. Added three optional fields to SignetNodeComponentArgs in types.go: - SignetNodeDataMountPath (defaults to /root/.local/share/reth) - RollupDataMountPath (defaults to /root/.local/share/exex) - ExecutionJwtMountPath (defaults to /etc/reth/execution-jwt) 2. Created default constants in constants.go for the default mount paths 3. Added ApplyDefaults() method in validation.go that sets default values if not provided 4. Updated internal types to include the new mount path fields 5. Modified the conversion function toInternal() to include the new fields 6. Updated NewSignetNode() in signet_node.go to: - Call ApplyDefaults() before validation - Use the configurable mount paths instead of hardcoded values 7. Added comprehensive tests for the new functionality
1 parent 767fc01 commit 6a9b558

File tree

5 files changed

+65
-3
lines changed

5 files changed

+65
-3
lines changed

pkg/signet_node/constants.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ const (
2929

3030
// Component name
3131
ComponentKind = "the-builder:index:SignetNode"
32+
33+
// Default mount paths for volumes
34+
DefaultSignetNodeDataMountPath = "/root/.local/share/reth"
35+
DefaultRollupDataMountPath = "/root/.local/share/exex"
36+
DefaultExecutionJwtMountPath = "/etc/reth/execution-jwt"
3237
)
3338

3439
// Resource name suffixes

pkg/signet_node/signet_node.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import (
1212
)
1313

1414
func NewSignetNode(ctx *pulumi.Context, args SignetNodeComponentArgs, opts ...pulumi.ResourceOption) (*SignetNodeComponent, error) {
15+
// Apply defaults before validation
16+
args.ApplyDefaults()
17+
1518
if err := args.Validate(); err != nil {
1619
return nil, fmt.Errorf("invalid signet node component args: %w", err)
1720
}
@@ -205,15 +208,15 @@ func NewSignetNode(ctx *pulumi.Context, args SignetNodeComponentArgs, opts ...pu
205208
VolumeMounts: corev1.VolumeMountArray{
206209
corev1.VolumeMountArgs{
207210
Name: pulumi.String("signet-node-data"),
208-
MountPath: pulumi.String("/root/.local/share/reth"),
211+
MountPath: internalArgs.SignetNodeDataMountPath,
209212
},
210213
corev1.VolumeMountArgs{
211214
Name: pulumi.String("rollup-data"),
212-
MountPath: pulumi.String("/root/.local/share/exex"),
215+
MountPath: internalArgs.RollupDataMountPath,
213216
},
214217
corev1.VolumeMountArgs{
215218
Name: pulumi.String("execution-jwt"),
216-
MountPath: pulumi.String("/etc/reth/execution-jwt"),
219+
MountPath: internalArgs.ExecutionJwtMountPath,
217220
},
218221
},
219222
Resources: NewResourceRequirements("2", "16Gi", "2", "4Gi"),

pkg/signet_node/types.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ type SignetNodeComponentArgs struct {
2929
ExecutionClientStartCommand []string
3030
ConsensusClientStartCommand []string
3131
AppLabels AppLabels
32+
SignetNodeDataMountPath string // Optional: defaults to "/root/.local/share/reth"
33+
RollupDataMountPath string // Optional: defaults to "/root/.local/share/exex"
34+
ExecutionJwtMountPath string // Optional: defaults to "/etc/reth/execution-jwt"
3235
}
3336

3437
// Internal structs with Pulumi types for use within the component
@@ -45,6 +48,9 @@ type signetNodeComponentArgsInternal struct {
4548
ExecutionClientStartCommand pulumi.StringArrayInput
4649
ConsensusClientStartCommand pulumi.StringArrayInput
4750
AppLabels AppLabels
51+
SignetNodeDataMountPath pulumi.StringInput
52+
RollupDataMountPath pulumi.StringInput
53+
ExecutionJwtMountPath pulumi.StringInput
4854
}
4955

5056
type SignetNodeComponent struct {
@@ -132,6 +138,9 @@ func (args SignetNodeComponentArgs) toInternal() signetNodeComponentArgsInternal
132138
ExecutionClientStartCommand: pulumi.ToStringArray(args.ExecutionClientStartCommand),
133139
ConsensusClientStartCommand: pulumi.ToStringArray(args.ConsensusClientStartCommand),
134140
AppLabels: args.AppLabels,
141+
SignetNodeDataMountPath: pulumi.String(args.SignetNodeDataMountPath),
142+
RollupDataMountPath: pulumi.String(args.RollupDataMountPath),
143+
ExecutionJwtMountPath: pulumi.String(args.ExecutionJwtMountPath),
135144
}
136145
}
137146

pkg/signet_node/validation.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@ import (
44
"fmt"
55
)
66

7+
// ApplyDefaults sets default values for optional fields
8+
func (args *SignetNodeComponentArgs) ApplyDefaults() {
9+
if args.SignetNodeDataMountPath == "" {
10+
args.SignetNodeDataMountPath = DefaultSignetNodeDataMountPath
11+
}
12+
if args.RollupDataMountPath == "" {
13+
args.RollupDataMountPath = DefaultRollupDataMountPath
14+
}
15+
if args.ExecutionJwtMountPath == "" {
16+
args.ExecutionJwtMountPath = DefaultExecutionJwtMountPath
17+
}
18+
}
19+
720
func (args *SignetNodeComponentArgs) Validate() error {
821
if args.Name == "" {
922
return fmt.Errorf("name is required")

pkg/signet_node/validation_test.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,3 +141,35 @@ func TestSignetNodeComponentArgsValidate(t *testing.T) {
141141
assert.Error(t, err)
142142
assert.Contains(t, err.Error(), "execution pvc size is required")
143143
}
144+
145+
func TestApplyDefaults(t *testing.T) {
146+
// Test with no mount paths specified
147+
args := SignetNodeComponentArgs{}
148+
args.ApplyDefaults()
149+
150+
assert.Equal(t, DefaultSignetNodeDataMountPath, args.SignetNodeDataMountPath)
151+
assert.Equal(t, DefaultRollupDataMountPath, args.RollupDataMountPath)
152+
assert.Equal(t, DefaultExecutionJwtMountPath, args.ExecutionJwtMountPath)
153+
154+
// Test with custom mount paths
155+
customArgs := SignetNodeComponentArgs{
156+
SignetNodeDataMountPath: "/custom/signet/data",
157+
RollupDataMountPath: "/custom/rollup/data",
158+
ExecutionJwtMountPath: "/custom/jwt",
159+
}
160+
customArgs.ApplyDefaults()
161+
162+
assert.Equal(t, "/custom/signet/data", customArgs.SignetNodeDataMountPath)
163+
assert.Equal(t, "/custom/rollup/data", customArgs.RollupDataMountPath)
164+
assert.Equal(t, "/custom/jwt", customArgs.ExecutionJwtMountPath)
165+
166+
// Test with partial custom mount paths
167+
partialArgs := SignetNodeComponentArgs{
168+
SignetNodeDataMountPath: "/custom/signet/data",
169+
}
170+
partialArgs.ApplyDefaults()
171+
172+
assert.Equal(t, "/custom/signet/data", partialArgs.SignetNodeDataMountPath)
173+
assert.Equal(t, DefaultRollupDataMountPath, partialArgs.RollupDataMountPath)
174+
assert.Equal(t, DefaultExecutionJwtMountPath, partialArgs.ExecutionJwtMountPath)
175+
}

0 commit comments

Comments
 (0)