0
Fork 0
mirror of https://github.com/project-zot/zot.git synced 2024-12-16 21:56:37 -05:00
zot/pkg/extensions
Jan-Otto Kröpke f618b1d4ef
ci(deps): upgrade golangci-lint (#2556)
* ci(deps): upgrade golangci-lint

Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>

* build(deps): removed disabled linters

Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>

* build(deps): go run github.com/daixiang0/gci@latest write .

Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>

* build(deps): go run golang.org/x/tools/cmd/goimports@latest -l -w .

Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>

* build(deps): go run github.com/bombsimon/wsl/v4/cmd...@latest -strict-append -test=true -fix ./...

Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>

* build(deps): go run github.com/catenacyber/perfsprint@latest -fix ./...

Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>

* build(deps): replace gomnd by mnd

Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>

* build(deps): make gqlgen

Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>

* build: Revert "build(deps): go run github.com/daixiang0/gci@latest write ."

This reverts commit 5bf8c42e1f.

Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>

* build(deps): go run github.com/daixiang0/gci@latest write -s 'standard' -s default -s 'prefix(zotregistry.dev/zot)' .

Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>

* build(deps): make gqlgen

Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>

* fix: wsl issues

Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>

* fix: wsl issues

Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>

* fix: wsl issues

Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>

* fix: wsl issues

Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>

* fix: wsl issues

Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>

* fix: wsl issues

Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>

* fix: wsl issues

Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>

* fix: wsl issues

Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>

* fix: wsl issues

Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>

* fix: wsl issues

Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>

* fix: wsl issues

Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>

* fix: wsl issues

Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>

* fix: wsl issues

Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>

* fix: wsl issues

Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>

* fix: wsl issues

Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>

* fix: wsl issues

Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>

* fix: wsl issues

Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>

* fix: wsl issues

Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>

* fix: wsl issues

Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>

* fix: wsl issues

Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>

* fix: wsl issues

Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>

* fix: wsl issues

Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>

* fix: wsl issues

Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>

* fix: wsl issues

Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>

* fix: check-log issues

Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>

* fix: gci issues

Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>

* fix: tests

Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>

---------

Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
2024-07-29 10:32:51 -07:00
..
config refactor: rename go module from zotregistry.io/zot to zotregistry.dev/zot (#2187) 2024-01-31 20:34:07 -08:00
imagetrust ci(deps): upgrade golangci-lint (#2556) 2024-07-29 10:32:51 -07:00
lint ci(deps): upgrade golangci-lint (#2556) 2024-07-29 10:32:51 -07:00
monitoring ci(deps): upgrade golangci-lint (#2556) 2024-07-29 10:32:51 -07:00
scrub ci(deps): upgrade golangci-lint (#2556) 2024-07-29 10:32:51 -07:00
search ci(deps): upgrade golangci-lint (#2556) 2024-07-29 10:32:51 -07:00
sync ci(deps): upgrade golangci-lint (#2556) 2024-07-29 10:32:51 -07:00
_zot.md refactor(extensions)!: refactor the extensions URLs and errors (#1636) 2023-08-02 21:58:34 +03:00
extension_image_trust.go ci(deps): upgrade golangci-lint (#2556) 2024-07-29 10:32:51 -07:00
extension_image_trust_disabled.go refactor: rename go module from zotregistry.io/zot to zotregistry.dev/zot (#2187) 2024-01-31 20:34:07 -08:00
extension_image_trust_disabled_test.go refactor: rename go module from zotregistry.io/zot to zotregistry.dev/zot (#2187) 2024-01-31 20:34:07 -08:00
extension_image_trust_test.go ci(deps): upgrade golangci-lint (#2556) 2024-07-29 10:32:51 -07:00
extension_metrics.go refactor: rename go module from zotregistry.io/zot to zotregistry.dev/zot (#2187) 2024-01-31 20:34:07 -08:00
extension_metrics_disabled.go refactor: rename go module from zotregistry.io/zot to zotregistry.dev/zot (#2187) 2024-01-31 20:34:07 -08:00
extension_mgmt.go refactor: rename go module from zotregistry.io/zot to zotregistry.dev/zot (#2187) 2024-01-31 20:34:07 -08:00
extension_mgmt_disabled.go refactor: rename go module from zotregistry.io/zot to zotregistry.dev/zot (#2187) 2024-01-31 20:34:07 -08:00
extension_scrub.go ci(deps): upgrade golangci-lint (#2556) 2024-07-29 10:32:51 -07:00
extension_scrub_disabled.go refactor: rename go module from zotregistry.io/zot to zotregistry.dev/zot (#2187) 2024-01-31 20:34:07 -08:00
extension_search.go refactor: rename go module from zotregistry.io/zot to zotregistry.dev/zot (#2187) 2024-01-31 20:34:07 -08:00
extension_search_disabled.go refactor: rename go module from zotregistry.io/zot to zotregistry.dev/zot (#2187) 2024-01-31 20:34:07 -08:00
extension_sync.go feat(sync): support for periodic repo sync in scale-out cluster (#2424) 2024-05-31 09:25:34 -07:00
extension_sync_disabled.go refactor: rename go module from zotregistry.io/zot to zotregistry.dev/zot (#2187) 2024-01-31 20:34:07 -08:00
extension_ui.go refactor: rename go module from zotregistry.io/zot to zotregistry.dev/zot (#2187) 2024-01-31 20:34:07 -08:00
extension_ui_disabled.go refactor: rename go module from zotregistry.io/zot to zotregistry.dev/zot (#2187) 2024-01-31 20:34:07 -08:00
extension_ui_test.go ci(deps): upgrade golangci-lint (#2556) 2024-07-29 10:32:51 -07:00
extension_userprefs.go refactor: rename go module from zotregistry.io/zot to zotregistry.dev/zot (#2187) 2024-01-31 20:34:07 -08:00
extension_userprefs_disable.go refactor: rename go module from zotregistry.io/zot to zotregistry.dev/zot (#2187) 2024-01-31 20:34:07 -08:00
extension_userprefs_test.go ci(deps): upgrade golangci-lint (#2556) 2024-07-29 10:32:51 -07:00
extensions_lint.go refactor: rename go module from zotregistry.io/zot to zotregistry.dev/zot (#2187) 2024-01-31 20:34:07 -08:00
extensions_lint_disabled.go refactor: rename go module from zotregistry.io/zot to zotregistry.dev/zot (#2187) 2024-01-31 20:34:07 -08:00
extensions_test.go ci(deps): upgrade golangci-lint (#2556) 2024-07-29 10:32:51 -07:00
get_extensions.go refactor: rename go module from zotregistry.io/zot to zotregistry.dev/zot (#2187) 2024-01-31 20:34:07 -08:00
get_extensions_disabled_test.go ci(deps): upgrade golangci-lint (#2556) 2024-07-29 10:32:51 -07:00
README.md fix: metrics should be protected behind authZ (#1895) 2023-10-20 10:33:26 +03:00
README_imagetrust.md feat: upload cosign public key and notation certificates to cloud (#1744) 2023-09-08 10:03:58 +03:00
README_mgmt.md chore: update image-spec and dist spec to 1.1.0 (#2255) 2024-02-20 13:27:21 +02:00
README_userprefs.md refactor(extensions)!: refactor the extensions URLs and errors (#1636) 2023-08-02 21:58:34 +03:00

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.