From 74ed8e6838f96ccc2d8b5c59726665b036c80d83 Mon Sep 17 00:00:00 2001 From: Nikola Jokic Date: Wed, 4 Jun 2025 20:07:43 +0200 Subject: [PATCH] wip: resolve conflicts --- cmd/ghalistener/config/config.go | 11 ++--------- .../autoscalingrunnerset_controller.go | 2 +- github/actions/multi_client.go | 5 +++-- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/cmd/ghalistener/config/config.go b/cmd/ghalistener/config/config.go index 846f39f0..51c91de2 100644 --- a/cmd/ghalistener/config/config.go +++ b/cmd/ghalistener/config/config.go @@ -109,15 +109,8 @@ func (c *Config) Validate() error { return fmt.Errorf(`MinRunners "%d" cannot be greater than MaxRunners "%d"`, c.MinRunners, c.MaxRunners) } - hasToken := len(c.Token) > 0 - hasPrivateKeyConfig := len(c.AppID) > 0 && c.AppPrivateKey != "" - - if !hasToken && !hasPrivateKeyConfig { - return fmt.Errorf(`GitHub auth credential is missing, token length: "%d", appId: %q, installationId: "%d", private key length: "%d"`, len(c.Token), c.AppID, c.AppInstallationID, len(c.AppPrivateKey)) - } - - if hasToken && hasPrivateKeyConfig { - return fmt.Errorf(`only one GitHub auth method supported at a time. Have both PAT and App auth: token length: "%d", appId: %q, installationId: "%d", private key length: "%d"`, len(c.Token), c.AppID, c.AppInstallationID, len(c.AppPrivateKey)) + if err := c.AppConfig.Validate(); err != nil { + return fmt.Errorf("AppConfig validation failed: %w", err) } return nil diff --git a/controllers/actions.github.com/autoscalingrunnerset_controller.go b/controllers/actions.github.com/autoscalingrunnerset_controller.go index 5f1462e3..c2e7b2c8 100644 --- a/controllers/actions.github.com/autoscalingrunnerset_controller.go +++ b/controllers/actions.github.com/autoscalingrunnerset_controller.go @@ -399,7 +399,7 @@ func (r *AutoscalingRunnerSetReconciler) createRunnerScaleSet(ctx context.Contex autoscalingRunnerSet.Spec.RunnerScaleSetName = autoscalingRunnerSet.Name } if err != nil { - logger.Error(err, "Failed to initialize Actions service client for creating a new runner scale set") + logger.Error(err, "Failed to initialize Actions service client for creating a new runner scale set", "error", err.Error()) return ctrl.Result{}, err } diff --git a/github/actions/multi_client.go b/github/actions/multi_client.go index cc81e045..b9ed5873 100644 --- a/github/actions/multi_client.go +++ b/github/actions/multi_client.go @@ -2,6 +2,7 @@ package actions import ( "context" + "fmt" "sync" "github.com/actions/actions-runner-controller/apis/actions.github.com/v1alpha1/appconfig" @@ -52,7 +53,7 @@ func (m *multiClient) GetClientFor(ctx context.Context, githubConfigURL string, m.logger.Info("retrieve actions client", "githubConfigURL", githubConfigURL, "namespace", namespace) if err := appConfig.Validate(); err != nil { - return nil, err + return nil, fmt.Errorf("failed to validate app config: %w", err) } var creds ActionsAuth @@ -74,7 +75,7 @@ func (m *multiClient) GetClientFor(ctx context.Context, githubConfigURL string, }, options...)..., ) if err != nil { - return nil, err + return nil, fmt.Errorf("failed to instantiate new client: %w", err) } m.mu.Lock()