harbor

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 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. It is a skip signal, not a hard failure: Harbor provisions users asynchronously, 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
	// desired: adding, re-roling and removing as needed.
	//
	// Users Harbor does not have yet (404 on add) are skipped and returned in
	// missingUsers for a later retry, without aborting the rest of the loop. An
	// error means an unrecoverable failure.
	ReconcileProjectMembers(ctx context.Context, projectName string, desired []ProjectMember) (missingUsers []string, err error)

	// EnsureRobot ensures the project's robot account exists.
	//
	// Credentials come back only when this call created the robot: Harbor reveals
	// a robot secret at the moment it sets one and never again. Nil credentials
	// mean "already there", not "failed" — callers needing credentials for such a
	// robot must ask RefreshRobotSecret.
	EnsureRobot(ctx context.Context, projectName string, robotName string) (*RobotCredentials, error)

	// RefreshRobotSecret has Harbor issue a new secret for an existing robot.
	// This invalidates the robot's previous secret, so it is for rebuilding lost
	// credentials rather than routine use. Refreshing a robot that does not exist
	// is an error.
	RefreshRobotSecret(ctx context.Context, projectName string, robotName string) (*RobotCredentials, 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