Documentation ¶
Index ¶
- func CheckResponse(errs []error, resp gorequest.Response, expected int) error
- func I64toA(in int64) string
- type AccessLog
- type CVEWhitelist
- type CVEWhitelistItem
- type ChangePassword
- type ChangePasswordAsAdmin
- type Client
- func (c *Client) GetStatistics() (StatisticMap, *gorequest.Response, []error)
- func (c *Client) NewRequest(method, subPath string) *gorequest.SuperAgent
- func (c *Client) Projects() *ProjectClient
- func (c *Client) Search() (Search, *gorequest.Response, []error)
- func (c *Client) SetBaseURL(urlStr string) error
- func (c *Client) Users() *UserClient
- type ComponentsOverview
- type ComponentsOverviewEntry
- type ImgScanOverview
- type ListLogOptions
- type ListOptions
- type ListProjectsOptions
- type ListRepositoriesOption
- type ManifestResp
- type MemberRequest
- type MemberUser
- type Project
- type ProjectClient
- func (s *ProjectClient) AddProjectMember(pid int, member ProjectMemberRequest) error
- func (s *ProjectClient) AddProjectMetadata(pid int64, metadata map[string]string) error
- func (s *ProjectClient) CheckProject(projectName string) error
- func (s *ProjectClient) CreateProject(p ProjectRequest) error
- func (s *ProjectClient) DeleteProject(pid int64) error
- func (s *ProjectClient) DeleteProjectMember(pid, mid int64) error
- func (s *ProjectClient) DeleteProjectMetadataSingle(pid int64, metadataName string) error
- func (s *ProjectClient) GetProjectByID(pid int64) (Project, error)
- func (s *ProjectClient) GetProjectLogByID(pid int64, opt ListLogOptions) ([]AccessLog, error)
- func (s *ProjectClient) GetProjectMember(pid, mid int) (Role, error)
- func (s *ProjectClient) GetProjectMembers(pid int64) ([]User, error)
- func (s *ProjectClient) GetProjectMetadata(pid int64) (map[string]string, error)
- func (s *ProjectClient) GetProjectMetadataSingle(pid int64, specified string) (map[string]string, error)
- func (s *ProjectClient) ListProjects(opt ListProjectsOptions) ([]Project, error)
- func (s *ProjectClient) UpdateProject(pid int64, p Project) error
- func (s *ProjectClient) UpdateProjectMember(pid, mid int64, role RoleRequest) error
- func (s *ProjectClient) UpdateProjectMetadataSingle(pid int64, metadataName string) error
- type ProjectMemberRequest
- type ProjectMetadata
- type ProjectRequest
- type RepoRecord
- type RepoResp
- type RepositoryClient
- func (s *RepositoryClient) DeleteRepository(repoName string) (gorequest.Response, []error)
- func (s *RepositoryClient) DeleteRepositoryTag(repoName, tag string) (gorequest.Response, []error)
- func (s *RepositoryClient) GetImageDetails(repoName, tag string) ([]VulnerabilityItem, gorequest.Response, []error)
- func (s *RepositoryClient) GetRepositorySignature(repoName string) ([]Signature, gorequest.Response, []error)
- func (s *RepositoryClient) GetRepositoryTag(repoName, tag string) (TagResp, gorequest.Response, []error)
- func (s *RepositoryClient) GetRepositoryTagManifests(repoName, tag string, version string) (ManifestResp, gorequest.Response, []error)
- func (s *RepositoryClient) GetRepositoryTop(top interface{}) ([]RepoResp, gorequest.Response, []error)
- func (s *RepositoryClient) ListRepository(opt *ListRepositoriesOption) ([]RepoRecord, gorequest.Response, []error)
- func (s *RepositoryClient) ListRepositoryTags(repoName string) ([]TagResp, gorequest.Response, []error)
- func (s *RepositoryClient) ScanImage(repoName, tag string) (gorequest.Response, []error)
- func (s *RepositoryClient) UpdateRepository(repoName string, d RepositoryDescription) (gorequest.Response, []error)
- type RepositoryDescription
- type Role
- type RoleRequest
- type Search
- type SearchRepository
- type Signature
- type StatisticMap
- type StatusCodeError
- type TagResp
- type User
- type UserClient
- func (s *UserClient) AddUser(usr UserRequest) error
- func (s *UserClient) DeleteUser(usr UserRequest) error
- func (s *UserClient) GetUser(usr UserRequest) (User, error)
- func (s *UserClient) ListUsers() ([]User, error)
- func (s *UserClient) SearchUser(usr UserRequest) (UserSearchResults, error)
- func (s *UserClient) ToggleUserSysAdmin(usr UserRequest) error
- func (s *UserClient) UpdateUserPassword(uid int64, oldPw, newPw string) error
- func (s *UserClient) UpdateUserPasswordAsAdmin(uid int64, newPw string) error
- func (s *UserClient) UpdateUserProfile(usr UserRequest) error
- type UserRequest
- type UserSearchResult
- type UserSearchResults
- type VulnerabilityItem
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckResponse ¶
CheckResponse flattens errors and checks the response status code
Types ¶
type AccessLog ¶
type AccessLog struct { LogID int `json:"log_id"` Username string `json:"username"` ProjectID int64 `json:"project_id"` RepoName string `json:"repo_name"` RepoTag string `json:"repo_tag"` GUID string `json:"guid"` Operation string `json:"operation"` OpTime time.Time `json:"op_time"` }
AccessLog holds the information of log entries
type CVEWhitelist ¶
type CVEWhitelist struct { ID int64 `json:"id"` ProjectID int64 `json:"projectID"` Items CVEWhitelistItem `json:"items,optional"` }
CVEWhitelist holds project specific information next to the set CVEWhitelistItem's
type CVEWhitelistItem ¶
type CVEWhitelistItem struct {
CVEID string `json:"CVEID"`
}
CVEWhitelistItem holds the CVE ids of a whitelisted item
type ChangePassword ¶
type ChangePassword struct { OldPassword string `json:"old_password"` NewPassword string `json:"new_password"` }
ChangePassword holds the information needed to change a users password
type ChangePasswordAsAdmin ¶
type ChangePasswordAsAdmin struct {
NewPassword string `json:"new_password"`
}
ChangePasswordAsAdmin holds the information needed to change a users password as administrator
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) GetStatistics ¶
func (c *Client) GetStatistics() (StatisticMap, *gorequest.Response, []error)
GetStatistics Get project and repository statistics
func (*Client) NewRequest ¶
func (c *Client) NewRequest(method, subPath string) *gorequest.SuperAgent
NewRequest creates an API request. A relative URL path can be provided in urlStr, in which case it is resolved relative to the base URL of the Client. Relative URL paths should always be specified without a preceding slash.
func (*Client) Projects ¶
func (c *Client) Projects() *ProjectClient
func (*Client) Search ¶
Search for projects and repositories
The Search endpoint returns information about the projects and repositories offered at public status or related to the current logged in user. The response includes the project and repository list in a proper display order.
Harbor API docs: https://github.com/vmware/harbor/blob/release-1.4.0/docs/swagger.yaml#L17
func (*Client) SetBaseURL ¶
SetBaseURL sets the base URL for API requests to a custom endpoint. urlStr should always be specified with a trailing slash.
func (*Client) Users ¶
func (c *Client) Users() *UserClient
type ComponentsOverview ¶
type ComponentsOverview struct { Total int `json:"total"` Summary []*ComponentsOverviewEntry `json:"summary"` }
ComponentsOverview holds information about the total number of components with a certain CVE severity
type ComponentsOverviewEntry ¶
ComponentsOverviewEntry ...
type ImgScanOverview ¶
type ImgScanOverview struct { ID int64 `json:"-"` Digest string `json:"image_digest"` Status string `json:"scan_status"` JobID int64 `json:"job_id"` Sev int `json:"severity"` CompOverviewStr string `json:"-"` CompOverview *ComponentsOverview `json:"components,omitempty"` DetailsKey string `json:"details_key"` }
ImgScanOverview maps the record of an image scan overview.
type ListLogOptions ¶
type ListLogOptions struct { ListOptions Username string `url:"username,omitempty"` // the operator's username of the log Repository string `url:"repository,omitempty"` // repository name Tag string `url:"tag,omitempty"` // tag name Operations []string `url:"operation,omitempty"` // operations BeginTime *time.Time `url:"begin_timestamp,omitempty"` // the time after which the operation is done EndTime *time.Time `url:"end_timestamp,omitempty"` // the time before which the operation is doen }
LogQueryParam is used to set query conditions when listing access logs
type ListOptions ¶
type ListOptions struct { // For paginated result sets, page of results to retrieve. Page int `url:"page,omitempty" json:"page,omitempty"` // For paginated result sets, the number of results to include per page. PageSize int `url:"page_size,omitempty" json:"page_size,omitempty"` }
ListOptions specifies the optional parameters to various List methods that support pagination.
type ListProjectsOptions ¶
type ListProjectsOptions struct { ListOptions Name string `url:"name,omitempty" json:"name,omitempty"` Public bool `url:"public,omitempty" json:"public,omitempty"` Owner string `url:"owner,omitempty" json:"owner,omitempty"` }
ListProjectsOptions holds the information needed to list a project
type ListRepositoriesOption ¶
type ListRepositoriesOption struct { ListOptions ProjectId int64 `url:"project_id,omitempty" json:"project_id,omitempty"` Q string `url:"q,omitempty" json:"q,omitempty"` Sort string `url:"sort,omitempty" json:"sort,omitempty"` }
type ManifestResp ¶
type ManifestResp struct { Manifest interface{} `json:"manifest"` Config interface{} `json:"config,omitempty" ` }
type MemberRequest ¶
MemberRequest holds the information needed to update a project member
type MemberUser ¶
MemberUser holds the user information needed for a project member request
type Project ¶
type Project struct { ProjectID int64 `json:"project_id"` OwnerID int64 `json:"owner_id"` Name string `json:"name"` CreationTime time.Time `json:"creation_time"` UpdateTime time.Time `json:"update_time"` Deleted bool `json:"deleted"` OwnerName string `json:"owner_name"` Toggleable bool `json:"toggleable"` Role int `json:"current_user_role_id"` RepoCount int64 `json:"repo_count"` Metadata map[string]string `json:"metadata"` CVEWhitelist CVEWhitelist `json:"CVEWhitelist"` StorageLimit int64 `json:"storageLimit"` }
Project holds the details of a project.
type ProjectClient ¶
type ProjectClient struct {
*Client
}
ProjectClient handles communication with the project related methods of the Harbor API.
func (*ProjectClient) AddProjectMember ¶
func (s *ProjectClient) AddProjectMember(pid int, member ProjectMemberRequest) error
AddProjectMember Add a project member to a project
func (*ProjectClient) AddProjectMetadata ¶
func (s *ProjectClient) AddProjectMetadata(pid int64, metadata map[string]string) error
AddProjectMetadata Add metadata to a project
func (*ProjectClient) CheckProject ¶
func (s *ProjectClient) CheckProject(projectName string) error
CheckProject Check if the project name provided already exist
func (*ProjectClient) CreateProject ¶
func (s *ProjectClient) CreateProject(p ProjectRequest) error
CreateProject Creates a new project
func (*ProjectClient) DeleteProject ¶
func (s *ProjectClient) DeleteProject(pid int64) error
DeleteProject Delete a project by project ID
func (*ProjectClient) DeleteProjectMember ¶
func (s *ProjectClient) DeleteProjectMember(pid, mid int64) error
DeleteProjectMember Delete a project member
func (*ProjectClient) DeleteProjectMetadataSingle ¶
func (s *ProjectClient) DeleteProjectMetadataSingle(pid int64, metadataName string) error
DeleteProjectMetadata Delete a specified metadata value of a project
func (*ProjectClient) GetProjectByID ¶
func (s *ProjectClient) GetProjectByID(pid int64) (Project, error)
GetProjectByID Return specific project details
func (*ProjectClient) GetProjectLogByID ¶
func (s *ProjectClient) GetProjectLogByID(pid int64, opt ListLogOptions) ([]AccessLog, error)
GetProjectLogByID Get access logs of a project with user-specified filter operations and date time ranges
func (*ProjectClient) GetProjectMember ¶
func (s *ProjectClient) GetProjectMember(pid, mid int) (Role, error)
GetProjectMemberRole Get the role of a project member
func (*ProjectClient) GetProjectMembers ¶
func (s *ProjectClient) GetProjectMembers(pid int64) ([]User, error)
GetProjectMembers Get members of the specified project
func (*ProjectClient) GetProjectMetadata ¶
func (s *ProjectClient) GetProjectMetadata(pid int64) (map[string]string, error)
GetProjectMetadataById Get the metadata of a project
func (*ProjectClient) GetProjectMetadataSingle ¶
func (s *ProjectClient) GetProjectMetadataSingle(pid int64, specified string) (map[string]string, error)
GetProjectMetadata Get the specified metadata value of a project
func (*ProjectClient) ListProjects ¶
func (s *ProjectClient) ListProjects(opt ListProjectsOptions) ([]Project, error)
List projects This endpoint returns all projects created by Harbor, and can be filtered by project name
func (*ProjectClient) UpdateProject ¶
func (s *ProjectClient) UpdateProject(pid int64, p Project) error
UpdateProject Update the properties of a project
func (*ProjectClient) UpdateProjectMember ¶
func (s *ProjectClient) UpdateProjectMember(pid, mid int64, role RoleRequest) error
UpdateProjectMember Update a project member
func (*ProjectClient) UpdateProjectMetadataSingle ¶
func (s *ProjectClient) UpdateProjectMetadataSingle(pid int64, metadataName string) error
UpdateProjectMetadata Update the metadata of a project
type ProjectMemberRequest ¶
type ProjectMemberRequest struct { RoleID int `json:"role_id"` MemberUser MemberUser `json:"member_user"` }
ProjectMemberRequest holds the information needed to add a project member
type ProjectMetadata ¶
type ProjectMetadata struct { ID int64 `json:"id"` ProjectID int64 `json:"project_id"` Name string `json:"name"` Value string `json:"value"` Deleted bool `json:"deleted"` }
ProjectMetadata holds the metadata of a project.
type ProjectRequest ¶
type ProjectRequest struct { Name string `url:"name,omitempty" json:"project_name"` Public *int `url:"public,omitempty" json:"public"` //deprecated, reserved for project creation in replication Metadata map[string]string `url:"-" json:"metadata"` }
ProjectRequest holds the information needed to create a project
type RepoRecord ¶
type RepoRecord struct { RepositoryID int64 `json:"repository_id"` Name string `json:"name"` ProjectID int64 `json:"project_id"` Description string `json:"description"` PullCount int64 `json:"pull_count"` StarCount int64 `json:"star_count"` }
RepoRecord holds the record of an repository, held by the database
type RepositoryClient ¶
type RepositoryClient struct {
// contains filtered or unexported fields
}
RepositoryClient handles communication with the repository related methods of the Harbor API
func (*RepositoryClient) DeleteRepository ¶
func (s *RepositoryClient) DeleteRepository(repoName string) (gorequest.Response, []error)
DeleteRepository Delete a repository
func (*RepositoryClient) DeleteRepositoryTag ¶
func (s *RepositoryClient) DeleteRepositoryTag(repoName, tag string) (gorequest.Response, []error)
DeleteRepositoryTag Delete tags of a repository
func (*RepositoryClient) GetImageDetails ¶
func (s *RepositoryClient) GetImageDetails(repoName, tag string) ([]VulnerabilityItem, gorequest.Response, []error)
GetImageDetails Get information from the Clair API containing vulnerability information based on the previous successful scan
func (*RepositoryClient) GetRepositorySignature ¶
func (s *RepositoryClient) GetRepositorySignature(repoName string) ([]Signature, gorequest.Response, []error)
GetRepositorySignature Get signature information of a repository, originating from the notary component of Harbor NOTE: If the repository does not have any signature information in notary, this API will return an empty list with response code 200, instead of 404
func (*RepositoryClient) GetRepositoryTag ¶
func (s *RepositoryClient) GetRepositoryTag(repoName, tag string) (TagResp, gorequest.Response, []error)
GetRepositoryTag Get the tag of a repository NOTE: If deployed with Notary, the signature property of response represents whether the image is signed or not If the property is null, the image is unsigned
func (*RepositoryClient) GetRepositoryTagManifests ¶
func (s *RepositoryClient) GetRepositoryTagManifests(repoName, tag string, version string) (ManifestResp, gorequest.Response, []error)
GetRepositoryTagManifests Get manifests from a relevant repository
func (*RepositoryClient) GetRepositoryTop ¶
func (s *RepositoryClient) GetRepositoryTop(top interface{}) ([]RepoResp, gorequest.Response, []error)
GetRepositoryTop Get the most popular public repositories
func (*RepositoryClient) ListRepository ¶
func (s *RepositoryClient) ListRepository(opt *ListRepositoriesOption) ([]RepoRecord, gorequest.Response, []error)
ListRepository Get repositories filtered by the relevant project ID and repository name
func (*RepositoryClient) ListRepositoryTags ¶
func (*RepositoryClient) ScanImage ¶
func (s *RepositoryClient) ScanImage(repoName, tag string) (gorequest.Response, []error)
ScanImage Trigger the jobservice component to call the Clair API to scan the image Only accessible for project admins
func (*RepositoryClient) UpdateRepository ¶
func (s *RepositoryClient) UpdateRepository(repoName string, d RepositoryDescription) (gorequest.Response, []error)
UpdateRepository Update the description of a repository
type RepositoryDescription ¶
type RepositoryDescription struct {
Description string `url:"description,omitempty" json:"description,omitempty"`
}
type Role ¶
type Role struct { RoleID int `json:"role_id"` RoleCode string `json:"role_code"` Name string `json:"role_name"` RoleMask int `json:"role_mask"` }
Role holds the details of a role.
type RoleRequest ¶
type RoleRequest struct {
Role int64 `json:"role"`
}
type Search ¶
type Search struct { // Search results of the projects that matched the filter keywords. Projects Project `json:"project,omitempty"` // Search results of the repositories that matched the filter keywords. Repositories []SearchRepository `json:"repository,omitempty"` }
type SearchRepository ¶
type SearchRepository struct { // The ID of the project that the repository belongs to ProjectId int32 `json:"project_id,omitempty"` // The name of the project that the repository belongs to ProjectName string `json:"project_name,omitempty"` // The flag to indicate the publicity of the project that the repository belongs to ProjectPublic bool `json:"project_public,omitempty"` // The name of the repository RepositoryName string `json:"repository_name,omitempty"` PullCount int32 `json:"pull_count,omitempty"` TagsCount int32 `json:"tags_count,omitempty"` }
type StatisticMap ¶
type StatisticMap struct { // The count of the private projects which the user is a member of. PrivateProjectCount int `json:"private_project_count,omitempty"` // The count of the private repositories belonging to the projects which the user is a member of. PrivateRepoCount int `json:"private_repo_count,omitempty"` // The count of the public projects. PublicProjectCount int `json:"public_project_count,omitempty"` // The count of the public repositories belonging to the public projects which the user is a member of. PublicRepoCount int `json:"public_repo_count,omitempty"` // The count of the total projects, only be seen when the is admin. TotalProjectCount int `json:"total_project_count,omitempty"` // The count of the total repositories, only be seen when the user is admin. TotalRepoCount int `json:"total_repo_count,omitempty"` }
type StatusCodeError ¶
func (*StatusCodeError) Error ¶
func (e *StatusCodeError) Error() string
type TagResp ¶
type TagResp struct { Signature *Signature `json:"signature"` ScanOverview *ImgScanOverview `json:"scan_overview,omitempty"` // contains filtered or unexported fields }
type User ¶
type User struct { UserID int64 `json:"user_id"` Username string `json:"username"` Email string `json:"email"` Password string `json:"password"` RealName string `json:"realname"` Comment string `json:"comment"` Deleted bool `json:"deleted"` RoleName string `json:"role_name"` Role int `json:"role_id"` RoleList []Role `json:"role_list"` HasAdminRole bool `json:"has_admin_role"` ResetUUID string `json:"reset_uuid"` Salt string `json:"-"` }
User holds the details of a user
type UserClient ¶
type UserClient struct {
*Client
}
UserClient handles communication with the user related methods of the Harbor API
func (*UserClient) DeleteUser ¶
func (s *UserClient) DeleteUser(usr UserRequest) error
DeleteUser Delete a user
func (*UserClient) GetUser ¶
func (s *UserClient) GetUser(usr UserRequest) (User, error)
GetUser Get a user's profile by ID
func (*UserClient) ListUsers ¶
func (s *UserClient) ListUsers() ([]User, error)
ListUsers Get a list of users
func (*UserClient) SearchUser ¶
func (s *UserClient) SearchUser(usr UserRequest) (UserSearchResults, error)
SearchUser Search User searches for a user by name
func (*UserClient) ToggleUserSysAdmin ¶
func (s *UserClient) ToggleUserSysAdmin(usr UserRequest) error
ToggleUserSysAdmin Toggle administrator privileges of a user
func (*UserClient) UpdateUserPassword ¶
func (s *UserClient) UpdateUserPassword(uid int64, oldPw, newPw string) error
UpdateUserPassword Update a users password NOTE: when using an admin user, the usage of ChangePasswordAsAdmin is recommended
func (*UserClient) UpdateUserPasswordAsAdmin ¶
func (s *UserClient) UpdateUserPasswordAsAdmin(uid int64, newPw string) error
UpdateUserPasswordAsAdmin Update a users password as admin (only usable by an admin user)
func (*UserClient) UpdateUserProfile ¶
func (s *UserClient) UpdateUserProfile(usr UserRequest) error
UpdateUserProfile Update a user's profile
type UserRequest ¶
type UserRequest struct { Username string `json:"username"` Password string `json:"password"` Email string `json:"email"` RealName string `json:"realname"` Comment string `json:"comment,omitempty"` Role int `json:"role_id"` HasAdminRole bool `json:"has_admin_role"` UserID int64 `json:"user_id,omitempty"` }
UserRequest holds the information needed for basic operations on users
type UserSearchResult ¶
UserSearchResult holds the information returned by the API when querying for a user name
type UserSearchResults ¶
type UserSearchResults []UserSearchResult
type VulnerabilityItem ¶
type VulnerabilityItem struct { ID string `json:"id"` Severity int64 `json:"severity"` Pkg string `json:"package"` Version string `json:"version"` Description string `json:"description"` Link string `json:"link"` Fixed string `json:"fixedVersion,omitempty"` }
VulnerabilityItem is an item in the vulnerability result returned by the vulnerability details API