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)
| 209 | // - tokenExchangeServiceURI is a valid URI with a http(s) scheme |
| 210 | // - subjectTokenPath and subjectTokenType are not empty. |
| 211 | func 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. |