resource

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const NON_RESOURCE_ID = "*"

Variables

View Source
var (
	ErrNotExist      = errors.New("resource doesn't exist")
	ErrInvalidUUID   = errors.New("invalid syntax of uuid")
	ErrInvalidID     = errors.New("resource id is invalid")
	ErrInvalidURN    = errors.New("resource urn is invalid")
	ErrConflict      = errors.New("resource already exist")
	ErrInvalidDetail = errors.New("invalid resource detail")
)

Functions

This section is empty.

Types

type ConfigRepository

type ConfigRepository interface {
	GetAll(ctx context.Context) ([]YAML, error)
}

type Filter

type Filter struct {
	ProjectID      string
	GroupID        string
	OrganizationID string
	NamespaceID    string
}

type ProjectService added in v0.5.1

type ProjectService interface {
	Get(ctx context.Context, id string) (project.Project, error)
}

type RelationService

type RelationService interface {
	Create(ctx context.Context, rel relation.RelationV2) (relation.RelationV2, error)
	Delete(ctx context.Context, rel relation.Relation) error
	CheckPermission(ctx context.Context, usr user.User, resourceNS namespace.Namespace, resourceIdxa string, action action.Action) (bool, error)
	DeleteSubjectRelations(ctx context.Context, resourceType, optionalResourceID string) error
}

type Repository

type Repository interface {
	GetByID(ctx context.Context, id string) (Resource, error)
	GetByURN(ctx context.Context, urn string) (Resource, error)
	Create(ctx context.Context, resource Resource) (Resource, error)
	List(ctx context.Context, flt Filter) ([]Resource, error)
	Update(ctx context.Context, id string, resource Resource) (Resource, error)
	GetByNamespace(ctx context.Context, name string, ns string) (Resource, error)
}

type Resource

type Resource struct {
	Idxa           string
	URN            string
	Name           string
	ProjectID      string
	OrganizationID string
	NamespaceID    string
	UserID         string
	CreatedAt      time.Time
	UpdatedAt      time.Time
}

func (Resource) CreateURN

func (res Resource) CreateURN() string

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(repository Repository, configRepository ConfigRepository, relationService RelationService, userService UserService, projectService ProjectService) *Service

func (Service) AddOrgToResource

func (s Service) AddOrgToResource(ctx context.Context, org organization.Organization, res Resource) error

func (Service) AddProjectToResource

func (s Service) AddProjectToResource(ctx context.Context, project project.Project, res Resource) error

func (Service) CheckAuthz

func (s Service) CheckAuthz(ctx context.Context, res Resource, act action.Action) (bool, error)

TODO(krkvrm): Separate Authz for Resources & System Namespaces

func (Service) Create

func (s Service) Create(ctx context.Context, res Resource) (Resource, error)

func (Service) Get

func (s Service) Get(ctx context.Context, id string) (Resource, error)

func (Service) GetAllConfigs

func (s Service) GetAllConfigs(ctx context.Context) ([]YAML, error)

func (Service) List

func (s Service) List(ctx context.Context, flt Filter) ([]Resource, error)

func (Service) Update

func (s Service) Update(ctx context.Context, id string, resource Resource) (Resource, error)

type UserService

type UserService interface {
	FetchCurrentUser(ctx context.Context) (user.User, error)
}

type YAML

type YAML struct {
	Name         string              `json:"name" yaml:"name"`
	Backend      string              `json:"backend" yaml:"backend"`
	ResourceType string              `json:"resource_type" yaml:"resource_type"`
	Actions      map[string][]string `json:"actions" yaml:"actions"`
}

Jump to

Keyboard shortcuts

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