MCPcopy Create free account
hub / github.com/cloudbase/garm / ensureAdminInfo

Method ensureAdminInfo

util/github/scalesets/token.go:85–112  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

83}
84
85func (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}

Callers 2

newActionsRequestMethod · 0.95

Calls 6

getActionServiceInfoMethod · 0.95
AddMethod · 0.80
LockMethod · 0.65
UnlockMethod · 0.65
ExpiresInMethod · 0.45

Tested by

no test coverage detected