DefaultKeyRewriter can be used to remove the "https://", "http://" prefix and any trailing forward-slash "/". Additionally it will replace colons ":" in an IP address with "-port-". Example: https://mydomain.com/key -> mydomain.com/key http://182.31.42.33:8455/key -> 182.31.42.33-port-8455/key
(serverURL string)
| 66 | // http://182.31.42.33:8455/key -> 182.31.42.33-port-8455/key |
| 67 | // https://io.docker.com/access-token/ -> io.docker.com/access-token |
| 68 | func DefaultKeyRewriter(serverURL string) string { |
| 69 | replacer := strings.NewReplacer("https://", "", "http://", "") |
| 70 | o := strings.TrimSuffix(replacer.Replace(serverURL), "/") |
| 71 | parts := strings.Split(o, "/") |
| 72 | |
| 73 | _, _, err := net.SplitHostPort(parts[0]) |
| 74 | if err == nil { |
| 75 | return strings.ReplaceAll(o, ":", "-port-") |
| 76 | } |
| 77 | return o |
| 78 | } |
| 79 | |
| 80 | func (s *credentialHelperStore) GetSecrets(_ context.Context, pattern plugin.Pattern) ([]plugin.Envelope, error) { |
| 81 | credentials, err := client.List(s.ProgramFunc) |
no outgoing calls