diff --git a/pkg/extensions/extension_mgmt.go b/pkg/extensions/extension_mgmt.go index 35c3a762..cd4bc53e 100644 --- a/pkg/extensions/extension_mgmt.go +++ b/pkg/extensions/extension_mgmt.go @@ -70,6 +70,14 @@ type mgmt struct { log log.Logger } +// mgmtHandler godoc +// @Summary Get current server configuration +// @Description Get current server configuration +// @Router /v2/_zot/ext/mgmt [get] +// @Accept json +// @Produce json +// @Success 200 {object} extensions.StrippedConfig +// @Failure 500 {string} string "internal server error". func (mgmt *mgmt) handler() http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { sanitizedConfig := mgmt.config.Sanitize() diff --git a/pkg/extensions/extension_userprefs.go b/pkg/extensions/extension_userprefs.go index 3531e285..124c95e7 100644 --- a/pkg/extensions/extension_userprefs.go +++ b/pkg/extensions/extension_userprefs.go @@ -43,6 +43,19 @@ func SetupUserPreferencesRoutes(config *config.Config, router *mux.Router, store } } +// ListTags godoc +// @Summary Add bookmarks/stars info +// @Description Add bookmarks/stars info +// @Router /v2/_zot/ext/userprefs [put] +// @Accept json +// @Produce json +// @Param action query string true "specify action" Enums("toggleBookmark", "toggleStar") +// @Param repo query string true "repository name" +// @Success 200 {string} string "ok" +// @Failure 404 {string} string "not found" +// @Failure 403 {string} string "forbidden" +// @Failure 500 {string} string "internal server error" +// @Failure 400 {string} string "bad request". func HandleUserPrefs(repoDB repodb.RepoDB, log log.Logger) func(w http.ResponseWriter, r *http.Request) { return func(rsp http.ResponseWriter, req *http.Request) { if !queryHasParams(req.URL.Query(), []string{"action"}) { diff --git a/swagger/docs.go b/swagger/docs.go index 1de46577..c1457659 100644 --- a/swagger/docs.go +++ b/swagger/docs.go @@ -141,6 +141,96 @@ const docTemplate = `{ } } }, + "/v2/_zot/ext/mgmt": { + "get": { + "description": "Get current server configuration", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "summary": "Get current server configuration", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/extensions.StrippedConfig" + } + }, + "500": { + "description": "internal server error\".", + "schema": { + "type": "string" + } + } + } + } + }, + "/v2/_zot/ext/userprefs": { + "put": { + "description": "Add bookmarks/stars info", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "summary": "Add bookmarks/stars info", + "parameters": [ + { + "enum": [ + "\"toggleBookmark\"", + "\"toggleStar\"" + ], + "type": "string", + "description": "specify action", + "name": "action", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "repository name", + "name": "repo", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "ok", + "schema": { + "type": "string" + } + }, + "400": { + "description": "bad request\".", + "schema": { + "type": "string" + } + }, + "403": { + "description": "forbidden", + "schema": { + "type": "string" + } + }, + "404": { + "description": "not found", + "schema": { + "type": "string" + } + }, + "500": { + "description": "internal server error", + "schema": { + "type": "string" + } + } + } + } + }, "/v2/{name}/blobs/uploads": { "post": { "description": "Create a new image blob/layer upload", @@ -927,6 +1017,36 @@ const docTemplate = `{ } } }, + "extensions.Auth": { + "type": "object", + "properties": { + "bearer": { + "$ref": "#/definitions/extensions.BearerConfig" + }, + "htpasswd": { + "$ref": "#/definitions/extensions.HTPasswd" + }, + "ldap": { + "type": "object", + "properties": { + "address": { + "type": "string" + } + } + } + } + }, + "extensions.BearerConfig": { + "type": "object", + "properties": { + "realm": { + "type": "string" + }, + "service": { + "type": "string" + } + } + }, "extensions.Extension": { "type": "object", "properties": { @@ -947,6 +1067,33 @@ const docTemplate = `{ } } }, + "extensions.HTPasswd": { + "type": "object", + "properties": { + "path": { + "type": "string" + } + } + }, + "extensions.StrippedConfig": { + "type": "object", + "properties": { + "binaryType": { + "type": "string" + }, + "distSpecVersion": { + "type": "string" + }, + "http": { + "type": "object", + "properties": { + "auth": { + "$ref": "#/definitions/extensions.Auth" + } + } + } + } + }, "github_com_opencontainers_image-spec_specs-go_v1.Descriptor": { "type": "object", "properties": { @@ -1001,7 +1148,7 @@ const docTemplate = `{ "type": "object", "properties": { "architecture": { - "description": "Architecture field specifies the CPU architecture, for example\n` + "`" + `amd64` + "`" + ` or ` + "`" + `ppc64` + "`" + `.", + "description": "Architecture field specifies the CPU architecture, for example\n` + "`" + `amd64` + "`" + ` or ` + "`" + `ppc64le` + "`" + `.", "type": "string" }, "os": { diff --git a/swagger/swagger.json b/swagger/swagger.json index b3144cf8..41d3b0b1 100644 --- a/swagger/swagger.json +++ b/swagger/swagger.json @@ -132,6 +132,96 @@ } } }, + "/v2/_zot/ext/mgmt": { + "get": { + "description": "Get current server configuration", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "summary": "Get current server configuration", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/extensions.StrippedConfig" + } + }, + "500": { + "description": "internal server error\".", + "schema": { + "type": "string" + } + } + } + } + }, + "/v2/_zot/ext/userprefs": { + "put": { + "description": "Add bookmarks/stars info", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "summary": "Add bookmarks/stars info", + "parameters": [ + { + "enum": [ + "\"toggleBookmark\"", + "\"toggleStar\"" + ], + "type": "string", + "description": "specify action", + "name": "action", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "repository name", + "name": "repo", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "ok", + "schema": { + "type": "string" + } + }, + "400": { + "description": "bad request\".", + "schema": { + "type": "string" + } + }, + "403": { + "description": "forbidden", + "schema": { + "type": "string" + } + }, + "404": { + "description": "not found", + "schema": { + "type": "string" + } + }, + "500": { + "description": "internal server error", + "schema": { + "type": "string" + } + } + } + } + }, "/v2/{name}/blobs/uploads": { "post": { "description": "Create a new image blob/layer upload", @@ -918,6 +1008,36 @@ } } }, + "extensions.Auth": { + "type": "object", + "properties": { + "bearer": { + "$ref": "#/definitions/extensions.BearerConfig" + }, + "htpasswd": { + "$ref": "#/definitions/extensions.HTPasswd" + }, + "ldap": { + "type": "object", + "properties": { + "address": { + "type": "string" + } + } + } + } + }, + "extensions.BearerConfig": { + "type": "object", + "properties": { + "realm": { + "type": "string" + }, + "service": { + "type": "string" + } + } + }, "extensions.Extension": { "type": "object", "properties": { @@ -938,6 +1058,33 @@ } } }, + "extensions.HTPasswd": { + "type": "object", + "properties": { + "path": { + "type": "string" + } + } + }, + "extensions.StrippedConfig": { + "type": "object", + "properties": { + "binaryType": { + "type": "string" + }, + "distSpecVersion": { + "type": "string" + }, + "http": { + "type": "object", + "properties": { + "auth": { + "$ref": "#/definitions/extensions.Auth" + } + } + } + } + }, "github_com_opencontainers_image-spec_specs-go_v1.Descriptor": { "type": "object", "properties": { @@ -992,7 +1139,7 @@ "type": "object", "properties": { "architecture": { - "description": "Architecture field specifies the CPU architecture, for example\n`amd64` or `ppc64`.", + "description": "Architecture field specifies the CPU architecture, for example\n`amd64` or `ppc64le`.", "type": "string" }, "os": { diff --git a/swagger/swagger.yaml b/swagger/swagger.yaml index f2f602a9..32e9d4d8 100644 --- a/swagger/swagger.yaml +++ b/swagger/swagger.yaml @@ -78,6 +78,25 @@ definitions: type: string type: array type: object + extensions.Auth: + properties: + bearer: + $ref: '#/definitions/extensions.BearerConfig' + htpasswd: + $ref: '#/definitions/extensions.HTPasswd' + ldap: + properties: + address: + type: string + type: object + type: object + extensions.BearerConfig: + properties: + realm: + type: string + service: + type: string + type: object extensions.Extension: properties: description: @@ -91,6 +110,23 @@ definitions: url: type: string type: object + extensions.HTPasswd: + properties: + path: + type: string + type: object + extensions.StrippedConfig: + properties: + binaryType: + type: string + distSpecVersion: + type: string + http: + properties: + auth: + $ref: '#/definitions/extensions.Auth' + type: object + type: object github_com_opencontainers_image-spec_specs-go_v1.Descriptor: properties: annotations: @@ -138,7 +174,7 @@ definitions: architecture: description: |- Architecture field specifies the CPU architecture, for example - `amd64` or `ppc64`. + `amd64` or `ppc64le`. type: string os: description: OS specifies the operating system, for example `linux` or `windows`. @@ -250,6 +286,66 @@ paths: schema: $ref: '#/definitions/api.ExtensionList' summary: List Registry level extensions + /v2/_zot/ext/mgmt: + get: + consumes: + - application/json + description: Get current server configuration + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/extensions.StrippedConfig' + "500": + description: internal server error". + schema: + type: string + summary: Get current server configuration + /v2/_zot/ext/userprefs: + put: + consumes: + - application/json + description: Add bookmarks/stars info + parameters: + - description: specify action + enum: + - '"toggleBookmark"' + - '"toggleStar"' + in: query + name: action + required: true + type: string + - description: repository name + in: query + name: repo + required: true + type: string + produces: + - application/json + responses: + "200": + description: ok + schema: + type: string + "400": + description: bad request". + schema: + type: string + "403": + description: forbidden + schema: + type: string + "404": + description: not found + schema: + type: string + "500": + description: internal server error + schema: + type: string + summary: Add bookmarks/stars info /v2/{name}/blobs/{digest}: delete: consumes: