8553712613
chore: upgrade trivy to v0.55.2, also update the logic of waiting for zot to start in some jobs Seems like there's an increate in the time zot requires to start before servicing requests. From my GitHub observations it is better check using curl instead of relying on hardcoded 5s or 10s values. The logic in .github/workflows/cluster.yaml seems to be old and out of date. Even on main right now there is only 1 our of 3 zots actualy running. The other 2 are actually erroring: Error: operation timeout: boltdb file is already in use, path '/tmp/zot/cache.db' This is unrelated to this PR, I am seeing the same issue in the olders workflow runs still showing the logs Signed-off-by: Andrei Aaron <aaaron@luxoft.com> |
||
---|---|---|
.. | ||
config | ||
imagetrust | ||
lint | ||
monitoring | ||
scrub | ||
search | ||
sync | ||
_zot.md | ||
extension_image_trust.go | ||
extension_image_trust_disabled.go | ||
extension_image_trust_disabled_test.go | ||
extension_image_trust_test.go | ||
extension_metrics.go | ||
extension_metrics_disabled.go | ||
extension_mgmt.go | ||
extension_mgmt_disabled.go | ||
extension_scrub.go | ||
extension_scrub_disabled.go | ||
extension_search.go | ||
extension_search_disabled.go | ||
extension_sync.go | ||
extension_sync_disabled.go | ||
extension_ui.go | ||
extension_ui_disabled.go | ||
extension_ui_test.go | ||
extension_userprefs.go | ||
extension_userprefs_disable.go | ||
extension_userprefs_test.go | ||
extensions_lint.go | ||
extensions_lint_disabled.go | ||
extensions_test.go | ||
get_extensions.go | ||
get_extensions_disabled_test.go | ||
README.md | ||
README_imagetrust.md | ||
README_mgmt.md | ||
README_userprefs.md |
Adding new extensions
As new requirements come and build time extensions need to be added, there are a few things that you have to make sure are present before commiting :
- files that should be included in the binary only with a specific extension must contain the following syntax at the beginning of the file :
//go:build sync will be added automatically by the linter, so only the second line is mandatory .
NOTE: the third line in the example should be blank, otherwise the build tag would be just another comment.
//go:build sync
// +build sync
package extensions
...................
-
when adding a new tag, specify the new order in which multiple tags should be used (bottom of this page)
-
for each and every new file that contains functions (functionalities) specific to an extension, one should create a corresponding file that must contain the exact same functions, but no functionalities included. This file must begin with an "anti-tag" (e.g. // +build !sync) which will include this file in binaries that don't include this extension ( in this example, the file won't be used in binaries that include sync extension ). See extension-sync-disabled.go for an example.
-
each extension is responsible with implementing authorization for newly added HTTP endpoints. zot will provide the necessary data, including user permissions, to the extension, but actual enforcement of these permissions is the responsibility of each extension. Each extension http.Handler has access to a context previously populated by BaseAuthzHandler with relevant user info. That info has the following structure:
type AccessControlContext struct { // read method action ReadGlobPatterns map[string]bool // detectManifestCollision behaviour action DmcGlobPatterns map[string]bool IsAdmin bool Username string Groups []string }
This data can then be accessed from the request context so that every extension can apply its own authorization logic, if needed .
-
when a new extension comes out, the developer should also write some blackbox tests, where a binary that contains the new extension should be tested in a real usage scenario. See test/blackbox folder for multiple extensions examples.
-
newly added blackbox tests should have targets in Makefile. You should also add them as Github Workflows, in .github/workflows/ecosystem-tools.yaml
-
with every new extension, you should modify the EXTENSIONS variable in Makefile by adding the new extension. The EXTENSIONS variable represents all extensions and is used in Make targets that require them all (e.g make test).
-
the available extensions that can be used at the moment are: sync, search, scrub, metrics, lint, ui, mgmt, userprefs, imagetrust . NOTE: When multiple extensions are used, they should be listed in the above presented order.