(ctx context.Context)
| 83 | } |
| 84 | |
| 85 | func (s *ScaleSetClient) ensureAdminInfo(ctx context.Context) error { |
| 86 | s.mux.Lock() |
| 87 | defer s.mux.Unlock() |
| 88 | |
| 89 | var expiresAt time.Time |
| 90 | if s.runnerRegistrationToken != nil { |
| 91 | expiresAt = s.runnerRegistrationToken.GetExpiresAt().Time |
| 92 | } |
| 93 | |
| 94 | now := time.Now().UTC().Add(2 * time.Minute) |
| 95 | if now.After(expiresAt) || s.runnerRegistrationToken == nil { |
| 96 | token, _, err := s.ghCli.CreateEntityRegistrationToken(ctx) |
| 97 | if err != nil { |
| 98 | return fmt.Errorf("failed to fetch runner registration token: %w", err) |
| 99 | } |
| 100 | s.runnerRegistrationToken = token |
| 101 | } |
| 102 | |
| 103 | if s.actionsServiceInfo == nil || s.actionsServiceInfo.ExpiresIn(2*time.Minute) { |
| 104 | info, err := s.getActionServiceInfo(ctx) |
| 105 | if err != nil { |
| 106 | return fmt.Errorf("failed to get action service info: %w", err) |
| 107 | } |
| 108 | s.actionsServiceInfo = &info |
| 109 | } |
| 110 | |
| 111 | return nil |
| 112 | } |
no test coverage detected