registry

package
v0.0.0-...-2175bb8 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var VersionStatuses statusesContainer = statusesContainer{
	Pending:   "pending",
	Preparing: "preparing",
	Ready:     "ready",
	Failed:    "failed",
	Archived:  "archived",
}

Functions

func BuildModuleTable

func BuildModuleTable(mods []Module) (h []string, r [][]string)

func BuildModuleVersionsTable

func BuildModuleVersionsTable(mvs []ModuleVersion) (h []string, r [][]string)

Types

type AddModuleV1DTO

type AddModuleV1DTO struct {
	Namespace string `validate:"required" json:"namespace"`
	Name      string `validate:"required" json:"name"`
	Provider  string `validate:"required" json:"provider"`
}

func (AddModuleV1DTO) ToFQN

func (d AddModuleV1DTO) ToFQN() ModuleFQN

type AddModuleV1Response

type AddModuleV1Response struct {
	Status           RegistryHandlerStatus
	Module           Module
	ValidationErrors []ValidationError
	// contains filtered or unexported fields
}

func (AddModuleV1Response) GetActionName

func (r AddModuleV1Response) GetActionName() string

func (AddModuleV1Response) GetAuditMeta

func (r AddModuleV1Response) GetAuditMeta() map[string]interface{}

func (AddModuleV1Response) GetResponseStatus

func (r AddModuleV1Response) GetResponseStatus() RegistryHandlerStatus

func (AddModuleV1Response) GetTimeOfOccurrence

func (r AddModuleV1Response) GetTimeOfOccurrence() time.Time

type AddModuleVersionV1ByModuleFqnDTO

type AddModuleVersionV1ByModuleFqnDTO struct {
	Version       string    `json:"version" validate:"required,version"`
	ModuleFQN     ModuleFQN `json:"required"`
	Source        string    `json:"source" validate:"required"`
	RepositoryURL string    `json:"repository_url" validate:"required"`
}

type AddModuleVersionV1DTO

type AddModuleVersionV1DTO struct {
	Version       string `json:"version" validate:"required,version"`
	ModuleId      string `json:"module_id" validate:"required,uuid"`
	Source        string `json:"source" validate:"required"`
	RepositoryURL string `json:"repository_url" validate:"required"`
}

type AddModuleVersionV1Response

type AddModuleVersionV1Response struct {
	Status           RegistryHandlerStatus
	ModuleVersion    ModuleVersion
	ValidationErrors []ValidationError
	// contains filtered or unexported fields
}

func (AddModuleVersionV1Response) GetActionName

func (r AddModuleVersionV1Response) GetActionName() string

func (AddModuleVersionV1Response) GetAuditMeta

func (r AddModuleVersionV1Response) GetAuditMeta() map[string]interface{}

func (AddModuleVersionV1Response) GetResponseStatus

func (r AddModuleVersionV1Response) GetResponseStatus() RegistryHandlerStatus

func (AddModuleVersionV1Response) GetTimeOfOccurrence

func (r AddModuleVersionV1Response) GetTimeOfOccurrence() time.Time

type AuditableAction

type AuditableAction interface {
	GetActionName() string
	GetTimeOfOccurrence() time.Time
	GetResponseStatus() RegistryHandlerStatus
	GetAuditMeta() map[string]interface{}
}

type Auditor

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

func NewAuditor

func NewAuditor(r auditLogsRepo, l zerolog.Logger) *Auditor

func (*Auditor) Record

func (a *Auditor) Record(action AuditableAction)

type ChunkingOptions

type ChunkingOptions struct {
	Size int
}

type CommandBus

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

func NewCommandBus

func NewCommandBus(opts ...WithDependency) *CommandBus

func (*CommandBus) AddModuleV1FromCLI

func (cb *CommandBus) AddModuleV1FromCLI(filePath string) (AddModuleV1Response, error)

func (*CommandBus) AddModuleV1FromDTO

func (cb *CommandBus) AddModuleV1FromDTO(dto AddModuleV1DTO) (AddModuleV1Response, error)

func (*CommandBus) AddModuleVersionV1ForModuleFqn

func (cb *CommandBus) AddModuleVersionV1ForModuleFqn(dto AddModuleVersionV1ByModuleFqnDTO) (AddModuleVersionV1Response, error)

func (*CommandBus) AddModuleVersionV1ForModuleId

func (cb *CommandBus) AddModuleVersionV1ForModuleId(dto AddModuleVersionV1DTO) (AddModuleVersionV1Response, error)

func (*CommandBus) AddModuleVersionV1FromCLI

func (cb *CommandBus) AddModuleVersionV1FromCLI(filePath string) (AddModuleVersionV1Response, error)

func (*CommandBus) DeleteModuleV1ByFqn

func (cb *CommandBus) DeleteModuleV1ByFqn(dto DeleteModuleV1ByFqnDTO) (DeleteModuleV1Response, error)

func (*CommandBus) DeleteModuleV1ById

func (cb *CommandBus) DeleteModuleV1ById(dto DeleteModuleV1DTO) (DeleteModuleV1Response, error)

func (*CommandBus) DeleteModuleV1FromCLI

func (cb *CommandBus) DeleteModuleV1FromCLI(idOrFQN string, deleteVersions bool, force bool) (DeleteModuleV1Response, error)

func (*CommandBus) DeleteModuleVersionV1ByFqn

func (cb *CommandBus) DeleteModuleVersionV1ByFqn(dto DeleteModuleVersionByFqnV1DTO) (DeleteModuleVersionV1Response, error)

func (*CommandBus) DeleteModuleVersionV1ById

func (cb *CommandBus) DeleteModuleVersionV1ById(dto DeleteModuleVersionV1DTO) (DeleteModuleVersionV1Response, error)

func (*CommandBus) DeleteModuleVersionV1FromCLI

func (cb *CommandBus) DeleteModuleVersionV1FromCLI(idOrFQN string, force bool) (DeleteModuleVersionV1Response, error)

func (*CommandBus) ListModuleVersionsV1ByFqn

func (cb *CommandBus) ListModuleVersionsV1ByFqn(dto ListModuleVersionsByFqnV1DTO) (ListModuleVersionsV1Response, error)

func (*CommandBus) ListModuleVersionsV1ById

func (cb *CommandBus) ListModuleVersionsV1ById(dto ListModuleVersionsV1DTO) (ListModuleVersionsV1Response, error)

func (*CommandBus) ListModuleVersionsV1FromCLI

func (cb *CommandBus) ListModuleVersionsV1FromCLI(idOrFQN string) (ListModuleVersionsV1Response, error)

func (*CommandBus) ListModulesV1FromCLI

func (cb *CommandBus) ListModulesV1FromCLI(p string, ns string) (ListModulesV1Response, error)

func (*CommandBus) ListModulesV1FromDTO

func (cb *CommandBus) ListModulesV1FromDTO(dto ListModulesV1DTO) (ListModulesV1Response, error)

func (*CommandBus) ShowModuleV1ByFQN

func (cb *CommandBus) ShowModuleV1ByFQN(dto ShowModuleV1ByFqnDTO) (ShowModuleV1Response, error)

func (*CommandBus) ShowModuleV1ByID

func (cb *CommandBus) ShowModuleV1ByID(dto ShowModuleV1DTO) (ShowModuleV1Response, error)

func (*CommandBus) ShowModuleV1FromCLI

func (cb *CommandBus) ShowModuleV1FromCLI(idOrFQN string) (ShowModuleV1Response, error)

func (*CommandBus) ShowModuleVersionV1ByFqn

func (cb *CommandBus) ShowModuleVersionV1ByFqn(dto ShowModuleVersionByFqnV1DTO) (ShowModuleVersionV1Response, error)

func (*CommandBus) ShowModuleVersionV1ById

func (cb *CommandBus) ShowModuleVersionV1ById(dto ShowModuleVersionV1DTO) (ShowModuleVersionV1Response, error)

func (*CommandBus) ShowModuleVersionV1FromCLI

func (cb *CommandBus) ShowModuleVersionV1FromCLI(idOrFQN string) (ShowModuleVersionV1Response, error)

type CommandValidator

type CommandValidator interface {
	ModuleNameMustBeUnique(r uniqueModuleNameRepository, sl validator.StructLevel, fqn ModuleFQN)
	ModuleVersionMustBeUniqueForFQN(r moduleVersionMustBeUniqueForFQNRepository, sl validator.StructLevel, fqn ModuleVersionFQN)
	ModuleVersionMustBeUniqueForId(r moduleVersionMustBeUniqueForIdRepository, sl validator.StructLevel, id string, version string)
	ModuleMustExistById(r moduleMustExistByIdRepository, sl validator.StructLevel, id string)
	ModuleMustExistByFQN(r moduleMustExistByFQNRepository, sl validator.StructLevel, fqn ModuleFQN)
	NoVersionsExistForModuleFQN(r noVersionsExistForModuleFQNRepository, sl validator.StructLevel, fqn ModuleFQN)
	NoVersionsExistForModuleId(r noVersionsExistForIdRepository, sl validator.StructLevel, id string)
	SetCustomMessageHandlers(handlers map[string]CustomValidationMessageHandler)
	RegisterStructLevelValidator(f validator.StructLevelFunc, t interface{})
	Validate(cmd interface{}) []ValidationError
}

func NewCommandValidator

func NewCommandValidator(l zerolog.Logger) CommandValidator

type CustomValidationMessageHandler

type CustomValidationMessageHandler func(e validator.FieldError) (string, error)

type DeleteModuleV1ByFqnDTO

type DeleteModuleV1ByFqnDTO struct {
	FQN            ModuleFQN `validate:"required"`
	DeleteVersions bool      `json:"delete_versions"`
}

type DeleteModuleV1DTO

type DeleteModuleV1DTO struct {
	Id             string `validate:"required,uuid"`
	DeleteVersions bool   `json:"delete_versions"`
}

type DeleteModuleV1Response

type DeleteModuleV1Response struct {
	Status           RegistryHandlerStatus
	Module           Module
	ValidationErrors []ValidationError
	// contains filtered or unexported fields
}

func (DeleteModuleV1Response) GetActionName

func (r DeleteModuleV1Response) GetActionName() string

func (DeleteModuleV1Response) GetAuditMeta

func (r DeleteModuleV1Response) GetAuditMeta() map[string]interface{}

func (DeleteModuleV1Response) GetResponseStatus

func (r DeleteModuleV1Response) GetResponseStatus() RegistryHandlerStatus

func (DeleteModuleV1Response) GetTimeOfOccurrence

func (r DeleteModuleV1Response) GetTimeOfOccurrence() time.Time

type DeleteModuleVersionByFqnV1DTO

type DeleteModuleVersionByFqnV1DTO struct {
	FQN ModuleVersionFQN `validate:"required"`
}

type DeleteModuleVersionV1DTO

type DeleteModuleVersionV1DTO struct {
	Id string `validate:"required,uuid"`
}

type DeleteModuleVersionV1Response

type DeleteModuleVersionV1Response struct {
	Status           RegistryHandlerStatus
	ModuleVersion    ModuleVersion
	ValidationErrors []ValidationError
	// contains filtered or unexported fields
}

func (DeleteModuleVersionV1Response) GetActionName

func (r DeleteModuleVersionV1Response) GetActionName() string

func (DeleteModuleVersionV1Response) GetAuditMeta

func (r DeleteModuleVersionV1Response) GetAuditMeta() map[string]interface{}

func (DeleteModuleVersionV1Response) GetResponseStatus

func (DeleteModuleVersionV1Response) GetTimeOfOccurrence

func (r DeleteModuleVersionV1Response) GetTimeOfOccurrence() time.Time

type DownloadModuleVersionV1Command

type DownloadModuleVersionV1Command struct {
	Namespace string
	Name      string
	Provider  string
	Version   string
}

func (DownloadModuleVersionV1Command) Handle

func (c DownloadModuleVersionV1Command) Handle(r downloadModuleVersionRepository, val downloadModuleV1CommandValidator, l zerolog.Logger) (HandleDownloadModuleVersionV1Response, error)

type ErrCouldNotParseModuleFQN

type ErrCouldNotParseModuleFQN struct {
	Value   string
	Message string
}

func (ErrCouldNotParseModuleFQN) Error

type ErrCouldNotParseModuleVersionFQN

type ErrCouldNotParseModuleVersionFQN struct {
	Value   string
	Message string
}

func (ErrCouldNotParseModuleVersionFQN) Error

type ErrCouldNotReadFile

type ErrCouldNotReadFile struct {
	Path string
}

func (ErrCouldNotReadFile) Error

func (e ErrCouldNotReadFile) Error() string

type ErrCouldNotUnmarshalJSONToDTO

type ErrCouldNotUnmarshalJSONToDTO struct {
	Path    string
	DTOName string
}

func (ErrCouldNotUnmarshalJSONToDTO) Error

type ErrFailedToConfirmAction

type ErrFailedToConfirmAction struct {
	Action string
}

func (ErrFailedToConfirmAction) Error

func (e ErrFailedToConfirmAction) Error() string

type ErrQuestionFailed

type ErrQuestionFailed struct {
	Question string
}

func (ErrQuestionFailed) Error

func (e ErrQuestionFailed) Error() string

type ErrRejectedByMessageHandler

type ErrRejectedByMessageHandler struct {
	Tag   string
	Field string
}

func (ErrRejectedByMessageHandler) Error

type ErrResourceNotFound

type ErrResourceNotFound struct {
	Type string
	URI  string
}

func (ErrResourceNotFound) Error

func (e ErrResourceNotFound) Error() string

type HandleDownloadModuleVersionV1Response

type HandleDownloadModuleVersionV1Response struct {
	Status           RegistryHandlerStatus
	LocationURI      string
	ValidationErrors []ValidationError
}

type HandleServiceDiscoveryResponse

type HandleServiceDiscoveryResponse struct {
	Status RegistryHandlerStatus
	Body   HandleServiceDiscoveryResponseBody
}

type HandleServiceDiscoveryResponseBody

type HandleServiceDiscoveryResponseBody struct {
	ModuleVersion string `json:"modules.v1"`
}

type ListModuleVersionsByFqnV1DTO

type ListModuleVersionsByFqnV1DTO struct {
	FQN ModuleFQN `validate:"required"`
}

type ListModuleVersionsV1DTO

type ListModuleVersionsV1DTO struct {
	ModuleId string `validate:"required,uuid"`
}

type ListModuleVersionsV1Response

type ListModuleVersionsV1Response struct {
	Status           RegistryHandlerStatus
	ValidationErrors []ValidationError
	List             []ModuleVersion
	// contains filtered or unexported fields
}

func (ListModuleVersionsV1Response) GetActionName

func (r ListModuleVersionsV1Response) GetActionName() string

func (ListModuleVersionsV1Response) GetAuditMeta

func (r ListModuleVersionsV1Response) GetAuditMeta() map[string]interface{}

func (ListModuleVersionsV1Response) GetResponseStatus

func (ListModuleVersionsV1Response) GetTimeOfOccurrence

func (r ListModuleVersionsV1Response) GetTimeOfOccurrence() time.Time

type ListModulesV1DTO

type ListModulesV1DTO struct {
	Namespace string
	Provider  string
	ChunkOpts ChunkingOptions
}

type ListModulesV1Response

type ListModulesV1Response struct {
	Status RegistryHandlerStatus
	List   []Module
	// contains filtered or unexported fields
}

func (ListModulesV1Response) GetActionName

func (r ListModulesV1Response) GetActionName() string

func (ListModulesV1Response) GetAuditMeta

func (r ListModulesV1Response) GetAuditMeta() map[string]interface{}

func (ListModulesV1Response) GetResponseStatus

func (r ListModulesV1Response) GetResponseStatus() RegistryHandlerStatus

func (ListModulesV1Response) GetTimeOfOccurrence

func (r ListModulesV1Response) GetTimeOfOccurrence() time.Time

type Module

type Module struct {
	Id        string `json:"id"`
	Name      string `json:"name"`
	Namespace string `json:"namespace"`
	Provider  string `json:"provider"`
}

type ModuleFQN

type ModuleFQN struct {
	Name      string `json:"name" validate:"required"`
	Namespace string `json:"namespace" validate:"required"`
	Provider  string `json:"provider" validate:"required"`
}

func ParseModuleFQN

func ParseModuleFQN(s string) (ModuleFQN, error)

func (ModuleFQN) String

func (m ModuleFQN) String() string

type ModuleFilters

type ModuleFilters struct {
	Provider  string
	Namespace string
}

type ModuleRepository

type ModuleRepository interface {
	ById(id string) (m Module, err error)
	ByFQN(ModuleFQN) (m Module, err error)
	All(chunkOpts ChunkingOptions, filters ModuleFilters) ([]Module, error)

	VersionById(id string) (m ModuleVersion, err error)
	VersionsByModule(moduleId string, chunkOpts ChunkingOptions) (m []ModuleVersion, err error)
	VersionsByModuleFQN(fqn ModuleFQN, chunkOpts ChunkingOptions) (m []ModuleVersion, err error)
	VersionByModuleAndValue(moduleId string, version string) (mv ModuleVersion, err error)
	VersionByFQN(fqn ModuleVersionFQN) (mv ModuleVersion, err error)

	AddModule(Module) (Module, error)
	DeleteModule(Module) error

	AddVersion(ModuleVersion) (m ModuleVersion, err error)
	DeleteVersionsForModule(Module) error
	DeleteModuleVersion(ModuleVersion) error
}

type ModuleVersion

type ModuleVersion struct {
	Id            string        `json:"id"`
	Version       string        `json:"version"`
	ModuleId      string        `json:"module_id"`
	Source        string        `json:"source"`
	DownloadURL   string        `json:"downloadURL"`
	RepositoryURL string        `json:"repositoryURL"`
	Status        VersionStatus `json:"status"`
}

type ModuleVersionFQN

type ModuleVersionFQN struct {
	ModuleFQN `validate:"required"`
	Version   string `validate:"required"`
}

func ParseModuleVersionFQN

func ParseModuleVersionFQN(s string) (ModuleVersionFQN, error)

func (ModuleVersionFQN) String

func (mv ModuleVersionFQN) String() string

type RegistryHandlerStatus

type RegistryHandlerStatus string
const STATUS_CONFLICT RegistryHandlerStatus = "CONFLICT"
const STATUS_CREATED RegistryHandlerStatus = "CREATED"
const STATUS_INTERNAL_ERROR RegistryHandlerStatus = "INTERNAL_ERROR"
const STATUS_INVALID RegistryHandlerStatus = "INVALID_PARAMS"
const STATUS_MODIFIED RegistryHandlerStatus = "MODIFIED"
const STATUS_NOT_FOUND RegistryHandlerStatus = "NOT_FOUND"
const STATUS_OKAY RegistryHandlerStatus = "OK"

type ServiceDiscoveryCommand

type ServiceDiscoveryCommand struct{}

func (ServiceDiscoveryCommand) Handle

type ShowModuleV1ByFqnDTO

type ShowModuleV1ByFqnDTO struct {
	FQN ModuleFQN `validate:"required"`
}

type ShowModuleV1DTO

type ShowModuleV1DTO struct {
	Id string `validate:"required,uuid"`
}

type ShowModuleV1Response

type ShowModuleV1Response struct {
	Status           RegistryHandlerStatus
	Module           Module
	ValidationErrors []ValidationError
	// contains filtered or unexported fields
}

func (ShowModuleV1Response) GetActionName

func (r ShowModuleV1Response) GetActionName() string

func (ShowModuleV1Response) GetAuditMeta

func (r ShowModuleV1Response) GetAuditMeta() map[string]interface{}

func (ShowModuleV1Response) GetResponseStatus

func (r ShowModuleV1Response) GetResponseStatus() RegistryHandlerStatus

func (ShowModuleV1Response) GetTimeOfOccurrence

func (r ShowModuleV1Response) GetTimeOfOccurrence() time.Time

type ShowModuleVersionByFqnV1DTO

type ShowModuleVersionByFqnV1DTO struct {
	FQN ModuleVersionFQN `validate:"required"`
}

type ShowModuleVersionV1DTO

type ShowModuleVersionV1DTO struct {
	Id string `validate:"required,uuid"`
}

type ShowModuleVersionV1Response

type ShowModuleVersionV1Response struct {
	Status           RegistryHandlerStatus
	ModuleVersion    ModuleVersion
	ValidationErrors []ValidationError
	// contains filtered or unexported fields
}

func (ShowModuleVersionV1Response) GetActionName

func (r ShowModuleVersionV1Response) GetActionName() string

func (ShowModuleVersionV1Response) GetAuditMeta

func (r ShowModuleVersionV1Response) GetAuditMeta() map[string]interface{}

func (ShowModuleVersionV1Response) GetResponseStatus

func (r ShowModuleVersionV1Response) GetResponseStatus() RegistryHandlerStatus

func (ShowModuleVersionV1Response) GetTimeOfOccurrence

func (r ShowModuleVersionV1Response) GetTimeOfOccurrence() time.Time

type ValidationError

type ValidationError struct {
	Message string
	Rule    string
	Field   string
	Value   interface{}
}

type ValidatorBuilder

type ValidatorBuilder func(l zerolog.Logger) CommandValidator

type VersionStatus

type VersionStatus string

type WithDependency

type WithDependency func(*CommandBus)

func WithCommandValidatorBuilder

func WithCommandValidatorBuilder(b ValidatorBuilder) WithDependency

func WithFS

func WithFS(fs afero.Fs) WithDependency

func WithLogger

func WithLogger(l zerolog.Logger) WithDependency

func WithModuleRepo

func WithModuleRepo(r ModuleRepository) WithDependency

func WithPrompter

func WithPrompter(p cliPrompter) WithDependency

Jump to

Keyboard shortcuts

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