Skip to content

Commit d960e81

Browse files
committed
fix: lint
1 parent b5bb2c8 commit d960e81

3 files changed

Lines changed: 23 additions & 13 deletions

File tree

internal/controller/authkey_controller.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ const (
5858
defaultAuthKeyRequeue = 6 * time.Hour
5959
dependentNotReadyRequeue = 30 * time.Second
6060
rotationRetryRequeue = 30 * time.Second
61+
62+
phaseReady = "Ready"
63+
phasePending = "Pending"
64+
phaseError = "Error"
6165
)
6266

6367
// AuthKeyReconciler reconciles a AuthKey object
@@ -70,6 +74,7 @@ type AuthKeyReconciler struct {
7074
// +kubebuilder:rbac:groups=kodiak.mnicloud.jp,resources=authkeys/status,verbs=get;update;patch
7175
// +kubebuilder:rbac:groups=kodiak.mnicloud.jp,resources=authkeys/finalizers,verbs=update
7276

77+
// nolint:gocyclo // the reconciliation flow is complex and already factored into helpers where practical
7378
func (r *AuthKeyReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
7479
logger := log.FromContext(ctx).WithValues("authkey", req.NamespacedName)
7580

@@ -372,7 +377,7 @@ func (r *AuthKeyReconciler) setReadyStatus(ctx context.Context, resource *kodiak
372377
Message: message,
373378
})
374379
resource.Status.Ready = true
375-
resource.Status.Phase = "Ready"
380+
resource.Status.Phase = phaseReady
376381
resource.Status.KeyID = remote.GetId()
377382
resource.Status.SecretRef = &corev1.LocalObjectReference{Name: secretName}
378383
resource.Status.CreatedAt = convertTimestamp(remote.GetCreatedAt())
@@ -397,7 +402,7 @@ func (r *AuthKeyReconciler) setPendingStatus(ctx context.Context, resource *kodi
397402
Message: message,
398403
})
399404
resource.Status.Ready = false
400-
resource.Status.Phase = "Pending"
405+
resource.Status.Phase = phasePending
401406

402407
if equality.Semantic.DeepEqual(current.Status, resource.Status) {
403408
return nil
@@ -423,7 +428,7 @@ func (r *AuthKeyReconciler) setErrorStatus(ctx context.Context, resource *kodiak
423428
Message: message,
424429
})
425430
resource.Status.Ready = false
426-
resource.Status.Phase = "Error"
431+
resource.Status.Phase = phaseError
427432

428433
if equality.Semantic.DeepEqual(current.Status, resource.Status) {
429434
return nil
@@ -468,7 +473,7 @@ func (r *AuthKeyReconciler) resetAuthKeyStatus(ctx context.Context, resource *ko
468473
Message: message,
469474
})
470475
resource.Status.Ready = false
471-
resource.Status.Phase = "Pending"
476+
resource.Status.Phase = phasePending
472477
resource.Status.KeyID = 0
473478
resource.Status.SecretRef = nil
474479
resource.Status.CreatedAt = nil

internal/controller/connector_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ const (
6565
reasonTailscaleDisconnected = "TailscaleDisconnected"
6666
reasonAuthKeyNotFound = "AuthKeyNotFound"
6767
reasonAuthKeyNotReady = "AuthKeyNotReady"
68-
reasonAuthKeySecretError = "AuthKeySecretUnavailable"
69-
reasonAuthKeyNotConfigured = "AuthKeyNotConfigured"
68+
reasonAuthKeySecretError = "AuthKeySecretUnavailable"
69+
reasonAuthKeyNotConfigured = "AuthKeyNotConfigured"
7070
)
7171

7272
var (

internal/controller/controlserver_controller.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ import (
4444
kodiakv1alpha1 "github.com/mNi-Cloud/kodiak/api/v1alpha1"
4545
)
4646

47+
const (
48+
schemeHTTP = "http"
49+
schemeHTTPS = "https"
50+
)
51+
4752
// ControlServerReconciler reconciles a ControlServer object
4853
type ControlServerReconciler struct {
4954
client.Client
@@ -125,7 +130,7 @@ func (r *ControlServerReconciler) Reconcile(ctx context.Context, req ctrl.Reques
125130
return ctrl.Result{RequeueAfter: 10 * time.Second}, nil
126131
}
127132

128-
if err := r.reconcileDeployment(ctx, &resource, portCfg, configHash, adminSecret, oidcSecret); err != nil {
133+
if err := r.reconcileDeployment(ctx, &resource, portCfg, configHash, adminSecret); err != nil {
129134
logger.Error(err, "failed to reconcile deployment")
130135
r.updateStatusWithError(ctx, &resource, "DeploymentError", err)
131136
return ctrl.Result{RequeueAfter: 10 * time.Second}, nil
@@ -320,7 +325,7 @@ func (r *ControlServerReconciler) reconcileService(ctx context.Context, resource
320325
return err
321326
}
322327

323-
func (r *ControlServerReconciler) reconcileDeployment(ctx context.Context, resource *kodiakv1alpha1.ControlServer, ports portConfiguration, configHash string, adminSecret *corev1.Secret, oidcSecret *corev1.Secret) error {
328+
func (r *ControlServerReconciler) reconcileDeployment(ctx context.Context, resource *kodiakv1alpha1.ControlServer, ports portConfiguration, configHash string, adminSecret *corev1.Secret) error {
324329
deploy := &appsv1.Deployment{
325330
ObjectMeta: metav1.ObjectMeta{
326331
Name: deploymentName(resource),
@@ -731,9 +736,9 @@ func renderControlServerConfig(resource *kodiakv1alpha1.ControlServer, includeAd
731736
}
732737

733738
func controlServerEndpoint(resource *kodiakv1alpha1.ControlServer, ports portConfiguration) string {
734-
scheme := "https"
739+
scheme := schemeHTTPS
735740
if resource.Spec.Config.TLS != nil && resource.Spec.Config.TLS.Disable {
736-
scheme = "http"
741+
scheme = schemeHTTP
737742
}
738743

739744
if resource.Spec.Config.PublicAddr != "" {
@@ -922,16 +927,16 @@ func sanitizePublicAddr(candidate string, tlsConfig *kodiakv1alpha1.TLSConfig, n
922927
return fmt.Sprintf("%s:%d", host, listenPort)
923928
}
924929

925-
scheme := "https"
930+
scheme := schemeHTTPS
926931
if tlsConfig != nil && tlsConfig.Disable {
927-
scheme = "http"
932+
scheme = schemeHTTP
928933
}
929934

930935
addr := trimScheme(candidate)
931936

932937
if _, _, err := net.SplitHostPort(addr); err != nil {
933938
defaultPort := 443
934-
if scheme == "http" {
939+
if scheme == schemeHTTP {
935940
defaultPort = 80
936941
}
937942
addr = fmt.Sprintf("%s:%d", addr, defaultPort)

0 commit comments

Comments
 (0)