Skip to content

Commit

Permalink
Merge pull request #184 from mittwald/task/bump-2-9-api
Browse files Browse the repository at this point in the history
bump v2 client apis to 2.9.1
  • Loading branch information
elenz97 authored Apr 23, 2024
2 parents ebbfe43 + 0bf977d commit 6734fd4
Show file tree
Hide file tree
Showing 43 changed files with 1,800 additions and 241 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ harbor-teardown test integration-test-v1-ci integration-test-v2-ci integration-t
fmt gofmt gofumpt goimports lint uninstall-harbor-v2 uninstall-harbor-v1

V1_VERSION = v1.10.18
V2_VERSION = v2.8.3
V2_VERSION = v2.9.1
MOCKERY_VERSION = v2.14.0
GOSWAGGER_VERSION = v0.25.0
GOLANGCI_LINT_VERSION = v1.50.1
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ A Go client library enabling programs to perform CRUD operations on the [goharbo
This client library utilizes types generated by [go-swagger](https://github.com/go-swagger/go-swagger).

## Compatibility
This library includes separate clients supporting the **v1.10** & **v2.8** versions of goharbor.
This library includes separate clients supporting the **v1.10** & **v2.9** versions of goharbor.

## Installation
Install the desired client library version using `go get`:
Expand Down
27 changes: 18 additions & 9 deletions apiv1/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ func (c *RESTClient) UpdateUserPassword(ctx context.Context, id int64, password

// NewProject wraps the NewProject method of the project sub-package.
func (c *RESTClient) NewProject(ctx context.Context, name string,
countLimit int, storageLimit int) (*model.Project, error) {
countLimit int, storageLimit int,
) (*model.Project, error) {
return c.project.NewProject(ctx, name, countLimit, storageLimit)
}

Expand Down Expand Up @@ -140,7 +141,8 @@ func (c *RESTClient) DeleteProjectMember(ctx context.Context, p *model.Project,

// AddProjectMetadata wraps the AddProjectMetadata method of the project sub-package.
func (c *RESTClient) AddProjectMetadata(ctx context.Context,
p *model.Project, key project.MetadataKey, value string) error {
p *model.Project, key project.MetadataKey, value string,
) error {
return c.project.AddProjectMetadata(ctx, p, key, value)
}

Expand All @@ -151,21 +153,24 @@ func (c *RESTClient) ListProjectMetadata(ctx context.Context, p *model.Project)

// UpdateProjectMetadata wraps the UpdateProjectMetadata method of the project sub-package.
func (c *RESTClient) UpdateProjectMetadata(ctx context.Context,
p *model.Project, key project.MetadataKey, value string) error {
p *model.Project, key project.MetadataKey, value string,
) error {
return c.project.UpdateProjectMetadata(ctx, p, key, value)
}

// DeleteProjectMetadataValue wraps the DeleteProjectMetadataValue method of the project sub-package.
func (c *RESTClient) DeleteProjectMetadataValue(ctx context.Context,
p *model.Project, key project.MetadataKey) error {
p *model.Project, key project.MetadataKey,
) error {
return c.project.DeleteProjectMetadataValue(ctx, p, key)
}

// Registry Client

// NewRegistry wraps the NewRegistry method of the registry sub-package.
func (c *RESTClient) NewRegistry(ctx context.Context, name, registryType, url string,
credential *model.RegistryCredential, insecure bool) (*model.Registry, error) {
credential *model.RegistryCredential, insecure bool,
) (*model.Registry, error) {
return c.registry.NewRegistry(ctx, name, registryType, url,
credential, insecure)
}
Expand All @@ -190,7 +195,8 @@ func (c *RESTClient) UpdateRegistry(ctx context.Context, r *model.Registry) erro
// NewReplicationPolicy wraps the NewReplicationPolicy method of the replication sub-package.
func (c *RESTClient) NewReplicationPolicy(ctx context.Context, destRegistry, srcRegistry *model.Registry,
replicateDeletion, override, enablePolicy bool, filters []*model.ReplicationFilter,
trigger *model.ReplicationTrigger, destNamespace, description, name string) (*model.ReplicationPolicy, error) {
trigger *model.ReplicationTrigger, destNamespace, description, name string,
) (*model.ReplicationPolicy, error) {
return c.replication.NewReplicationPolicy(ctx, destRegistry, srcRegistry, replicateDeletion,
override, enablePolicy, filters, trigger, destNamespace, description, name)
}
Expand Down Expand Up @@ -222,7 +228,8 @@ func (c *RESTClient) TriggerReplicationExecution(ctx context.Context, r *model.R

// GetReplicationExecutions wraps the GetReplicationExecutions method of the replication sub-package.
func (c *RESTClient) GetReplicationExecutions(ctx context.Context,
r *model.ReplicationExecution) ([]*model.ReplicationExecution, error) {
r *model.ReplicationExecution,
) ([]*model.ReplicationExecution, error) {
return c.replication.GetReplicationExecutions(ctx, r)
}

Expand All @@ -235,13 +242,15 @@ func (c *RESTClient) GetReplicationExecutionByID(ctx context.Context, id int64)

// NewSystemGarbageCollection wraps the NewSystemGarbageCollection method of the system sub-package.
func (c *RESTClient) NewSystemGarbageCollection(ctx context.Context,
cron, scheduleType string) (*model.AdminJobSchedule, error) {
cron, scheduleType string,
) (*model.AdminJobSchedule, error) {
return c.system.NewSystemGarbageCollection(ctx, cron, scheduleType)
}

// UpdateSystemGarbageCollection wraps the UpdateSystemGarbageCollection method of the system sub-package.
func (c *RESTClient) UpdateSystemGarbageCollection(ctx context.Context,
newGcSchedule *model.AdminJobScheduleObj) error {
newGcSchedule *model.AdminJobScheduleObj,
) error {
return c.system.UpdateSystemGarbageCollection(ctx, newGcSchedule)
}

Expand Down
15 changes: 10 additions & 5 deletions apiv1/project/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ type Client interface {
// CountLimit limits the number of repositories for this project.
// StorageLimit limits the allocatable space for this project.
func (c *RESTClient) NewProject(ctx context.Context, name string,
countLimit int, storageLimit int) (*model.Project, error) {
countLimit int, storageLimit int,
) (*model.Project, error) {
pReq := &model.ProjectReq{
CveWhitelist: nil,
Metadata: nil,
Expand Down Expand Up @@ -93,7 +94,8 @@ func (c *RESTClient) NewProject(ctx context.Context, name string,
// Returns an error when no matching project is found or when
// having difficulties talking to the API.
func (c *RESTClient) DeleteProject(ctx context.Context,
p *model.Project) error {
p *model.Project,
) error {
if p == nil {
return &ErrProjectNotProvided{}
}
Expand All @@ -119,7 +121,8 @@ func (c *RESTClient) DeleteProject(ctx context.Context,
// Returns an error if it cannot find a matching project or when
// having difficulties talking to the API.
func (c *RESTClient) GetProject(ctx context.Context,
name string) (*model.Project, error) {
name string,
) (*model.Project, error) {
if name == "" {
return nil, &ErrProjectNameNotProvided{}
}
Expand All @@ -145,7 +148,8 @@ func (c *RESTClient) GetProject(ctx context.Context,
// Returns all projects if name is an empty string.
// Returns an error if no projects were found.
func (c *RESTClient) ListProjects(ctx context.Context,
nameFilter string) ([]*model.Project, error) {
nameFilter string,
) ([]*model.Project, error) {
resp, err := c.Client.Products.GetProjects(
&products.GetProjectsParams{
Name: &nameFilter,
Expand All @@ -165,7 +169,8 @@ func (c *RESTClient) ListProjects(ctx context.Context,
// UpdateProject updates a project with the specified data.
// Returns an error if name/ID pair of p does not match a stored project.
func (c *RESTClient) UpdateProject(ctx context.Context, p *model.Project,
countLimit int, storageLimit int) error {
countLimit int, storageLimit int,
) error {
project, err := c.GetProject(ctx, p.Name)
if err != nil {
return err
Expand Down
6 changes: 4 additions & 2 deletions apiv1/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ type Client interface {
// Returns the registry as it is stored inside Harbor or an error,
// if it cannot be created.
func (c *RESTClient) NewRegistry(ctx context.Context, name, registryType, url string,
credential *model.RegistryCredential, insecure bool) (*model.Registry, error) {
credential *model.RegistryCredential, insecure bool,
) (*model.Registry, error) {
rReq := &model.Registry{
Credential: credential,
Insecure: insecure,
Expand Down Expand Up @@ -94,7 +95,8 @@ func (c *RESTClient) GetRegistry(ctx context.Context, name string) (*model.Regis
// Returns an error when no matching registry is found or when
// having difficulties talking to the API.
func (c *RESTClient) DeleteRegistry(ctx context.Context,
r *model.Registry) error {
r *model.Registry,
) error {
if r == nil {
return &ErrRegistryNotProvided{}
}
Expand Down
9 changes: 6 additions & 3 deletions apiv1/replication/replication.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ type Client interface {
func (c *RESTClient) NewReplicationPolicy(ctx context.Context, destRegistry, srcRegistry *model.Registry,
replicateDeletion, override, enablePolicy bool,
filters []*model.ReplicationFilter, trigger *model.ReplicationTrigger,
destNamespace, description, name string) (*model.ReplicationPolicy, error) {
destNamespace, description, name string,
) (*model.ReplicationPolicy, error) {
pReq := &model.ReplicationPolicy{
Deletion: replicateDeletion,
Description: description,
Expand Down Expand Up @@ -125,7 +126,8 @@ func (c *RESTClient) GetReplicationPolicyByID(ctx context.Context, id int64) (*m
// Returns an error when no matching replication is found or when
// having difficulties talking to the API.
func (c *RESTClient) DeleteReplicationPolicy(ctx context.Context,
r *model.ReplicationPolicy) error {
r *model.ReplicationPolicy,
) error {
if r == nil {
return &ErrReplicationNotProvided{}
}
Expand All @@ -150,7 +152,8 @@ func (c *RESTClient) DeleteReplicationPolicy(ctx context.Context,

// Update updates a replication.
func (c *RESTClient) UpdateReplicationPolicy(ctx context.Context,
r *model.ReplicationPolicy) error {
r *model.ReplicationPolicy,
) error {
if r == nil {
return &ErrReplicationNotProvided{}
}
Expand Down
6 changes: 4 additions & 2 deletions apiv1/system/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ type Client interface {

// NewSystemGarbageCollection creates a new garbage collection schedule.
func (c *RESTClient) NewSystemGarbageCollection(ctx context.Context, cron,
scheduleType string) (*model.AdminJobSchedule, error) {
scheduleType string,
) (*model.AdminJobSchedule, error) {
gcReq := &model.AdminJobSchedule{
Schedule: &model.AdminJobScheduleObj{
Cron: cron,
Expand Down Expand Up @@ -64,7 +65,8 @@ func (c *RESTClient) NewSystemGarbageCollection(ctx context.Context, cron,

// UpdateSystemGarbageCollection updates the system GC schedule.
func (c *RESTClient) UpdateSystemGarbageCollection(ctx context.Context,
newGcSchedule *model.AdminJobScheduleObj) error {
newGcSchedule *model.AdminJobScheduleObj,
) error {
if newGcSchedule == nil {
return &ErrSystemGcScheduleNotProvided{}
}
Expand Down
3 changes: 2 additions & 1 deletion apiv1/user/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ type Client interface {
// password is the password for this user.
// comments as a comment attached to the user.
func (c *RESTClient) NewUser(ctx context.Context, username, email, realname, password,
comments string) (*model.User, error) {
comments string,
) (*model.User, error) {
uReq := &model.User{
Username: username,
Password: password,
Expand Down
12 changes: 11 additions & 1 deletion apiv2/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,24 +374,31 @@ func (c *RESTClient) DeleteProjectMetadataValue(ctx context.Context, projectName
func (c *RESTClient) CreatePurgeSchedule(ctx context.Context, schedule *modelv2.Schedule) error {
return c.purge.CreatePurgeSchedule(ctx, schedule)
}

func (c *RESTClient) RunPurge(ctx context.Context, dryRun bool) error {
return c.purge.RunPurge(ctx, dryRun)
}

func (c *RESTClient) ListPurgeHistory(ctx context.Context) ([]*modelv2.ExecHistory, error) {
return c.purge.ListPurgeHistory(ctx)
}

func (c *RESTClient) GetPurgeJob(ctx context.Context, id int64) (*modelv2.ExecHistory, error) {
return c.purge.GetPurgeJob(ctx, id)
}

func (c *RESTClient) GetPurgeJobLog(ctx context.Context, id int64) (string, error) {
return c.purge.GetPurgeJobLog(ctx, id)
}

func (c *RESTClient) GetPurgeSchedule(ctx context.Context) (*modelv2.ExecHistory, error) {
return c.purge.GetPurgeSchedule(ctx)
}

func (c *RESTClient) StopPurge(ctx context.Context, id int64) error {
return c.purge.StopPurge(ctx, id)
}

func (c *RESTClient) UpdatePurgeSchedule(ctx context.Context, schedule *modelv2.Schedule) error {
return c.purge.UpdatePurgeSchedule(ctx, schedule)
}
Expand Down Expand Up @@ -441,7 +448,8 @@ func (c *RESTClient) UpdateRegistry(ctx context.Context, u *modelv2.RegistryUpda
func (c *RESTClient) NewReplicationPolicy(ctx context.Context, destRegistry, srcRegistry *modelv2.Registry,
replicateDeletion, override, enablePolicy bool,
filters []*modelv2.ReplicationFilter, trigger *modelv2.ReplicationTrigger,
destNamespace, description, name string) error {
destNamespace, description, name string,
) error {
return c.replication.NewReplicationPolicy(ctx, destRegistry, srcRegistry,
replicateDeletion, override, enablePolicy,
filters, trigger, destNamespace, description, name)
Expand Down Expand Up @@ -590,9 +598,11 @@ func (c *RESTClient) GetStatistic(ctx context.Context) (*modelv2.Statistic, erro
func (c *RESTClient) CreateScanAllSchedule(ctx context.Context, schedule *modelv2.Schedule) error {
return c.scanall.CreateScanAllSchedule(ctx, schedule)
}

func (c *RESTClient) GetScanAllSchedule(ctx context.Context) (*modelv2.Schedule, error) {
return c.scanall.GetScanAllSchedule(ctx)
}

func (c *RESTClient) UpdateScanAllSchedule(ctx context.Context, schedule *modelv2.Schedule) error {
return c.scanall.UpdateScanAllSchedule(ctx, schedule)
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions apiv2/internal/api/client/harbor_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6734fd4

Please sign in to comment.