Skip to content
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
16 changes: 9 additions & 7 deletions pkg/signet_node/signet_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
func NewSignetNode(ctx *pulumi.Context, args SignetNodeComponentArgs, opts ...pulumi.ResourceOption) (*SignetNodeComponent, error) {
// Apply defaults before validation
args.ApplyDefaults()

if err := args.Validate(); err != nil {
return nil, fmt.Errorf("invalid signet node component args: %w", err)
}
Expand Down Expand Up @@ -54,7 +54,7 @@ func NewSignetNode(ctx *pulumi.Context, args SignetNodeComponentArgs, opts ...pu
return nil, fmt.Errorf("failed to create rollup data pvc: %w", err)
}

secretName := "execution-jwt"
secretName := fmt.Sprintf("%s-execution-jwt", args.Name)
secret, err := corev1.NewSecret(ctx, secretName, &corev1.SecretArgs{
StringData: pulumi.StringMap{
"jwt.hex": internalArgs.ExecutionJwt,
Expand All @@ -63,19 +63,20 @@ func NewSignetNode(ctx *pulumi.Context, args SignetNodeComponentArgs, opts ...pu
Namespace: internalArgs.Namespace,
Labels: utils.CreateResourceLabels(args.Name, secretName, args.Name, nil),
},
})
}, pulumi.Parent(component))
if err != nil {
return nil, fmt.Errorf("failed to create execution jwt secret: %w", err)
}

// Create ConfigMap for execution environment variables
executionConfigMapName := "exex-configmap"
executionConfigMapName := fmt.Sprintf("%s-exex-configmap", args.Name)
executionConfigMap, err := utils.CreateConfigMap(
ctx,
executionConfigMapName,
internalArgs.Namespace,
utils.CreateResourceLabels(args.Name, executionConfigMapName, args.Name, nil),
internalArgs.Env,
component,
)
if err != nil {
return nil, fmt.Errorf("failed to create execution configmap: %w", err)
Expand Down Expand Up @@ -215,7 +216,7 @@ func NewSignetNode(ctx *pulumi.Context, args SignetNodeComponentArgs, opts ...pu
MountPath: internalArgs.RollupDataMountPath,
},
corev1.VolumeMountArgs{
Name: pulumi.String("execution-jwt"),
Name: pulumi.String(secretName),
MountPath: internalArgs.ExecutionJwtMountPath,
},
},
Expand All @@ -230,7 +231,7 @@ func NewSignetNode(ctx *pulumi.Context, args SignetNodeComponentArgs, opts ...pu
},
},
corev1.VolumeArgs{
Name: pulumi.String("execution-jwt"),
Name: pulumi.String(secretName),
Secret: &corev1.SecretVolumeSourceArgs{
SecretName: secret.Metadata.Name(),
},
Expand Down Expand Up @@ -270,13 +271,14 @@ func NewSignetNode(ctx *pulumi.Context, args SignetNodeComponentArgs, opts ...pu
Example: "example",
}

consensusConfigMapName := "consensus-configmap-env-config"
consensusConfigMapName := fmt.Sprintf("%s-consensus-configmap-env-config", args.Name)
consensusConfigMap, err := utils.CreateConfigMap(
ctx,
consensusConfigMapName,
internalArgs.Namespace,
utils.CreateResourceLabels(args.Name, consensusConfigMapName, args.Name, nil),
consensusEnv.toInternal(),
component,
)
if err != nil {
return nil, fmt.Errorf("failed to create consensus configmap: %w", err)
Expand Down
24 changes: 14 additions & 10 deletions pkg/utils/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,33 @@ type EnvProvider interface {

// CreateConfigMap creates a Kubernetes ConfigMap from an environment variables struct
// It automatically converts field names to environment variable format (UPPER_SNAKE_CASE)
// The optional parent parameter can be provided to set the parent resource for the ConfigMap
func CreateConfigMap[T EnvProvider](
ctx *pulumi.Context,
name string,
namespace pulumi.StringInput,
labels pulumi.StringMap,
env T,
parent ...pulumi.Resource,
Copy link

Copilot AI Aug 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variadic parameter parent ...pulumi.Resource allows multiple parents to be passed, but the implementation only uses the first one. Consider using a single optional parameter parent pulumi.Resource or *pulumi.Resource to make the API intention clearer and prevent confusion.

Suggested change
parent ...pulumi.Resource,
parent pulumi.Resource,

Copilot uses AI. Check for mistakes.
) (*corev1.ConfigMap, error) {
// Create metadata for ConfigMap
metadata := &metav1.ObjectMetaArgs{
Name: pulumi.String(name),
Namespace: namespace,
Labels: labels,
}

// Get environment variables as a map using the EnvProvider interface
data := env.GetEnvMap()

// Prepare options with parent if provided
var opts []pulumi.ResourceOption
if len(parent) > 0 && parent[0] != nil {
opts = append(opts, pulumi.Parent(parent[0]))
}

// Create and return ConfigMap
return corev1.NewConfigMap(ctx, name, &corev1.ConfigMapArgs{
Metadata: metadata,
Data: data,
})
Metadata: &metav1.ObjectMetaArgs{
Namespace: namespace,
Labels: labels,
},
Comment on lines +43 to +46
Copy link

Copilot AI Aug 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Name field was removed from the metadata, but there's no comment explaining why this change was necessary. Consider adding a comment explaining that Pulumi automatically sets the name based on the resource name parameter to avoid confusion for future maintainers.

Copilot uses AI. Check for mistakes.
Data: data,
}, opts...)
}

// CreateEnvMap converts a struct to a map of environment variables
Expand Down Expand Up @@ -212,7 +217,6 @@ func CreatePersistentVolumeClaim(

return corev1.NewPersistentVolumeClaim(ctx, name, &corev1.PersistentVolumeClaimArgs{
Metadata: &metav1.ObjectMetaArgs{
Name: pulumi.String(name),
Labels: labels,
Namespace: namespace,
},
Expand Down
Loading