roles

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package roles manages global roles and global environments: the Access API's /api/v1/roles and /api/v1/environments (issue #77, decision 0013). The built-in roles and environments (types.BuiltinGlobalRoles, types.BuiltinEnvironments) are not stored; this package merges them with the stored custom ones, and it is how the permission evaluator reads a global role (Role, then types.RoleActions).

Index

Constants

View Source
const DefaultGlobalEnvironmentLimit = 10

DefaultGlobalEnvironmentLimit is how many global environments may exist, DEV and PROD among them, when nothing else is configured: Access's environments.global-limit (supported Access configurations; createglobalenvironment, "By default, Artifactory supports up to 10 global environments").

Variables

View Source
var (
	// ErrInvalid reports a request the API refuses as malformed.
	ErrInvalid = errors.New("invalid")
	// ErrBuiltin reports a change to a built-in role or environment.
	ErrBuiltin = errors.New("built in")
	// ErrNotFound reports a role or environment that does not exist.
	ErrNotFound = errors.New("not found")
	// ErrConflict reports a name that is already taken.
	ErrConflict = errors.New("already exists")
	// ErrInUse reports an environment that repositories still belong to.
	ErrInUse = errors.New("in use")
)

Errors the handlers map to statuses. The Access API returns their text verbatim, so package prefixes would change existing response messages.

Functions

This section is empty.

Types

type Service

type Service struct {
	Store store.Store
	// GlobalLimit caps the global environments, DEV and PROD included;
	// zero means DefaultGlobalEnvironmentLimit.
	GlobalLimit int
}

Service reads and writes global roles and environments in Store.

func (Service) CreateEnvironment

func (s Service) CreateEnvironment(ctx context.Context, name string) error

CreateEnvironment adds a global environment, while fewer than the limit exist.

func (Service) CreateRole

func (s Service) CreateRole(ctx context.Context, r types.Role) error

CreateRole adds a CUSTOM_GLOBAL role.

func (Service) DeleteEnvironment

func (s Service) DeleteEnvironment(ctx context.Context, name string) error

DeleteEnvironment removes a global environment that no repository or global role names.

func (Service) DeleteRole

func (s Service) DeleteRole(ctx context.Context, name string) error

DeleteRole removes a custom global role and every project membership's assignment of it.

func (Service) Environments

func (s Service) Environments(ctx context.Context) ([]string, error)

Environments returns the global environment names: DEV and PROD, then the stored ones by name.

func (Service) RenameEnvironment

func (s Service) RenameEnvironment(ctx context.Context, name, to string) error

RenameEnvironment renames a global environment and every repository and role that names it.

func (Service) Role

func (s Service) Role(ctx context.Context, name string) (types.Role, error)

Role returns the global role called name: a built-in one with any stored change to its actions and environments, or a custom one.

func (Service) Roles

func (s Service) Roles(ctx context.Context) ([]types.Role, error)

Roles returns the built-in global roles, with any stored changes to the predefined ones, then the custom ones by name.

func (Service) UpdateRole

func (s Service) UpdateRole(ctx context.Context, name string, r types.Role) error

UpdateRole replaces the global role called name with r. A custom role changes its description, actions and environments; a PREDEFINED one only its actions and environments, stored over the built-in defaults. No role is renamed or changes type, and the ADMIN role does not change at all.

Jump to

Keyboard shortcuts

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