mirror of
https://github.com/goharbor/harbor.git
synced 2025-01-13 19:21:56 +01:00
fix: remove x-go-type in swagger.yaml (#15923)
Closes #15912 Signed-off-by: He Weiwei <hweiwei@vmware.com>
This commit is contained in:
parent
71ee8b57c2
commit
b2268dbf8e
@ -2742,7 +2742,7 @@ paths:
|
|||||||
type: integer
|
type: integer
|
||||||
Link:
|
Link:
|
||||||
description: Link to previous page and next page
|
description: Link to previous page and next page
|
||||||
type: string
|
type: string
|
||||||
'401':
|
'401':
|
||||||
$ref: '#/responses/401'
|
$ref: '#/responses/401'
|
||||||
'403':
|
'403':
|
||||||
@ -6773,10 +6773,6 @@ definitions:
|
|||||||
additionalProperties:
|
additionalProperties:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
x-go-type:
|
|
||||||
type: ResourceList
|
|
||||||
import:
|
|
||||||
package: "github.com/goharbor/harbor/src/pkg/quota/types"
|
|
||||||
ReplicationExecution:
|
ReplicationExecution:
|
||||||
type: object
|
type: object
|
||||||
description: The replication execution
|
description: The replication execution
|
||||||
@ -7794,7 +7790,7 @@ definitions:
|
|||||||
description: The name of the user group
|
description: The name of the user group
|
||||||
group_type:
|
group_type:
|
||||||
type: integer
|
type: integer
|
||||||
description: 'The group type, 1 for LDAP group, 2 for HTTP group.'
|
description: 'The group type, 1 for LDAP group, 2 for HTTP group.'
|
||||||
SupportedWebhookEventTypes:
|
SupportedWebhookEventTypes:
|
||||||
type: object
|
type: object
|
||||||
description: Supportted webhook event types and notify types.
|
description: Supportted webhook event types and notify types.
|
||||||
@ -7927,10 +7923,18 @@ definitions:
|
|||||||
format: date-time
|
format: date-time
|
||||||
InternalConfigurationsResponse:
|
InternalConfigurationsResponse:
|
||||||
type: object
|
type: object
|
||||||
x-go-type:
|
additionalProperties:
|
||||||
type: InternalCfg
|
$ref: '#/definitions/InternalConfigurationValue'
|
||||||
import:
|
InternalConfigurationValue:
|
||||||
package: "github.com/goharbor/harbor/src/lib/config"
|
type: object
|
||||||
|
properties:
|
||||||
|
value:
|
||||||
|
type: object
|
||||||
|
description: The value of current config item
|
||||||
|
editable:
|
||||||
|
type: boolean
|
||||||
|
x-omitempty: false
|
||||||
|
description: The configure item can be updated or not
|
||||||
ConfigurationsResponse:
|
ConfigurationsResponse:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
@ -8105,280 +8109,280 @@ definitions:
|
|||||||
description: 'The parameters of the policy, the values are dependent on the type of the policy.'
|
description: 'The parameters of the policy, the values are dependent on the type of the policy.'
|
||||||
Configurations:
|
Configurations:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
auth_mode:
|
auth_mode:
|
||||||
type: string
|
type: string
|
||||||
description: The auth mode of current system, such as "db_auth", "ldap_auth", "oidc_auth"
|
description: The auth mode of current system, such as "db_auth", "ldap_auth", "oidc_auth"
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
email_from:
|
email_from:
|
||||||
type: string
|
type: string
|
||||||
description: The sender name for Email notification.
|
description: The sender name for Email notification.
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
email_host:
|
email_host:
|
||||||
type: string
|
type: string
|
||||||
description: The hostname of SMTP server that sends Email notification.
|
description: The hostname of SMTP server that sends Email notification.
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
email_identity:
|
email_identity:
|
||||||
type: string
|
type: string
|
||||||
description: By default it's empty so the email_username is picked
|
description: By default it's empty so the email_username is picked
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
email_insecure:
|
email_insecure:
|
||||||
type: boolean
|
type: boolean
|
||||||
description: Whether or not the certificate will be verified when Harbor tries to access the email server.
|
description: Whether or not the certificate will be verified when Harbor tries to access the email server.
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
email_password:
|
email_password:
|
||||||
type: string
|
type: string
|
||||||
description: Email password
|
description: Email password
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
email_port:
|
email_port:
|
||||||
type: integer
|
type: integer
|
||||||
description: The port of SMTP server
|
description: The port of SMTP server
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
email_ssl:
|
email_ssl:
|
||||||
type: boolean
|
type: boolean
|
||||||
description: When it''s set to true the system will access Email server via TLS by default. If it''s set to false, it still will handle "STARTTLS" from server side.
|
description: When it''s set to true the system will access Email server via TLS by default. If it''s set to false, it still will handle "STARTTLS" from server side.
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
email_username:
|
email_username:
|
||||||
type: string
|
type: string
|
||||||
description: The username for authenticate against SMTP server
|
description: The username for authenticate against SMTP server
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
ldap_base_dn:
|
ldap_base_dn:
|
||||||
type: string
|
type: string
|
||||||
description: The Base DN for LDAP binding.
|
description: The Base DN for LDAP binding.
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
ldap_filter:
|
ldap_filter:
|
||||||
type: string
|
type: string
|
||||||
description: The filter for LDAP search
|
description: The filter for LDAP search
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
ldap_group_base_dn:
|
ldap_group_base_dn:
|
||||||
type: string
|
type: string
|
||||||
description: The base DN to search LDAP group.
|
description: The base DN to search LDAP group.
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
ldap_group_admin_dn:
|
ldap_group_admin_dn:
|
||||||
type: string
|
type: string
|
||||||
description: Specify the ldap group which have the same privilege with Harbor admin
|
description: Specify the ldap group which have the same privilege with Harbor admin
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
ldap_group_attribute_name:
|
ldap_group_attribute_name:
|
||||||
type: string
|
type: string
|
||||||
description: The attribute which is used as identity of the LDAP group, default is cn.'
|
description: The attribute which is used as identity of the LDAP group, default is cn.'
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
ldap_group_search_filter:
|
ldap_group_search_filter:
|
||||||
type: string
|
type: string
|
||||||
description: The filter to search the ldap group
|
description: The filter to search the ldap group
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
ldap_group_search_scope:
|
ldap_group_search_scope:
|
||||||
type: integer
|
type: integer
|
||||||
description: The scope to search ldap group. ''0-LDAP_SCOPE_BASE, 1-LDAP_SCOPE_ONELEVEL, 2-LDAP_SCOPE_SUBTREE''
|
description: The scope to search ldap group. ''0-LDAP_SCOPE_BASE, 1-LDAP_SCOPE_ONELEVEL, 2-LDAP_SCOPE_SUBTREE''
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
ldap_scope:
|
ldap_scope:
|
||||||
type: integer
|
type: integer
|
||||||
description: The scope to search ldap users,'0-LDAP_SCOPE_BASE, 1-LDAP_SCOPE_ONELEVEL, 2-LDAP_SCOPE_SUBTREE'
|
description: The scope to search ldap users,'0-LDAP_SCOPE_BASE, 1-LDAP_SCOPE_ONELEVEL, 2-LDAP_SCOPE_SUBTREE'
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
ldap_search_dn:
|
ldap_search_dn:
|
||||||
type: string
|
type: string
|
||||||
description: The DN of the user to do the search.
|
description: The DN of the user to do the search.
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
ldap_search_password:
|
ldap_search_password:
|
||||||
type: string
|
type: string
|
||||||
description: The password of the ldap search dn
|
description: The password of the ldap search dn
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
ldap_timeout:
|
ldap_timeout:
|
||||||
type: integer
|
type: integer
|
||||||
description: Timeout in seconds for connection to LDAP server
|
description: Timeout in seconds for connection to LDAP server
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
ldap_uid:
|
ldap_uid:
|
||||||
type: string
|
type: string
|
||||||
description: The attribute which is used as identity for the LDAP binding, such as "CN" or "SAMAccountname"
|
description: The attribute which is used as identity for the LDAP binding, such as "CN" or "SAMAccountname"
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
ldap_url:
|
ldap_url:
|
||||||
type: string
|
type: string
|
||||||
description: The URL of LDAP server
|
description: The URL of LDAP server
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
ldap_verify_cert:
|
ldap_verify_cert:
|
||||||
type: boolean
|
type: boolean
|
||||||
description: Whether verify your OIDC server certificate, disable it if your OIDC server is hosted via self-hosted certificate.
|
description: Whether verify your OIDC server certificate, disable it if your OIDC server is hosted via self-hosted certificate.
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
ldap_group_membership_attribute:
|
ldap_group_membership_attribute:
|
||||||
type: string
|
type: string
|
||||||
description: The user attribute to identify the group membership
|
description: The user attribute to identify the group membership
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
project_creation_restriction:
|
project_creation_restriction:
|
||||||
type: string
|
type: string
|
||||||
description: Indicate who can create projects, it could be ''adminonly'' or ''everyone''.
|
description: Indicate who can create projects, it could be ''adminonly'' or ''everyone''.
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
read_only:
|
read_only:
|
||||||
type: boolean
|
type: boolean
|
||||||
description: The flag to indicate whether Harbor is in readonly mode.
|
description: The flag to indicate whether Harbor is in readonly mode.
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
self_registration:
|
self_registration:
|
||||||
type: boolean
|
type: boolean
|
||||||
description: Whether the Harbor instance supports self-registration. If it''s set to false, admin need to add user to the instance.
|
description: Whether the Harbor instance supports self-registration. If it''s set to false, admin need to add user to the instance.
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
token_expiration:
|
token_expiration:
|
||||||
type: integer
|
type: integer
|
||||||
description: The expiration time of the token for internal Registry, in minutes.
|
description: The expiration time of the token for internal Registry, in minutes.
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
uaa_client_id:
|
uaa_client_id:
|
||||||
type: string
|
type: string
|
||||||
description: The client id of UAA
|
description: The client id of UAA
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
uaa_client_secret:
|
uaa_client_secret:
|
||||||
type: string
|
type: string
|
||||||
description: The client secret of the UAA
|
description: The client secret of the UAA
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
uaa_endpoint:
|
uaa_endpoint:
|
||||||
type: string
|
type: string
|
||||||
description: The endpoint of the UAA
|
description: The endpoint of the UAA
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
uaa_verify_cert:
|
uaa_verify_cert:
|
||||||
type: boolean
|
type: boolean
|
||||||
description: Verify the certificate in UAA server
|
description: Verify the certificate in UAA server
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
http_authproxy_endpoint:
|
http_authproxy_endpoint:
|
||||||
type: string
|
type: string
|
||||||
description: The endpoint of the HTTP auth
|
description: The endpoint of the HTTP auth
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
http_authproxy_tokenreview_endpoint:
|
http_authproxy_tokenreview_endpoint:
|
||||||
type: string
|
type: string
|
||||||
description: The token review endpoint
|
description: The token review endpoint
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
http_authproxy_admin_groups:
|
http_authproxy_admin_groups:
|
||||||
type: string
|
type: string
|
||||||
description: The group which has the harbor admin privileges
|
description: The group which has the harbor admin privileges
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
http_authproxy_admin_usernames:
|
http_authproxy_admin_usernames:
|
||||||
type: string
|
type: string
|
||||||
description: The username which has the harbor admin privileges
|
description: The username which has the harbor admin privileges
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
http_authproxy_verify_cert:
|
http_authproxy_verify_cert:
|
||||||
type: boolean
|
type: boolean
|
||||||
description: Verify the HTTP auth provider's certificate
|
description: Verify the HTTP auth provider's certificate
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
http_authproxy_skip_search:
|
http_authproxy_skip_search:
|
||||||
type: boolean
|
type: boolean
|
||||||
description: Search user before onboard
|
description: Search user before onboard
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
http_authproxy_server_certificate:
|
http_authproxy_server_certificate:
|
||||||
type: string
|
type: string
|
||||||
description: The certificate of the HTTP auth provider
|
description: The certificate of the HTTP auth provider
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
oidc_name:
|
oidc_name:
|
||||||
type: string
|
type: string
|
||||||
description: The OIDC provider name
|
description: The OIDC provider name
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
oidc_endpoint:
|
oidc_endpoint:
|
||||||
type: string
|
type: string
|
||||||
description: The endpoint of the OIDC provider
|
description: The endpoint of the OIDC provider
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
oidc_client_id:
|
oidc_client_id:
|
||||||
type: string
|
type: string
|
||||||
description: The client ID of the OIDC provider
|
description: The client ID of the OIDC provider
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
oidc_client_secret:
|
oidc_client_secret:
|
||||||
type: string
|
type: string
|
||||||
description: The OIDC provider secret
|
description: The OIDC provider secret
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
oidc_groups_claim:
|
oidc_groups_claim:
|
||||||
type: string
|
type: string
|
||||||
description: The attribute claims the group name
|
description: The attribute claims the group name
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
oidc_admin_group:
|
oidc_admin_group:
|
||||||
type: string
|
type: string
|
||||||
description: The OIDC group which has the harbor admin privileges
|
description: The OIDC group which has the harbor admin privileges
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
oidc_scope:
|
oidc_scope:
|
||||||
type: string
|
type: string
|
||||||
description: The scope of the OIDC provider
|
description: The scope of the OIDC provider
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
oidc_user_claim:
|
oidc_user_claim:
|
||||||
type: string
|
type: string
|
||||||
description: The attribute claims the username
|
description: The attribute claims the username
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
oidc_verify_cert:
|
oidc_verify_cert:
|
||||||
type: boolean
|
type: boolean
|
||||||
description: Verify the OIDC provider's certificate'
|
description: Verify the OIDC provider's certificate'
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
oidc_auto_onboard:
|
oidc_auto_onboard:
|
||||||
type: boolean
|
type: boolean
|
||||||
description: Auto onboard the OIDC user
|
description: Auto onboard the OIDC user
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
oidc_extra_redirect_parms:
|
oidc_extra_redirect_parms:
|
||||||
type: string
|
type: string
|
||||||
description: Extra parameters to add when redirect request to OIDC provider
|
description: Extra parameters to add when redirect request to OIDC provider
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
robot_token_duration:
|
robot_token_duration:
|
||||||
type: integer
|
type: integer
|
||||||
description: The robot account token duration in days
|
description: The robot account token duration in days
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
robot_name_prefix:
|
robot_name_prefix:
|
||||||
type: string
|
type: string
|
||||||
description: The rebot account name prefix
|
description: The rebot account name prefix
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
notification_enable:
|
notification_enable:
|
||||||
type: boolean
|
type: boolean
|
||||||
description: Enable notification
|
description: Enable notification
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
quota_per_project_enable:
|
quota_per_project_enable:
|
||||||
type: boolean
|
type: boolean
|
||||||
description: Enable quota per project
|
description: Enable quota per project
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
storage_per_project:
|
storage_per_project:
|
||||||
type: integer
|
type: integer
|
||||||
description: The storage quota per project
|
description: The storage quota per project
|
||||||
x-omitempty: true
|
x-omitempty: true
|
||||||
x-isnullable: true
|
x-isnullable: true
|
||||||
StringConfigItem:
|
StringConfigItem:
|
||||||
|
@ -22,7 +22,6 @@ import (
|
|||||||
"github.com/goharbor/harbor/src/common"
|
"github.com/goharbor/harbor/src/common"
|
||||||
comModels "github.com/goharbor/harbor/src/common/models"
|
comModels "github.com/goharbor/harbor/src/common/models"
|
||||||
"github.com/goharbor/harbor/src/lib/config/metadata"
|
"github.com/goharbor/harbor/src/lib/config/metadata"
|
||||||
"github.com/goharbor/harbor/src/lib/config/models"
|
|
||||||
"github.com/goharbor/harbor/src/lib/encrypt"
|
"github.com/goharbor/harbor/src/lib/encrypt"
|
||||||
"github.com/goharbor/harbor/src/lib/log"
|
"github.com/goharbor/harbor/src/lib/log"
|
||||||
"github.com/goharbor/harbor/src/lib/orm"
|
"github.com/goharbor/harbor/src/lib/orm"
|
||||||
@ -43,9 +42,6 @@ var (
|
|||||||
managers = make(map[string]Manager)
|
managers = make(map[string]Manager)
|
||||||
)
|
)
|
||||||
|
|
||||||
// InternalCfg internal configure response model
|
|
||||||
type InternalCfg map[string]*models.Value
|
|
||||||
|
|
||||||
// Manager defines the operation for config
|
// Manager defines the operation for config
|
||||||
type Manager interface {
|
type Manager interface {
|
||||||
Load(ctx context.Context) error
|
Load(ctx context.Context) error
|
||||||
|
@ -17,6 +17,7 @@ package handler
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/go-openapi/runtime/middleware"
|
"github.com/go-openapi/runtime/middleware"
|
||||||
"github.com/goharbor/harbor/src/common/rbac"
|
"github.com/goharbor/harbor/src/common/rbac"
|
||||||
"github.com/goharbor/harbor/src/common/security"
|
"github.com/goharbor/harbor/src/common/security"
|
||||||
@ -111,7 +112,13 @@ func (c *configAPI) GetInternalconfig(ctx context.Context, params configure.GetI
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return c.SendError(ctx, err)
|
return c.SendError(ctx, err)
|
||||||
}
|
}
|
||||||
return configure.NewGetInternalconfigOK().WithPayload(resultCfg)
|
|
||||||
|
payload := make(models.InternalConfigurationsResponse, len(resultCfg))
|
||||||
|
for key, cfg := range resultCfg {
|
||||||
|
payload[key] = models.InternalConfigurationValue{Value: cfg.Val, Editable: cfg.Editable}
|
||||||
|
}
|
||||||
|
|
||||||
|
return configure.NewGetInternalconfigOK().WithPayload(payload)
|
||||||
}
|
}
|
||||||
|
|
||||||
func toResponseModel(cfg map[string]*cfgModels.Value) (*models.ConfigurationsResponse, error) {
|
func toResponseModel(cfg map[string]*cfgModels.Value) (*models.ConfigurationsResponse, error) {
|
||||||
|
@ -54,8 +54,8 @@ func (q *Quota) ToSwagger(ctx context.Context) *models.Quota {
|
|||||||
return &models.Quota{
|
return &models.Quota{
|
||||||
ID: q.ID,
|
ID: q.ID,
|
||||||
Ref: q.Ref,
|
Ref: q.Ref,
|
||||||
Hard: hard,
|
Hard: NewResourceList(hard).ToSwagger(),
|
||||||
Used: used,
|
Used: NewResourceList(used).ToSwagger(),
|
||||||
CreationTime: strfmt.DateTime(q.CreationTime),
|
CreationTime: strfmt.DateTime(q.CreationTime),
|
||||||
UpdateTime: strfmt.DateTime(q.UpdateTime),
|
UpdateTime: strfmt.DateTime(q.UpdateTime),
|
||||||
}
|
}
|
||||||
|
41
src/server/v2.0/handler/model/resource_list.go
Normal file
41
src/server/v2.0/handler/model/resource_list.go
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
// Copyright Project Harbor Authors
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/goharbor/harbor/src/pkg/quota/types"
|
||||||
|
"github.com/goharbor/harbor/src/server/v2.0/models"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ResourceList model
|
||||||
|
type ResourceList struct {
|
||||||
|
types.ResourceList
|
||||||
|
}
|
||||||
|
|
||||||
|
// ToSwagger converts the resource list to the swagger model
|
||||||
|
func (rl *ResourceList) ToSwagger() models.ResourceList {
|
||||||
|
result := make(map[string]int64, len(rl.ResourceList))
|
||||||
|
|
||||||
|
for name, value := range rl.ResourceList {
|
||||||
|
result[string(name)] = value
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewResourceList new resource list instance
|
||||||
|
func NewResourceList(rl types.ResourceList) *ResourceList {
|
||||||
|
return &ResourceList{ResourceList: rl}
|
||||||
|
}
|
@ -748,10 +748,10 @@ func getProjectQuotaSummary(ctx context.Context, p *project.Project, summary *mo
|
|||||||
|
|
||||||
summary.Quota = &models.ProjectSummaryQuota{}
|
summary.Quota = &models.ProjectSummaryQuota{}
|
||||||
if hard, err := q.GetHard(); err == nil {
|
if hard, err := q.GetHard(); err == nil {
|
||||||
summary.Quota.Hard = hard
|
summary.Quota.Hard = model.NewResourceList(hard).ToSwagger()
|
||||||
}
|
}
|
||||||
if used, err := q.GetUsed(); err == nil {
|
if used, err := q.GetUsed(); err == nil {
|
||||||
summary.Quota.Used = used
|
summary.Quota.Used = model.NewResourceList(used).ToSwagger()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ import (
|
|||||||
"github.com/goharbor/harbor/src/lib"
|
"github.com/goharbor/harbor/src/lib"
|
||||||
"github.com/goharbor/harbor/src/lib/errors"
|
"github.com/goharbor/harbor/src/lib/errors"
|
||||||
"github.com/goharbor/harbor/src/lib/q"
|
"github.com/goharbor/harbor/src/lib/q"
|
||||||
|
"github.com/goharbor/harbor/src/pkg/quota/types"
|
||||||
"github.com/goharbor/harbor/src/server/v2.0/handler/model"
|
"github.com/goharbor/harbor/src/server/v2.0/handler/model"
|
||||||
"github.com/goharbor/harbor/src/server/v2.0/models"
|
"github.com/goharbor/harbor/src/server/v2.0/models"
|
||||||
operation "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/quota"
|
operation "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/quota"
|
||||||
@ -102,11 +103,16 @@ func (qa *quotaAPI) UpdateQuota(ctx context.Context, params operation.UpdateQuot
|
|||||||
return qa.SendError(ctx, err)
|
return qa.SendError(ctx, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := quota.Validate(ctx, q.Reference, params.Hard.Hard); err != nil {
|
hard := make(types.ResourceList, len(params.Hard.Hard))
|
||||||
|
for name, value := range params.Hard.Hard {
|
||||||
|
hard[types.ResourceName(name)] = value
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := quota.Validate(ctx, q.Reference, hard); err != nil {
|
||||||
return qa.SendError(ctx, errors.BadRequestError(nil).WithMessage(err.Error()))
|
return qa.SendError(ctx, errors.BadRequestError(nil).WithMessage(err.Error()))
|
||||||
}
|
}
|
||||||
|
|
||||||
q.SetHard(params.Hard.Hard)
|
q.SetHard(hard)
|
||||||
|
|
||||||
if err := qa.quotaCtl.Update(ctx, q); err != nil {
|
if err := qa.quotaCtl.Update(ctx, q); err != nil {
|
||||||
return qa.SendError(ctx, err)
|
return qa.SendError(ctx, err)
|
||||||
|
@ -25,7 +25,6 @@ import (
|
|||||||
|
|
||||||
"github.com/goharbor/harbor/src/lib/errors"
|
"github.com/goharbor/harbor/src/lib/errors"
|
||||||
"github.com/goharbor/harbor/src/pkg/quota"
|
"github.com/goharbor/harbor/src/pkg/quota"
|
||||||
"github.com/goharbor/harbor/src/pkg/quota/types"
|
|
||||||
"github.com/goharbor/harbor/src/server/v2.0/models"
|
"github.com/goharbor/harbor/src/server/v2.0/models"
|
||||||
"github.com/goharbor/harbor/src/server/v2.0/restapi"
|
"github.com/goharbor/harbor/src/server/v2.0/restapi"
|
||||||
quotatesting "github.com/goharbor/harbor/src/testing/controller/quota"
|
quotatesting "github.com/goharbor/harbor/src/testing/controller/quota"
|
||||||
@ -75,7 +74,7 @@ func (suite *QuotaTestSuite) TestAuthorization() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
quota := models.QuotaUpdateReq{
|
quota := models.QuotaUpdateReq{
|
||||||
Hard: types.ResourceList{"storage": 1000},
|
Hard: models.ResourceList{"storage": 1000},
|
||||||
}
|
}
|
||||||
|
|
||||||
reqs := []struct {
|
reqs := []struct {
|
||||||
@ -214,7 +213,7 @@ func (suite *QuotaTestSuite) TestUpdateQuota() {
|
|||||||
{
|
{
|
||||||
// update quota with empty hard
|
// update quota with empty hard
|
||||||
quota := models.QuotaUpdateReq{
|
quota := models.QuotaUpdateReq{
|
||||||
Hard: types.ResourceList{},
|
Hard: models.ResourceList{},
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := suite.PutJSON("/quotas/1", quota)
|
res, err := suite.PutJSON("/quotas/1", quota)
|
||||||
@ -227,7 +226,7 @@ func (suite *QuotaTestSuite) TestUpdateQuota() {
|
|||||||
mock.OnAnything(suite.quotaCtl, "Get").Return(nil, errors.NotFoundError(nil)).Once()
|
mock.OnAnything(suite.quotaCtl, "Get").Return(nil, errors.NotFoundError(nil)).Once()
|
||||||
|
|
||||||
quota := models.QuotaUpdateReq{
|
quota := models.QuotaUpdateReq{
|
||||||
Hard: types.ResourceList{"storage": 1000},
|
Hard: models.ResourceList{"storage": 1000},
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := suite.PutJSON("/quotas/1", quota)
|
res, err := suite.PutJSON("/quotas/1", quota)
|
||||||
@ -241,7 +240,7 @@ func (suite *QuotaTestSuite) TestUpdateQuota() {
|
|||||||
mock.OnAnything(suite.quotaCtl, "Update").Return(nil).Once()
|
mock.OnAnything(suite.quotaCtl, "Update").Return(nil).Once()
|
||||||
|
|
||||||
quota := models.QuotaUpdateReq{
|
quota := models.QuotaUpdateReq{
|
||||||
Hard: types.ResourceList{"storage": 1000},
|
Hard: models.ResourceList{"storage": 1000},
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := suite.PutJSON("/quotas/1", quota)
|
res, err := suite.PutJSON("/quotas/1", quota)
|
||||||
@ -255,7 +254,7 @@ func (suite *QuotaTestSuite) TestUpdateQuota() {
|
|||||||
mock.OnAnything(suite.quotaCtl, "Update").Return(fmt.Errorf("failed to update the quota")).Once()
|
mock.OnAnything(suite.quotaCtl, "Update").Return(fmt.Errorf("failed to update the quota")).Once()
|
||||||
|
|
||||||
quota := models.QuotaUpdateReq{
|
quota := models.QuotaUpdateReq{
|
||||||
Hard: types.ResourceList{"storage": 1000},
|
Hard: models.ResourceList{"storage": 1000},
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := suite.PutJSON("/quotas/1", quota)
|
res, err := suite.PutJSON("/quotas/1", quota)
|
||||||
@ -269,7 +268,7 @@ func (suite *QuotaTestSuite) TestUpdateQuota() {
|
|||||||
mock.OnAnything(suite.quotaCtl, "Update").Return(nil).Once()
|
mock.OnAnything(suite.quotaCtl, "Update").Return(nil).Once()
|
||||||
|
|
||||||
quota := models.QuotaUpdateReq{
|
quota := models.QuotaUpdateReq{
|
||||||
Hard: types.ResourceList{"size": 1000},
|
Hard: models.ResourceList{"size": 1000},
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := suite.PutJSON("/quotas/1", quota)
|
res, err := suite.PutJSON("/quotas/1", quota)
|
||||||
|
Loading…
Reference in New Issue
Block a user