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

Function validateProviders

aibridge/bridge.go:89–102  ·  view source on GitHub ↗

validateProviders checks that provider names are valid and unique.

(providers []provider.Provider)

Source from the content-addressed store, hash-verified

87
88// validateProviders checks that provider names are valid and unique.
89func validateProviders(providers []provider.Provider) error {
90 names := make(map[string]bool, len(providers))
91 for _, prov := range providers {
92 name := prov.Name()
93 if !validProviderName.MatchString(name) {
94 return xerrors.Errorf("invalid provider name %q: must contain only lowercase alphanumeric characters and hyphens", name)
95 }
96 if names[name] {
97 return xerrors.Errorf("duplicate provider name: %q", name)
98 }
99 names[name] = true
100 }
101 return nil
102}
103
104// NewRequestBridge creates a new *[RequestBridge] and registers the HTTP routes defined by the given providers.
105// Any routes which are requested but not registered will be reverse-proxied to the upstream service.

Callers 1

NewRequestBridgeFunction · 0.85

Calls 2

NameMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected