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

Function withGiteaURLs

util/github/client.go:633–659  ·  view source on GitHub ↗
(client *github.Client, apiBaseURL string)

Source from the content-addressed store, hash-verified

631}
632
633func withGiteaURLs(client *github.Client, apiBaseURL string) (*github.Client, error) {
634 if client == nil {
635 return nil, errors.New("client is nil")
636 }
637
638 if apiBaseURL == "" {
639 return nil, errors.New("invalid gitea URLs")
640 }
641
642 parsedBaseURL, err := url.ParseRequestURI(apiBaseURL)
643 if err != nil {
644 return nil, fmt.Errorf("error parsing gitea base URL: %w", err)
645 }
646
647 if !strings.HasSuffix(parsedBaseURL.Path, "/") {
648 parsedBaseURL.Path += "/"
649 }
650
651 if !strings.HasSuffix(parsedBaseURL.Path, "/api/v1/") {
652 parsedBaseURL.Path += "api/v1/"
653 }
654
655 client.BaseURL = parsedBaseURL
656 client.UploadURL = parsedBaseURL
657
658 return client, nil
659}
660
661func Client(ctx context.Context, entity params.ForgeEntity) (common.GithubClient, error) {
662 httpClient, err := entity.Credentials.GetHTTPClient(ctx)

Callers 1

ClientFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected