fix: [CODE-2855]: Use space permissions in labels and rules controllers (#3060)

* Use space permissions in labels and rules controllers
This commit is contained in:
Darko Draskovic 2024-11-27 17:22:55 +00:00 committed by Harness
parent 843dc4df5f
commit 1c0e049151
14 changed files with 14 additions and 14 deletions

View File

@ -30,7 +30,7 @@ func (c *Controller) DefineLabel(
spaceRef string, spaceRef string,
in *types.DefineLabelInput, in *types.DefineLabelInput,
) (*types.Label, error) { ) (*types.Label, error) {
space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionRepoEdit) space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionSpaceEdit)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to acquire access to space: %w", err) return nil, fmt.Errorf("failed to acquire access to space: %w", err)
} }

View File

@ -29,7 +29,7 @@ func (c *Controller) DeleteLabel(
spaceRef string, spaceRef string,
key string, key string,
) error { ) error {
space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionRepoEdit) space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionSpaceEdit)
if err != nil { if err != nil {
return fmt.Errorf("failed to acquire access to space: %w", err) return fmt.Errorf("failed to acquire access to space: %w", err)
} }

View File

@ -30,7 +30,7 @@ func (c *Controller) ListLabels(
spaceRef string, spaceRef string,
filter *types.LabelFilter, filter *types.LabelFilter,
) ([]*types.Label, int64, error) { ) ([]*types.Label, int64, error) {
space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionRepoView) space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionSpaceView)
if err != nil { if err != nil {
return nil, 0, fmt.Errorf("failed to acquire access to space: %w", err) return nil, 0, fmt.Errorf("failed to acquire access to space: %w", err)
} }

View File

@ -30,7 +30,7 @@ func (c *Controller) SaveLabel(
spaceRef string, spaceRef string,
in *types.SaveInput, in *types.SaveInput,
) (*types.LabelWithValues, error) { ) (*types.LabelWithValues, error) {
space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionRepoEdit) space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionSpaceEdit)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to acquire access to space: %w", err) return nil, fmt.Errorf("failed to acquire access to space: %w", err)
} }

View File

@ -31,7 +31,7 @@ func (c *Controller) UpdateLabel(
key string, key string,
in *types.UpdateLabelInput, in *types.UpdateLabelInput,
) (*types.Label, error) { ) (*types.Label, error) {
space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionRepoEdit) space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionSpaceEdit)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to acquire access to space: %w", err) return nil, fmt.Errorf("failed to acquire access to space: %w", err)
} }

View File

@ -31,7 +31,7 @@ func (c *Controller) DefineLabelValue(
key string, key string,
in *types.DefineValueInput, in *types.DefineValueInput,
) (*types.LabelValue, error) { ) (*types.LabelValue, error) {
space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionRepoEdit) space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionSpaceEdit)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to acquire access to space: %w", err) return nil, fmt.Errorf("failed to acquire access to space: %w", err)
} }

View File

@ -30,7 +30,7 @@ func (c *Controller) DeleteLabelValue(
key string, key string,
value string, value string,
) error { ) error {
space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionRepoEdit) space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionSpaceEdit)
if err != nil { if err != nil {
return fmt.Errorf("failed to acquire access to space: %w", err) return fmt.Errorf("failed to acquire access to space: %w", err)
} }

View File

@ -31,7 +31,7 @@ func (c *Controller) ListLabelValues(
key string, key string,
filter *types.ListQueryFilter, filter *types.ListQueryFilter,
) ([]*types.LabelValue, error) { ) ([]*types.LabelValue, error) {
space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionRepoView) space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionSpaceView)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to acquire access to space: %w", err) return nil, fmt.Errorf("failed to acquire access to space: %w", err)
} }

View File

@ -32,7 +32,7 @@ func (c *Controller) UpdateLabelValue(
value string, value string,
in *types.UpdateValueInput, in *types.UpdateValueInput,
) (*types.LabelValue, error) { ) (*types.LabelValue, error) {
space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionRepoEdit) space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionSpaceEdit)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to acquire access to space: %w", err) return nil, fmt.Errorf("failed to acquire access to space: %w", err)
} }

View File

@ -30,7 +30,7 @@ func (c *Controller) RuleCreate(ctx context.Context,
spaceRef string, spaceRef string,
in *rules.CreateInput, in *rules.CreateInput,
) (*types.Rule, error) { ) (*types.Rule, error) {
space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionRepoEdit) space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionSpaceEdit)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to acquire access to space: %w", err) return nil, fmt.Errorf("failed to acquire access to space: %w", err)
} }

View File

@ -28,7 +28,7 @@ func (c *Controller) RuleDelete(ctx context.Context,
spaceRef string, spaceRef string,
identifier string, identifier string,
) error { ) error {
space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionRepoEdit) space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionSpaceEdit)
if err != nil { if err != nil {
return fmt.Errorf("failed to acquire access to space: %w", err) return fmt.Errorf("failed to acquire access to space: %w", err)
} }

View File

@ -29,7 +29,7 @@ func (c *Controller) RuleFind(ctx context.Context,
spaceRef string, spaceRef string,
identifier string, identifier string,
) (*types.Rule, error) { ) (*types.Rule, error) {
space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionRepoView) space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionSpaceView)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to acquire access to space: %w", err) return nil, fmt.Errorf("failed to acquire access to space: %w", err)
} }

View File

@ -30,7 +30,7 @@ func (c *Controller) RuleList(ctx context.Context,
inherited bool, inherited bool,
filter *types.RuleFilter, filter *types.RuleFilter,
) ([]types.Rule, int64, error) { ) ([]types.Rule, int64, error) {
space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionRepoView) space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionSpaceView)
if err != nil { if err != nil {
return nil, 0, fmt.Errorf("failed to acquire access to space: %w", err) return nil, 0, fmt.Errorf("failed to acquire access to space: %w", err)
} }

View File

@ -31,7 +31,7 @@ func (c *Controller) RuleUpdate(ctx context.Context,
identifier string, identifier string,
in *rules.UpdateInput, in *rules.UpdateInput,
) (*types.Rule, error) { ) (*types.Rule, error) {
space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionRepoEdit) space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionSpaceEdit)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to acquire access to space: %w", err) return nil, fmt.Errorf("failed to acquire access to space: %w", err)
} }