harbor

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RoleProjectAdmin int = 1
	RoleDeveloper    int = 2
	RoleGuest        int = 3
)

Harbor project role IDs.

Variables

View Source
var ErrUserNotFound = errors.New("harbor user not found")

ErrUserNotFound is returned when Harbor reports the target user does not exist. Callers treat this as a skip signal rather than a hard failure, because the user may be provisioned asynchronously (e.g. on first OIDC login).

Functions

This section is empty.

Types

type Client

type Client interface {
	// EnsureProject ensures a Harbor project with the given name exists.
	EnsureProject(ctx context.Context, projectName string) error

	// ReconcileProjectMembers synchronizes the Harbor project membership to match
	// the desired list of members. It adds missing members, updates roles that
	// have changed, and removes members that are no longer desired.
	//
	// Desired users that do not yet exist in Harbor (404 on add) are skipped and
	// returned in missingUsers so the caller can schedule a later retry. Skipping
	// one user does not abort the rest of the loop; an error is only returned for
	// unrecoverable failures.
	ReconcileProjectMembers(ctx context.Context, projectName string, desired []ProjectMember) (missingUsers []string, err error)

	// EnsureRobotAccount ensures a robot account exists for the given project.
	// Returns the credentials and whether the robot was newly created.
	// If the robot already exists, created is false and credentials are nil.
	EnsureRobotAccount(ctx context.Context, projectName string, robotName string) (creds *RobotCredentials, created bool, err error)
}

Client defines the operations needed for workspace Harbor integration.

func NewClient

func NewClient(baseURL, username, password string) Client

NewClient creates a new Harbor API client.

type ProjectMember added in v0.8.7

type ProjectMember struct {
	Username string
	RoleID   int
}

ProjectMember represents a desired Harbor project member.

type RobotCredentials

type RobotCredentials struct {
	Name   string // full robot name, e.g. robot$workspace-mynamespace
	Secret string // the token/password
}

RobotCredentials holds the credentials returned by Harbor for a robot account.

Jump to

Keyboard shortcuts

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