summaryrefslogtreecommitdiff
path: root/registry/service.go
Commit message (Collapse)AuthorAgeFilesLines
* registry: return concrete service typeCory Snider2023-03-101-28/+13
| | | | | | | | | Move interface definitions to the packages which use the registry service. https://github.com/golang/go/wiki/CodeReviewComments#interfaces Signed-off-by: Cory Snider <csnider@mirantis.com>
* Move filtered registry search out of image serviceCory Snider2023-03-101-63/+2
| | | | | | | | | | | | | | | | | | | | | | | SearchRegistryForImages does not make sense as part of the image service interface. The implementation just wraps the search API of the registry service to filter the results client-side. It has nothing to do with local image storage, and the implementation of search does not need to change when changing which backend (graph driver vs. containerd snapshotter) is used for local image storage. Filtering of the search results is an implementation detail: the consumer of the results does not care which actor does the filtering so long as the results are filtered as requested. Move filtering into the exported API of the registry service to hide the implementation details. Only one thing---the registry service implementation---would need to change in order to support server-side filtering of search results if Docker Hub or other registry servers were to add support for it to their APIs. Use a fake registry server in the search unit tests to avoid having to mock out the registry API client. Signed-off-by: Cory Snider <csnider@mirantis.com>
* registry: acquire mutex in IsInsecureRegistryCory Snider2023-02-281-0/+2
| | | | | | | The mutex needs to be held when accessing s.config to prevent data races. Signed-off-by: Cory Snider <csnider@mirantis.com>
* c8d/resolver: Fallback to http for insecure registriesPaweł Gronowski2023-01-111-0/+7
| | | | Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
* registry: use types/registry.AuthConfigSebastiaan van Stijn2022-07-291-5/+4
| | | | Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* Merge pull request #43394 from thaJeztah/cleanup_registry_step2Sebastiaan van Stijn2022-03-181-26/+9
|\ | | | | registry: remove more dead code
| * registry: remove unused fallbackErrorSebastiaan van Stijn2022-03-181-16/+9
| | | | | | | | | | | | Nothing was emitting this error. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| * registry: remove unused Service.TLSConfig()Sebastiaan van Stijn2022-03-181-10/+0
| | | | | | | | Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* | search: un-export registry.DefaultSearchLimit, and fix API status codesSebastiaan van Stijn2022-03-181-5/+0
|/ | | | | | | | | | | | | | | | | Move the default to the service itself, and produce the correct status code if an invalid limit was specified. The default is currently set both on the cli and on the daemon side, and it should be only set on one of them. There is a slight change in behavior; previously, searching with `--limit=0` would produce an error, but with this change, it's considered the equivalent of "no limit set" (and using the default). We could keep the old behavior by passing a pointer (`nil` means "not set"), but I left that for a follow-up exercise (we may want to pass an actual config instead of separate arguments, as well as some other things that need cleaning up). Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* registry: move allowNondistributableArtifacts, isSecureIndex to configSebastiaan van Stijn2022-03-171-1/+1
| | | | | | This felt slightly more natural to make it a function of the config type itself. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* registry: make defaultService.ServiceConfig() more idiomaticSebastiaan van Stijn2022-03-171-23/+2
| | | | | | | | | | | | | | | The intent of this function is to return a copy of the service's configuration, and to copy / dereference the options in its configuration. The code was doing this in slightly complicated fashion. This patch; - adds a `copy()` function to serviceConfig - rewrites the code to use a slightly more idiomatic approach, using one of the approaches described in "golang SliceTricks" https://github.com/golang/go/wiki/SliceTricks#copy - changes defaultService.ServiceConfig() to use this function, and updates its godoc to better describe that it returns a copy. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* registry: defaultService: use sync.RWMutexSebastiaan van Stijn2022-03-171-19/+15
| | | | | | | | Most operations only require read access, so change this to use an RWMutex, and some minor refactoring in lookupV2Endpoints() so that we are not constructing tlsconfig multiple times in some cases. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* registry: minor improvements and cleanupSebastiaan van Stijn2022-03-171-9/+6
| | | | | | | | | | | | - registry: newIndexInfo(): minor refactor - registry: loadAllowNondistributableArtifacts() minor refactor initialise the slices with a length. - registry: defaultService.Search(): minor refactor Perform all manipulation earlier, so that it's not needed to scroll up to learn what's done. - various other minor cleanups Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* registry: remove unneeded alias for api/types/registry importSebastiaan van Stijn2022-03-171-9/+9
| | | | Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* registry: return "errdefs" compatible error typesSebastiaan van Stijn2022-03-171-4/+3
| | | | | | Adding some small utility functions to make generating them easier. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* registry: remove ErrInvalidRepositoryNameSebastiaan van Stijn2022-03-171-2/+2
| | | | | | | | | | | | | This error was only returned in a single location, and not used anywhere as a specific type. The error returned by `validateNoScheme()` also appeared to only be used in one case; in all other cases, the error itself was ignored, and replaced with a custom error. Because of this, this patch also replace `validateNoScheme()` with a `hasScheme()` function that returns a boolean, to better match how it's used. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* registry: un-export config.LoadXXX() functionsSebastiaan van Stijn2022-03-171-3/+3
| | | | | | | | | | | | | Un-export: - config.LoadAllowNondistributableArtifacts() - config.LoadInsecureRegistries() - config.LoadMirrors() The config type is already un-exported; this also un-exports these functions to be explicit they're internal only. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* registry: un-export Session, remove NewSession()Sebastiaan van Stijn2022-03-171-1/+1
| | | | | | It's only used internally for search. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* registry: un-export V1Endpoint and NewV1Endpoint()Sebastiaan van Stijn2022-03-171-1/+1
| | | | | | They're deprecated, and only used internally for the v1 search. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* registry: un-export DefaultServiceSebastiaan van Stijn2022-03-171-16/+16
| | | | | | | | | | The DefaultService was not really meant to be used outside of the package, so un-export it, and change NewService()'s signature to return a Service interface. To un-export this type, a test in daemon/images was updated to not use DefaultService, but now using the registry.Service interface itself. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* registry: remove unused authConfig from SessionSebastiaan van Stijn2022-03-171-1/+1
| | | | Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* registry: remove unused ToV1Endpoint()Sebastiaan van Stijn2021-10-051-6/+0
| | | | Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* registry: remove tlsConfigForMirror()Sebastiaan van Stijn2021-10-051-5/+1
| | | | | | | This function was just a shallow wrapper around tlsConfig(), so remove the abstraction. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* registry.Auth: try next endpoints on non-auth failuresSebastiaan van Stijn2021-02-231-1/+9
| | | | | | Allow falling back to non-TLS endpoints if present. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* Remove more of registry v1 code.Tibor Vass2021-02-231-12/+3
| | | | | Signed-off-by: Tibor Vass <tibor@docker.com> Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* registry: minor cleanup in search codeSebastiaan van Stijn2020-10-281-17/+7
| | | | Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* registry: DefaultService.Auth(): skip parsing default registrySebastiaan van Stijn2020-10-281-11/+13
| | | | | | | There's no need to parse or validate the default registry, as it's a constant value. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* registry: remove v1 authenticationSebastiaan van Stijn2020-10-281-20/+12
| | | | Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* Remove the rest of v1 manifest supportJustin Cormack2019-03-021-16/+1
| | | | | | | | | As people are using the UUID in `docker info` that was based on the v1 manifest signing key, replace with a UUID instead. Remove deprecated `--disable-legacy-registry` option that was scheduled to be removed in 18.03. Signed-off-by: Justin Cormack <justin.cormack@docker.com>
* Switch from x/net/context -> contextKir Kolyshkin2018-04-231-2/+1
| | | | | | | | | | | Since Go 1.7, context is a standard package. Since Go 1.9, everything that is provided by "x/net/context" is a couple of type aliases to types in "context". Many vendored packages still use x/net/context, so vendor entry remains for now. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
* Add canonical import commentDaniel Nephin2018-02-051-1/+1
| | | | Signed-off-by: Daniel Nephin <dnephin@docker.com>
* Move api/errdefs to errdefsBrian Goff2018-01-111-1/+1
| | | | Signed-off-by: Brian Goff <cpuguy83@gmail.com>
* Add helpers to create errdef errorsBrian Goff2018-01-111-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of having to create a bunch of custom error types that are doing nothing but wrapping another error in sub-packages, use a common helper to create errors of the requested type. e.g. instead of re-implementing this over and over: ```go type notFoundError struct { cause error } func(e notFoundError) Error() string { return e.cause.Error() } func(e notFoundError) NotFound() {} func(e notFoundError) Cause() error { return e.cause } ``` Packages can instead just do: ``` errdefs.NotFound(err) ``` Signed-off-by: Brian Goff <cpuguy83@gmail.com>
* Remove Docker from some functionsVincent Demeester2017-10-251-1/+1
| | | | Signed-off-by: Vincent Demeester <vincent@sbr.pm>
* Exit if service config is loaded unsuccessfully on startupBoaz Shuster2017-09-171-4/+4
| | | | Signed-off-by: Boaz Shuster <ripcurld.github@gmail.com>
* Remove string checking in API error handlingBrian Goff2017-08-151-4/+5
| | | | | | | | | | | | | | Use strongly typed errors to set HTTP status codes. Error interfaces are defined in the api/errors package and errors returned from controllers are checked against these interfaces. Errors can be wraeped in a pkg/errors.Causer, as long as somewhere in the line of causes one of the interfaces is implemented. The special error interfaces take precedence over Causer, meaning if both Causer and one of the new error interfaces are implemented, the Causer is not traversed. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
* Update logrus to v1.0.1Derek McGowan2017-07-311-1/+1
| | | | | | Fixes case sensitivity issue Signed-off-by: Derek McGowan <derek@mcgstyle.net>
* Add daemon option to push foreign layersNoah Treuhaft2017-05-161-9/+23
| | | | | | | | | | | | | | | | The --allow-nondistributable-artifacts daemon option specifies registries to which foreign layers should be pushed. (By default, foreign layers are not pushed to registries.) Additionally, to make this option effective, foreign layers are now pulled from the registry if possible, falling back to the URLs in the image manifest otherwise. This option is useful when pushing images containing foreign layers to a registry on an air-gapped network so hosts on that network can pull the images without connecting to another server. Signed-off-by: Noah Treuhaft <noah.treuhaft@docker.com>
* Remove use of forked reference package for cliDerek McGowan2017-01-191-1/+1
| | | | | | | Use resolving to repo info as the split point between the legitimate reference package and forked reference package. Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
* support registry mirror config reloadallencloud2017-01-041-0/+9
| | | | Signed-off-by: allencloud <allen.sun@daocloud.io>
* support insecure registry in configuration reloadallencloud2016-10-201-2/+52
| | | | Signed-off-by: allencloud <allen.sun@daocloud.io>
* registry: Remove unused method ResolveIndexAaron Lehmann2016-10-181-6/+0
| | | | | | This does not appear to be used. Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
* Add engine-api types to dockerMichael Crosby2016-09-071-2/+2
| | | | | | | This moves the types for the `engine-api` repo to the existing types package. Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
* Allow v1 search to use v2 auth with identity tokenDerek McGowan2016-07-131-3/+37
| | | | | | | Updates the v1 search endpoint to also support v2 auth when an identity token is given. Only search v1 endpoint is supported since there is not v2 search currently defined to replace it. Signed-off-by: Derek McGowan <derek@mcgstyle.net>
* Add `--limit` option to `docker search`Yong Tang2016-06-021-4/+9
| | | | | | | | | | | | | | | | | This fix tries to address the issue raised in #23055. Currently `docker search` result caps at 25 and there is no way to allow getting more results (if exist). This fix adds the flag `--limit` so that it is possible to return more results from the `docker search`. Related documentation has been updated. Additional tests have been added to cover the changes. This fix fixes #23055. Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
* Add Unit test to daemon.SearchRegistryForImages…Vincent Demeester2016-05-241-15/+31
| | | | | | | | | | | | | | … and refactor a little bit some daemon on the way. - Move `SearchRegistryForImages` to a new file (`daemon/search.go`) as `daemon.go` is getting pretty big. - `registry.Service` is now an interface (allowing us to decouple it a little bit and thus unit test easily). - Add some unit test for `SearchRegistryForImages`. - Use UniqueExactMatch for search filters - And use empty restore id for now in client.ContainerStart. Signed-off-by: Vincent Demeester <vincent@sbr.pm>
* Add default `serveraddress` value in remote API `/auth`Yong Tang2016-04-221-0/+3
| | | | | | | | | | | | | | | | | This fix tries to address the issue in #22244 where the remote API `/auth` will not set the default value of `serveraddress` if not provided. This behavior happens after only in 1.11.0 and is a regression as in 1.10.3 `serveraddress` will be assigned with `IndexServer` if no value is provided. The default value `IndexServer` is assigned to `serveraddress` if no value provided in this fix. An integration test `TestAuthApi` has been added to cover this change This fix fixes #22244. Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
* 1.change validateNoSchema into validateNoSchemeallencloud2016-03-311-1/+1
| | | | | | 2.change schema into scheme in docs and some annotations. Signed-off-by: allencloud <allen.sun@daocloud.io>
* Merge pull request #20970 from dmcgowan/login-oauthVincent Demeester2016-03-141-6/+16
|\ | | | | OAuth support for registries
| * Add support for identity token with token handlerDerek McGowan2016-03-091-6/+16
| | | | | | | | | | | | | | | | Use token handler options for initialization. Update auth endpoint to set identity token in response. Update credential store to match distribution interface changes. Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)