...

Source file src/edge-infra.dev/pkg/f8n/devinfra/github-actions-exporter/metrics/workflows_cache.go

Documentation: edge-infra.dev/pkg/f8n/devinfra/github-actions-exporter/metrics

     1  package metrics
     2  
     3  import (
     4  	"context"
     5  	"log"
     6  
     7  	"github.com/google/go-github/v47/github"
     8  )
     9  
    10  var (
    11  	workflows map[string]map[int64]github.Workflow
    12  )
    13  
    14  // workflowCache - used for limit calls to github api
    15  func workflowCache() {
    16  	for {
    17  		opts := github.ListOptions{}
    18  		ww := make(map[string]map[int64]github.Workflow)
    19  		resp, _, err := client.Actions.ListWorkflows(context.Background(), org, repo, &opts)
    20  		if err != nil {
    21  			log.Printf("ListWorkflows error for %s: %s", repo, err.Error())
    22  		} else {
    23  			s := make(map[int64]github.Workflow)
    24  			for _, w := range resp.Workflows {
    25  				s[*w.ID] = *w
    26  			}
    27  			ww[repo] = s
    28  		}
    29  		workflows = ww
    30  	}
    31  }
    32  

View as plain text