Documentation
¶
Overview ¶
Package harbor adapts goharbor/go-client to the parts of Harbor's v2.0 API the registry controllers use: registry endpoints, projects, and the repositories that have to go before a project can be deleted.
Index ¶
- func IsConflict(err error) bool
- func IsNotFound(err error) bool
- type Client
- func (c *Client) CreateProject(ctx context.Context, name string, public bool) error
- func (c *Client) CreateProxyProject(ctx context.Context, name string, registryID int64, public bool) error
- func (c *Client) CreateRegistry(ctx context.Context, r *Registry) error
- func (c *Client) CreateRobot(ctx context.Context, r *Robot) (*Robot, error)
- func (c *Client) DeleteEmptyProject(ctx context.Context, name string) error
- func (c *Client) DeleteProject(ctx context.Context, name string) error
- func (c *Client) DeleteRegistry(ctx context.Context, id int64) error
- func (c *Client) DeleteRobot(ctx context.Context, id int64) error
- func (c *Client) FindRobot(ctx context.Context, projectID int64, name string) (int64, error)
- func (c *Client) GetProject(ctx context.Context, name string) (*Project, error)
- func (c *Client) GetRegistry(ctx context.Context, name string) (*Registry, error)
- func (c *Client) Ping(ctx context.Context) error
- func (c *Client) RefreshRobotSecret(ctx context.Context, id int64) (string, error)
- func (c *Client) RobotExists(ctx context.Context, id int64) (bool, error)
- func (c *Client) SetProjectPublic(ctx context.Context, name string, public bool) error
- func (c *Client) SystemInfo(ctx context.Context) (*SystemInfo, error)
- func (c *Client) UpdateRegistry(ctx context.Context, id int64, url string, insecure bool, cred *Credential) error
- type Credential
- type Project
- type Registry
- type Robot
- type RobotAccess
- type RobotPermission
- type SystemInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsConflict ¶ added in v0.1.4
IsConflict reports whether err is a 409 from Harbor.
func IsNotFound ¶
IsNotFound reports whether err is a 404 from Harbor.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to one Harbor instance as one user.
func (*Client) CreateProject ¶ added in v0.1.3
CreateProject creates a project that holds what is pushed to it.
func (*Client) CreateProxyProject ¶
func (c *Client) CreateProxyProject(ctx context.Context, name string, registryID int64, public bool) error
CreateProxyProject creates a project that proxies registryID.
func (*Client) CreateRegistry ¶
CreateRegistry adds a registry endpoint.
func (*Client) CreateRobot ¶ added in v0.1.4
CreateRobot creates a robot and returns it with its ID, full name and secret.
func (*Client) DeleteEmptyProject ¶ added in v0.1.3
DeleteEmptyProject deletes a project, which Harbor refuses while it holds any repository. A project that is already gone is not an error.
func (*Client) DeleteProject ¶
DeleteProject deletes a project along with every repository in it, since Harbor refuses to delete a project that still holds any.
func (*Client) DeleteRegistry ¶
DeleteRegistry removes a registry endpoint. Harbor refuses while a project still proxies it.
func (*Client) DeleteRobot ¶ added in v0.1.4
DeleteRobot deletes a robot; one already gone is not an error.
func (*Client) FindRobot ¶ added in v0.1.4
FindRobot returns the id of the robot called name in the project with projectID, or 0. Harbor lists only system robots unless the query names a project, and stores names without its robot$ prefix, so this lists the project's robots and matches the name's end.
func (*Client) GetProject ¶
GetProject returns the project called name, or nil if there is none.
func (*Client) GetRegistry ¶
GetRegistry returns the registry endpoint called name, or nil if there is none.
func (*Client) RefreshRobotSecret ¶ added in v0.1.4
RefreshRobotSecret replaces a robot's secret and returns the new one.
func (*Client) RobotExists ¶ added in v0.1.4
RobotExists reports whether the robot with id is still in Harbor.
func (*Client) SetProjectPublic ¶
SetProjectPublic changes whether anonymous clients can pull from a project.
func (*Client) SystemInfo ¶
func (c *Client) SystemInfo(ctx context.Context) (*SystemInfo, error)
SystemInfo returns the instance's public addresses.
func (*Client) UpdateRegistry ¶
func (c *Client) UpdateRegistry(ctx context.Context, id int64, url string, insecure bool, cred *Credential) error
UpdateRegistry sets an endpoint's URL and, when cred is non-nil, its credential. A registry's type cannot be updated.
type Credential ¶
type Credential struct {
Type string `json:"type"`
AccessKey string `json:"access_key"`
AccessSecret string `json:"access_secret"`
}
Credential authenticates Harbor to an upstream registry.
type Project ¶
type Project struct {
ProjectID int64 `json:"project_id"`
Name string `json:"name"`
RegistryID int64 `json:"registry_id"`
Metadata map[string]string `json:"metadata"`
}
Project is a Harbor project. RegistryID is non-zero on a proxy-cache project and cannot change after creation.
type Registry ¶
type Registry struct {
ID int64 `json:"id,omitempty"`
Name string `json:"name"`
Type string `json:"type"`
URL string `json:"url"`
Insecure bool `json:"insecure"`
Credential *Credential `json:"credential,omitempty"`
}
Registry is a Harbor registry endpoint, the upstream side of a proxy cache. Harbor masks AccessSecret when reading one back.
type Robot ¶ added in v0.1.4
type Robot struct {
ID int64 `json:"id"`
Name string `json:"name"`
Level string `json:"level"`
Duration int64 `json:"duration"`
Permissions []RobotPermission `json:"permissions"`
Secret string `json:"secret,omitempty"`
}
Robot is a Harbor robot account. Name is the full username Harbor assigns, robot$<project>+<name> for a project robot, and Secret is only filled on creation or refresh.
type RobotAccess ¶ added in v0.1.4
RobotAccess is one action on one kind of resource.
type RobotPermission ¶ added in v0.1.4
type RobotPermission struct {
Kind string `json:"kind"`
Namespace string `json:"namespace"`
Access []RobotAccess `json:"access"`
}
RobotPermission grants a robot actions on resources in one project.
type SystemInfo ¶
type SystemInfo struct {
ExternalURL string `json:"external_url"`
RegistryURL string `json:"registry_url"`
}
SystemInfo is the subset of /systeminfo the controllers read.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package harbortest is an in-memory stand-in for the parts of Harbor's API that package harbor calls.
|
Package harbortest is an in-memory stand-in for the parts of Harbor's API that package harbor calls. |