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
- Variables
- type Service
- func (s Service) CreateEnvironment(ctx context.Context, name string) error
- func (s Service) CreateRole(ctx context.Context, r types.Role) error
- func (s Service) DeleteEnvironment(ctx context.Context, name string) error
- func (s Service) DeleteRole(ctx context.Context, name string) error
- func (s Service) Environments(ctx context.Context) ([]string, error)
- func (s Service) RenameEnvironment(ctx context.Context, name, to string) error
- func (s Service) Role(ctx context.Context, name string) (types.Role, error)
- func (s Service) Roles(ctx context.Context) ([]types.Role, error)
- func (s Service) UpdateRole(ctx context.Context, name string, r types.Role) error
Constants ¶
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 ¶
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 ¶
CreateEnvironment adds a global environment, while fewer than the limit exist.
func (Service) CreateRole ¶
CreateRole adds a CUSTOM_GLOBAL role.
func (Service) DeleteEnvironment ¶
DeleteEnvironment removes a global environment that no repository or global role names.
func (Service) DeleteRole ¶
DeleteRole removes a custom global role and every project membership's assignment of it.
func (Service) Environments ¶
Environments returns the global environment names: DEV and PROD, then the stored ones by name.
func (Service) RenameEnvironment ¶
RenameEnvironment renames a global environment and every repository and role that names it.
func (Service) Role ¶
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 ¶
Roles returns the built-in global roles, with any stored changes to the predefined ones, then the custom ones by name.
func (Service) UpdateRole ¶
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.