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

Method ListCredentials

runner/github_credentials.go:27–51  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

25)
26
27func (r *Runner) ListCredentials(ctx context.Context) ([]params.ForgeCredentials, error) {
28 if !auth.IsAdmin(ctx) {
29 return nil, runnerErrors.ErrUnauthorized
30 }
31
32 // Get the credentials from the store. The cache is always updated after the database successfully
33 // commits the transaction that created/updated the credentials.
34 // If we create a set of credentials then immediately after we call ListCredentials,
35 // there is a posibillity that not all creds will be in the cache.
36 creds, err := r.store.ListGithubCredentials(ctx)
37 if err != nil {
38 return nil, fmt.Errorf("error fetching github credentials: %w", err)
39 }
40
41 // If we do have cache, update the rate limit for each credential. The rate limits are queried
42 // every 30 seconds and set in cache.
43 credsCache := cache.GetAllGithubCredentialsAsMap()
44 for idx, cred := range creds {
45 inCache, ok := credsCache[cred.ID]
46 if ok {
47 creds[idx].RateLimit = inCache.RateLimit
48 }
49 }
50 return creds, nil
51}
52
53func (r *Runner) CreateGithubCredentials(ctx context.Context, param params.CreateGithubCredentialsParams) (params.ForgeCredentials, error) {
54 if !auth.IsAdmin(ctx) {

Callers

nothing calls this directly

Calls 3

IsAdminFunction · 0.92
ListGithubCredentialsMethod · 0.65

Tested by

no test coverage detected