MCPcopy Create free account
hub / github.com/docker/secrets-engine / DefaultKeyRewriter

Function DefaultKeyRewriter

plugins/credentialhelper/store.go:68–78  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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
68func 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
80func (s *credentialHelperStore) GetSecrets(_ context.Context, pattern plugin.Pattern) ([]plugin.Envelope, error) {
81 credentials, err := client.List(s.ProgramFunc)

Callers 2

GetSecretsMethod · 0.85
TestDefaultKeyRewriterFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestDefaultKeyRewriterFunction · 0.68