0
Fork 0
mirror of https://github.com/project-zot/zot.git synced 2024-12-16 21:56:37 -05:00
zot/pkg/common/model.go
Andrei Aaron 77149aa85c
refactor(extensions)!: refactor the extensions URLs and errors (#1636)
BREAKING CHANGE: The functionality provided by the mgmt endpoint has beed redesigned - see details below
BREAKING CHANGE: The API keys endpoint has been moved -  see details below
BREAKING CHANGE: The mgmt extension config has been removed - endpoint is now enabled by having both the search and the ui extensions enabled
BREAKING CHANGE: The API keys configuration has been moved from extensions to http>auth>apikey

mgmt and imagetrust extensions:
- separate the _zot/ext/mgmt into 3 separate endpoints: _zot/ext/auth, _zot/ext/notation, _zot/ext/cosign
- signature verification logic is in a separate `imagetrust` extension
- better hanling or errors in case of signature uploads: logging and error codes (more 400 and less 500 errors)
- add authz on signature uploads (and add a new middleware in common for this purpose)
- remove the mgmt extension configuration - it is now enabled if the UI and the search extensions are enabled

userprefs estension:
- userprefs are enabled if both search and ui extensions are enabled (as opposed to just search)

apikey extension is removed and logic moved into the api folder
- Move apikeys code out of pkg/extensions and into pkg/api
- Remove apikey configuration options from the extensions configuration and move it inside the http auth section
- remove the build label apikeys

other changes:
- move most of the logic adding handlers to the extensions endpoints out of routes.go and into the extensions files.
- add warnings in case the users are still using configurations with the obsolete settings for mgmt and api keys
- add a new function in the extension package which could be a single point of starting backgroud tasks for all extensions
- more clear methods for verifying specific extensions are enabled
- fix http methods paired with the UI handlers
- rebuild swagger docs

Signed-off-by: Andrei Aaron <aaaron@luxoft.com>
2023-08-02 21:58:34 +03:00

256 lines
7.1 KiB
Go

package common
import (
"time"
)
type PageInfo struct {
TotalCount int
ItemCount int
}
type RepoInfo struct {
Summary RepoSummary
ImageSummaries []ImageSummary `json:"images"`
}
type RepoSummary struct {
Name string `json:"name"`
LastUpdated time.Time `json:"lastUpdated"`
Size string `json:"size"`
Platforms []Platform `json:"platforms"`
Vendors []string `json:"vendors"`
IsStarred bool `json:"isStarred"`
IsBookmarked bool `json:"isBookmarked"`
StarCount int `json:"starCount"`
DownloadCount int `json:"downloadCount"`
NewestImage ImageSummary `json:"newestImage"`
}
type PaginatedImagesResult struct {
Results []ImageSummary `json:"results"`
Page PageInfo `json:"page"`
}
type ImageSummary struct {
RepoName string `json:"repoName"`
Tag string `json:"tag"`
Digest string `json:"digest"`
MediaType string `json:"mediaType"`
Manifests []ManifestSummary `json:"manifests"`
Size string `json:"size"`
DownloadCount int `json:"downloadCount"`
LastUpdated time.Time `json:"lastUpdated"`
Description string `json:"description"`
IsSigned bool `json:"isSigned"`
Licenses string `json:"licenses"`
Labels string `json:"labels"`
Title string `json:"title"`
Source string `json:"source"`
Documentation string `json:"documentation"`
Authors string `json:"authors"`
Vendor string `json:"vendor"`
Vulnerabilities ImageVulnerabilitySummary `json:"vulnerabilities"`
Referrers []Referrer `json:"referrers"`
SignatureInfo []SignatureSummary `json:"signatureInfo"`
}
type ManifestSummary struct {
Digest string `json:"digest"`
ConfigDigest string `json:"configDigest"`
LastUpdated time.Time `json:"lastUpdated"`
Size string `json:"size"`
Platform Platform `json:"platform"`
IsSigned bool `json:"isSigned"`
DownloadCount int `json:"downloadCount"`
Layers []LayerSummary `json:"layers"`
History []LayerHistory `json:"history"`
Vulnerabilities ImageVulnerabilitySummary `json:"vulnerabilities"`
Referrers []Referrer `json:"referrers"`
ArtifactType string `json:"artifactType"`
SignatureInfo []SignatureSummary `json:"signatureInfo"`
}
type SignatureSummary struct {
Tool string `json:"tool"`
IsTrusted bool `json:"isTrusted"`
Author string `json:"author"`
}
type Platform struct {
Os string `json:"os"`
Arch string `json:"arch"`
Variant string `json:"variant"`
}
type ImageVulnerabilitySummary struct {
MaxSeverity string `json:"maxSeverity"`
Count int `json:"count"`
}
type LayerSummary struct {
Size string `json:"size"`
Digest string `json:"digest"`
Score int `json:"score"`
}
type LayerHistory struct {
Layer LayerSummary `json:"layer"`
HistoryDescription HistoryDescription `json:"historyDescription"`
}
type HistoryDescription struct {
Created time.Time `json:"created"`
CreatedBy string `json:"createdBy"`
Author string `json:"author"`
Comment string `json:"comment"`
EmptyLayer bool `json:"emptyLayer"`
}
type Referrer struct {
MediaType string `json:"mediatype"`
ArtifactType string `json:"artifacttype"`
Size int `json:"size"`
Digest string `json:"digest"`
Annotations []Annotation `json:"annotations"`
}
type Annotation struct {
Key string `json:"key"`
Value string `json:"value"`
}
type ImageListWithCVEFixedResponse struct {
Errors []ErrorGQL `json:"errors"`
ImageListWithCVEFixed `json:"data"`
}
type ImageListWithCVEFixed struct {
PaginatedImagesResult `json:"ImageListWithCVEFixed"` //nolint:tagliatelle // graphQL schema
}
type ImagesForCve struct {
Errors []ErrorGQL `json:"errors"`
ImagesForCVEList `json:"data"`
}
type ImagesForCVEList struct {
PaginatedImagesResult `json:"ImageListForCVE"` //nolint:tagliatelle // graphQL schema
}
type ImagesForDigest struct {
Errors []ErrorGQL `json:"errors"`
ImagesForDigestList `json:"data"`
}
type ImagesForDigestList struct {
PaginatedImagesResult `json:"ImageListForDigest"` //nolint:tagliatelle // graphQL schema
}
type RepoWithNewestImageResponse struct {
RepoListWithNewestImage `json:"data"`
Errors []ErrorGQL `json:"errors"`
}
type DerivedImageListResponse struct {
DerivedImageList `json:"data"`
Errors []ErrorGQL `json:"errors"`
}
type BaseImageListResponse struct {
BaseImageList `json:"data"`
Errors []ErrorGQL `json:"errors"`
}
type DerivedImageList struct {
PaginatedImagesResult `json:"derivedImageList"`
}
type BaseImageList struct {
PaginatedImagesResult `json:"baseImageList"`
}
type ImageListResponse struct {
ImageList `json:"data"`
Errors []ErrorGQL `json:"errors"`
}
type ImageList struct {
PaginatedImagesResult `json:"imageList"`
}
type ExpandedRepoInfoResp struct {
ExpandedRepoInfo `json:"data"`
Errors []ErrorGQL `json:"errors"`
}
type ReferrersResp struct {
ReferrersResult `json:"data"`
Errors []ErrorGQL `json:"errors"`
}
type ReferrersResult struct {
Referrers []Referrer `json:"referrers"`
}
type GlobalSearchResultResp struct {
GlobalSearchResult `json:"data"`
Errors []ErrorGQL `json:"errors"`
}
type GlobalSearchResult struct {
GlobalSearch `json:"globalSearch"`
}
type GlobalSearch struct {
Images []ImageSummary `json:"images"`
Repos []RepoSummary `json:"repos"`
Layers []LayerSummary `json:"layers"`
Page PageInfo `json:"page"`
}
type ExpandedRepoInfo struct {
RepoInfo `json:"expandedRepoInfo"`
}
type PaginatedReposResult struct {
Results []RepoSummary `json:"results"`
Page PageInfo `json:"page"`
}
//nolint:tagliatelle // graphQL schema
type RepoListWithNewestImage struct {
PaginatedReposResult `json:"RepoListWithNewestImage"`
}
type ErrorGQL struct {
Message string `json:"message"`
Path []string `json:"path"`
}
type SingleImageSummary struct {
ImageSummary `json:"Image"` //nolint:tagliatelle
}
type ImageSummaryResult struct {
SingleImageSummary `json:"data"`
Errors []ErrorGQL `json:"errors"`
}
//nolint:tagliatelle // graphQL schema
type StarredRepos struct {
PaginatedReposResult `json:"StarredRepos"`
}
//nolint:tagliatelle // graphQL schema
type BookmarkedRepos struct {
PaginatedReposResult `json:"BookmarkedRepos"`
}
type StarredReposResponse struct {
StarredRepos `json:"data"`
Errors []ErrorGQL `json:"errors"`
}
type BookmarkedReposResponse struct {
BookmarkedRepos `json:"data"`
Errors []ErrorGQL `json:"errors"`
}