harbor

package
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2026 License: Apache-2.0 Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsConflict added in v0.1.4

func IsConflict(err error) bool

IsConflict reports whether err is a 409 from Harbor.

func IsNotFound

func IsNotFound(err error) bool

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 New

func New(baseURL, username, password string) (*Client, error)

New returns a Client for the Harbor at baseURL, which excludes /api/v2.0.

func (*Client) CreateProject added in v0.1.3

func (c *Client) CreateProject(ctx context.Context, name string, public bool) error

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

func (c *Client) CreateRegistry(ctx context.Context, r *Registry) error

CreateRegistry adds a registry endpoint.

func (*Client) CreateRobot added in v0.1.4

func (c *Client) CreateRobot(ctx context.Context, r *Robot) (*Robot, error)

CreateRobot creates a robot and returns it with its ID, full name and secret.

func (*Client) DeleteEmptyProject added in v0.1.3

func (c *Client) DeleteEmptyProject(ctx context.Context, name string) error

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

func (c *Client) DeleteProject(ctx context.Context, name string) error

DeleteProject deletes a project along with every repository in it, since Harbor refuses to delete a project that still holds any.

func (*Client) DeleteRegistry

func (c *Client) DeleteRegistry(ctx context.Context, id int64) error

DeleteRegistry removes a registry endpoint. Harbor refuses while a project still proxies it.

func (*Client) DeleteRobot added in v0.1.4

func (c *Client) DeleteRobot(ctx context.Context, id int64) error

DeleteRobot deletes a robot; one already gone is not an error.

func (*Client) FindRobot added in v0.1.4

func (c *Client) FindRobot(ctx context.Context, projectID int64, name string) (int64, error)

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

func (c *Client) GetProject(ctx context.Context, name string) (*Project, error)

GetProject returns the project called name, or nil if there is none.

func (*Client) GetRegistry

func (c *Client) GetRegistry(ctx context.Context, name string) (*Registry, error)

GetRegistry returns the registry endpoint called name, or nil if there is none.

func (*Client) Ping

func (c *Client) Ping(ctx context.Context) error

Ping checks the credentials by fetching the current user.

func (*Client) RefreshRobotSecret added in v0.1.4

func (c *Client) RefreshRobotSecret(ctx context.Context, id int64) (string, error)

RefreshRobotSecret replaces a robot's secret and returns the new one.

func (*Client) RobotExists added in v0.1.4

func (c *Client) RobotExists(ctx context.Context, id int64) (bool, error)

RobotExists reports whether the robot with id is still in Harbor.

func (*Client) SetProjectPublic

func (c *Client) SetProjectPublic(ctx context.Context, name string, public bool) error

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

type RobotAccess struct {
	Resource string `json:"resource"`
	Action   string `json:"action"`
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL