project

package
v5.4.1 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2023 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// ErrProjectIllegalIDFormatMsg is the error message for ErrProjectIllegalIDFormat error.
	ErrProjectIllegalIDFormatMsg = "illegal format of provided ID value"

	// ErrProjectUnauthorizedMsg is the error message for ErrProjectUnauthorized error.
	ErrProjectUnauthorizedMsg = "unauthorized"

	// ErrProjectInternalErrorsMsg is the error message for ErrProjectInternalErrors error.
	ErrProjectInternalErrorsMsg = "unexpected internal errors"

	// ErrProjectNoPermissionMsg is the error message for ErrProjectNoPermission error.
	ErrProjectNoPermissionMsg = "user does not have permission to the project"

	// ErrProjectIDNotExistsMsg is the error message for ErrProjectIDNotExists error.
	ErrProjectIDNotExistsMsg = "project ID does not exist"

	// ErrProjectNameAlreadyExistsMsg is the error message for ErrProjectNameAlreadyExists error.
	ErrProjectNameAlreadyExistsMsg = "project name already exists"

	// ErrProjectMismatchMsg is the error message for ErrProjectMismatch error.
	ErrProjectMismatchMsg = "id/name pair not found on server side"

	// ErrProjectNotFoundMsg is the error message for ErrProjectNotFound error.
	ErrProjectNotFoundMsg = "project not found on server side"

	// ErrProjectNotProvidedMsg is the error message for ErrProjectNotProvided error.
	ErrProjectNotProvidedMsg = "no project provided"

	// ErrProjectNoMemberProvidedMsg is the error message for ErrProjectNoMemberProvided error.
	ErrProjectNoMemberProvidedMsg = "no project member provided"

	// ErrProjectMemberMismatchMsg is the error message for ErrProjectMemberMismatch error.
	ErrProjectMemberMismatchMsg = "no user with id/name pair found on server side"

	// ErrProjectMemberIllegalFormatMsg is the error message for ErrProjectMemberIllegalFormat error.
	ErrProjectMemberIllegalFormatMsg = "illegal format of project member or project id is invalid, or LDAP DN is invalid"

	// ErrProjectUserIsNoMemberMsg is the error message for ErrProjectUserIsNoMember.
	ErrProjectUserIsNoMemberMsg = "user is no member in project"

	// ErrProjectInvalidRequestMsg is the error message for ErrProjectInvalidRequest error.
	ErrProjectInvalidRequestMsg = "invalid request"

	// ErrProjectMetadataAlreadyExistsMsg is the error message for ErrProjectMetadataAlreadyExists error.
	ErrProjectMetadataAlreadyExistsMsg = "metadata key already exists"

	// ErrProjectUnknownResourceMsg is the error message for ErrProjectUnknownResource error.
	ErrProjectUnknownResourceMsg = "resource unknown"

	// ErrProjectNameNotProvidedMsg is the error message for ErrProjectNameNotProvided error.
	ErrProjectNameNotProvidedMsg = "project name not provided"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	NewProject(ctx context.Context, name string, countLimit int, storageLimit int)
	DeleteProject(ctx context.Context, p *model.Project) error
	GetProject(ctx context.Context, name string) (*model.Project, error)
	ListProjects(ctx context.Context, nameFilter string) ([]*model.Project, error)
	UpdateProject(ctx context.Context, p *model.Project, countLimit int, storageLimit int) error
	AddProjectMember(ctx context.Context, p *model.Project, u *model.User, roleID int) error
	ListProjectMembers(ctx context.Context, p *model.Project) ([]*model.ProjectMemberEntity, error)
	UpdateProjectMemberRole(ctx context.Context, p *model.Project, u *model.User, roleID int) error
	DeleteProjectMember(ctx context.Context, p *model.Project, u *model.User) error
	AddProjectMetadata(ctx context.Context, p *model.Project, key MetadataKey, value string) error
	ListProjectMetadata(ctx context.Context, p *model.Project) (*model.ProjectMetadata, error)
	GetProjectMetadataValue(ctx context.Context, p *model.Project, key MetadataKey) (string, error)
	UpdateProjectMetadata(ctx context.Context, p *model.Project, key MetadataKey, value string) error
	DeleteProjectMetadataValue(ctx context.Context, p *model.Project, key MetadataKey) error
}

type ErrProjectIDNotExists

type ErrProjectIDNotExists struct{}

ErrProjectIDNotExists describes an error when no proper project ID is found.

func (*ErrProjectIDNotExists) Error

func (e *ErrProjectIDNotExists) Error() string

Error returns the error message.

type ErrProjectIllegalIDFormat

type ErrProjectIllegalIDFormat struct{}

ErrProjectIllegalIDFormat describes an illegal request format.

func (*ErrProjectIllegalIDFormat) Error

func (e *ErrProjectIllegalIDFormat) Error() string

Error returns the error message.

type ErrProjectInternalErrors

type ErrProjectInternalErrors struct{}

ErrProjectInternalErrors describes server-side internal errors.

func (*ErrProjectInternalErrors) Error

func (e *ErrProjectInternalErrors) Error() string

Error returns the error message.

type ErrProjectInvalidRequest

type ErrProjectInvalidRequest struct{}

ErrProjectMemberIllegalFormat describes an communication error when performing project member operations.

func (*ErrProjectInvalidRequest) Error

func (e *ErrProjectInvalidRequest) Error() string

Error returns the error message.

type ErrProjectMemberIllegalFormat

type ErrProjectMemberIllegalFormat struct{}

ErrProjectMemberIllegalFormat describes an communication error when performing project member operations.

func (*ErrProjectMemberIllegalFormat) Error

Error returns the error message.

type ErrProjectMemberMismatch

type ErrProjectMemberMismatch struct{}

ErrProjectMemberMismatch describes an error when user does not exist in context of project member operations.

func (*ErrProjectMemberMismatch) Error

func (e *ErrProjectMemberMismatch) Error() string

Error returns the error message.

type ErrProjectMetadataAlreadyExists

type ErrProjectMetadataAlreadyExists struct{}

ErrProjectMetadataAlreadyExists describes an error, which happens when a metadata key of a project is tried to be created a second time.

func (*ErrProjectMetadataAlreadyExists) Error

Error returns the error message.

type ErrProjectMismatch

type ErrProjectMismatch struct{}

ErrProjectMismatch describes a failed lookup of a project with name/id pair.

func (*ErrProjectMismatch) Error

func (e *ErrProjectMismatch) Error() string

Error returns the error message.

type ErrProjectNameAlreadyExists

type ErrProjectNameAlreadyExists struct{}

ErrProjectNameAlreadyExists describes a duplicate project name error.

func (*ErrProjectNameAlreadyExists) Error

Error returns the error message.

type ErrProjectNameNotProvided

type ErrProjectNameNotProvided struct{}

ErrProjectNameNotProvided describes a missing project name.

func (*ErrProjectNameNotProvided) Error

func (e *ErrProjectNameNotProvided) Error() string

Error returns the error message.

type ErrProjectNoMemberProvided

type ErrProjectNoMemberProvided struct{}

ErrProjectNoMemberProvided

func (*ErrProjectNoMemberProvided) Error

Error returns the error message.

type ErrProjectNoPermission

type ErrProjectNoPermission struct{}

ErrProjectNoPermission describes a request error without permission.

func (*ErrProjectNoPermission) Error

func (e *ErrProjectNoPermission) Error() string

Error returns the error message.

type ErrProjectNotFound

type ErrProjectNotFound struct{}

ErrProjectNotFound describes an error when a specific project is not found.

func (*ErrProjectNotFound) Error

func (e *ErrProjectNotFound) Error() string

Error returns the error message.

type ErrProjectNotProvided

type ErrProjectNotProvided struct{}

func (*ErrProjectNotProvided) Error

func (e *ErrProjectNotProvided) Error() string

Error returns the error message.

type ErrProjectUnauthorized

type ErrProjectUnauthorized struct{}

ErrProjectUnauthorized describes an unauthorized request.

func (*ErrProjectUnauthorized) Error

func (e *ErrProjectUnauthorized) Error() string

Error returns the error message.

type ErrProjectUnknownResource

type ErrProjectUnknownResource struct{}

ErrProjectUnknownResource describes which happens, when requesting an unknown resource.

func (*ErrProjectUnknownResource) Error

func (e *ErrProjectUnknownResource) Error() string

Error returns the error message.

type ErrProjectUserIsNoMember

type ErrProjectUserIsNoMember struct{}

ErrProjectUserIsNoMember describes an error case, where a given user is no member of a given project.

func (*ErrProjectUserIsNoMember) Error

func (e *ErrProjectUserIsNoMember) Error() string

Error returns the error message.

type MetadataKey

type MetadataKey string
const (
	ProjectMetadataKeyEnableContentTrust   MetadataKey = "enable_content_trust"
	ProjectMetadataKeyAutoScan             MetadataKey = "auto_scan"
	ProjectMetadataKeySeverity             MetadataKey = "severity"
	ProjectMetadataKeyReuseSysCVEWhitelist MetadataKey = "reuse_sys_cve_whitelist"
	ProjectMetadataKeyPublic               MetadataKey = "public"
	ProjectMetadataKeyPreventVul           MetadataKey = "prevent_vul"
)

type RESTClient

type RESTClient struct {
	// The swagger client
	Client *client.Harbor

	// AuthInfo contain auth information, which are provided on API calls.
	AuthInfo runtime.ClientAuthInfoWriter
}

RESTClient is a subclient forhandling project related actions.

func NewClient

func NewClient(cl *client.Harbor, authInfo runtime.ClientAuthInfoWriter) *RESTClient

func (*RESTClient) AddProjectMember

func (c *RESTClient) AddProjectMember(ctx context.Context, p *model.Project, u *model.User, roleID int) error

AddProjectMember creates a membership between a user and a project.

func (*RESTClient) AddProjectMetadata

func (c *RESTClient) AddProjectMetadata(ctx context.Context, p *model.Project, key MetadataKey, value string) error

AddMetadata adds metadata with a specific key and value to project p. See this for more explanation of possible keys and values: https://github.com/goharbor/harbor/blob/v1.10.2/api/harbor/swagger.yaml#L4894

func (*RESTClient) DeleteProject

func (c *RESTClient) DeleteProject(ctx context.Context,
	p *model.Project) error

DeleteProject deletes the specified project. Returns an error when no matching project is found or when having difficulties talking to the API.

func (*RESTClient) DeleteProjectMember

func (c *RESTClient) DeleteProjectMember(ctx context.Context, p *model.Project, u *model.User) error

DeleteProjectMember deletes the membership between a user and a project.

func (*RESTClient) DeleteProjectMetadataValue

func (c *RESTClient) DeleteProjectMetadataValue(ctx context.Context, p *model.Project, key MetadataKey) error

DeleteMetadataValue deletes metadata of project p given by key.

func (*RESTClient) GetProject

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

GetProject returns an existing project identified by name. Returns an error if it cannot find a matching project or when having difficulties talking to the API.

func (*RESTClient) GetProjectMetadataValue

func (c *RESTClient) GetProjectMetadataValue(ctx context.Context, p *model.Project, key MetadataKey) (string, error)

GetProjectMetadataValue retrieves metadata with key of project p.

func (*RESTClient) ListProjectMembers

func (c *RESTClient) ListProjectMembers(ctx context.Context, p *model.Project) ([]*model.ProjectMemberEntity, error)

ListProjectMembers returns a list of project members.

func (*RESTClient) ListProjectMetadata

func (c *RESTClient) ListProjectMetadata(ctx context.Context, p *model.Project) (*model.ProjectMetadata, error)

ListMetadata lists all metadata of a project

func (*RESTClient) ListProjects

func (c *RESTClient) ListProjects(ctx context.Context,
	nameFilter string) ([]*model.Project, error)

ListProjects returns a list of projects based on a name filter. Returns all projects if name is an empty string. Returns an error if no projects were found.

func (*RESTClient) NewProject

func (c *RESTClient) NewProject(ctx context.Context, name string,
	countLimit int, storageLimit int) (*model.Project, error)

NewProject creates a new project with name as the project's name. Returns the project as it is stored inside Harbor or an error, if the project could not be created. CountLimit limits the number of repositories for this project. StorageLimit limits the allocatable space for this project.

func (*RESTClient) UpdateProject

func (c *RESTClient) UpdateProject(ctx context.Context, p *model.Project,
	countLimit int, storageLimit int) error

UpdateProject updates a project with the specified data. Returns an error if name/ID pair of p does not match a stored project.

func (*RESTClient) UpdateProjectMemberRole

func (c *RESTClient) UpdateProjectMemberRole(ctx context.Context, p *model.Project, u *model.User, roleID int) error

UpdateProjectMemberRole updates the role of a project member.

func (*RESTClient) UpdateProjectMetadata

func (c *RESTClient) UpdateProjectMetadata(ctx context.Context, p *model.Project, key MetadataKey, value string) error

UpdateMetadata deletes the specified metadata key, if it exists and re-adds this metadata key with the given value. This function works around the faulty behaviour of the corresponding 'Update' endpoint of the Harbor API.

Jump to

Keyboard shortcuts

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