MCPcopy Index your code
hub / github.com/coder/coder / New

Function New

coderd/externalauth/gitprovider/gitprovider.go:184–203  ·  view source on GitHub ↗

New creates a Provider for the given provider type and API base URL. Returns (nil, nil) for unsupported provider types and a non-nil error if construction fails.

(providerType string, apiBaseURL string, httpClient *http.Client, opts ...Option)

Source from the content-addressed store, hash-verified

182// URL. Returns (nil, nil) for unsupported provider types and a
183// non-nil error if construction fails.
184func New(providerType string, apiBaseURL string, httpClient *http.Client, opts ...Option) (Provider, error) {
185 o := providerOptions{}
186 for _, opt := range opts {
187 opt(&o)
188 }
189 if o.clock == nil {
190 o.clock = quartz.NewReal()
191 }
192
193 switch providerType {
194 case "github":
195 return newGitHub(apiBaseURL, httpClient, o.clock), nil
196 case "gitlab":
197 return newGitLab(apiBaseURL, httpClient, o.clock)
198 default:
199 // Other providers (bitbucket-cloud, etc.) will be
200 // added here as they are implemented.
201 return nil, nil //nolint:nilnil // nil provider means unsupported type, not an error
202 }
203}
204
205// parseRetryAfter extracts a retry duration from rate-limit response
206// headers. It checks Retry-After (seconds) first, then the named

Calls 2

newGitHubFunction · 0.85
newGitLabFunction · 0.85