Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
samirtahir91 committed Apr 1, 2024
1 parent 34c9430 commit 4a6b25a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions internal/controller/githubapp_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func (r *GithubAppReconciler) checkExpiryAndUpdateAccessToken(ctx context.Contex

// If expiresAt status field is not present or expiry time has already passed, generate or renew access token
if expiresAt.IsZero() || expiresAt.Before(time.Now()) {
return r.generateOrUpdateAccessToken(ctx, githubApp, req)
return r.generateOrUpdateAccessToken(ctx, githubApp)
}

// Check if the access token secret exists if not reconcile immediately
Expand All @@ -198,7 +198,7 @@ func (r *GithubAppReconciler) checkExpiryAndUpdateAccessToken(ctx context.Contex
if err := r.Get(ctx, accessTokenSecretKey, accessTokenSecret); err != nil {
if apierrors.IsNotFound(err) {
// Secret doesn't exist, reconcile straight away
return r.generateOrUpdateAccessToken(ctx, githubApp, req)
return r.generateOrUpdateAccessToken(ctx, githubApp)
}
// Error other than NotFound, return error
return err
Expand All @@ -207,7 +207,7 @@ func (r *GithubAppReconciler) checkExpiryAndUpdateAccessToken(ctx context.Contex
for key := range accessTokenSecret.Data {
if key != "token" && key != "username" {
l.Info("Removing invalid key in access token secret", "Key", key)
return r.generateOrUpdateAccessToken(ctx, githubApp, req)
return r.generateOrUpdateAccessToken(ctx, githubApp)
}
}

Expand All @@ -216,9 +216,9 @@ func (r *GithubAppReconciler) checkExpiryAndUpdateAccessToken(ctx context.Contex
username := string(accessTokenSecret.Data["username"])

// Check if the access token is a valid github token via gh api auth
if !isAccessTokenValid(ctx, username, accessToken, req) {
if !isAccessTokenValid(ctx, username, accessToken) {
// If accessToken is invalid, generate or update access token
return r.generateOrUpdateAccessToken(ctx, githubApp, req)
return r.generateOrUpdateAccessToken(ctx, githubApp)
}

// Access token exists, calculate the duration until expiry
Expand All @@ -229,7 +229,7 @@ func (r *GithubAppReconciler) checkExpiryAndUpdateAccessToken(ctx context.Contex
l.Info(
"Expiry threshold reached - renewing",
)
err := r.generateOrUpdateAccessToken(ctx, githubApp, req)
err := r.generateOrUpdateAccessToken(ctx, githubApp)
return err
}

Expand Down Expand Up @@ -323,7 +323,7 @@ func (r *GithubAppReconciler) checkExpiryAndRequeue(ctx context.Context, githubA
}

// Function to generate or update access token
func (r *GithubAppReconciler) generateOrUpdateAccessToken(ctx context.Context, githubApp *githubappv1.GithubApp, req ctrl.Request) error {
func (r *GithubAppReconciler) generateOrUpdateAccessToken(ctx context.Context, githubApp *githubappv1.GithubApp) error {
l := log.FromContext(ctx)

// Get the private key from the Secret
Expand Down

0 comments on commit 4a6b25a

Please sign in to comment.