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

Method Validate

config/config.go:356–394  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

354}
355
356func (g *Github) Validate() error {
357 if g.Name == "" {
358 return fmt.Errorf("missing credentials name")
359 }
360
361 if g.APIBaseURL != "" {
362 if _, err := url.ParseRequestURI(g.APIBaseURL); err != nil {
363 return fmt.Errorf("invalid api_base_url: %w", err)
364 }
365 }
366
367 if g.UploadBaseURL != "" {
368 if _, err := url.ParseRequestURI(g.UploadBaseURL); err != nil {
369 return fmt.Errorf("invalid upload_base_url: %w", err)
370 }
371 }
372
373 if g.BaseURL != "" {
374 if _, err := url.ParseRequestURI(g.BaseURL); err != nil {
375 return fmt.Errorf("invalid base_url: %w", err)
376 }
377 }
378
379 switch g.AuthType {
380 case GithubAuthTypeApp:
381 if err := g.App.Validate(); err != nil {
382 return fmt.Errorf("invalid github app config: %w", err)
383 }
384 default:
385 if g.OAuth2Token == "" && g.PAT.OAuth2Token == "" {
386 return fmt.Errorf("missing github oauth2 token")
387 }
388 if g.OAuth2Token != "" {
389 slog.Warn("the github.oauth2_token option is deprecated, please use the PAT section")
390 }
391 }
392
393 return nil
394}
395
396func (g *Github) HTTPClient(ctx context.Context) (*http.Client, error) {
397 if err := g.Validate(); err != nil {

Callers 1

HTTPClientMethod · 0.95

Calls 1

ValidateMethod · 0.45

Tested by

no test coverage detected