namespace

package
v0.6.17 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidID     = errors.New("namespace id is invalid")
	ErrNotExist      = errors.New("namespace doesn't exist")
	ErrConflict      = errors.New("namespace name already exist")
	ErrInvalidDetail = errors.New("invalid namespace detail")
	ErrLogActivity   = errors.New("error while logging activity")
)
View Source
var DefinitionOrg = Namespace{
	ID:   "shield/organization",
	Name: "Organization",
}
View Source
var DefinitionProject = Namespace{
	ID:   "shield/project",
	Name: "Project",
}
View Source
var DefinitionTeam = Namespace{
	ID:   "shield/group",
	Name: "Group",
}
View Source
var DefinitionUser = Namespace{
	ID:   "shield/user",
	Name: "User",
}

Functions

func CreateID

func CreateID(backend, resourceType string) string

func IsSystemNamespaceID

func IsSystemNamespaceID(nsID string) bool

Types

type ActivityService added in v0.6.15

type ActivityService interface {
	Log(ctx context.Context, action string, actor string, data any) error
}

type Namespace

type Namespace struct {
	ID           string
	Name         string
	Backend      string
	ResourceType string
	CreatedAt    time.Time
	UpdatedAt    time.Time
}

func (Namespace) ToNameSpaceLogData added in v0.6.15

func (namespace Namespace) ToNameSpaceLogData() NamspaceLogData

type NamspaceLogData added in v0.6.15

type NamspaceLogData struct {
	Entity       string `mapstructure:"entity"`
	ID           string `mapstructure:"id"`
	Name         string `mapstructure:"name"`
	Backend      string `mapstructure:"backend"`
	ResourceType string `mapstructure:"resource_type"`
}

type Repository

type Repository interface {
	Get(ctx context.Context, id string) (Namespace, error)
	Create(ctx context.Context, ns Namespace) (Namespace, error)
	List(ctx context.Context) ([]Namespace, error)
	Update(ctx context.Context, ns Namespace) (Namespace, error)
}

type Service

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

func NewService

func NewService(logger log.Logger, repository Repository, userService UserService, activityService ActivityService) *Service

func (Service) Create

func (s Service) Create(ctx context.Context, ns Namespace) (Namespace, error)

func (Service) Get

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

func (Service) List

func (s Service) List(ctx context.Context) ([]Namespace, error)

func (Service) Update

func (s Service) Update(ctx context.Context, ns Namespace) (Namespace, error)

type UserService added in v0.6.15

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

Jump to

Keyboard shortcuts

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