0
Fork 0
mirror of https://github.com/project-zot/zot.git synced 2024-12-16 21:56:37 -05:00
zot/pkg/extensions/get_extensions.go
LaurentiuNiculae 2b8479f7f2
feat(userprefs): update documentation and list extensions endpoint (#1456)
Signed-off-by: Laurentiu Niculae <niculae.laurentiu1@gmail.com>
2023-05-25 14:46:52 +03:00

42 lines
1.1 KiB
Go

package extensions
import (
distext "github.com/opencontainers/distribution-spec/specs-go/v1/extensions"
"zotregistry.io/zot/pkg/api/config"
"zotregistry.io/zot/pkg/api/constants"
)
func GetExtensions(config *config.Config) distext.ExtensionList {
extensionList := distext.ExtensionList{}
endpoints := []string{}
extensions := []distext.Extension{}
if config.Extensions != nil && config.Extensions.Search != nil {
if IsBuiltWithSearchExtension() {
endpoints = append(endpoints, constants.FullSearchPrefix)
}
if IsBuiltWithUserPrefsExtension() {
endpoints = append(endpoints, constants.FullUserPreferencesPrefix)
}
}
if IsBuiltWithMGMTExtension() && config.Extensions != nil && config.Extensions.Mgmt != nil {
endpoints = append(endpoints, constants.FullMgmtPrefix)
}
if len(endpoints) > 0 {
extensions = append(extensions, distext.Extension{
Name: "_zot",
URL: "https://github.com/project-zot/zot/blob/" + config.ReleaseTag + "/pkg/extensions/_zot.md",
Description: "zot registry extensions",
Endpoints: endpoints,
})
}
extensionList.Extensions = extensions
return extensionList
}