harbor

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 10 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 is a minimal client for 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 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

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

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) 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) 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) 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 Error

type Error struct {
	Method string
	Path   string
	Status int
	Body   string
}

Error is a non-2xx response from Harbor.

func (*Error) Error

func (e *Error) Error() string

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 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