(rawurl string)
| 27 | } |
| 28 | |
| 29 | func parseConsulURL(rawurl string) (config *api.Config, key string, err error) { |
| 30 | if rawurl == "" || !strings.HasPrefix(rawurl, "http://") && !strings.HasPrefix(rawurl, "https://") { |
| 31 | return nil, "", errors.New("invalid url") |
| 32 | } |
| 33 | |
| 34 | u, err := url.Parse(rawurl) |
| 35 | if err != nil { |
| 36 | return nil, "", err |
| 37 | } |
| 38 | |
| 39 | config = &api.Config{Address: u.Host, Scheme: u.Scheme} |
| 40 | if len(u.Query()["token"]) > 0 { |
| 41 | config.Token = u.Query()["token"][0] |
| 42 | } |
| 43 | |
| 44 | // path needs to point to kv store and we need |
| 45 | // to strip the prefix off to get the key |
| 46 | const prefix = "/v1/kv/" |
| 47 | key = u.Path |
| 48 | if !strings.HasPrefix(key, prefix) { |
| 49 | return nil, "", errors.New("missing prefix: " + prefix) |
| 50 | } |
| 51 | key = key[len(prefix):] |
| 52 | return |
| 53 | } |
| 54 | |
| 55 | func (s ConsulSource) LoadClientCAs() (*x509.CertPool, error) { |
| 56 | if s.ClientCAURL == "" { |
no outgoing calls