Documentation ¶
Index ¶
- Constants
- Variables
- func AddProjectMember(projectID int64, request models.MemberReq) (int, error)
- func Init() error
- func SyncRegistry(pm promgr.ProjectManager) error
- type BaseController
- func (b *BaseController) Prepare()
- func (b *BaseController) RenderFormatedError(code int, err error)
- func (b *BaseController) SendBadRequestError(err error)
- func (b *BaseController) SendConflictError(err error)
- func (b *BaseController) SendForbiddenError(err error)
- func (b *BaseController) SendInternalServerError(err error)
- func (b *BaseController) SendNotFoundError(err error)
- func (b *BaseController) SendUnAuthorizedError(err error)
- func (b *BaseController) WriteJSONData(object interface{})
- func (b *BaseController) WriteYamlData(object interface{})
- type ChartLabelAPI
- type ChartRepositoryAPI
- func (cra *ChartRepositoryAPI) DeleteChart()
- func (cra *ChartRepositoryAPI) DeleteChartVersion()
- func (cra *ChartRepositoryAPI) DownloadChart()
- func (cra *ChartRepositoryAPI) GetChartVersion()
- func (cra *ChartRepositoryAPI) GetHealthStatus()
- func (cra *ChartRepositoryAPI) GetIndex()
- func (cra *ChartRepositoryAPI) GetIndexByRepo()
- func (cra *ChartRepositoryAPI) ListChartVersions()
- func (cra *ChartRepositoryAPI) ListCharts()
- func (cra *ChartRepositoryAPI) Prepare()
- func (cra *ChartRepositoryAPI) UploadChartProvFile()
- func (cra *ChartRepositoryAPI) UploadChartVersion()
- type ConfigAPI
- type EmailAPI
- type GCAPI
- type GeneralInfo
- type InternalAPI
- type LabelAPI
- type LabelResourceAPI
- type LdapAPI
- type LogAPI
- type MetadataAPI
- type ProjectAPI
- type ProjectMemberAPI
- type RepJobAPI
- type RepPolicyAPI
- type ReplicationAPI
- type RepositoryAPI
- func (ra *RepositoryAPI) Delete()
- func (ra *RepositoryAPI) Get()
- func (ra *RepositoryAPI) GetManifests()
- func (ra *RepositoryAPI) GetSignatures()
- func (ra *RepositoryAPI) GetTag()
- func (ra *RepositoryAPI) GetTags()
- func (ra *RepositoryAPI) GetTopRepos()
- func (ra *RepositoryAPI) Put()
- func (ra *RepositoryAPI) Retag()
- func (ra *RepositoryAPI) ScanAll()
- func (ra *RepositoryAPI) ScanImage()
- func (ra *RepositoryAPI) VulnerabilityDetails()
- type RepositoryLabelAPI
- func (r *RepositoryLabelAPI) AddToImage()
- func (r *RepositoryLabelAPI) AddToRepository()
- func (r *RepositoryLabelAPI) GetOfImage()
- func (r *RepositoryLabelAPI) GetOfRepository()
- func (r *RepositoryLabelAPI) Prepare()
- func (r *RepositoryLabelAPI) RemoveFromImage()
- func (r *RepositoryLabelAPI) RemoveFromRepository()
- type ScanJobAPI
- type SearchAPI
- type StatisticAPI
- type Storage
- type SystemInfo
- type SystemInfoAPI
- type TargetAPI
- type UserAPI
- type UserGroupAPI
Constants ¶
const ( // ReplicationJobType ... ReplicationJobType = "replication" // ScanJobType ... ScanJobType = "scan" )
const ( // PriPC : count of private projects PriPC = "private_project_count" // PriRC : count of private repositories PriRC = "private_repo_count" // PubPC : count of public projects PubPC = "public_project_count" // PubRC : count of public repositories PubRC = "public_repo_count" // TPC : total count of projects TPC = "total_project_count" // TRC : total count of repositories TRC = "total_repo_count" )
Variables ¶
var ErrDuplicateProjectMember = errors.New("The project member specified already exist")
ErrDuplicateProjectMember ...
var ErrInvalidRole = errors.New("Failed to update project member, role is not in 1,2,3")
ErrInvalidRole ...
Functions ¶
func AddProjectMember ¶
AddProjectMember ...
func SyncRegistry ¶
func SyncRegistry(pm promgr.ProjectManager) error
SyncRegistry syncs the repositories of registry with database.
Types ¶
type BaseController ¶
type BaseController struct { api.BaseAPI // SecurityCtx is the security context used to authN &authZ SecurityCtx security.Context // ProjectMgr is the project manager which abstracts the operations // related to projects ProjectMgr promgr.ProjectManager }
BaseController ...
func (*BaseController) Prepare ¶
func (b *BaseController) Prepare()
Prepare inits security context and project manager from request context 从请求的 context 中获取 security context 和 project manager
func (*BaseController) RenderFormatedError ¶
func (b *BaseController) RenderFormatedError(code int, err error)
RenderFormatedError renders errors with well formted style `{"error": "This is an error"}`
func (*BaseController) SendBadRequestError ¶
func (b *BaseController) SendBadRequestError(err error)
SendBadRequestError sends bad request error to the client.
func (*BaseController) SendConflictError ¶
func (b *BaseController) SendConflictError(err error)
SendConflictError sends conflict error to the client.
func (*BaseController) SendForbiddenError ¶
func (b *BaseController) SendForbiddenError(err error)
SendForbiddenError sends forbidden error to the client.
func (*BaseController) SendInternalServerError ¶
func (b *BaseController) SendInternalServerError(err error)
SendInternalServerError sends internal server error to the client.
func (*BaseController) SendNotFoundError ¶
func (b *BaseController) SendNotFoundError(err error)
SendNotFoundError sends not found error to the client.
func (*BaseController) SendUnAuthorizedError ¶
func (b *BaseController) SendUnAuthorizedError(err error)
SendUnAuthorizedError sends unauthorized error to the client.
func (*BaseController) WriteJSONData ¶
func (b *BaseController) WriteJSONData(object interface{})
WriteJSONData writes the JSON data to the client.
func (*BaseController) WriteYamlData ¶
func (b *BaseController) WriteYamlData(object interface{})
WriteYamlData writes the yaml data to the client.
type ChartLabelAPI ¶
type ChartLabelAPI struct { LabelResourceAPI // contains filtered or unexported fields }
ChartLabelAPI handles the requests of marking/removing lables to/from charts.
func (*ChartLabelAPI) GetLabels ¶
func (cla *ChartLabelAPI) GetLabels()
GetLabels gets labels for the specified chart version.
func (*ChartLabelAPI) MarkLabel ¶
func (cla *ChartLabelAPI) MarkLabel()
MarkLabel handles the request of marking label to chart.
func (*ChartLabelAPI) Prepare ¶
func (cla *ChartLabelAPI) Prepare()
Prepare required material for follow-up actions.
func (*ChartLabelAPI) RemoveLabel ¶
func (cla *ChartLabelAPI) RemoveLabel()
RemoveLabel handles the request of removing label from chart.
type ChartRepositoryAPI ¶
type ChartRepositoryAPI struct { // The base controller to provide common utilities BaseController // contains filtered or unexported fields }
ChartRepositoryAPI provides related API handlers for the chart repository APIs
func (*ChartRepositoryAPI) DeleteChart ¶
func (cra *ChartRepositoryAPI) DeleteChart()
DeleteChart deletes all the chart versions of the specified chart.
func (*ChartRepositoryAPI) DeleteChartVersion ¶
func (cra *ChartRepositoryAPI) DeleteChartVersion()
DeleteChartVersion handles DELETE /api/:repo/charts/:name/:version
func (*ChartRepositoryAPI) DownloadChart ¶
func (cra *ChartRepositoryAPI) DownloadChart()
DownloadChart handles GET /:repo/charts/:filename
func (*ChartRepositoryAPI) GetChartVersion ¶
func (cra *ChartRepositoryAPI) GetChartVersion()
GetChartVersion handles GET /api/:repo/charts/:name/:version
func (*ChartRepositoryAPI) GetHealthStatus ¶
func (cra *ChartRepositoryAPI) GetHealthStatus()
GetHealthStatus handles GET /api/chartrepo/health
func (*ChartRepositoryAPI) GetIndex ¶
func (cra *ChartRepositoryAPI) GetIndex()
GetIndex handles GET /index.yaml
func (*ChartRepositoryAPI) GetIndexByRepo ¶
func (cra *ChartRepositoryAPI) GetIndexByRepo()
GetIndexByRepo handles GET /:repo/index.yaml
func (*ChartRepositoryAPI) ListChartVersions ¶
func (cra *ChartRepositoryAPI) ListChartVersions()
ListChartVersions GET /api/:repo/charts/:name
func (*ChartRepositoryAPI) ListCharts ¶
func (cra *ChartRepositoryAPI) ListCharts()
ListCharts handles GET /api/:repo/charts
func (*ChartRepositoryAPI) Prepare ¶
func (cra *ChartRepositoryAPI) Prepare()
Prepare something for the following actions
func (*ChartRepositoryAPI) UploadChartProvFile ¶
func (cra *ChartRepositoryAPI) UploadChartProvFile()
UploadChartProvFile handles POST /api/:repo/prov
func (*ChartRepositoryAPI) UploadChartVersion ¶
func (cra *ChartRepositoryAPI) UploadChartVersion()
UploadChartVersion handles POST /api/:repo/charts
type ConfigAPI ¶
type ConfigAPI struct {
BaseController
}
ConfigAPI ...
func (*ConfigAPI) GetInternalConfig ¶
func (c *ConfigAPI) GetInternalConfig()
GetInternalConfig returns internal configurations
type EmailAPI ¶
type EmailAPI struct {
BaseController
}
EmailAPI ...
type GCAPI ¶
type GCAPI struct {
BaseController
}
GCAPI handles request of harbor admin...
type GeneralInfo ¶
type GeneralInfo struct { WithNotary bool `json:"with_notary"` WithClair bool `json:"with_clair"` WithAdmiral bool `json:"with_admiral"` AdmiralEndpoint string `json:"admiral_endpoint"` AuthMode string `json:"auth_mode"` RegistryURL string `json:"registry_url"` ProjectCreationRestrict string `json:"project_creation_restriction"` SelfRegistration bool `json:"self_registration"` HasCARoot bool `json:"has_ca_root"` HarborVersion string `json:"harbor_version"` ClairVulnStatus *models.ClairVulnerabilityStatus `json:"clair_vulnerability_status,omitempty"` RegistryStorageProviderName string `json:"registry_storage_provider_name"` ReadOnly bool `json:"read_only"` WithChartMuseum bool `json:"with_chartmuseum"` }
GeneralInfo wraps common systeminfo for anonymous request
type InternalAPI ¶
type InternalAPI struct {
BaseController
}
InternalAPI handles request of harbor admin...
func (*InternalAPI) RenameAdmin ¶
func (ia *InternalAPI) RenameAdmin()
RenameAdmin we don't provide flexibility in this API, as this is a workaround.
func (*InternalAPI) SyncRegistry ¶
func (ia *InternalAPI) SyncRegistry()
SyncRegistry ... 从 registry 同步所有的 repository 数据到数据库中
type LabelAPI ¶
type LabelAPI struct { BaseController // contains filtered or unexported fields }
LabelAPI handles requests for label management
func (*LabelAPI) ListResources ¶
func (l *LabelAPI) ListResources()
ListResources lists the resources that the label is referenced by
type LabelResourceAPI ¶
type LabelResourceAPI struct { BaseController // contains filtered or unexported fields }
LabelResourceAPI provides the related basic functions to handle marking labels to resources
func (*LabelResourceAPI) Prepare ¶
func (lra *LabelResourceAPI) Prepare()
Prepare resources for follow-up actions.
type LdapAPI ¶
type LdapAPI struct { BaseController // contains filtered or unexported fields }
LdapAPI handles requesst to /api/ldap/ping /api/ldap/user/search /api/ldap/user/import
func (*LdapAPI) SearchGroup ¶
func (l *LdapAPI) SearchGroup()
SearchGroup ... Search LDAP by groupname
type LogAPI ¶
type LogAPI struct { BaseController // contains filtered or unexported fields }
LogAPI handles request api/logs
type MetadataAPI ¶
type MetadataAPI struct { BaseController // contains filtered or unexported fields }
MetadataAPI ...
type ProjectAPI ¶
type ProjectAPI struct { BaseController // contains filtered or unexported fields }
ProjectAPI handles request to /api/projects/{} /api/projects/{}/logs
type ProjectMemberAPI ¶
type ProjectMemberAPI struct { BaseController // contains filtered or unexported fields }
在给具体 project 增加成员时,总共需要 3 个请求 HPM] GET /api/projects/1/members?entityname=chenxu -> http://172.16.21.135 [HPM] POST /api/projects/1/members -> http://172.16.21.135 [HPM] GET /api/projects/1/members?entityname= -> http://172.16.21.135
ProjectMemberAPI handles request to /api/projects/{}/members/{}
func (*ProjectMemberAPI) Prepare ¶
func (pma *ProjectMemberAPI) Prepare()
Prepare validates the URL and parms
func (*ProjectMemberAPI) Put ¶
func (pma *ProjectMemberAPI) Put()
Put ... Update an exist project member
type RepJobAPI ¶
type RepJobAPI struct { BaseController // contains filtered or unexported fields }
RepJobAPI handles request to /api/replicationJobs /api/replicationJobs/:id/log
type RepPolicyAPI ¶
type RepPolicyAPI struct {
BaseController
}
RepPolicyAPI handles /api/replicationPolicies /api/replicationPolicies/:id/enablement
func (*RepPolicyAPI) Prepare ¶
func (pa *RepPolicyAPI) Prepare()
Prepare validates whether the user has system admin role
type ReplicationAPI ¶
type ReplicationAPI struct {
BaseController
}
ReplicationAPI handles API calls for replication
func (*ReplicationAPI) Post ¶
func (r *ReplicationAPI) Post()
Post trigger a replication according to the specified policy
func (*ReplicationAPI) Prepare ¶
func (r *ReplicationAPI) Prepare()
Prepare does authentication and authorization works
type RepositoryAPI ¶
type RepositoryAPI struct {
BaseController
}
RepositoryAPI handles request to /api/repositories /api/repositories/tags /api/repositories/manifests, the parm has to be put in the query string as the web framework can not parse the URL if it contains veriadic sectors.
func (*RepositoryAPI) GetManifests ¶
func (ra *RepositoryAPI) GetManifests()
GetManifests returns the manifest of a tag
func (*RepositoryAPI) GetSignatures ¶
func (ra *RepositoryAPI) GetSignatures()
GetSignatures returns signatures of a repository
func (*RepositoryAPI) GetTag ¶
func (ra *RepositoryAPI) GetTag()
GetTag returns the tag of a repository
func (*RepositoryAPI) GetTags ¶
func (ra *RepositoryAPI) GetTags()
GetTags returns tags of a repository
func (*RepositoryAPI) GetTopRepos ¶
func (ra *RepositoryAPI) GetTopRepos()
GetTopRepos returns the most populor repositories
func (*RepositoryAPI) Put ¶
func (ra *RepositoryAPI) Put()
Put updates description info for the repository
func (*RepositoryAPI) Retag ¶
func (ra *RepositoryAPI) Retag()
Retag tags an existing image to another tag in this repo, the source image is specified by request body.
func (*RepositoryAPI) ScanAll ¶
func (ra *RepositoryAPI) ScanAll()
ScanAll handles the api to scan all images on Harbor.
func (*RepositoryAPI) ScanImage ¶
func (ra *RepositoryAPI) ScanImage()
ScanImage handles request POST /api/repository/$repository/tags/$tag/scan to trigger image scan manually. 启动镜像扫描
func (*RepositoryAPI) VulnerabilityDetails ¶
func (ra *RepositoryAPI) VulnerabilityDetails()
VulnerabilityDetails fetch vulnerability info from clair, transform to Harbor's format and return to client.
type RepositoryLabelAPI ¶
type RepositoryLabelAPI struct { LabelResourceAPI // contains filtered or unexported fields }
RepositoryLabelAPI handles requests for adding/removing label to/from repositories and images
func (*RepositoryLabelAPI) AddToImage ¶
func (r *RepositoryLabelAPI) AddToImage()
AddToImage adds the label to an image
func (*RepositoryLabelAPI) AddToRepository ¶
func (r *RepositoryLabelAPI) AddToRepository()
AddToRepository adds the label to a repository
func (*RepositoryLabelAPI) GetOfImage ¶
func (r *RepositoryLabelAPI) GetOfImage()
GetOfImage returns labels of an image
func (*RepositoryLabelAPI) GetOfRepository ¶
func (r *RepositoryLabelAPI) GetOfRepository()
GetOfRepository returns labels of a repository
func (*RepositoryLabelAPI) RemoveFromImage ¶
func (r *RepositoryLabelAPI) RemoveFromImage()
RemoveFromImage removes the label from an image
func (*RepositoryLabelAPI) RemoveFromRepository ¶
func (r *RepositoryLabelAPI) RemoveFromRepository()
RemoveFromRepository removes the label from a repository
type ScanJobAPI ¶
type ScanJobAPI struct { BaseController // contains filtered or unexported fields }
ScanJobAPI handles request to /api/scanJobs/:id/log
func (*ScanJobAPI) Prepare ¶
func (sj *ScanJobAPI) Prepare()
Prepare validates that whether user has read permission to the project of the repo the scan job scanned.
type StatisticAPI ¶
type StatisticAPI struct { BaseController // contains filtered or unexported fields }
StatisticAPI handles request to /api/statistics/
func (*StatisticAPI) Prepare ¶
func (s *StatisticAPI) Prepare()
Prepare validates the URL and the user
type SystemInfo ¶
type SystemInfo struct {
HarborStorage Storage `json:"storage"`
}
SystemInfo models for system info.
type SystemInfoAPI ¶
type SystemInfoAPI struct {
BaseController
}
SystemInfoAPI handle requests for getting system info /api/systeminfo
func (*SystemInfoAPI) GetCert ¶
func (sia *SystemInfoAPI) GetCert()
GetCert gets default self-signed certificate.
func (*SystemInfoAPI) GetGeneralInfo ¶
func (sia *SystemInfoAPI) GetGeneralInfo()
GetGeneralInfo returns the general system info, which is to be called by anonymous user
func (*SystemInfoAPI) GetVolumeInfo ¶
func (sia *SystemInfoAPI) GetVolumeInfo()
GetVolumeInfo gets specific volume storage info.
type TargetAPI ¶
type TargetAPI struct { BaseController // contains filtered or unexported fields }
TargetAPI handles request to /api/targets/ping /api/targets/{}
type UserAPI ¶
type UserAPI struct { BaseController SelfRegistration bool IsAdmin bool AuthMode string // contains filtered or unexported fields }
UserAPI handles request to /api/users/{}
func (*UserAPI) ChangePassword ¶
func (ua *UserAPI) ChangePassword()
ChangePassword handles PUT to /api/users/{}/password
func (*UserAPI) ToggleUserAdminRole ¶
func (ua *UserAPI) ToggleUserAdminRole()
ToggleUserAdminRole handles PUT api/users/{}/sysadmin 将用户身份设置为 管理员
type UserGroupAPI ¶
type UserGroupAPI struct { BaseController // contains filtered or unexported fields }
UserGroupAPI ...
func (*UserGroupAPI) Prepare ¶
func (uga *UserGroupAPI) Prepare()
Prepare validates the URL and parms
Source Files ¶
- base.go
- chart_label.go
- chart_repository.go
- config.go
- email.go
- internal.go
- label.go
- label_resource.go
- ldap.go
- log.go
- metadata.go
- project.go
- projectmember.go
- reg_gc.go
- replication.go
- replication_job.go
- replication_policy.go
- repository.go
- repository_label.go
- scan_job.go
- search.go
- statistic.go
- systeminfo.go
- target.go
- user.go
- usergroup.go
- utils.go