lookasideStorageBaseURL returns an appropriate signature storage URL for ref, for write access if “write”. the usage of the BaseURL is defined under docker/distribution registries—separate storage of docs/signature-protocols.md
(dr dockerReference, write bool)
| 169 | // lookasideStorageBaseURL returns an appropriate signature storage URL for ref, for write access if “write”. |
| 170 | // the usage of the BaseURL is defined under docker/distribution registries—separate storage of docs/signature-protocols.md |
| 171 | func (config *registryConfiguration) lookasideStorageBaseURL(dr dockerReference, write bool) (*url.URL, error) { |
| 172 | topLevel := config.signatureTopLevel(dr, write) |
| 173 | var baseURL *url.URL |
| 174 | if topLevel != "" { |
| 175 | u, err := url.Parse(topLevel) |
| 176 | if err != nil { |
| 177 | return nil, fmt.Errorf("Invalid signature storage URL %s: %w", topLevel, err) |
| 178 | } |
| 179 | baseURL = u |
| 180 | } else { |
| 181 | // returns default directory if no lookaside specified in configuration file |
| 182 | baseURL = builtinDefaultLookasideStorageDir(rootless.GetRootlessEUID()) |
| 183 | logrus.Debugf(" No signature storage configuration found for %s, using built-in default %s", dr.PolicyConfigurationIdentity(), baseURL.Redacted()) |
| 184 | } |
| 185 | // NOTE: Keep this in sync with docs/signature-protocols.md! |
| 186 | // FIXME? Restrict to explicitly supported schemes? |
| 187 | repo := reference.Path(dr.ref) // Note that this is without a tag or digest. |
| 188 | if path.Clean(repo) != repo { // Coverage: This should not be reachable because /./ and /../ components are not valid in docker references |
| 189 | return nil, fmt.Errorf("Unexpected path elements in Docker reference %s for signature storage", dr.ref.String()) |
| 190 | } |
| 191 | baseURL.Path = baseURL.Path + "/" + repo |
| 192 | return baseURL, nil |
| 193 | } |
| 194 | |
| 195 | // builtinDefaultLookasideStorageDir returns default signature storage URL as per euid |
| 196 | func builtinDefaultLookasideStorageDir(euid int) *url.URL { |
no test coverage detected