Skip to content

Commit

Permalink
Merge pull request #191 from cvegagimenez/fix/immutable-client
Browse files Browse the repository at this point in the history
fix: RestClient for immutable rules
  • Loading branch information
elenz97 authored Jul 25, 2024
2 parents e8e1e62 + 99795c9 commit 2bf7f02
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions apiv2/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"strings"

"github.com/mittwald/goharbor-client/v5/apiv2/pkg/clients/configure"
"github.com/mittwald/goharbor-client/v5/apiv2/pkg/clients/immutable"
"github.com/mittwald/goharbor-client/v5/apiv2/pkg/clients/ping"
"github.com/mittwald/goharbor-client/v5/apiv2/pkg/clients/scanall"
"github.com/mittwald/goharbor-client/v5/apiv2/pkg/clients/statistic"
Expand Down Expand Up @@ -58,6 +59,7 @@ type Client interface {
configure.Client
gc.Client
health.Client
immutable.Client
label.Client
member.Client
ping.Client
Expand All @@ -84,6 +86,7 @@ type RESTClient struct {
configure *configure.RESTClient
gc *gc.RESTClient
health *health.RESTClient
immutable *immutable.RESTClient
label *label.RESTClient
member *member.RESTClient
ping *ping.RESTClient
Expand Down Expand Up @@ -116,6 +119,7 @@ func NewRESTClient(v2Client *v2client.Harbor, opts *config.Options, authInfo run
configure: configure.NewClient(v2Client, opts, authInfo),
gc: gc.NewClient(v2Client, opts, authInfo),
health: health.NewClient(v2Client, opts, authInfo),
immutable: immutable.NewClient(v2Client, opts, authInfo),
label: label.NewClient(v2Client, opts, authInfo),
member: member.NewClient(v2Client, opts, authInfo),
ping: ping.NewClient(v2Client, opts, authInfo),
Expand Down Expand Up @@ -281,6 +285,24 @@ func (c *RESTClient) GetHealth(ctx context.Context) (*modelv2.OverallHealthStatu
return c.health.GetHealth(ctx)
}

// Immutable Client

func (c *RESTClient) CreateImmuRule(ctx context.Context, projectNameOrID string, immutableRule *modelv2.ImmutableRule) error {
return c.immutable.CreateImmuRule(ctx, projectNameOrID, immutableRule)
}

func (c *RESTClient) UpdateImmuRule(ctx context.Context, projectNameOrID string, immutableRule *modelv2.ImmutableRule, immutableRuleID int64) error {
return c.immutable.UpdateImmuRule(ctx, projectNameOrID, immutableRule, immutableRuleID)
}

func (c *RESTClient) DeleteImmuRule(ctx context.Context, projectNameOrID string, immutableRuleID int64) error {
return c.immutable.DeleteImmuRule(ctx, projectNameOrID, immutableRuleID)
}

func (c *RESTClient) ListImmuRules(ctx context.Context, projectNameOrID string) ([]*modelv2.ImmutableRule, error) {
return c.immutable.ListImmuRules(ctx, projectNameOrID)
}

// Label Client

func (c *RESTClient) CreateLabel(ctx context.Context, l *modelv2.Label) error {
Expand Down
2 changes: 1 addition & 1 deletion apiv2/pkg/clients/immutable/immutable.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func NewClient(v2Client *v2client.Harbor, opts *config.Options, authInfo runtime

type Client interface {
CreateImmuRule(ctx context.Context, projectNameOrID string, immutableRule *model.ImmutableRule) error
UpdateImmuRule(ctx context.Context, projectNameOrID string, immutableRule *model.ImmutableRule) error
UpdateImmuRule(ctx context.Context, projectNameOrID string, immutableRule *model.ImmutableRule, immutableRuleID int64) error
DeleteImmuRule(ctx context.Context, projectNameOrID string, immutableRuleID int64) error
ListImmuRules(ctx context.Context, projectNameOrID string) ([]*model.ImmutableRule, error)
}
Expand Down

0 comments on commit 2bf7f02

Please sign in to comment.