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

Function Client

util/github/client.go:661–703  ·  view source on GitHub ↗
(ctx context.Context, entity params.ForgeEntity)

Source from the content-addressed store, hash-verified

659}
660
661func Client(ctx context.Context, entity params.ForgeEntity) (common.GithubClient, error) {
662 httpClient, err := entity.Credentials.GetHTTPClient(ctx)
663 if err != nil {
664 return nil, fmt.Errorf("error fetching http client: %w", err)
665 }
666
667 slog.DebugContext(
668 ctx, "creating client for entity",
669 "entity", entity.String(), "base_url", entity.Credentials.APIBaseURL,
670 "upload_url", entity.Credentials.UploadBaseURL)
671
672 ghClient := github.NewClient(httpClient)
673 switch entity.Credentials.ForgeType {
674 case params.GithubEndpointType:
675 ghClient, err = ghClient.WithEnterpriseURLs(entity.Credentials.APIBaseURL, entity.Credentials.UploadBaseURL)
676 case params.GiteaEndpointType:
677 ghClient, err = withGiteaURLs(ghClient, entity.Credentials.APIBaseURL)
678 }
679
680 if err != nil {
681 return nil, fmt.Errorf("error fetching github client: %w", err)
682 }
683
684 cli := &githubClient{
685 ActionsService: ghClient.Actions,
686 org: ghClient.Organizations,
687 repo: ghClient.Repositories,
688 enterprise: ghClient.Enterprise,
689 rateLimit: ghClient.RateLimit,
690 cli: ghClient,
691 entity: entity,
692 }
693
694 limits, err := cli.RateLimit(ctx)
695 if err == nil && limits != nil {
696 core := limits.GetCore()
697 if core != nil {
698 cli.recordLimits(*core)
699 }
700 }
701
702 return cli, nil
703}

Callers 8

DeleteScaleSetByIDMethod · 0.92
UpdateScaleSetByIDMethod · 0.92
CreateEntityScaleSetMethod · 0.92
getGHCliFromInstanceMethod · 0.92
updateToolsMethod · 0.92
StartMethod · 0.92

Calls 5

RateLimitMethod · 0.95
recordLimitsMethod · 0.95
withGiteaURLsFunction · 0.85
GetHTTPClientMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected