Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: RestClient for immutable rules #191

Merged
merged 1 commit into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading