repository

package
v1.3.4 Latest Latest
Warning

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

Go to latest
Published: May 28, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ProjectsCache

type ProjectsCache struct {
	// contains filtered or unexported fields
}

ProjectsCache is a cache for harbor projects it is protected against concurrent access with a mutex

func (*ProjectsCache) Get

func (p *ProjectsCache) Get() []harbor.Project

Get reads from the cache

func (*ProjectsCache) Set

func (p *ProjectsCache) Set(project harbor.Project)

Set sets the cache item

type Repository

type Repository struct {
	Client       harbor.API
	PollInterval time.Duration

	// StateHash is a uniqe number which is computed
	// with the projects and robots structs.
	// This is used to compare the old/new version of data
	StateHash     uint64
	ProjectsCache *ProjectsCache
	RobotsCache   *RobotsCache
	// contains filtered or unexported fields
}

Repository implements the harbor.API interface it caches the API resources using a polling mechanism in the background

func New

func New(client harbor.API, interval time.Duration) (*Repository, error)

New is the repository constructor

func (*Repository) BaseURL

func (r *Repository) BaseURL() string

BaseURL returns the harbor base url

func (*Repository) CreateRobotAccount

func (r *Repository) CreateRobotAccount(name string, pushAccess bool, project harbor.Project) (*harbor.CreateRobotResponse, error)

CreateRobotAccount creates a robot account and updates the internal cache

func (*Repository) DeleteRobotAccount

func (r *Repository) DeleteRobotAccount(project harbor.Project, robotID int) error

DeleteRobotAccount deletes the robot account and updates the internal cache

func (*Repository) GetRobotAccounts

func (r *Repository) GetRobotAccounts(project harbor.Project) ([]harbor.Robot, error)

GetRobotAccounts returns a list of robot accounts for the given project

func (*Repository) ListProjects

func (r *Repository) ListProjects() ([]harbor.Project, error)

ListProjects implements the harbor.API it returns all harbor projects

func (*Repository) Start added in v1.3.4

func (r *Repository) Start(stop <-chan struct{}) error

Start starts the goroutine which polls the API for changes The component will stop running when the channel is closed. Start blocks until the channel is closed

func (*Repository) Sync

func (r *Repository) Sync() <-chan struct{}

Sync returns a channel which notifies the user when the underlying data has changed

func (*Repository) Update

func (r *Repository) Update() error

Update fetches the projects and robot accounts

func (*Repository) UpdateHash

func (r *Repository) UpdateHash() error

UpdateHash recalculates the StateHash

type RobotsCache

type RobotsCache struct {
	// contains filtered or unexported fields
}

RobotsCache is a cache for robot accounts it is protected against concurrent access with a mutex

func (*RobotsCache) Get

func (r *RobotsCache) Get(key string) []harbor.Robot

Get returns an item from cache

func (*RobotsCache) Set

func (r *RobotsCache) Set(key string, val []harbor.Robot)

Set sets the cache item

Jump to

Keyboard shortcuts

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