Skip to content

Commit 15f7eec

Browse files
Refactor OpBatcher code: constants, formatting, and unused params
Co-authored-by: kbambridge1 <kbambridge1@gmail.com>
1 parent 0431be5 commit 15f7eec

2 files changed

Lines changed: 22 additions & 6 deletions

File tree

internal/controller/opbatcher_controller.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ import (
4242
// OpBatcherFinalizer is the finalizer for OpBatcher resources
4343
const OpBatcherFinalizer = "opbatcher.optimism.io/finalizer"
4444

45+
// Node type constants
46+
const (
47+
NodeTypeSequencer = "sequencer"
48+
)
49+
4550
// Phase constants for OpBatcher status
4651
const (
4752
OpBatcherPhasePending = "Pending"
@@ -141,7 +146,7 @@ func (r *OpBatcherReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
141146
goto updateStatus
142147
}
143148
// Check if sequencer is running and is actually a sequencer
144-
if sequencer.Spec.NodeType != "sequencer" {
149+
if sequencer.Spec.NodeType != NodeTypeSequencer {
145150
utils.SetCondition(&opBatcher.Status.Conditions, "SequencerReference", metav1.ConditionFalse, "InvalidSequencer", "Referenced OpNode is not a sequencer")
146151
opBatcher.Status.Phase = OpBatcherPhaseError
147152
goto updateStatus
@@ -340,7 +345,7 @@ func (r *OpBatcherReconciler) validatePrivateKeySecret(ctx context.Context, opBa
340345
}
341346

342347
// testL1Connectivity tests connectivity to L1 RPC endpoint
343-
func (r *OpBatcherReconciler) testL1Connectivity(ctx context.Context, network *optimismv1alpha1.OptimismNetwork) error {
348+
func (r *OpBatcherReconciler) testL1Connectivity(_ context.Context, network *optimismv1alpha1.OptimismNetwork) error {
344349
// For now, we'll do a basic validation that the URL is set and looks valid
345350
// In a full implementation, this would make an actual RPC call
346351
if network.Spec.L1RpcUrl == "" {
@@ -355,7 +360,7 @@ func (r *OpBatcherReconciler) testL1Connectivity(ctx context.Context, network *o
355360
}
356361

357362
// testL2Connectivity tests connectivity to L2 sequencer
358-
func (r *OpBatcherReconciler) testL2Connectivity(ctx context.Context, opBatcher *optimismv1alpha1.OpBatcher, sequencerServiceName string) error {
363+
func (r *OpBatcherReconciler) testL2Connectivity(_ context.Context, _ *optimismv1alpha1.OpBatcher, sequencerServiceName string) error {
359364
// For now, we'll do a basic validation that the service name is set
360365
// In a full implementation, this would make an actual RPC call to the sequencer
361366
if sequencerServiceName == "" {

pkg/resources/deployment.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ import (
1515
)
1616

1717
// CreateOpBatcherDeployment creates a Deployment for an OpBatcher instance
18-
func CreateOpBatcherDeployment(opBatcher *optimismv1alpha1.OpBatcher, network *optimismv1alpha1.OptimismNetwork, sequencerServiceName string) *appsv1.Deployment {
18+
func CreateOpBatcherDeployment(
19+
opBatcher *optimismv1alpha1.OpBatcher,
20+
network *optimismv1alpha1.OptimismNetwork,
21+
sequencerServiceName string,
22+
) *appsv1.Deployment {
1923
labels := map[string]string{
2024
"app.kubernetes.io/name": "opbatcher",
2125
"app.kubernetes.io/instance": opBatcher.Name,
@@ -148,7 +152,11 @@ func CreateOpBatcherDeployment(opBatcher *optimismv1alpha1.OpBatcher, network *o
148152
}
149153

150154
// buildOpBatcherArgs builds command line arguments for op-batcher
151-
func buildOpBatcherArgs(opBatcher *optimismv1alpha1.OpBatcher, network *optimismv1alpha1.OptimismNetwork, sequencerServiceName string) []string {
155+
func buildOpBatcherArgs(
156+
opBatcher *optimismv1alpha1.OpBatcher,
157+
network *optimismv1alpha1.OptimismNetwork,
158+
sequencerServiceName string,
159+
) []string {
152160
args := []string{}
153161

154162
// L1 RPC configuration from OptimismNetwork
@@ -255,7 +263,10 @@ func buildOpBatcherArgs(opBatcher *optimismv1alpha1.OpBatcher, network *optimism
255263
}
256264

257265
// buildOpBatcherEnvVars builds environment variables for op-batcher
258-
func buildOpBatcherEnvVars(opBatcher *optimismv1alpha1.OpBatcher, network *optimismv1alpha1.OptimismNetwork) []corev1.EnvVar {
266+
func buildOpBatcherEnvVars(
267+
_ *optimismv1alpha1.OpBatcher,
268+
_ *optimismv1alpha1.OptimismNetwork,
269+
) []corev1.EnvVar {
259270
envVars := []corev1.EnvVar{
260271
{
261272
Name: "POD_NAME",

0 commit comments

Comments
 (0)