project

package
v0.0.0-...-e2755d2 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Prefix for all project keys in the registry
	Prefix = "projects/"
)

Variables

This section is empty.

Functions

func FetchProjectID

func FetchProjectID(ctx context.Context, val string) string

FetchProjectID returns the key for storing in the registry

func IsValidProjectID

func IsValidProjectID(ctx context.Context, projectID string) bool

IsValidProjectID validates the projectID

Types

type Core

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

Core implements all business logic for project

func (*Core) CreateProject

func (c *Core) CreateProject(ctx context.Context, m *Model) error

CreateProject creates a new project

func (*Core) DeleteProject

func (c *Core) DeleteProject(ctx context.Context, m *Model) error

DeleteProject deletes a project and all resources in it

func (*Core) Exists

func (c *Core) Exists(ctx context.Context, key string) (bool, error)

Exists to check if the project exists with fully qualified consul key

func (*Core) ExistsWithID

func (c *Core) ExistsWithID(ctx context.Context, id string) (bool, error)

ExistsWithID to check if the project exists with the projectID

func (*Core) Get

func (c *Core) Get(ctx context.Context, projectID string) (*Model, error)

Get returns project with the given key

func (*Core) ListKeys

func (c *Core) ListKeys(ctx context.Context) ([]string, error)

ListKeys returns List of Projects keys

type ICore

type ICore interface {
	CreateProject(ctx context.Context, m *Model) error
	Get(ctx context.Context, key string) (*Model, error)
	ListKeys(ctx context.Context) ([]string, error)
	Exists(ctx context.Context, key string) (bool, error)
	ExistsWithID(ctx context.Context, id string) (bool, error)
	DeleteProject(ctx context.Context, m *Model) error
}

ICore is an interface over project core

func NewCore

func NewCore(repo IRepo) ICore

NewCore returns an instance of Core

type IRepo

type IRepo interface {
	common.IRepo
}

IRepo interface over database repository

func NewRepo

func NewRepo(registry registry.IRegistry) IRepo

NewRepo returns IRepo

type Model

type Model struct {
	common.BaseModel
	Name      string            `json:"name"`
	ProjectID string            `json:"project_id"`
	Labels    map[string]string `json:"labels"`
}

Model for a project

func GetValidatedModelForCreate

func GetValidatedModelForCreate(ctx context.Context, req *metrov1.Project) (*Model, error)

GetValidatedModelForCreate validates an incoming proto request and returns a project model for create requests

func GetValidatedModelForDelete

func GetValidatedModelForDelete(ctx context.Context, req *metrov1.Project) (*Model, error)

GetValidatedModelForDelete validates an incoming proto request and returns a project model for delete requests

func (*Model) Key

func (m *Model) Key() string

Key returns the key for storing in the registry

func (*Model) Prefix

func (m *Model) Prefix() string

Prefix returns the key prefix

type Repo

type Repo struct {
	common.BaseRepo
}

Repo implements various repository methods

Jump to

Keyboard shortcuts

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