MCPcopy
hub / github.com/grpc/grpc-go / validateOptions

Function validateOptions

credentials/sts/sts.go:211–230  ·  view source on GitHub ↗

validateOptions performs the following validation checks on opts: - tokenExchangeServiceURI is not empty - tokenExchangeServiceURI is a valid URI with a http(s) scheme - subjectTokenPath and subjectTokenType are not empty.

(opts Options)

Source from the content-addressed store, hash-verified

209// - tokenExchangeServiceURI is a valid URI with a http(s) scheme
210// - subjectTokenPath and subjectTokenType are not empty.
211func validateOptions(opts Options) error {
212 if opts.TokenExchangeServiceURI == "" {
213 return errors.New("empty token_exchange_service_uri in options")
214 }
215 u, err := url.Parse(opts.TokenExchangeServiceURI)
216 if err != nil {
217 return err
218 }
219 if u.Scheme != "http" && u.Scheme != "https" {
220 return fmt.Errorf("scheme is not supported: %q. Only http(s) is supported", u.Scheme)
221 }
222
223 if opts.SubjectTokenPath == "" {
224 return errors.New("required field SubjectTokenPath is not specified")
225 }
226 if opts.SubjectTokenType == "" {
227 return errors.New("required field SubjectTokenType is not specified")
228 }
229 return nil
230}
231
232// cachedMetadata returns the cached metadata provided it is not going to
233// expire anytime soon.

Callers 2

NewCredentialsFunction · 0.85
TestValidateOptionsMethod · 0.85

Calls 2

ParseMethod · 0.65
ErrorfMethod · 0.65

Tested by 1

TestValidateOptionsMethod · 0.68