From df7859fd39225dd08e16118e67b6af1102bfb0ac Mon Sep 17 00:00:00 2001 From: Eike David Lenz Date: Wed, 4 May 2022 14:21:08 +0200 Subject: [PATCH 1/2] bump v1 & v2 apis --- Makefile | 10 +- README.md | 2 +- apiv1/mocks/client_service.go | 14 +- apiv1/testing/const.go | 2 +- .../api/client/artifact/artifact_client.go | 39 ++ .../artifact/get_artifact_parameters.go | 50 ++- ...get_vulnerabilities_addition_parameters.go | 8 +- .../artifact/list_accessories_parameters.go | 351 ++++++++++++++++++ .../artifact/list_accessories_responses.go | 316 ++++++++++++++++ .../artifact/list_artifacts_parameters.go | 50 ++- .../configure/get_internalconfig_responses.go | 6 +- apiv2/mocks/artifact_client_service.go | 37 +- apiv2/mocks/auditlog_client_service.go | 14 +- apiv2/mocks/configure_client_service.go | 14 +- apiv2/mocks/gc_client_service.go | 14 +- apiv2/mocks/health_client_service.go | 14 +- apiv2/mocks/icon_client_service.go | 14 +- apiv2/mocks/immutable_client_service.go | 14 +- apiv2/mocks/label_client_service.go | 14 +- apiv2/mocks/ldap_client_service.go | 14 +- apiv2/mocks/member_client_service.go | 14 +- apiv2/mocks/oidc_client_service.go | 14 +- apiv2/mocks/ping_client_service.go | 14 +- apiv2/mocks/preheat_client_service.go | 14 +- apiv2/mocks/project_client_service.go | 14 +- .../mocks/project_metadata_client_service.go | 14 +- apiv2/mocks/quota_client_service.go | 14 +- apiv2/mocks/registry_client_service.go | 14 +- apiv2/mocks/replication_client_service.go | 14 +- apiv2/mocks/repository_client_service.go | 14 +- apiv2/mocks/retention_client_service.go | 14 +- apiv2/mocks/robot_client_service.go | 14 +- apiv2/mocks/robotv1_client_service.go | 14 +- apiv2/mocks/scan_all_client_service.go | 14 +- apiv2/mocks/scan_client_service.go | 14 +- apiv2/mocks/scanner_client_service.go | 14 +- apiv2/mocks/search_client_service.go | 14 +- apiv2/mocks/statistic_client_service.go | 14 +- .../system_cve_allowlist_client_service.go | 14 +- apiv2/mocks/systeminfo_client_service.go | 14 +- apiv2/mocks/user_client_service.go | 14 +- apiv2/mocks/usergroup_client_service.go | 14 +- apiv2/mocks/webhook_client_service.go | 14 +- apiv2/mocks/webhookjob_client_service.go | 14 +- apiv2/model/accessory.go | 89 +++++ apiv2/model/artifact.go | 32 ++ apiv2/model/general_info.go | 22 ++ apiv2/model/internal_configuration_value.go | 46 +++ .../model/internal_configurations_response.go | 40 ++ apiv2/model/project_metadata.go | 3 + apiv2/model/project_summary_quota.go | 5 +- apiv2/model/quota.go | 5 +- apiv2/model/quota_update_req.go | 3 +- apiv2/model/resource_list.go | 20 + apiv2/pkg/clients/quota/quota.go | 4 +- 55 files changed, 1534 insertions(+), 68 deletions(-) create mode 100644 apiv2/internal/api/client/artifact/list_accessories_parameters.go create mode 100644 apiv2/internal/api/client/artifact/list_accessories_responses.go create mode 100644 apiv2/model/accessory.go create mode 100644 apiv2/model/internal_configuration_value.go create mode 100644 apiv2/model/internal_configurations_response.go create mode 100644 apiv2/model/resource_list.go diff --git a/Makefile b/Makefile index 2a1ecaf2..f9f1802c 100644 --- a/Makefile +++ b/Makefile @@ -2,11 +2,11 @@ harbor-teardown test integration-test-v1-ci integration-test-v2-ci integration-test-v1 integration-test-v2 \ fmt gofmt gofumpt goimports lint uninstall-harbor-v2 uninstall-harbor-v1 -V1_VERSION = v1.10.9 -V2_VERSION = v2.4.1 -MOCKERY_VERSION = v2.9.4 +V1_VERSION = v1.10.10 +V2_VERSION = v2.5.0 +MOCKERY_VERSION = v2.12.1 GOSWAGGER_VERSION = v0.25.0 -GOLANGCI_LINT_VERSION = v1.43.0 +GOLANGCI_LINT_VERSION = v1.45.2 # Run all code generation targets generate: swagger-generate mock-generate @@ -46,7 +46,7 @@ uninstall-harbor-v1: test: go test -v ./... -tags !integration -INTREGRATION_V1 = CGO_ENABLED=0 go test -p 1 -count 1 -v github.com/mittwald/goharbor-client/v5/apiv1/... -tags integration +INTEGRATION_V1 = CGO_ENABLED=0 go test -p 1 -count 1 -v github.com/mittwald/goharbor-client/v5/apiv1/... -tags integration INTEGRATION_V2 = CGO_ENABLED=0 go test -p 1 -count 1 -v github.com/mittwald/goharbor-client/v5/apiv2/... -tags integration # Integration testing (CI Jobs) diff --git a/README.md b/README.md index 2ba3efec..271bc627 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ A Go client library enabling programs to perform CRUD operations on the [goharbo This client library utilizes types generated by [go-swagger](https://github.com/go-swagger/go-swagger). ## Compatibility -This library includes separate clients supporting the **v1.10** & **v2.4** versions of goharbor. +This library includes separate clients supporting the **v1.10** & **v2.5** versions of goharbor. ## Installation Install the desired client library version using `go get`: diff --git a/apiv1/mocks/client_service.go b/apiv1/mocks/client_service.go index ba6d077e..7efe9d53 100644 --- a/apiv1/mocks/client_service.go +++ b/apiv1/mocks/client_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.9.4. DO NOT EDIT. +// Code generated by mockery v2.12.1. DO NOT EDIT. package mocks @@ -6,6 +6,8 @@ import ( runtime "github.com/go-openapi/runtime" products "github.com/mittwald/goharbor-client/v5/apiv1/internal/api/client/products" mock "github.com/stretchr/testify/mock" + + testing "testing" ) // MockClientService is an autogenerated mock type for the ClientService type @@ -891,3 +893,13 @@ func (_m *MockClientService) PutUsersUserIDPassword(params *products.PutUsersUse func (_m *MockClientService) SetTransport(transport runtime.ClientTransport) { _m.Called(transport) } + +// NewMockClientService creates a new instance of MockClientService. It also registers the testing.TB interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockClientService(t testing.TB) *MockClientService { + mock := &MockClientService{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/apiv1/testing/const.go b/apiv1/testing/const.go index 59060ac5..42d7d99d 100644 --- a/apiv1/testing/const.go +++ b/apiv1/testing/const.go @@ -1,7 +1,7 @@ package testing const ( - Host = "http://localhost:30002/api" + Host = "http://localhost:80/api" User = "admin" Password = "Harbor12345" SetupScript = "scripts/setup-harbor.sh" diff --git a/apiv2/internal/api/client/artifact/artifact_client.go b/apiv2/internal/api/client/artifact/artifact_client.go index fc1003b2..062a26ef 100644 --- a/apiv2/internal/api/client/artifact/artifact_client.go +++ b/apiv2/internal/api/client/artifact/artifact_client.go @@ -43,6 +43,8 @@ type ClientService interface { GetVulnerabilitiesAddition(params *GetVulnerabilitiesAdditionParams, authInfo runtime.ClientAuthInfoWriter) (*GetVulnerabilitiesAdditionOK, error) + ListAccessories(params *ListAccessoriesParams, authInfo runtime.ClientAuthInfoWriter) (*ListAccessoriesOK, error) + ListArtifacts(params *ListArtifactsParams, authInfo runtime.ClientAuthInfoWriter) (*ListArtifactsOK, error) ListTags(params *ListTagsParams, authInfo runtime.ClientAuthInfoWriter) (*ListTagsOK, error) @@ -348,6 +350,43 @@ func (a *Client) GetVulnerabilitiesAddition(params *GetVulnerabilitiesAdditionPa panic(msg) } +/* + ListAccessories lists accessories + + List accessories of the specific artifact +*/ +func (a *Client) ListAccessories(params *ListAccessoriesParams, authInfo runtime.ClientAuthInfoWriter) (*ListAccessoriesOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewListAccessoriesParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "listAccessories", + Method: "GET", + PathPattern: "/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/accessories", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &ListAccessoriesReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + success, ok := result.(*ListAccessoriesOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for listAccessories: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + /* ListArtifacts lists artifacts diff --git a/apiv2/internal/api/client/artifact/get_artifact_parameters.go b/apiv2/internal/api/client/artifact/get_artifact_parameters.go index 9ea33fa4..7bf618ae 100644 --- a/apiv2/internal/api/client/artifact/get_artifact_parameters.go +++ b/apiv2/internal/api/client/artifact/get_artifact_parameters.go @@ -21,9 +21,10 @@ import ( // with the default values initialized. func NewGetArtifactParams() *GetArtifactParams { var ( - xAcceptVulnerabilitiesDefault = string("application/vnd.security.vulnerability.report; version=1.1, application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0") + xAcceptVulnerabilitiesDefault = string("application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0") pageDefault = int64(1) pageSizeDefault = int64(10) + withAccessoryDefault = bool(false) withImmutableStatusDefault = bool(false) withLabelDefault = bool(false) withScanOverviewDefault = bool(false) @@ -34,6 +35,7 @@ func NewGetArtifactParams() *GetArtifactParams { XAcceptVulnerabilities: &xAcceptVulnerabilitiesDefault, Page: &pageDefault, PageSize: &pageSizeDefault, + WithAccessory: &withAccessoryDefault, WithImmutableStatus: &withImmutableStatusDefault, WithLabel: &withLabelDefault, WithScanOverview: &withScanOverviewDefault, @@ -48,9 +50,10 @@ func NewGetArtifactParams() *GetArtifactParams { // with the default values initialized, and the ability to set a timeout on a request func NewGetArtifactParamsWithTimeout(timeout time.Duration) *GetArtifactParams { var ( - xAcceptVulnerabilitiesDefault = string("application/vnd.security.vulnerability.report; version=1.1, application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0") + xAcceptVulnerabilitiesDefault = string("application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0") pageDefault = int64(1) pageSizeDefault = int64(10) + withAccessoryDefault = bool(false) withImmutableStatusDefault = bool(false) withLabelDefault = bool(false) withScanOverviewDefault = bool(false) @@ -61,6 +64,7 @@ func NewGetArtifactParamsWithTimeout(timeout time.Duration) *GetArtifactParams { XAcceptVulnerabilities: &xAcceptVulnerabilitiesDefault, Page: &pageDefault, PageSize: &pageSizeDefault, + WithAccessory: &withAccessoryDefault, WithImmutableStatus: &withImmutableStatusDefault, WithLabel: &withLabelDefault, WithScanOverview: &withScanOverviewDefault, @@ -75,9 +79,10 @@ func NewGetArtifactParamsWithTimeout(timeout time.Duration) *GetArtifactParams { // with the default values initialized, and the ability to set a context for a request func NewGetArtifactParamsWithContext(ctx context.Context) *GetArtifactParams { var ( - xAcceptVulnerabilitiesDefault = string("application/vnd.security.vulnerability.report; version=1.1, application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0") + xAcceptVulnerabilitiesDefault = string("application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0") pageDefault = int64(1) pageSizeDefault = int64(10) + withAccessoryDefault = bool(false) withImmutableStatusDefault = bool(false) withLabelDefault = bool(false) withScanOverviewDefault = bool(false) @@ -88,6 +93,7 @@ func NewGetArtifactParamsWithContext(ctx context.Context) *GetArtifactParams { XAcceptVulnerabilities: &xAcceptVulnerabilitiesDefault, Page: &pageDefault, PageSize: &pageSizeDefault, + WithAccessory: &withAccessoryDefault, WithImmutableStatus: &withImmutableStatusDefault, WithLabel: &withLabelDefault, WithScanOverview: &withScanOverviewDefault, @@ -102,9 +108,10 @@ func NewGetArtifactParamsWithContext(ctx context.Context) *GetArtifactParams { // with the default values initialized, and the ability to set a custom HTTPClient for a request func NewGetArtifactParamsWithHTTPClient(client *http.Client) *GetArtifactParams { var ( - xAcceptVulnerabilitiesDefault = string("application/vnd.security.vulnerability.report; version=1.1, application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0") + xAcceptVulnerabilitiesDefault = string("application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0") pageDefault = int64(1) pageSizeDefault = int64(10) + withAccessoryDefault = bool(false) withImmutableStatusDefault = bool(false) withLabelDefault = bool(false) withScanOverviewDefault = bool(false) @@ -115,6 +122,7 @@ func NewGetArtifactParamsWithHTTPClient(client *http.Client) *GetArtifactParams XAcceptVulnerabilities: &xAcceptVulnerabilitiesDefault, Page: &pageDefault, PageSize: &pageSizeDefault, + WithAccessory: &withAccessoryDefault, WithImmutableStatus: &withImmutableStatusDefault, WithLabel: &withLabelDefault, WithScanOverview: &withScanOverviewDefault, @@ -165,8 +173,13 @@ type GetArtifactParams struct { */ RepositoryName string + /*WithAccessory + Specify whether the accessories are included of the returning artifacts. + + */ + WithAccessory *bool /*WithImmutableStatus - Specify whether the immutable status is inclued inside the tags of the returning artifacts. Only works when setting "with_tag=true" + Specify whether the immutable status is inclued inside the tags of the returning artifacts. */ WithImmutableStatus *bool @@ -306,6 +319,17 @@ func (o *GetArtifactParams) SetRepositoryName(repositoryName string) { o.RepositoryName = repositoryName } +// WithWithAccessory adds the withAccessory to the get artifact params +func (o *GetArtifactParams) WithWithAccessory(withAccessory *bool) *GetArtifactParams { + o.SetWithAccessory(withAccessory) + return o +} + +// SetWithAccessory adds the withAccessory to the get artifact params +func (o *GetArtifactParams) SetWithAccessory(withAccessory *bool) { + o.WithAccessory = withAccessory +} + // WithWithImmutableStatus adds the withImmutableStatus to the get artifact params func (o *GetArtifactParams) WithWithImmutableStatus(withImmutableStatus *bool) *GetArtifactParams { o.SetWithImmutableStatus(withImmutableStatus) @@ -434,6 +458,22 @@ func (o *GetArtifactParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.R return err } + if o.WithAccessory != nil { + + // query param with_accessory + var qrWithAccessory bool + if o.WithAccessory != nil { + qrWithAccessory = *o.WithAccessory + } + qWithAccessory := swag.FormatBool(qrWithAccessory) + if qWithAccessory != "" { + if err := r.SetQueryParam("with_accessory", qWithAccessory); err != nil { + return err + } + } + + } + if o.WithImmutableStatus != nil { // query param with_immutable_status diff --git a/apiv2/internal/api/client/artifact/get_vulnerabilities_addition_parameters.go b/apiv2/internal/api/client/artifact/get_vulnerabilities_addition_parameters.go index c0c1fb98..787929c6 100644 --- a/apiv2/internal/api/client/artifact/get_vulnerabilities_addition_parameters.go +++ b/apiv2/internal/api/client/artifact/get_vulnerabilities_addition_parameters.go @@ -20,7 +20,7 @@ import ( // with the default values initialized. func NewGetVulnerabilitiesAdditionParams() *GetVulnerabilitiesAdditionParams { var ( - xAcceptVulnerabilitiesDefault = string("application/vnd.security.vulnerability.report; version=1.1, application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0") + xAcceptVulnerabilitiesDefault = string("application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0") ) return &GetVulnerabilitiesAdditionParams{ XAcceptVulnerabilities: &xAcceptVulnerabilitiesDefault, @@ -33,7 +33,7 @@ func NewGetVulnerabilitiesAdditionParams() *GetVulnerabilitiesAdditionParams { // with the default values initialized, and the ability to set a timeout on a request func NewGetVulnerabilitiesAdditionParamsWithTimeout(timeout time.Duration) *GetVulnerabilitiesAdditionParams { var ( - xAcceptVulnerabilitiesDefault = string("application/vnd.security.vulnerability.report; version=1.1, application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0") + xAcceptVulnerabilitiesDefault = string("application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0") ) return &GetVulnerabilitiesAdditionParams{ XAcceptVulnerabilities: &xAcceptVulnerabilitiesDefault, @@ -46,7 +46,7 @@ func NewGetVulnerabilitiesAdditionParamsWithTimeout(timeout time.Duration) *GetV // with the default values initialized, and the ability to set a context for a request func NewGetVulnerabilitiesAdditionParamsWithContext(ctx context.Context) *GetVulnerabilitiesAdditionParams { var ( - xAcceptVulnerabilitiesDefault = string("application/vnd.security.vulnerability.report; version=1.1, application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0") + xAcceptVulnerabilitiesDefault = string("application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0") ) return &GetVulnerabilitiesAdditionParams{ XAcceptVulnerabilities: &xAcceptVulnerabilitiesDefault, @@ -59,7 +59,7 @@ func NewGetVulnerabilitiesAdditionParamsWithContext(ctx context.Context) *GetVul // with the default values initialized, and the ability to set a custom HTTPClient for a request func NewGetVulnerabilitiesAdditionParamsWithHTTPClient(client *http.Client) *GetVulnerabilitiesAdditionParams { var ( - xAcceptVulnerabilitiesDefault = string("application/vnd.security.vulnerability.report; version=1.1, application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0") + xAcceptVulnerabilitiesDefault = string("application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0") ) return &GetVulnerabilitiesAdditionParams{ XAcceptVulnerabilities: &xAcceptVulnerabilitiesDefault, diff --git a/apiv2/internal/api/client/artifact/list_accessories_parameters.go b/apiv2/internal/api/client/artifact/list_accessories_parameters.go new file mode 100644 index 00000000..a2ec1a5c --- /dev/null +++ b/apiv2/internal/api/client/artifact/list_accessories_parameters.go @@ -0,0 +1,351 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewListAccessoriesParams creates a new ListAccessoriesParams object +// with the default values initialized. +func NewListAccessoriesParams() *ListAccessoriesParams { + var ( + pageDefault = int64(1) + pageSizeDefault = int64(10) + ) + return &ListAccessoriesParams{ + Page: &pageDefault, + PageSize: &pageSizeDefault, + + timeout: cr.DefaultTimeout, + } +} + +// NewListAccessoriesParamsWithTimeout creates a new ListAccessoriesParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewListAccessoriesParamsWithTimeout(timeout time.Duration) *ListAccessoriesParams { + var ( + pageDefault = int64(1) + pageSizeDefault = int64(10) + ) + return &ListAccessoriesParams{ + Page: &pageDefault, + PageSize: &pageSizeDefault, + + timeout: timeout, + } +} + +// NewListAccessoriesParamsWithContext creates a new ListAccessoriesParams object +// with the default values initialized, and the ability to set a context for a request +func NewListAccessoriesParamsWithContext(ctx context.Context) *ListAccessoriesParams { + var ( + pageDefault = int64(1) + pageSizeDefault = int64(10) + ) + return &ListAccessoriesParams{ + Page: &pageDefault, + PageSize: &pageSizeDefault, + + Context: ctx, + } +} + +// NewListAccessoriesParamsWithHTTPClient creates a new ListAccessoriesParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewListAccessoriesParamsWithHTTPClient(client *http.Client) *ListAccessoriesParams { + var ( + pageDefault = int64(1) + pageSizeDefault = int64(10) + ) + return &ListAccessoriesParams{ + Page: &pageDefault, + PageSize: &pageSizeDefault, + HTTPClient: client, + } +} + +/*ListAccessoriesParams contains all the parameters to send to the API endpoint +for the list accessories operation typically these are written to a http.Request +*/ +type ListAccessoriesParams struct { + + /*XRequestID + An unique ID for the request + + */ + XRequestID *string + /*Page + The page number + + */ + Page *int64 + /*PageSize + The size of per page + + */ + PageSize *int64 + /*ProjectName + The name of the project + + */ + ProjectName string + /*Q + Query string to query resources. Supported query patterns are "exact match(k=v)", "fuzzy match(k=~v)", "range(k=[min~max])", "list with union releationship(k={v1 v2 v3})" and "list with intersetion relationship(k=(v1 v2 v3))". The value of range and list can be string(enclosed by " or '), integer or time(in format "2020-04-09 02:36:00"). All of these query patterns should be put in the query string "q=xxx" and splitted by ",". e.g. q=k1=v1,k2=~v2,k3=[min~max] + + */ + Q *string + /*Reference + The reference of the artifact, can be digest or tag + + */ + Reference string + /*RepositoryName + The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -> a%252Fb + + */ + RepositoryName string + /*Sort + Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + + */ + Sort *string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the list accessories params +func (o *ListAccessoriesParams) WithTimeout(timeout time.Duration) *ListAccessoriesParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the list accessories params +func (o *ListAccessoriesParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the list accessories params +func (o *ListAccessoriesParams) WithContext(ctx context.Context) *ListAccessoriesParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the list accessories params +func (o *ListAccessoriesParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the list accessories params +func (o *ListAccessoriesParams) WithHTTPClient(client *http.Client) *ListAccessoriesParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the list accessories params +func (o *ListAccessoriesParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithXRequestID adds the xRequestID to the list accessories params +func (o *ListAccessoriesParams) WithXRequestID(xRequestID *string) *ListAccessoriesParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the list accessories params +func (o *ListAccessoriesParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + +// WithPage adds the page to the list accessories params +func (o *ListAccessoriesParams) WithPage(page *int64) *ListAccessoriesParams { + o.SetPage(page) + return o +} + +// SetPage adds the page to the list accessories params +func (o *ListAccessoriesParams) SetPage(page *int64) { + o.Page = page +} + +// WithPageSize adds the pageSize to the list accessories params +func (o *ListAccessoriesParams) WithPageSize(pageSize *int64) *ListAccessoriesParams { + o.SetPageSize(pageSize) + return o +} + +// SetPageSize adds the pageSize to the list accessories params +func (o *ListAccessoriesParams) SetPageSize(pageSize *int64) { + o.PageSize = pageSize +} + +// WithProjectName adds the projectName to the list accessories params +func (o *ListAccessoriesParams) WithProjectName(projectName string) *ListAccessoriesParams { + o.SetProjectName(projectName) + return o +} + +// SetProjectName adds the projectName to the list accessories params +func (o *ListAccessoriesParams) SetProjectName(projectName string) { + o.ProjectName = projectName +} + +// WithQ adds the q to the list accessories params +func (o *ListAccessoriesParams) WithQ(q *string) *ListAccessoriesParams { + o.SetQ(q) + return o +} + +// SetQ adds the q to the list accessories params +func (o *ListAccessoriesParams) SetQ(q *string) { + o.Q = q +} + +// WithReference adds the reference to the list accessories params +func (o *ListAccessoriesParams) WithReference(reference string) *ListAccessoriesParams { + o.SetReference(reference) + return o +} + +// SetReference adds the reference to the list accessories params +func (o *ListAccessoriesParams) SetReference(reference string) { + o.Reference = reference +} + +// WithRepositoryName adds the repositoryName to the list accessories params +func (o *ListAccessoriesParams) WithRepositoryName(repositoryName string) *ListAccessoriesParams { + o.SetRepositoryName(repositoryName) + return o +} + +// SetRepositoryName adds the repositoryName to the list accessories params +func (o *ListAccessoriesParams) SetRepositoryName(repositoryName string) { + o.RepositoryName = repositoryName +} + +// WithSort adds the sort to the list accessories params +func (o *ListAccessoriesParams) WithSort(sort *string) *ListAccessoriesParams { + o.SetSort(sort) + return o +} + +// SetSort adds the sort to the list accessories params +func (o *ListAccessoriesParams) SetSort(sort *string) { + o.Sort = sort +} + +// WriteToRequest writes these params to a swagger request +func (o *ListAccessoriesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + + } + + if o.Page != nil { + + // query param page + var qrPage int64 + if o.Page != nil { + qrPage = *o.Page + } + qPage := swag.FormatInt64(qrPage) + if qPage != "" { + if err := r.SetQueryParam("page", qPage); err != nil { + return err + } + } + + } + + if o.PageSize != nil { + + // query param page_size + var qrPageSize int64 + if o.PageSize != nil { + qrPageSize = *o.PageSize + } + qPageSize := swag.FormatInt64(qrPageSize) + if qPageSize != "" { + if err := r.SetQueryParam("page_size", qPageSize); err != nil { + return err + } + } + + } + + // path param project_name + if err := r.SetPathParam("project_name", o.ProjectName); err != nil { + return err + } + + if o.Q != nil { + + // query param q + var qrQ string + if o.Q != nil { + qrQ = *o.Q + } + qQ := qrQ + if qQ != "" { + if err := r.SetQueryParam("q", qQ); err != nil { + return err + } + } + + } + + // path param reference + if err := r.SetPathParam("reference", o.Reference); err != nil { + return err + } + + // path param repository_name + if err := r.SetPathParam("repository_name", o.RepositoryName); err != nil { + return err + } + + if o.Sort != nil { + + // query param sort + var qrSort string + if o.Sort != nil { + qrSort = *o.Sort + } + qSort := qrSort + if qSort != "" { + if err := r.SetQueryParam("sort", qSort); err != nil { + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/apiv2/internal/api/client/artifact/list_accessories_responses.go b/apiv2/internal/api/client/artifact/list_accessories_responses.go new file mode 100644 index 00000000..9164e5c7 --- /dev/null +++ b/apiv2/internal/api/client/artifact/list_accessories_responses.go @@ -0,0 +1,316 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/mittwald/goharbor-client/v5/apiv2/model" +) + +// ListAccessoriesReader is a Reader for the ListAccessories structure. +type ListAccessoriesReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ListAccessoriesReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewListAccessoriesOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewListAccessoriesBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewListAccessoriesUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewListAccessoriesForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewListAccessoriesNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewListAccessoriesInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewListAccessoriesOK creates a ListAccessoriesOK with default headers values +func NewListAccessoriesOK() *ListAccessoriesOK { + return &ListAccessoriesOK{} +} + +/*ListAccessoriesOK handles this case with default header values. + +Success +*/ +type ListAccessoriesOK struct { + /*Link refers to the previous page and next page + */ + Link string + /*The total count of accessories + */ + XTotalCount int64 + + Payload []*model.Accessory +} + +func (o *ListAccessoriesOK) Error() string { + return fmt.Sprintf("[GET /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/accessories][%d] listAccessoriesOK %+v", 200, o.Payload) +} + +func (o *ListAccessoriesOK) GetPayload() []*model.Accessory { + return o.Payload +} + +func (o *ListAccessoriesOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response header Link + o.Link = response.GetHeader("Link") + + // response header X-Total-Count + xTotalCount, err := swag.ConvertInt64(response.GetHeader("X-Total-Count")) + if err != nil { + return errors.InvalidType("X-Total-Count", "header", "int64", response.GetHeader("X-Total-Count")) + } + o.XTotalCount = xTotalCount + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListAccessoriesBadRequest creates a ListAccessoriesBadRequest with default headers values +func NewListAccessoriesBadRequest() *ListAccessoriesBadRequest { + return &ListAccessoriesBadRequest{} +} + +/*ListAccessoriesBadRequest handles this case with default header values. + +Bad request +*/ +type ListAccessoriesBadRequest struct { + /*The ID of the corresponding request for the response + */ + XRequestID string + + Payload *model.Errors +} + +func (o *ListAccessoriesBadRequest) Error() string { + return fmt.Sprintf("[GET /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/accessories][%d] listAccessoriesBadRequest %+v", 400, o.Payload) +} + +func (o *ListAccessoriesBadRequest) GetPayload() *model.Errors { + return o.Payload +} + +func (o *ListAccessoriesBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response header X-Request-Id + o.XRequestID = response.GetHeader("X-Request-Id") + + o.Payload = new(model.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListAccessoriesUnauthorized creates a ListAccessoriesUnauthorized with default headers values +func NewListAccessoriesUnauthorized() *ListAccessoriesUnauthorized { + return &ListAccessoriesUnauthorized{} +} + +/*ListAccessoriesUnauthorized handles this case with default header values. + +Unauthorized +*/ +type ListAccessoriesUnauthorized struct { + /*The ID of the corresponding request for the response + */ + XRequestID string + + Payload *model.Errors +} + +func (o *ListAccessoriesUnauthorized) Error() string { + return fmt.Sprintf("[GET /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/accessories][%d] listAccessoriesUnauthorized %+v", 401, o.Payload) +} + +func (o *ListAccessoriesUnauthorized) GetPayload() *model.Errors { + return o.Payload +} + +func (o *ListAccessoriesUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response header X-Request-Id + o.XRequestID = response.GetHeader("X-Request-Id") + + o.Payload = new(model.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListAccessoriesForbidden creates a ListAccessoriesForbidden with default headers values +func NewListAccessoriesForbidden() *ListAccessoriesForbidden { + return &ListAccessoriesForbidden{} +} + +/*ListAccessoriesForbidden handles this case with default header values. + +Forbidden +*/ +type ListAccessoriesForbidden struct { + /*The ID of the corresponding request for the response + */ + XRequestID string + + Payload *model.Errors +} + +func (o *ListAccessoriesForbidden) Error() string { + return fmt.Sprintf("[GET /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/accessories][%d] listAccessoriesForbidden %+v", 403, o.Payload) +} + +func (o *ListAccessoriesForbidden) GetPayload() *model.Errors { + return o.Payload +} + +func (o *ListAccessoriesForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response header X-Request-Id + o.XRequestID = response.GetHeader("X-Request-Id") + + o.Payload = new(model.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListAccessoriesNotFound creates a ListAccessoriesNotFound with default headers values +func NewListAccessoriesNotFound() *ListAccessoriesNotFound { + return &ListAccessoriesNotFound{} +} + +/*ListAccessoriesNotFound handles this case with default header values. + +Not found +*/ +type ListAccessoriesNotFound struct { + /*The ID of the corresponding request for the response + */ + XRequestID string + + Payload *model.Errors +} + +func (o *ListAccessoriesNotFound) Error() string { + return fmt.Sprintf("[GET /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/accessories][%d] listAccessoriesNotFound %+v", 404, o.Payload) +} + +func (o *ListAccessoriesNotFound) GetPayload() *model.Errors { + return o.Payload +} + +func (o *ListAccessoriesNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response header X-Request-Id + o.XRequestID = response.GetHeader("X-Request-Id") + + o.Payload = new(model.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListAccessoriesInternalServerError creates a ListAccessoriesInternalServerError with default headers values +func NewListAccessoriesInternalServerError() *ListAccessoriesInternalServerError { + return &ListAccessoriesInternalServerError{} +} + +/*ListAccessoriesInternalServerError handles this case with default header values. + +Internal server error +*/ +type ListAccessoriesInternalServerError struct { + /*The ID of the corresponding request for the response + */ + XRequestID string + + Payload *model.Errors +} + +func (o *ListAccessoriesInternalServerError) Error() string { + return fmt.Sprintf("[GET /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/accessories][%d] listAccessoriesInternalServerError %+v", 500, o.Payload) +} + +func (o *ListAccessoriesInternalServerError) GetPayload() *model.Errors { + return o.Payload +} + +func (o *ListAccessoriesInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response header X-Request-Id + o.XRequestID = response.GetHeader("X-Request-Id") + + o.Payload = new(model.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/apiv2/internal/api/client/artifact/list_artifacts_parameters.go b/apiv2/internal/api/client/artifact/list_artifacts_parameters.go index ec82711a..10ba43ff 100644 --- a/apiv2/internal/api/client/artifact/list_artifacts_parameters.go +++ b/apiv2/internal/api/client/artifact/list_artifacts_parameters.go @@ -21,9 +21,10 @@ import ( // with the default values initialized. func NewListArtifactsParams() *ListArtifactsParams { var ( - xAcceptVulnerabilitiesDefault = string("application/vnd.security.vulnerability.report; version=1.1, application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0") + xAcceptVulnerabilitiesDefault = string("application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0") pageDefault = int64(1) pageSizeDefault = int64(10) + withAccessoryDefault = bool(false) withImmutableStatusDefault = bool(false) withLabelDefault = bool(false) withScanOverviewDefault = bool(false) @@ -34,6 +35,7 @@ func NewListArtifactsParams() *ListArtifactsParams { XAcceptVulnerabilities: &xAcceptVulnerabilitiesDefault, Page: &pageDefault, PageSize: &pageSizeDefault, + WithAccessory: &withAccessoryDefault, WithImmutableStatus: &withImmutableStatusDefault, WithLabel: &withLabelDefault, WithScanOverview: &withScanOverviewDefault, @@ -48,9 +50,10 @@ func NewListArtifactsParams() *ListArtifactsParams { // with the default values initialized, and the ability to set a timeout on a request func NewListArtifactsParamsWithTimeout(timeout time.Duration) *ListArtifactsParams { var ( - xAcceptVulnerabilitiesDefault = string("application/vnd.security.vulnerability.report; version=1.1, application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0") + xAcceptVulnerabilitiesDefault = string("application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0") pageDefault = int64(1) pageSizeDefault = int64(10) + withAccessoryDefault = bool(false) withImmutableStatusDefault = bool(false) withLabelDefault = bool(false) withScanOverviewDefault = bool(false) @@ -61,6 +64,7 @@ func NewListArtifactsParamsWithTimeout(timeout time.Duration) *ListArtifactsPara XAcceptVulnerabilities: &xAcceptVulnerabilitiesDefault, Page: &pageDefault, PageSize: &pageSizeDefault, + WithAccessory: &withAccessoryDefault, WithImmutableStatus: &withImmutableStatusDefault, WithLabel: &withLabelDefault, WithScanOverview: &withScanOverviewDefault, @@ -75,9 +79,10 @@ func NewListArtifactsParamsWithTimeout(timeout time.Duration) *ListArtifactsPara // with the default values initialized, and the ability to set a context for a request func NewListArtifactsParamsWithContext(ctx context.Context) *ListArtifactsParams { var ( - xAcceptVulnerabilitiesDefault = string("application/vnd.security.vulnerability.report; version=1.1, application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0") + xAcceptVulnerabilitiesDefault = string("application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0") pageDefault = int64(1) pageSizeDefault = int64(10) + withAccessoryDefault = bool(false) withImmutableStatusDefault = bool(false) withLabelDefault = bool(false) withScanOverviewDefault = bool(false) @@ -88,6 +93,7 @@ func NewListArtifactsParamsWithContext(ctx context.Context) *ListArtifactsParams XAcceptVulnerabilities: &xAcceptVulnerabilitiesDefault, Page: &pageDefault, PageSize: &pageSizeDefault, + WithAccessory: &withAccessoryDefault, WithImmutableStatus: &withImmutableStatusDefault, WithLabel: &withLabelDefault, WithScanOverview: &withScanOverviewDefault, @@ -102,9 +108,10 @@ func NewListArtifactsParamsWithContext(ctx context.Context) *ListArtifactsParams // with the default values initialized, and the ability to set a custom HTTPClient for a request func NewListArtifactsParamsWithHTTPClient(client *http.Client) *ListArtifactsParams { var ( - xAcceptVulnerabilitiesDefault = string("application/vnd.security.vulnerability.report; version=1.1, application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0") + xAcceptVulnerabilitiesDefault = string("application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0") pageDefault = int64(1) pageSizeDefault = int64(10) + withAccessoryDefault = bool(false) withImmutableStatusDefault = bool(false) withLabelDefault = bool(false) withScanOverviewDefault = bool(false) @@ -115,6 +122,7 @@ func NewListArtifactsParamsWithHTTPClient(client *http.Client) *ListArtifactsPar XAcceptVulnerabilities: &xAcceptVulnerabilitiesDefault, Page: &pageDefault, PageSize: &pageSizeDefault, + WithAccessory: &withAccessoryDefault, WithImmutableStatus: &withImmutableStatusDefault, WithLabel: &withLabelDefault, WithScanOverview: &withScanOverviewDefault, @@ -170,8 +178,13 @@ type ListArtifactsParams struct { */ Sort *string + /*WithAccessory + Specify whether the accessories are included of the returning artifacts. Only works when setting "with_accessory=true" + + */ + WithAccessory *bool /*WithImmutableStatus - Specify whether the immutable status is included inside the tags of the returning artifacts. Only works when setting "with_tag=true" + Specify whether the immutable status is included inside the tags of the returning artifacts. Only works when setting "with_immutable_status=true" */ WithImmutableStatus *bool @@ -322,6 +335,17 @@ func (o *ListArtifactsParams) SetSort(sort *string) { o.Sort = sort } +// WithWithAccessory adds the withAccessory to the list artifacts params +func (o *ListArtifactsParams) WithWithAccessory(withAccessory *bool) *ListArtifactsParams { + o.SetWithAccessory(withAccessory) + return o +} + +// SetWithAccessory adds the withAccessory to the list artifacts params +func (o *ListArtifactsParams) SetWithAccessory(withAccessory *bool) { + o.WithAccessory = withAccessory +} + // WithWithImmutableStatus adds the withImmutableStatus to the list artifacts params func (o *ListArtifactsParams) WithWithImmutableStatus(withImmutableStatus *bool) *ListArtifactsParams { o.SetWithImmutableStatus(withImmutableStatus) @@ -477,6 +501,22 @@ func (o *ListArtifactsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt } + if o.WithAccessory != nil { + + // query param with_accessory + var qrWithAccessory bool + if o.WithAccessory != nil { + qrWithAccessory = *o.WithAccessory + } + qWithAccessory := swag.FormatBool(qrWithAccessory) + if qWithAccessory != "" { + if err := r.SetQueryParam("with_accessory", qWithAccessory); err != nil { + return err + } + } + + } + if o.WithImmutableStatus != nil { // query param with_immutable_status diff --git a/apiv2/internal/api/client/configure/get_internalconfig_responses.go b/apiv2/internal/api/client/configure/get_internalconfig_responses.go index 56d206af..1729cd96 100644 --- a/apiv2/internal/api/client/configure/get_internalconfig_responses.go +++ b/apiv2/internal/api/client/configure/get_internalconfig_responses.go @@ -12,7 +12,7 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/goharbor/harbor/src/lib/config" + "github.com/mittwald/goharbor-client/v5/apiv2/model" ) // GetInternalconfigReader is a Reader for the GetInternalconfig structure. @@ -63,14 +63,14 @@ func NewGetInternalconfigOK() *GetInternalconfigOK { Get system configurations successfully. The response body is a map. */ type GetInternalconfigOK struct { - Payload config.InternalCfg + Payload model.InternalConfigurationsResponse } func (o *GetInternalconfigOK) Error() string { return fmt.Sprintf("[GET /internalconfig][%d] getInternalconfigOK %+v", 200, o.Payload) } -func (o *GetInternalconfigOK) GetPayload() config.InternalCfg { +func (o *GetInternalconfigOK) GetPayload() model.InternalConfigurationsResponse { return o.Payload } diff --git a/apiv2/mocks/artifact_client_service.go b/apiv2/mocks/artifact_client_service.go index 25882905..debc2fa2 100644 --- a/apiv2/mocks/artifact_client_service.go +++ b/apiv2/mocks/artifact_client_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.9.4. DO NOT EDIT. +// Code generated by mockery v2.12.1. DO NOT EDIT. package mocks @@ -7,6 +7,8 @@ import ( mock "github.com/stretchr/testify/mock" runtime "github.com/go-openapi/runtime" + + testing "testing" ) // MockArtifactClientService is an autogenerated mock type for the ClientService type @@ -198,6 +200,29 @@ func (_m *MockArtifactClientService) GetVulnerabilitiesAddition(params *artifact return r0, r1 } +// ListAccessories provides a mock function with given fields: params, authInfo +func (_m *MockArtifactClientService) ListAccessories(params *artifact.ListAccessoriesParams, authInfo runtime.ClientAuthInfoWriter) (*artifact.ListAccessoriesOK, error) { + ret := _m.Called(params, authInfo) + + var r0 *artifact.ListAccessoriesOK + if rf, ok := ret.Get(0).(func(*artifact.ListAccessoriesParams, runtime.ClientAuthInfoWriter) *artifact.ListAccessoriesOK); ok { + r0 = rf(params, authInfo) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*artifact.ListAccessoriesOK) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(*artifact.ListAccessoriesParams, runtime.ClientAuthInfoWriter) error); ok { + r1 = rf(params, authInfo) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + // ListArtifacts provides a mock function with given fields: params, authInfo func (_m *MockArtifactClientService) ListArtifacts(params *artifact.ListArtifactsParams, authInfo runtime.ClientAuthInfoWriter) (*artifact.ListArtifactsOK, error) { ret := _m.Called(params, authInfo) @@ -271,3 +296,13 @@ func (_m *MockArtifactClientService) RemoveLabel(params *artifact.RemoveLabelPar func (_m *MockArtifactClientService) SetTransport(transport runtime.ClientTransport) { _m.Called(transport) } + +// NewMockArtifactClientService creates a new instance of MockArtifactClientService. It also registers the testing.TB interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockArtifactClientService(t testing.TB) *MockArtifactClientService { + mock := &MockArtifactClientService{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/apiv2/mocks/auditlog_client_service.go b/apiv2/mocks/auditlog_client_service.go index 441e3a92..a0a0fbc7 100644 --- a/apiv2/mocks/auditlog_client_service.go +++ b/apiv2/mocks/auditlog_client_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.9.4. DO NOT EDIT. +// Code generated by mockery v2.12.1. DO NOT EDIT. package mocks @@ -7,6 +7,8 @@ import ( mock "github.com/stretchr/testify/mock" runtime "github.com/go-openapi/runtime" + + testing "testing" ) // MockAuditlogClientService is an autogenerated mock type for the ClientService type @@ -41,3 +43,13 @@ func (_m *MockAuditlogClientService) ListAuditLogs(params *auditlog.ListAuditLog func (_m *MockAuditlogClientService) SetTransport(transport runtime.ClientTransport) { _m.Called(transport) } + +// NewMockAuditlogClientService creates a new instance of MockAuditlogClientService. It also registers the testing.TB interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockAuditlogClientService(t testing.TB) *MockAuditlogClientService { + mock := &MockAuditlogClientService{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/apiv2/mocks/configure_client_service.go b/apiv2/mocks/configure_client_service.go index a95a45c0..e5b3cba6 100644 --- a/apiv2/mocks/configure_client_service.go +++ b/apiv2/mocks/configure_client_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.9.4. DO NOT EDIT. +// Code generated by mockery v2.12.1. DO NOT EDIT. package mocks @@ -7,6 +7,8 @@ import ( mock "github.com/stretchr/testify/mock" runtime "github.com/go-openapi/runtime" + + testing "testing" ) // MockConfigureClientService is an autogenerated mock type for the ClientService type @@ -87,3 +89,13 @@ func (_m *MockConfigureClientService) UpdateConfigurations(params *configure.Upd return r0, r1 } + +// NewMockConfigureClientService creates a new instance of MockConfigureClientService. It also registers the testing.TB interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockConfigureClientService(t testing.TB) *MockConfigureClientService { + mock := &MockConfigureClientService{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/apiv2/mocks/gc_client_service.go b/apiv2/mocks/gc_client_service.go index ceea62fb..9bd95d6e 100644 --- a/apiv2/mocks/gc_client_service.go +++ b/apiv2/mocks/gc_client_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.9.4. DO NOT EDIT. +// Code generated by mockery v2.12.1. DO NOT EDIT. package mocks @@ -7,6 +7,8 @@ import ( mock "github.com/stretchr/testify/mock" runtime "github.com/go-openapi/runtime" + + testing "testing" ) // MockGcClientService is an autogenerated mock type for the ClientService type @@ -156,3 +158,13 @@ func (_m *MockGcClientService) UpdateGCSchedule(params *gc.UpdateGCScheduleParam return r0, r1 } + +// NewMockGcClientService creates a new instance of MockGcClientService. It also registers the testing.TB interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockGcClientService(t testing.TB) *MockGcClientService { + mock := &MockGcClientService{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/apiv2/mocks/health_client_service.go b/apiv2/mocks/health_client_service.go index 6d477629..e6e22c17 100644 --- a/apiv2/mocks/health_client_service.go +++ b/apiv2/mocks/health_client_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.9.4. DO NOT EDIT. +// Code generated by mockery v2.12.1. DO NOT EDIT. package mocks @@ -7,6 +7,8 @@ import ( mock "github.com/stretchr/testify/mock" runtime "github.com/go-openapi/runtime" + + testing "testing" ) // MockHealthClientService is an autogenerated mock type for the ClientService type @@ -41,3 +43,13 @@ func (_m *MockHealthClientService) GetHealth(params *health.GetHealthParams, aut func (_m *MockHealthClientService) SetTransport(transport runtime.ClientTransport) { _m.Called(transport) } + +// NewMockHealthClientService creates a new instance of MockHealthClientService. It also registers the testing.TB interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockHealthClientService(t testing.TB) *MockHealthClientService { + mock := &MockHealthClientService{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/apiv2/mocks/icon_client_service.go b/apiv2/mocks/icon_client_service.go index 93645b9a..71f65eab 100644 --- a/apiv2/mocks/icon_client_service.go +++ b/apiv2/mocks/icon_client_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.9.4. DO NOT EDIT. +// Code generated by mockery v2.12.1. DO NOT EDIT. package mocks @@ -7,6 +7,8 @@ import ( mock "github.com/stretchr/testify/mock" runtime "github.com/go-openapi/runtime" + + testing "testing" ) // MockIconClientService is an autogenerated mock type for the ClientService type @@ -41,3 +43,13 @@ func (_m *MockIconClientService) GetIcon(params *icon.GetIconParams, authInfo ru func (_m *MockIconClientService) SetTransport(transport runtime.ClientTransport) { _m.Called(transport) } + +// NewMockIconClientService creates a new instance of MockIconClientService. It also registers the testing.TB interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockIconClientService(t testing.TB) *MockIconClientService { + mock := &MockIconClientService{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/apiv2/mocks/immutable_client_service.go b/apiv2/mocks/immutable_client_service.go index 85c9ec43..4e1baa53 100644 --- a/apiv2/mocks/immutable_client_service.go +++ b/apiv2/mocks/immutable_client_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.9.4. DO NOT EDIT. +// Code generated by mockery v2.12.1. DO NOT EDIT. package mocks @@ -7,6 +7,8 @@ import ( mock "github.com/stretchr/testify/mock" runtime "github.com/go-openapi/runtime" + + testing "testing" ) // MockImmutableClientService is an autogenerated mock type for the ClientService type @@ -110,3 +112,13 @@ func (_m *MockImmutableClientService) UpdateImmuRule(params *immutable.UpdateImm return r0, r1 } + +// NewMockImmutableClientService creates a new instance of MockImmutableClientService. It also registers the testing.TB interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockImmutableClientService(t testing.TB) *MockImmutableClientService { + mock := &MockImmutableClientService{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/apiv2/mocks/label_client_service.go b/apiv2/mocks/label_client_service.go index a1722c21..e8b34fbc 100644 --- a/apiv2/mocks/label_client_service.go +++ b/apiv2/mocks/label_client_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.9.4. DO NOT EDIT. +// Code generated by mockery v2.12.1. DO NOT EDIT. package mocks @@ -7,6 +7,8 @@ import ( mock "github.com/stretchr/testify/mock" runtime "github.com/go-openapi/runtime" + + testing "testing" ) // MockLabelClientService is an autogenerated mock type for the ClientService type @@ -133,3 +135,13 @@ func (_m *MockLabelClientService) UpdateLabel(params *label.UpdateLabelParams, a return r0, r1 } + +// NewMockLabelClientService creates a new instance of MockLabelClientService. It also registers the testing.TB interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockLabelClientService(t testing.TB) *MockLabelClientService { + mock := &MockLabelClientService{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/apiv2/mocks/ldap_client_service.go b/apiv2/mocks/ldap_client_service.go index 34bdd1a0..ddfa0fcd 100644 --- a/apiv2/mocks/ldap_client_service.go +++ b/apiv2/mocks/ldap_client_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.9.4. DO NOT EDIT. +// Code generated by mockery v2.12.1. DO NOT EDIT. package mocks @@ -7,6 +7,8 @@ import ( mock "github.com/stretchr/testify/mock" runtime "github.com/go-openapi/runtime" + + testing "testing" ) // MockLdapClientService is an autogenerated mock type for the ClientService type @@ -110,3 +112,13 @@ func (_m *MockLdapClientService) SearchLdapUser(params *ldap.SearchLdapUserParam func (_m *MockLdapClientService) SetTransport(transport runtime.ClientTransport) { _m.Called(transport) } + +// NewMockLdapClientService creates a new instance of MockLdapClientService. It also registers the testing.TB interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockLdapClientService(t testing.TB) *MockLdapClientService { + mock := &MockLdapClientService{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/apiv2/mocks/member_client_service.go b/apiv2/mocks/member_client_service.go index 626ea396..424534ae 100644 --- a/apiv2/mocks/member_client_service.go +++ b/apiv2/mocks/member_client_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.9.4. DO NOT EDIT. +// Code generated by mockery v2.12.1. DO NOT EDIT. package mocks @@ -7,6 +7,8 @@ import ( mock "github.com/stretchr/testify/mock" runtime "github.com/go-openapi/runtime" + + testing "testing" ) // MockMemberClientService is an autogenerated mock type for the ClientService type @@ -133,3 +135,13 @@ func (_m *MockMemberClientService) UpdateProjectMember(params *member.UpdateProj return r0, r1 } + +// NewMockMemberClientService creates a new instance of MockMemberClientService. It also registers the testing.TB interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockMemberClientService(t testing.TB) *MockMemberClientService { + mock := &MockMemberClientService{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/apiv2/mocks/oidc_client_service.go b/apiv2/mocks/oidc_client_service.go index 3910b39f..02f391d0 100644 --- a/apiv2/mocks/oidc_client_service.go +++ b/apiv2/mocks/oidc_client_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.9.4. DO NOT EDIT. +// Code generated by mockery v2.12.1. DO NOT EDIT. package mocks @@ -6,6 +6,8 @@ import ( runtime "github.com/go-openapi/runtime" oidc "github.com/mittwald/goharbor-client/v5/apiv2/internal/api/client/oidc" mock "github.com/stretchr/testify/mock" + + testing "testing" ) // MockOidcClientService is an autogenerated mock type for the ClientService type @@ -40,3 +42,13 @@ func (_m *MockOidcClientService) PingOIDC(params *oidc.PingOIDCParams, authInfo func (_m *MockOidcClientService) SetTransport(transport runtime.ClientTransport) { _m.Called(transport) } + +// NewMockOidcClientService creates a new instance of MockOidcClientService. It also registers the testing.TB interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockOidcClientService(t testing.TB) *MockOidcClientService { + mock := &MockOidcClientService{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/apiv2/mocks/ping_client_service.go b/apiv2/mocks/ping_client_service.go index f04b457a..3b73c285 100644 --- a/apiv2/mocks/ping_client_service.go +++ b/apiv2/mocks/ping_client_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.9.4. DO NOT EDIT. +// Code generated by mockery v2.12.1. DO NOT EDIT. package mocks @@ -6,6 +6,8 @@ import ( runtime "github.com/go-openapi/runtime" ping "github.com/mittwald/goharbor-client/v5/apiv2/internal/api/client/ping" mock "github.com/stretchr/testify/mock" + + testing "testing" ) // MockPingClientService is an autogenerated mock type for the ClientService type @@ -40,3 +42,13 @@ func (_m *MockPingClientService) GetPing(params *ping.GetPingParams, authInfo ru func (_m *MockPingClientService) SetTransport(transport runtime.ClientTransport) { _m.Called(transport) } + +// NewMockPingClientService creates a new instance of MockPingClientService. It also registers the testing.TB interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockPingClientService(t testing.TB) *MockPingClientService { + mock := &MockPingClientService{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/apiv2/mocks/preheat_client_service.go b/apiv2/mocks/preheat_client_service.go index 5df24e91..f4234c4a 100644 --- a/apiv2/mocks/preheat_client_service.go +++ b/apiv2/mocks/preheat_client_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.9.4. DO NOT EDIT. +// Code generated by mockery v2.12.1. DO NOT EDIT. package mocks @@ -6,6 +6,8 @@ import ( runtime "github.com/go-openapi/runtime" preheat "github.com/mittwald/goharbor-client/v5/apiv2/internal/api/client/preheat" mock "github.com/stretchr/testify/mock" + + testing "testing" ) // MockPreheatClientService is an autogenerated mock type for the ClientService type @@ -454,3 +456,13 @@ func (_m *MockPreheatClientService) UpdatePolicy(params *preheat.UpdatePolicyPar return r0, r1 } + +// NewMockPreheatClientService creates a new instance of MockPreheatClientService. It also registers the testing.TB interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockPreheatClientService(t testing.TB) *MockPreheatClientService { + mock := &MockPreheatClientService{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/apiv2/mocks/project_client_service.go b/apiv2/mocks/project_client_service.go index 7c668226..ce45e059 100644 --- a/apiv2/mocks/project_client_service.go +++ b/apiv2/mocks/project_client_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.9.4. DO NOT EDIT. +// Code generated by mockery v2.12.1. DO NOT EDIT. package mocks @@ -6,6 +6,8 @@ import ( runtime "github.com/go-openapi/runtime" project "github.com/mittwald/goharbor-client/v5/apiv2/internal/api/client/project" mock "github.com/stretchr/testify/mock" + + testing "testing" ) // MockProjectClientService is an autogenerated mock type for the ClientService type @@ -293,3 +295,13 @@ func (_m *MockProjectClientService) UpdateProject(params *project.UpdateProjectP return r0, r1 } + +// NewMockProjectClientService creates a new instance of MockProjectClientService. It also registers the testing.TB interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockProjectClientService(t testing.TB) *MockProjectClientService { + mock := &MockProjectClientService{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/apiv2/mocks/project_metadata_client_service.go b/apiv2/mocks/project_metadata_client_service.go index 8796317c..d594fb4f 100644 --- a/apiv2/mocks/project_metadata_client_service.go +++ b/apiv2/mocks/project_metadata_client_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.9.4. DO NOT EDIT. +// Code generated by mockery v2.12.1. DO NOT EDIT. package mocks @@ -6,6 +6,8 @@ import ( runtime "github.com/go-openapi/runtime" project_metadata "github.com/mittwald/goharbor-client/v5/apiv2/internal/api/client/project_metadata" mock "github.com/stretchr/testify/mock" + + testing "testing" ) // MockProject_metadataClientService is an autogenerated mock type for the ClientService type @@ -132,3 +134,13 @@ func (_m *MockProject_metadataClientService) UpdateProjectMetadata(params *proje return r0, r1 } + +// NewMockProject_metadataClientService creates a new instance of MockProject_metadataClientService. It also registers the testing.TB interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockProject_metadataClientService(t testing.TB) *MockProject_metadataClientService { + mock := &MockProject_metadataClientService{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/apiv2/mocks/quota_client_service.go b/apiv2/mocks/quota_client_service.go index 4086cfbb..6978bbef 100644 --- a/apiv2/mocks/quota_client_service.go +++ b/apiv2/mocks/quota_client_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.9.4. DO NOT EDIT. +// Code generated by mockery v2.12.1. DO NOT EDIT. package mocks @@ -6,6 +6,8 @@ import ( runtime "github.com/go-openapi/runtime" quota "github.com/mittwald/goharbor-client/v5/apiv2/internal/api/client/quota" mock "github.com/stretchr/testify/mock" + + testing "testing" ) // MockQuotaClientService is an autogenerated mock type for the ClientService type @@ -86,3 +88,13 @@ func (_m *MockQuotaClientService) UpdateQuota(params *quota.UpdateQuotaParams, a return r0, r1 } + +// NewMockQuotaClientService creates a new instance of MockQuotaClientService. It also registers the testing.TB interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockQuotaClientService(t testing.TB) *MockQuotaClientService { + mock := &MockQuotaClientService{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/apiv2/mocks/registry_client_service.go b/apiv2/mocks/registry_client_service.go index d17fea2d..9c21cf60 100644 --- a/apiv2/mocks/registry_client_service.go +++ b/apiv2/mocks/registry_client_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.9.4. DO NOT EDIT. +// Code generated by mockery v2.12.1. DO NOT EDIT. package mocks @@ -6,6 +6,8 @@ import ( runtime "github.com/go-openapi/runtime" registry "github.com/mittwald/goharbor-client/v5/apiv2/internal/api/client/registry" mock "github.com/stretchr/testify/mock" + + testing "testing" ) // MockRegistryClientService is an autogenerated mock type for the ClientService type @@ -224,3 +226,13 @@ func (_m *MockRegistryClientService) UpdateRegistry(params *registry.UpdateRegis return r0, r1 } + +// NewMockRegistryClientService creates a new instance of MockRegistryClientService. It also registers the testing.TB interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockRegistryClientService(t testing.TB) *MockRegistryClientService { + mock := &MockRegistryClientService{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/apiv2/mocks/replication_client_service.go b/apiv2/mocks/replication_client_service.go index cf4ce3d7..fbf2cfe1 100644 --- a/apiv2/mocks/replication_client_service.go +++ b/apiv2/mocks/replication_client_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.9.4. DO NOT EDIT. +// Code generated by mockery v2.12.1. DO NOT EDIT. package mocks @@ -6,6 +6,8 @@ import ( runtime "github.com/go-openapi/runtime" replication "github.com/mittwald/goharbor-client/v5/apiv2/internal/api/client/replication" mock "github.com/stretchr/testify/mock" + + testing "testing" ) // MockReplicationClientService is an autogenerated mock type for the ClientService type @@ -270,3 +272,13 @@ func (_m *MockReplicationClientService) UpdateReplicationPolicy(params *replicat return r0, r1 } + +// NewMockReplicationClientService creates a new instance of MockReplicationClientService. It also registers the testing.TB interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockReplicationClientService(t testing.TB) *MockReplicationClientService { + mock := &MockReplicationClientService{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/apiv2/mocks/repository_client_service.go b/apiv2/mocks/repository_client_service.go index c83fef1e..1a465fd5 100644 --- a/apiv2/mocks/repository_client_service.go +++ b/apiv2/mocks/repository_client_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.9.4. DO NOT EDIT. +// Code generated by mockery v2.12.1. DO NOT EDIT. package mocks @@ -6,6 +6,8 @@ import ( runtime "github.com/go-openapi/runtime" repository "github.com/mittwald/goharbor-client/v5/apiv2/internal/api/client/repository" mock "github.com/stretchr/testify/mock" + + testing "testing" ) // MockRepositoryClientService is an autogenerated mock type for the ClientService type @@ -132,3 +134,13 @@ func (_m *MockRepositoryClientService) UpdateRepository(params *repository.Updat return r0, r1 } + +// NewMockRepositoryClientService creates a new instance of MockRepositoryClientService. It also registers the testing.TB interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockRepositoryClientService(t testing.TB) *MockRepositoryClientService { + mock := &MockRepositoryClientService{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/apiv2/mocks/retention_client_service.go b/apiv2/mocks/retention_client_service.go index d11ca402..02cc93f5 100644 --- a/apiv2/mocks/retention_client_service.go +++ b/apiv2/mocks/retention_client_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.9.4. DO NOT EDIT. +// Code generated by mockery v2.12.1. DO NOT EDIT. package mocks @@ -6,6 +6,8 @@ import ( runtime "github.com/go-openapi/runtime" retention "github.com/mittwald/goharbor-client/v5/apiv2/internal/api/client/retention" mock "github.com/stretchr/testify/mock" + + testing "testing" ) // MockRetentionClientService is an autogenerated mock type for the ClientService type @@ -256,3 +258,13 @@ func (_m *MockRetentionClientService) UpdateRetention(params *retention.UpdateRe return r0, r1 } + +// NewMockRetentionClientService creates a new instance of MockRetentionClientService. It also registers the testing.TB interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockRetentionClientService(t testing.TB) *MockRetentionClientService { + mock := &MockRetentionClientService{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/apiv2/mocks/robot_client_service.go b/apiv2/mocks/robot_client_service.go index 8c48dfc2..9889fe3a 100644 --- a/apiv2/mocks/robot_client_service.go +++ b/apiv2/mocks/robot_client_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.9.4. DO NOT EDIT. +// Code generated by mockery v2.12.1. DO NOT EDIT. package mocks @@ -6,6 +6,8 @@ import ( runtime "github.com/go-openapi/runtime" robot "github.com/mittwald/goharbor-client/v5/apiv2/internal/api/client/robot" mock "github.com/stretchr/testify/mock" + + testing "testing" ) // MockRobotClientService is an autogenerated mock type for the ClientService type @@ -155,3 +157,13 @@ func (_m *MockRobotClientService) UpdateRobot(params *robot.UpdateRobotParams, a return r0, r1 } + +// NewMockRobotClientService creates a new instance of MockRobotClientService. It also registers the testing.TB interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockRobotClientService(t testing.TB) *MockRobotClientService { + mock := &MockRobotClientService{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/apiv2/mocks/robotv1_client_service.go b/apiv2/mocks/robotv1_client_service.go index fe534c06..98920237 100644 --- a/apiv2/mocks/robotv1_client_service.go +++ b/apiv2/mocks/robotv1_client_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.9.4. DO NOT EDIT. +// Code generated by mockery v2.12.1. DO NOT EDIT. package mocks @@ -6,6 +6,8 @@ import ( runtime "github.com/go-openapi/runtime" robotv1 "github.com/mittwald/goharbor-client/v5/apiv2/internal/api/client/robotv1" mock "github.com/stretchr/testify/mock" + + testing "testing" ) // MockRobotv1ClientService is an autogenerated mock type for the ClientService type @@ -132,3 +134,13 @@ func (_m *MockRobotv1ClientService) UpdateRobotV1(params *robotv1.UpdateRobotV1P return r0, r1 } + +// NewMockRobotv1ClientService creates a new instance of MockRobotv1ClientService. It also registers the testing.TB interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockRobotv1ClientService(t testing.TB) *MockRobotv1ClientService { + mock := &MockRobotv1ClientService{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/apiv2/mocks/scan_all_client_service.go b/apiv2/mocks/scan_all_client_service.go index 41e33224..200e371f 100644 --- a/apiv2/mocks/scan_all_client_service.go +++ b/apiv2/mocks/scan_all_client_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.9.4. DO NOT EDIT. +// Code generated by mockery v2.12.1. DO NOT EDIT. package mocks @@ -7,6 +7,8 @@ import ( mock "github.com/stretchr/testify/mock" scan_all "github.com/mittwald/goharbor-client/v5/apiv2/internal/api/client/scan_all" + + testing "testing" ) // MockScan_allClientService is an autogenerated mock type for the ClientService type @@ -156,3 +158,13 @@ func (_m *MockScan_allClientService) UpdateScanAllSchedule(params *scan_all.Upda return r0, r1 } + +// NewMockScan_allClientService creates a new instance of MockScan_allClientService. It also registers the testing.TB interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockScan_allClientService(t testing.TB) *MockScan_allClientService { + mock := &MockScan_allClientService{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/apiv2/mocks/scan_client_service.go b/apiv2/mocks/scan_client_service.go index d22b4ff7..ddd4d9dd 100644 --- a/apiv2/mocks/scan_client_service.go +++ b/apiv2/mocks/scan_client_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.9.4. DO NOT EDIT. +// Code generated by mockery v2.12.1. DO NOT EDIT. package mocks @@ -7,6 +7,8 @@ import ( mock "github.com/stretchr/testify/mock" scan "github.com/mittwald/goharbor-client/v5/apiv2/internal/api/client/scan" + + testing "testing" ) // MockScanClientService is an autogenerated mock type for the ClientService type @@ -87,3 +89,13 @@ func (_m *MockScanClientService) StopScanArtifact(params *scan.StopScanArtifactP return r0, r1 } + +// NewMockScanClientService creates a new instance of MockScanClientService. It also registers the testing.TB interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockScanClientService(t testing.TB) *MockScanClientService { + mock := &MockScanClientService{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/apiv2/mocks/scanner_client_service.go b/apiv2/mocks/scanner_client_service.go index ccaa3d17..bb1014a9 100644 --- a/apiv2/mocks/scanner_client_service.go +++ b/apiv2/mocks/scanner_client_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.9.4. DO NOT EDIT. +// Code generated by mockery v2.12.1. DO NOT EDIT. package mocks @@ -7,6 +7,8 @@ import ( mock "github.com/stretchr/testify/mock" scanner "github.com/mittwald/goharbor-client/v5/apiv2/internal/api/client/scanner" + + testing "testing" ) // MockScannerClientService is an autogenerated mock type for the ClientService type @@ -202,3 +204,13 @@ func (_m *MockScannerClientService) UpdateScanner(params *scanner.UpdateScannerP return r0, r1 } + +// NewMockScannerClientService creates a new instance of MockScannerClientService. It also registers the testing.TB interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockScannerClientService(t testing.TB) *MockScannerClientService { + mock := &MockScannerClientService{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/apiv2/mocks/search_client_service.go b/apiv2/mocks/search_client_service.go index ac437449..e72809d4 100644 --- a/apiv2/mocks/search_client_service.go +++ b/apiv2/mocks/search_client_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.9.4. DO NOT EDIT. +// Code generated by mockery v2.12.1. DO NOT EDIT. package mocks @@ -7,6 +7,8 @@ import ( mock "github.com/stretchr/testify/mock" search "github.com/mittwald/goharbor-client/v5/apiv2/internal/api/client/search" + + testing "testing" ) // MockSearchClientService is an autogenerated mock type for the ClientService type @@ -41,3 +43,13 @@ func (_m *MockSearchClientService) Search(params *search.SearchParams, authInfo func (_m *MockSearchClientService) SetTransport(transport runtime.ClientTransport) { _m.Called(transport) } + +// NewMockSearchClientService creates a new instance of MockSearchClientService. It also registers the testing.TB interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockSearchClientService(t testing.TB) *MockSearchClientService { + mock := &MockSearchClientService{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/apiv2/mocks/statistic_client_service.go b/apiv2/mocks/statistic_client_service.go index 9bc0ae64..8e09c292 100644 --- a/apiv2/mocks/statistic_client_service.go +++ b/apiv2/mocks/statistic_client_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.9.4. DO NOT EDIT. +// Code generated by mockery v2.12.1. DO NOT EDIT. package mocks @@ -7,6 +7,8 @@ import ( mock "github.com/stretchr/testify/mock" statistic "github.com/mittwald/goharbor-client/v5/apiv2/internal/api/client/statistic" + + testing "testing" ) // MockStatisticClientService is an autogenerated mock type for the ClientService type @@ -41,3 +43,13 @@ func (_m *MockStatisticClientService) GetStatistic(params *statistic.GetStatisti func (_m *MockStatisticClientService) SetTransport(transport runtime.ClientTransport) { _m.Called(transport) } + +// NewMockStatisticClientService creates a new instance of MockStatisticClientService. It also registers the testing.TB interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockStatisticClientService(t testing.TB) *MockStatisticClientService { + mock := &MockStatisticClientService{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/apiv2/mocks/system_cve_allowlist_client_service.go b/apiv2/mocks/system_cve_allowlist_client_service.go index 28b4eaf1..39e8b4fa 100644 --- a/apiv2/mocks/system_cve_allowlist_client_service.go +++ b/apiv2/mocks/system_cve_allowlist_client_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.9.4. DO NOT EDIT. +// Code generated by mockery v2.12.1. DO NOT EDIT. package mocks @@ -7,6 +7,8 @@ import ( mock "github.com/stretchr/testify/mock" system_cve_allowlist "github.com/mittwald/goharbor-client/v5/apiv2/internal/api/client/system_cve_allowlist" + + testing "testing" ) // MockSystem_cve_allowlistClientService is an autogenerated mock type for the ClientService type @@ -64,3 +66,13 @@ func (_m *MockSystem_cve_allowlistClientService) PutSystemCVEAllowlist(params *s func (_m *MockSystem_cve_allowlistClientService) SetTransport(transport runtime.ClientTransport) { _m.Called(transport) } + +// NewMockSystem_cve_allowlistClientService creates a new instance of MockSystem_cve_allowlistClientService. It also registers the testing.TB interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockSystem_cve_allowlistClientService(t testing.TB) *MockSystem_cve_allowlistClientService { + mock := &MockSystem_cve_allowlistClientService{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/apiv2/mocks/systeminfo_client_service.go b/apiv2/mocks/systeminfo_client_service.go index 8e4039e5..a83fe505 100644 --- a/apiv2/mocks/systeminfo_client_service.go +++ b/apiv2/mocks/systeminfo_client_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.9.4. DO NOT EDIT. +// Code generated by mockery v2.12.1. DO NOT EDIT. package mocks @@ -9,6 +9,8 @@ import ( mock "github.com/stretchr/testify/mock" systeminfo "github.com/mittwald/goharbor-client/v5/apiv2/internal/api/client/systeminfo" + + testing "testing" ) // MockSysteminfoClientService is an autogenerated mock type for the ClientService type @@ -89,3 +91,13 @@ func (_m *MockSysteminfoClientService) GetVolumes(params *systeminfo.GetVolumesP func (_m *MockSysteminfoClientService) SetTransport(transport runtime.ClientTransport) { _m.Called(transport) } + +// NewMockSysteminfoClientService creates a new instance of MockSysteminfoClientService. It also registers the testing.TB interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockSysteminfoClientService(t testing.TB) *MockSysteminfoClientService { + mock := &MockSysteminfoClientService{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/apiv2/mocks/user_client_service.go b/apiv2/mocks/user_client_service.go index bbe65c24..ec51aac9 100644 --- a/apiv2/mocks/user_client_service.go +++ b/apiv2/mocks/user_client_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.9.4. DO NOT EDIT. +// Code generated by mockery v2.12.1. DO NOT EDIT. package mocks @@ -6,6 +6,8 @@ import ( runtime "github.com/go-openapi/runtime" mock "github.com/stretchr/testify/mock" + testing "testing" + user "github.com/mittwald/goharbor-client/v5/apiv2/internal/api/client/user" ) @@ -271,3 +273,13 @@ func (_m *MockUserClientService) UpdateUserProfile(params *user.UpdateUserProfil return r0, r1 } + +// NewMockUserClientService creates a new instance of MockUserClientService. It also registers the testing.TB interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockUserClientService(t testing.TB) *MockUserClientService { + mock := &MockUserClientService{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/apiv2/mocks/usergroup_client_service.go b/apiv2/mocks/usergroup_client_service.go index 36eb09ea..962d05b7 100644 --- a/apiv2/mocks/usergroup_client_service.go +++ b/apiv2/mocks/usergroup_client_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.9.4. DO NOT EDIT. +// Code generated by mockery v2.12.1. DO NOT EDIT. package mocks @@ -6,6 +6,8 @@ import ( runtime "github.com/go-openapi/runtime" mock "github.com/stretchr/testify/mock" + testing "testing" + usergroup "github.com/mittwald/goharbor-client/v5/apiv2/internal/api/client/usergroup" ) @@ -156,3 +158,13 @@ func (_m *MockUsergroupClientService) UpdateUserGroup(params *usergroup.UpdateUs return r0, r1 } + +// NewMockUsergroupClientService creates a new instance of MockUsergroupClientService. It also registers the testing.TB interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockUsergroupClientService(t testing.TB) *MockUsergroupClientService { + mock := &MockUsergroupClientService{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/apiv2/mocks/webhook_client_service.go b/apiv2/mocks/webhook_client_service.go index fac617e9..6c0d8c71 100644 --- a/apiv2/mocks/webhook_client_service.go +++ b/apiv2/mocks/webhook_client_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.9.4. DO NOT EDIT. +// Code generated by mockery v2.12.1. DO NOT EDIT. package mocks @@ -6,6 +6,8 @@ import ( runtime "github.com/go-openapi/runtime" mock "github.com/stretchr/testify/mock" + testing "testing" + webhook "github.com/mittwald/goharbor-client/v5/apiv2/internal/api/client/webhook" ) @@ -179,3 +181,13 @@ func (_m *MockWebhookClientService) UpdateWebhookPolicyOfProject(params *webhook return r0, r1 } + +// NewMockWebhookClientService creates a new instance of MockWebhookClientService. It also registers the testing.TB interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockWebhookClientService(t testing.TB) *MockWebhookClientService { + mock := &MockWebhookClientService{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/apiv2/mocks/webhookjob_client_service.go b/apiv2/mocks/webhookjob_client_service.go index 462c103e..6f51cfe0 100644 --- a/apiv2/mocks/webhookjob_client_service.go +++ b/apiv2/mocks/webhookjob_client_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.9.4. DO NOT EDIT. +// Code generated by mockery v2.12.1. DO NOT EDIT. package mocks @@ -6,6 +6,8 @@ import ( runtime "github.com/go-openapi/runtime" mock "github.com/stretchr/testify/mock" + testing "testing" + webhookjob "github.com/mittwald/goharbor-client/v5/apiv2/internal/api/client/webhookjob" ) @@ -41,3 +43,13 @@ func (_m *MockWebhookjobClientService) ListWebhookJobs(params *webhookjob.ListWe func (_m *MockWebhookjobClientService) SetTransport(transport runtime.ClientTransport) { _m.Called(transport) } + +// NewMockWebhookjobClientService creates a new instance of MockWebhookjobClientService. It also registers the testing.TB interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockWebhookjobClientService(t testing.TB) *MockWebhookjobClientService { + mock := &MockWebhookjobClientService{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/apiv2/model/accessory.go b/apiv2/model/accessory.go new file mode 100644 index 00000000..d0df5ed2 --- /dev/null +++ b/apiv2/model/accessory.go @@ -0,0 +1,89 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Accessory The accessory of the artifact +// +// swagger:model Accessory +type Accessory struct { + + // The artifact id of the accessory + ArtifactID int64 `json:"artifact_id"` + + // The creation time of the accessory + // Format: date-time + CreationTime strfmt.DateTime `json:"creation_time,omitempty"` + + // The artifact digest of the accessory + Digest string `json:"digest"` + + // The icon of the accessory + Icon string `json:"icon"` + + // The ID of the accessory + ID int64 `json:"id,omitempty"` + + // The artifact size of the accessory + Size int64 `json:"size"` + + // The subject artifact id of the accessory + SubjectArtifactID int64 `json:"subject_artifact_id"` + + // The artifact size of the accessory + Type string `json:"type"` +} + +// Validate validates this accessory +func (m *Accessory) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCreationTime(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Accessory) validateCreationTime(formats strfmt.Registry) error { + + if swag.IsZero(m.CreationTime) { // not required + return nil + } + + if err := validate.FormatOf("creation_time", "body", "date-time", m.CreationTime.String(), formats); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Accessory) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Accessory) UnmarshalBinary(b []byte) error { + var res Accessory + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/apiv2/model/artifact.go b/apiv2/model/artifact.go index 0a3d4a19..83188f86 100644 --- a/apiv2/model/artifact.go +++ b/apiv2/model/artifact.go @@ -19,6 +19,9 @@ import ( // swagger:model Artifact type Artifact struct { + // accessories + Accessories []*Accessory `json:"accessories"` + // addition links AdditionLinks AdditionLinks `json:"addition_links,omitempty"` @@ -80,6 +83,10 @@ type Artifact struct { func (m *Artifact) Validate(formats strfmt.Registry) error { var res []error + if err := m.validateAccessories(formats); err != nil { + res = append(res, err) + } + if err := m.validateAdditionLinks(formats); err != nil { res = append(res, err) } @@ -122,6 +129,31 @@ func (m *Artifact) Validate(formats strfmt.Registry) error { return nil } +func (m *Artifact) validateAccessories(formats strfmt.Registry) error { + + if swag.IsZero(m.Accessories) { // not required + return nil + } + + for i := 0; i < len(m.Accessories); i++ { + if swag.IsZero(m.Accessories[i]) { // not required + continue + } + + if m.Accessories[i] != nil { + if err := m.Accessories[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("accessories" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + func (m *Artifact) validateAdditionLinks(formats strfmt.Registry) error { if swag.IsZero(m.AdditionLinks) { // not required diff --git a/apiv2/model/general_info.go b/apiv2/model/general_info.go index 8c142d2c..752ec5ce 100644 --- a/apiv2/model/general_info.go +++ b/apiv2/model/general_info.go @@ -9,6 +9,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" + "github.com/go-openapi/validate" ) // GeneralInfo general info @@ -22,6 +23,10 @@ type GeneralInfo struct { // The setting of auth proxy this is only available when Harbor relies on authproxy for authentication. AuthproxySettings *AuthproxySetting `json:"authproxy_settings,omitempty"` + // The current time of the server. + // Format: date-time + CurrentTime *strfmt.DateTime `json:"current_time,omitempty"` + // The external URL of Harbor, with protocol. ExternalURL *string `json:"external_url,omitempty"` @@ -64,6 +69,10 @@ func (m *GeneralInfo) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateCurrentTime(formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -88,6 +97,19 @@ func (m *GeneralInfo) validateAuthproxySettings(formats strfmt.Registry) error { return nil } +func (m *GeneralInfo) validateCurrentTime(formats strfmt.Registry) error { + + if swag.IsZero(m.CurrentTime) { // not required + return nil + } + + if err := validate.FormatOf("current_time", "body", "date-time", m.CurrentTime.String(), formats); err != nil { + return err + } + + return nil +} + // MarshalBinary interface implementation func (m *GeneralInfo) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/apiv2/model/internal_configuration_value.go b/apiv2/model/internal_configuration_value.go new file mode 100644 index 00000000..c21a6346 --- /dev/null +++ b/apiv2/model/internal_configuration_value.go @@ -0,0 +1,46 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// InternalConfigurationValue internal configuration value +// +// swagger:model InternalConfigurationValue +type InternalConfigurationValue struct { + + // The configure item can be updated or not + Editable bool `json:"editable"` + + // The value of current config item + Value interface{} `json:"value,omitempty"` +} + +// Validate validates this internal configuration value +func (m *InternalConfigurationValue) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *InternalConfigurationValue) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *InternalConfigurationValue) UnmarshalBinary(b []byte) error { + var res InternalConfigurationValue + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/apiv2/model/internal_configurations_response.go b/apiv2/model/internal_configurations_response.go new file mode 100644 index 00000000..6f2bcaf1 --- /dev/null +++ b/apiv2/model/internal_configurations_response.go @@ -0,0 +1,40 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// InternalConfigurationsResponse internal configurations response +// +// swagger:model InternalConfigurationsResponse +type InternalConfigurationsResponse map[string]InternalConfigurationValue + +// Validate validates this internal configurations response +func (m InternalConfigurationsResponse) Validate(formats strfmt.Registry) error { + var res []error + + for k := range m { + + if err := validate.Required(k, "body", m[k]); err != nil { + return err + } + if val, ok := m[k]; ok { + if err := val.Validate(formats); err != nil { + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/apiv2/model/project_metadata.go b/apiv2/model/project_metadata.go index 823f8f38..8e010d54 100644 --- a/apiv2/model/project_metadata.go +++ b/apiv2/model/project_metadata.go @@ -21,6 +21,9 @@ type ProjectMetadata struct { // Whether content trust is enabled or not. If it is enabled, user can't pull unsigned images from this project. The valid values are "true", "false". EnableContentTrust *string `json:"enable_content_trust,omitempty"` + // Whether cosign content trust is enabled or not. If it is enabled, user can't pull images without cosign signature from this project. The valid values are "true", "false". + EnableContentTrustCosign *string `json:"enable_content_trust_cosign,omitempty"` + // Whether prevent the vulnerable images from running. The valid values are "true", "false". PreventVul *string `json:"prevent_vul,omitempty"` diff --git a/apiv2/model/project_summary_quota.go b/apiv2/model/project_summary_quota.go index f0a91f5e..eb4134d6 100644 --- a/apiv2/model/project_summary_quota.go +++ b/apiv2/model/project_summary_quota.go @@ -9,7 +9,6 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - "github.com/goharbor/harbor/src/pkg/quota/types" ) // ProjectSummaryQuota project summary quota @@ -18,10 +17,10 @@ import ( type ProjectSummaryQuota struct { // The hard limits of the quota - Hard types.ResourceList `json:"hard,omitempty"` + Hard ResourceList `json:"hard,omitempty"` // The used status of the quota - Used types.ResourceList `json:"used,omitempty"` + Used ResourceList `json:"used,omitempty"` } // Validate validates this project summary quota diff --git a/apiv2/model/quota.go b/apiv2/model/quota.go index 55cd7832..f2a18299 100644 --- a/apiv2/model/quota.go +++ b/apiv2/model/quota.go @@ -10,7 +10,6 @@ import ( "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - "github.com/goharbor/harbor/src/pkg/quota/types" ) // Quota The quota object @@ -23,7 +22,7 @@ type Quota struct { CreationTime strfmt.DateTime `json:"creation_time,omitempty"` // The hard limits of the quota - Hard types.ResourceList `json:"hard,omitempty"` + Hard ResourceList `json:"hard,omitempty"` // ID of the quota ID int64 `json:"id,omitempty"` @@ -36,7 +35,7 @@ type Quota struct { UpdateTime strfmt.DateTime `json:"update_time,omitempty"` // The used status of the quota - Used types.ResourceList `json:"used,omitempty"` + Used ResourceList `json:"used,omitempty"` } // Validate validates this quota diff --git a/apiv2/model/quota_update_req.go b/apiv2/model/quota_update_req.go index bc105cd1..3a4d87ca 100644 --- a/apiv2/model/quota_update_req.go +++ b/apiv2/model/quota_update_req.go @@ -9,7 +9,6 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - "github.com/goharbor/harbor/src/pkg/quota/types" ) // QuotaUpdateReq quota update req @@ -18,7 +17,7 @@ import ( type QuotaUpdateReq struct { // The new hard limits for the quota - Hard types.ResourceList `json:"hard,omitempty"` + Hard ResourceList `json:"hard,omitempty"` } // Validate validates this quota update req diff --git a/apiv2/model/resource_list.go b/apiv2/model/resource_list.go new file mode 100644 index 00000000..53193c37 --- /dev/null +++ b/apiv2/model/resource_list.go @@ -0,0 +1,20 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" +) + +// ResourceList resource list +// +// swagger:model ResourceList +type ResourceList map[string]int64 + +// Validate validates this resource list +func (m ResourceList) Validate(formats strfmt.Registry) error { + return nil +} diff --git a/apiv2/pkg/clients/quota/quota.go b/apiv2/pkg/clients/quota/quota.go index 09f87f0c..cc72f9c3 100644 --- a/apiv2/pkg/clients/quota/quota.go +++ b/apiv2/pkg/clients/quota/quota.go @@ -91,8 +91,8 @@ func (c *RESTClient) UpdateStorageQuotaByProjectID(ctx context.Context, projectI params := "a.UpdateQuotaParams{ Hard: &modelv2.QuotaUpdateReq{ - Hard: map[types.ResourceName]int64{ - types.ResourceStorage: storageLimit, + Hard: modelv2.ResourceList{ + string(types.ResourceStorage): storageLimit, }, }, ID: projectID, From 1ae5ad288ea53717cc5f98a0d090f66c7f6eab37 Mon Sep 17 00:00:00 2001 From: Eike David Lenz Date: Wed, 4 May 2022 14:28:03 +0200 Subject: [PATCH 2/2] fix unit tests --- apiv2/pkg/clients/quota/quota_test.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/apiv2/pkg/clients/quota/quota_test.go b/apiv2/pkg/clients/quota/quota_test.go index fa31e827..67b05b34 100644 --- a/apiv2/pkg/clients/quota/quota_test.go +++ b/apiv2/pkg/clients/quota/quota_test.go @@ -82,8 +82,8 @@ func TestRESTClient_GetQuotaByProjectID(t *testing.T) { mock.AnythingOfType("runtime.ClientAuthInfoWriterFunc")). Return("a.ListQuotasOK{ Payload: []*modelv2.Quota{{ - Hard: types.ResourceList{ - types.ResourceStorage: 10, + Hard: modelv2.ResourceList{ + string(types.ResourceStorage): 10, }, ID: exampleProjectID, Ref: modelv2.QuotaRefObject(map[string]interface{}{ @@ -108,8 +108,8 @@ func TestRESTClient_UpdateStorageQuotaByProjectID(t *testing.T) { t.Run("PositiveLimit", func(t *testing.T) { updateParams := "a.UpdateQuotaParams{ Hard: &modelv2.QuotaUpdateReq{ - Hard: map[types.ResourceName]int64{ - types.ResourceStorage: testStorageLimitPositive, + Hard: modelv2.ResourceList{ + string(types.ResourceStorage): testStorageLimitPositive, }, }, ID: exampleQuotaID, @@ -132,8 +132,8 @@ func TestRESTClient_UpdateStorageQuotaByProjectID(t *testing.T) { t.Run("NegativeLimit", func(t *testing.T) { updateParams := "a.UpdateQuotaParams{ Hard: &modelv2.QuotaUpdateReq{ - Hard: map[types.ResourceName]int64{ - types.ResourceStorage: testStorageLimitNegative, + Hard: modelv2.ResourceList{ + string(types.ResourceStorage): testStorageLimitNegative, }, }, ID: exampleQuotaID, @@ -156,8 +156,8 @@ func TestRESTClient_UpdateStorageQuotaByProjectID(t *testing.T) { t.Run("NullLimit", func(t *testing.T) { updateParams := "a.UpdateQuotaParams{ Hard: &modelv2.QuotaUpdateReq{ - Hard: map[types.ResourceName]int64{ - types.ResourceStorage: testStorageLimitNegative, + Hard: modelv2.ResourceList{ + string(types.ResourceStorage): testStorageLimitNegative, }, }, ID: exampleQuotaID,