configurations

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: MIT Imports: 30 Imported by: 4

Documentation

Index

Constants

View Source
const (
	ApplicationKind              = "application"
	ApplicationConfigurationName = "application.codefly.yaml"
)
View Source
const (
	AGENT = "agent"

	PROJECT     = "project"
	APPLICATION = "application"
	SERVICE     = "service"
	ENDPOINT    = "endpoint"
)
View Source
const AgentConfigurationName = "agent.codefly.yaml"
View Source
const EndpointPrefix = "CODEFLY_ENDPOINT__"
View Source
const FactoryServiceAgent = "codefly:service:factory"
View Source
const InfoConfigurationName = "info.codefly.yaml"
View Source
const NA = "NA"
View Source
const ProjectConfigurationName = "project.codefly.yaml"
View Source
const ProjectProviderOrigin = "ProjectProviderOrigin"
View Source
const ProviderPrefix = "CODEFLY_PROVIDER__"
View Source
const RestRoutePrefix = "CODEFLY_RESTROUTE__"
View Source
const RuntimeServiceAgent = "codefly:service:runtime"
View Source
const ServiceAgent = AgentKind("codefly:service")
View Source
const ServiceConfigurationName = "service.codefly.yaml"
View Source
const Unknown = "unknown"
View Source
const WorkspaceConfigurationName = "workspace.codefly.yaml"

Variables

This section is empty.

Functions

func ApplicationMode added in v0.0.51

func ApplicationMode() bool

func AsEndpointEnvironmentVariable added in v0.0.13

func AsEndpointEnvironmentVariable(endpoint *Endpoint, addresses []string) string

func AsRestRouteEnvironmentVariable added in v0.0.91

func AsRestRouteEnvironmentVariable(endpoint *basev0.Endpoint) []string

func Condensed added in v0.0.65

func Condensed(es []*basev0.Endpoint) []string

func ConfigurationFile added in v0.0.42

func ConfigurationFile[C Configuration]() string

func ContainsRoute added in v0.0.28

func ContainsRoute(routes []*RestRoute, r *RestRoute) bool

func EndpointBaseProto added in v0.0.65

func EndpointBaseProto(e *Endpoint) *basev0.Endpoint

func EndpointDestination added in v0.0.81

func EndpointDestination(e *basev0.Endpoint) string

func EndpointEnvironmentVariableKey added in v0.0.91

func EndpointEnvironmentVariableKey(endpoint *Endpoint) string

func ExistsAtDir

func ExistsAtDir[C Configuration](dir string) bool

func ExtendDomain

func ExtendDomain(domain string, extension string) string

func ExtraValidOrganizationName added in v0.0.51

func ExtraValidOrganizationName(name string) bool

func FindEndpointForRoute added in v0.0.65

func FindEndpointForRoute(ctx context.Context, endpoints []*basev0.Endpoint, route *RestRoute) *basev0.Endpoint

func FindUp

func FindUp[C Configuration](ctx context.Context) (*string, error)

FindUp looks for a configuration in the active directory and up

func FlattenRestRoutes added in v0.0.65

func FlattenRestRoutes(_ context.Context, endpoints []*basev0.Endpoint) []*basev0.RestRoute

func FromProtoAPI added in v0.0.65

func FromProtoAPI(api *basev0.API) string

func HasRest added in v0.0.65

func HasRest(_ context.Context, api *basev0.API) *basev0.RestAPI

func HomeDir

func HomeDir() (string, error)

func InPartialMode added in v0.0.15

func InPartialMode() bool

func IsInitialized added in v0.0.51

func IsInitialized(ctx context.Context) (bool, error)

func Light added in v0.0.65

func Light(e *basev0.Endpoint) *basev0.Endpoint

func LightAPI added in v0.0.65

func LightAPI(api *basev0.API) *basev0.API

func LoadFromBytes added in v0.0.13

func LoadFromBytes[C Configuration](content []byte) (*C, error)

func LoadFromDir

func LoadFromDir[C Configuration](ctx context.Context, dir string) (*C, error)

func LoadFromFs added in v0.0.42

func LoadFromFs[C any](fs shared.FileSystem) (*C, error)

func LoadFromPath

func LoadFromPath[C Configuration](ctx context.Context, p string) (*C, error)

func LoadProviderFromEnvFiles added in v0.1.6

func LoadProviderFromEnvFiles(ctx context.Context, project *Project, env *Environment) ([]*basev0.ProviderInformation, error)

func LoadSpec

func LoadSpec(ctx context.Context, content []byte, obj any) error

func MakeActive added in v0.0.51

func MakeActive(entry string) string

func MakeInactive added in v0.0.51

func MakeInactive(entry string) string

func MakeRouteUnique added in v0.0.91

func MakeRouteUnique(app string, service string, path string) string

func NewGrpcAPI added in v0.0.65

func NewGrpcAPI(ctx context.Context, endpoint *Endpoint, filename string) (*basev0.Endpoint, error)

func NewHTTPApi added in v0.0.81

func NewHTTPApi(ctx context.Context, endpoint *Endpoint) (*basev0.Endpoint, error)

func NewRestAPI added in v0.0.65

func NewRestAPI(ctx context.Context, endpoint *Endpoint) (*basev0.Endpoint, error)

func NewRestAPIFromOpenAPI added in v0.0.65

func NewRestAPIFromOpenAPI(ctx context.Context, endpoint *Endpoint, filename string) (*basev0.Endpoint, error)

func NewTCPAPI added in v0.1.6

func NewTCPAPI(ctx context.Context, endpoint *Endpoint) (*basev0.Endpoint, error)

func OverridePath added in v0.0.51

func OverridePath(defaultPath string, path string) *string

OverridePath is nil if the name is the same as the desired relative path

func Path

func Path[C Configuration](ctx context.Context, dir string) (string, error)

func ProviderInformationAsEnvironmentVariables added in v0.1.6

func ProviderInformationAsEnvironmentVariables(info *basev0.ProviderInformation) []string

func ProviderInformationEnv added in v0.1.6

func ProviderInformationEnv(info *basev0.ProviderInformation, key string, value string) string

func ProviderInformationEnvKey added in v0.1.6

func ProviderInformationEnvKey(info *basev0.ProviderInformation, key string) string

func ReferenceMatch added in v0.0.51

func ReferenceMatch(entry string, name string) bool

func RegisterAgent added in v0.0.51

func RegisterAgent(kind AgentKind, protoKind basev0.Agent_Kind)

func RestRouteEnvironmentVariableKey added in v0.0.91

func RestRouteEnvironmentVariableKey(endpoint *basev0.Endpoint, route *basev0.RestRoute) string

func RestRoutesAsEnvironmentVariable added in v0.0.91

func RestRoutesAsEnvironmentVariable(endpoint *basev0.Endpoint, route *basev0.RestRoute) string

func RouteUnique added in v0.0.91

func RouteUnique(endpoint *basev0.Endpoint, route *basev0.RestRoute) string

func SaveToDir

func SaveToDir[C Configuration](ctx context.Context, c *C, dir string) error

func SerializeAddresses

func SerializeAddresses(addresses []string) string

func SerializeSpec

func SerializeSpec(ctx context.Context, spec any) ([]byte, error)

func ServiceUnique added in v0.0.81

func ServiceUnique(app string, service string) string

func SetLoadWorkspaceUnsafe added in v0.0.51

func SetLoadWorkspaceUnsafe(w *Workspace)

func SetMode added in v0.0.15

func SetMode(m Mode)

func SolveDir

func SolveDir(dir string) (string, error)

func SolveDirOrCreate

func SolveDirOrCreate(dir string) (string, error)

func StandardPort added in v0.0.65

func StandardPort(api *basev0.API) (int, error)

func ToOrganizationDomain added in v0.0.51

func ToOrganizationDomain(name string) string

func TypeName

func TypeName[C Configuration]() string

func ValidOrganization added in v0.0.51

func ValidOrganization(org *basev0.Organization) error

func ValidOrganizationDomain added in v0.0.51

func ValidOrganizationDomain(domain string) bool

func ValidateAgent added in v0.0.51

func ValidateAgent(agent *basev0.Agent) error

func ValidateDomain

func ValidateDomain()

func Version added in v0.0.42

func Version(ctx context.Context) (string, error)

func WhichAPI added in v0.0.65

func WhichAPI(api *basev0.API) (string, error)

func WhichAPIFromEndpoint added in v0.0.65

func WhichAPIFromEndpoint(endpoint *basev0.Endpoint) (string, error)

func WithAPI added in v0.0.65

func WithAPI(ctx context.Context, endpoint *Endpoint, source APISource) (*basev0.Endpoint, error)

func WorkspaceConfigurationDir added in v0.0.51

func WorkspaceConfigurationDir() string

WorkspaceConfigurationDir returns the directory where the Workspace configuration is stored

Types

type APISource added in v0.0.65

type APISource interface {
	Proto() (*basev0.API, error)
}

type Agent added in v0.0.23

type Agent struct {
	Kind      AgentKind `yaml:"kind" json:"kind"`
	Name      string    `yaml:"name" json:"name"`
	Version   string    `yaml:"version" json:"version"`
	Publisher string    `yaml:"publisher" json:"publisher"`
}
var CLI *Agent

func AgentFromProto added in v0.0.51

func AgentFromProto(agent *basev0.Agent) *Agent

func LoadAgent added in v0.0.51

func LoadAgent(ctx context.Context, action *basev0.Agent) (*Agent, error)

func ParseAgent added in v0.0.23

func ParseAgent(ctx context.Context, k AgentKind, s string) (*Agent, error)

func (*Agent) AsResource added in v0.0.55

func (p *Agent) AsResource() *wool.Resource

func (*Agent) Identifier added in v0.0.23

func (p *Agent) Identifier() string

func (*Agent) IsService added in v0.0.51

func (p *Agent) IsService() bool

func (*Agent) Key added in v0.0.23

func (p *Agent) Key(kind AgentKind, unique string) string

func (*Agent) Of added in v0.0.23

func (p *Agent) Of(kind AgentKind) *Agent

func (*Agent) Patch added in v0.0.23

func (p *Agent) Patch() (*Agent, error)

func (*Agent) Path added in v0.0.23

func (p *Agent) Path() (string, error)

func (*Agent) Proto added in v0.0.55

func (p *Agent) Proto() *basev0.Agent

func (*Agent) String added in v0.0.23

func (p *Agent) String() string

func (*Agent) Unique added in v0.0.23

func (p *Agent) Unique() string

type AgentKind added in v0.0.51

type AgentKind string

func AgentKindFromProto added in v0.0.51

func AgentKindFromProto(kind basev0.Agent_Kind) (*AgentKind, error)

type Application

type Application struct {
	Kind         string  `yaml:"kind"`
	Name         string  `yaml:"name"`
	PathOverride *string `yaml:"path,omitempty"`

	Project     string `yaml:"project"`
	Domain      string `yaml:"domain"`
	Description string `yaml:"description,omitempty"`

	Services []*ServiceReference `yaml:"services"`
	// contains filtered or unexported fields
}

An Application is a collection of services that are deployed together.

func LoadApplicationFromDirUnsafe added in v0.0.51

func LoadApplicationFromDirUnsafe(ctx context.Context, dir string) (*Application, error)

func LoadApplicationFromPath added in v0.0.51

func LoadApplicationFromPath(ctx context.Context) (*Application, error)

LoadApplicationFromPath loads an application from a path

func ReloadApplication added in v0.0.51

func ReloadApplication(ctx context.Context, app *Application) (*Application, error)

func (*Application) ActiveService added in v0.0.51

func (app *Application) ActiveService(_ context.Context) *string

func (*Application) AddService

func (app *Application) AddService(_ context.Context, service *Service) error

func (*Application) DeleteService added in v0.0.51

func (app *Application) DeleteService(ctx context.Context, name string) error

DeleteService deletes a service from an application

func (*Application) DeleteServiceDependencies added in v0.0.91

func (app *Application) DeleteServiceDependencies(ctx context.Context, ref *ServiceReference) error

func (*Application) Dir

func (app *Application) Dir() string

Dir returns the directory of the application

func (*Application) ExistsService added in v0.0.51

func (app *Application) ExistsService(ctx context.Context, name string) bool

ExistsService returns true if the service exists in the application

func (*Application) GetServiceReferences

func (app *Application) GetServiceReferences(name string) (*ServiceReference, error)

func (*Application) LoadActiveService added in v0.0.51

func (app *Application) LoadActiveService(ctx context.Context) (*Service, error)

func (*Application) LoadServiceFromName added in v0.0.13

func (app *Application) LoadServiceFromName(ctx context.Context, name string) (*Service, error)

func (*Application) LoadServiceFromReference added in v0.0.36

func (app *Application) LoadServiceFromReference(ctx context.Context, ref *ServiceReference) (*Service, error)

func (*Application) LoadServices added in v0.0.51

func (app *Application) LoadServices(ctx context.Context) ([]*Service, error)

func (*Application) NewService added in v0.0.51

func (app *Application) NewService(ctx context.Context, action *actionsv0.AddService) (*Service, error)

NewService creates a service in an application

func (*Application) Proto added in v0.0.51

func (app *Application) Proto() *basev0.Application

func (*Application) PublicEndpoints added in v0.0.65

func (app *Application) PublicEndpoints(ctx context.Context) ([]*basev0.Endpoint, error)

func (*Application) Reference added in v0.0.15

func (app *Application) Reference() *ApplicationReference

func (*Application) Save

func (app *Application) Save(ctx context.Context) error

func (*Application) SaveToDir added in v0.0.51

func (app *Application) SaveToDir(ctx context.Context, dir string) error

func (*Application) ServiceDomain

func (app *Application) ServiceDomain(name string) string

func (*Application) ServicePath added in v0.0.51

func (app *Application) ServicePath(_ context.Context, ref *ServiceReference) string

ServicePath returns the absolute path of an Service Cases for Reference.Dir nil: relative path to application with name rel: relative path /abs: absolute path

func (*Application) SetActiveService added in v0.0.51

func (app *Application) SetActiveService(ctx context.Context, name string) error

func (*Application) Unique

func (app *Application) Unique() string

type ApplicationReference added in v0.0.9

type ApplicationReference struct {
	Name         string  `yaml:"name"`
	PathOverride *string `yaml:"path,omitempty"`
}

An ApplicationReference

func (*ApplicationReference) IsActive added in v0.0.51

func (ref *ApplicationReference) IsActive() (*ApplicationReference, bool)

IsActive returns true if the project is marked as active

func (*ApplicationReference) MarkAsActive added in v0.0.51

func (ref *ApplicationReference) MarkAsActive()

MarkAsActive marks a project as active

type ApplicationRestRoute added in v0.0.13

type ApplicationRestRoute struct {
	ServiceRestRoutes []*ServiceRestRoute
	Name              string
}

func (*ApplicationRestRoute) Save added in v0.0.13

func (r *ApplicationRestRoute) Save(ctx context.Context, dir string) error

Save as folder structure

type ClientEntry

type ClientEntry struct {
	Name string   `yaml:"name"`
	APIs []string `yaml:"apis"`
}

func (*ClientEntry) Validate

func (c *ClientEntry) Validate() error

type Configuration

type Configuration interface{}

type DockerImage added in v0.0.26

type DockerImage struct {
	Repository string
	Name       string
	Tag        string
}

func (*DockerImage) FullName added in v0.1.1

func (image *DockerImage) FullName() string

type Endpoint

type Endpoint struct {
	Name        string `yaml:"name"`
	Service     string `yaml:"service,omitempty"`
	Application string `yaml:"application,omitempty"`
	Description string `yaml:"description,omitempty"`
	Visibility  string `yaml:"visibility,omitempty"`
	API         string `yaml:"api,omitempty"`
	// FailOver indicates that this endpoint should fail over to another endpoint
	FailOver *Endpoint `yaml:"fail-over,omitempty"`
}

Endpoint is the fundamental entity that standardize communication between services.

func FromProtoEndpoint added in v0.0.65

func FromProtoEndpoint(e *basev0.Endpoint) *Endpoint

func FromProtoEndpoints added in v0.0.65

func FromProtoEndpoints(es ...*basev0.Endpoint) ([]*Endpoint, error)

func ParseEndpoint added in v0.1.6

func ParseEndpoint(unique string) (*Endpoint, error)

func (*Endpoint) AsReference added in v0.0.51

func (e *Endpoint) AsReference() *EndpointReference

func (*Endpoint) Unique added in v0.0.13

func (e *Endpoint) Unique() string

type EndpointInstance added in v0.0.13

type EndpointInstance struct {
	*Endpoint
	Addresses []string
}

func (*EndpointInstance) Address added in v0.1.6

func (instance *EndpointInstance) Address() (string, error)

func (*EndpointInstance) PortAddress added in v0.1.6

func (instance *EndpointInstance) PortAddress() (string, error)

type EndpointReference added in v0.0.9

type EndpointReference struct {
	Name string `yaml:"name"`
}

An EndpointReference

type EndpointSummary added in v0.0.81

type EndpointSummary struct {
	Count   int
	Uniques []string
}

func MakeEndpointSummary added in v0.0.81

func MakeEndpointSummary(endpoints []*basev0.Endpoint) EndpointSummary

type Environment added in v0.0.17

type Environment struct {
	Name        string `yaml:"name"`
	Description string `yaml:"description,omitempty"`
}

Environment is a configuration for an environment

func LoadEnvironmentFromReference added in v0.0.31

func LoadEnvironmentFromReference(ref *EnvironmentReference) (*Environment, error)

func Local added in v0.0.17

func Local() *Environment

Local is a local environment that is always available

type EnvironmentExistsError added in v0.0.51

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

func (*EnvironmentExistsError) Error added in v0.0.51

func (err *EnvironmentExistsError) Error() string

type EnvironmentReference added in v0.0.31

type EnvironmentReference struct {
	Name string `yaml:"name"`
}

An EnvironmentReference at the Project level

func (*EnvironmentReference) String added in v0.0.51

func (ref *EnvironmentReference) String() string

type EnvironmentVariableManager added in v0.1.6

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

func NewEnvironmentVariableManager added in v0.1.6

func NewEnvironmentVariableManager() *EnvironmentVariableManager

func (*EnvironmentVariableManager) Add added in v0.1.6

func (holder *EnvironmentVariableManager) Add(envs ...string)

func (*EnvironmentVariableManager) Get added in v0.1.7

func (holder *EnvironmentVariableManager) Get() []string

func (*EnvironmentVariableManager) GetBase added in v0.1.8

func (holder *EnvironmentVariableManager) GetBase() []string

func (*EnvironmentVariableManager) GetEndpoint added in v0.1.6

func (holder *EnvironmentVariableManager) GetEndpoint(ctx context.Context, unique string) (*EndpointInstance, error)

func (*EnvironmentVariableManager) GetProjectProvider added in v0.1.6

func (holder *EnvironmentVariableManager) GetProjectProvider(_ context.Context, key string) (string, error)

func (*EnvironmentVariableManager) GetServiceProvider added in v0.1.6

func (holder *EnvironmentVariableManager) GetServiceProvider(_ context.Context, unique string, name string, key string) (string, error)

type ExtendedRestRoute added in v0.0.13

type ExtendedRestRoute[T any] struct {
	RestRoute `yaml:",inline"`

	Extension T `yaml:"extension"`
}

func LoadApplicationExtendedRoutes added in v0.0.13

func LoadApplicationExtendedRoutes[T any](_ context.Context, dir string) ([]*ExtendedRestRoute[T], error)

func LoadExtendedRestRoute added in v0.0.13

func LoadExtendedRestRoute[T any](p string, app string, service string) (*ExtendedRestRoute[T], error)

func LoadExtendedRoutes added in v0.0.13

func LoadExtendedRoutes[T any](dir string, app string, service string) ([]*ExtendedRestRoute[T], error)

func LoadServiceExtendedRoutes added in v0.0.13

func LoadServiceExtendedRoutes[T any](dir string, app string) ([]*ExtendedRestRoute[T], error)

func NewExtendedRestRoute added in v0.0.13

func NewExtendedRestRoute[T any](rest RestRoute, value T) *ExtendedRestRoute[T]

type Forwarding added in v0.0.65

type Forwarding interface {
	Forward(r *RestRoute) (*RestRoute, error)
}

type GrpcAPI added in v0.0.65

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

func (*GrpcAPI) Proto added in v0.0.65

func (grpc *GrpcAPI) Proto() (*basev0.API, error)

type HTTPAPI added in v0.0.81

type HTTPAPI struct{}

func (*HTTPAPI) Proto added in v0.0.81

func (h *HTTPAPI) Proto() (*basev0.API, error)

type HTTPMethod added in v0.0.51

type HTTPMethod string
const (
	HTTPMethodGet     HTTPMethod = "GET"
	HTTPMethodPut     HTTPMethod = "PUT"
	HTTPMethodPost    HTTPMethod = "POST"
	HTTPMethodDelete  HTTPMethod = "DELETE"
	HTTPMethodPatch   HTTPMethod = "PATCH"
	HTTPMethodOptions HTTPMethod = "OPTIONS"
	HTTPMethodHead    HTTPMethod = "HEAD"
)

func ConvertMethod added in v0.0.28

func ConvertMethod(m basev0.HTTPMethod) HTTPMethod

func ConvertMethods added in v0.0.28

func ConvertMethods(methods []basev0.HTTPMethod) []HTTPMethod

type Info added in v0.0.42

type Info struct {
	Version string `yaml:"version"`
}

type Mode added in v0.0.15

type Mode = string
const (
	ModeApplication Mode = "application"
	ModePartial     Mode = "partial"
	ModeService     Mode = "service"
)

type NilAPIError added in v0.0.65

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

func (*NilAPIError) Error added in v0.0.65

func (err *NilAPIError) Error() string

type NilEndpointError added in v0.0.65

type NilEndpointError struct{}

func (NilEndpointError) Error added in v0.0.65

func (n NilEndpointError) Error() string

type NoApplicationError

type NoApplicationError struct {
	Project string
}

func (NoApplicationError) Error

func (e NoApplicationError) Error() string

type Organization added in v0.0.51

type Organization struct {
	// ID must be globally unique
	ID string `yaml:"id"`

	Name   string `yaml:"name"`
	Domain string `yaml:"domain"`
}

func OrganizationFromProto added in v0.0.51

func OrganizationFromProto(_ context.Context, m *basev0.Organization) (*Organization, error)

func (*Organization) Proto added in v0.0.51

func (organization *Organization) Proto() *basev0.Organization

type Partial added in v0.0.13

type Partial struct {
	Name    string `yaml:"name"`
	Project string `yaml:"project"`
	// Applications in the partial of the project
	Applications []string `yaml:"applications"`
}

type Project

type Project struct {
	Name string `yaml:"name"`
	// ID must be globally unique
	ID string `yaml:"id,omitempty"`

	Organization Organization `yaml:"organization"`
	Domain       string       `yaml:"domain,omitempty"`
	Description  string       `yaml:"description,omitempty"`

	// Applications in the project
	Applications []*ApplicationReference `yaml:"applications"`

	// Environments in the project
	Environments []*EnvironmentReference `yaml:"environments"`
	// contains filtered or unexported fields
}

func LoadProjectFromDirUnsafe added in v0.0.51

func LoadProjectFromDirUnsafe(ctx context.Context, dir string) (*Project, error)

LoadProjectFromDirUnsafe loads a Project configuration from a directory

func LoadProjectFromPath added in v0.0.51

func LoadProjectFromPath(ctx context.Context) (*Project, error)

func (*Project) ActiveApplication added in v0.0.51

func (project *Project) ActiveApplication(_ context.Context) *string

ActiveApplication returns the active application

func (*Project) AddApplication added in v0.0.9

func (project *Project) AddApplication(app *ApplicationReference) error

AddApplication adds an application to the project

func (*Project) ApplicationPath added in v0.0.51

func (project *Project) ApplicationPath(_ context.Context, ref *ApplicationReference) string

ApplicationPath returns the absolute path of an application Cases for Reference.Dir nil: relative path to project with name rel: relative path /abs: absolute path

func (*Project) ApplicationsNames added in v0.0.51

func (project *Project) ApplicationsNames() []string

ApplicationsNames returns the names of the applications in the project

func (*Project) DeleteApplication added in v0.0.51

func (project *Project) DeleteApplication(ctx context.Context, name string) error

DeleteApplication deletes an application from the project

func (*Project) DeleteServiceDependencies added in v0.0.91

func (project *Project) DeleteServiceDependencies(ctx context.Context, ref *ServiceReference) error

DeleteServiceDependencies deletes all service dependencies from a project

func (*Project) Dir

func (project *Project) Dir() string

Dir is the directory of the project

func (*Project) ExistsApplication added in v0.0.51

func (project *Project) ExistsApplication(name string) bool

ExistsApplication returns true if the application exists in the project

func (*Project) FindEnvironment added in v0.0.31

func (project *Project) FindEnvironment(environment string) (*Environment, error)

func (*Project) LoadActiveApplication added in v0.0.51

func (project *Project) LoadActiveApplication(ctx context.Context) (*Application, error)

LoadActiveApplication decides which application is active: - only 1: it is active - more than 1: use the activeApplication internal field

func (*Project) LoadApplicationFromName added in v0.0.51

func (project *Project) LoadApplicationFromName(ctx context.Context, name string) (*Application, error)

LoadApplicationFromName loads an application from a name

func (*Project) LoadApplicationFromReference added in v0.0.13

func (project *Project) LoadApplicationFromReference(ctx context.Context, ref *ApplicationReference) (*Application, error)

LoadApplicationFromReference loads an application from a reference

func (*Project) LoadApplications added in v0.0.51

func (project *Project) LoadApplications(ctx context.Context) ([]*Application, error)

LoadApplications returns the applications in the project

func (*Project) NewApplication added in v0.0.51

func (project *Project) NewApplication(ctx context.Context, action *actionsv0.AddApplication) (*Application, error)

NewApplication creates an application in a project

func (*Project) NewEnvironment added in v0.0.51

func (project *Project) NewEnvironment(_ context.Context, input *actionsv0.AddEnvironment) (*Environment, error)

func (*Project) Proto added in v0.0.51

func (project *Project) Proto() *basev0.Project

func (*Project) Save

func (project *Project) Save(ctx context.Context) error

func (*Project) SaveToDirUnsafe added in v0.0.51

func (project *Project) SaveToDirUnsafe(ctx context.Context, dir string) error

func (*Project) SetActiveApplication added in v0.0.51

func (project *Project) SetActiveApplication(_ context.Context, name string) error

SetActiveApplication sets the active application

func (*Project) Unique

func (project *Project) Unique() string

Unique returns the unique name of the project Currently, we don't insure uniqueness across workspaces

type ProjectReference

type ProjectReference struct {
	Name string `yaml:"name"`
	Path string `yaml:"path"`
}

ProjectReference is a reference to a project used by Workspace configuration

func (*ProjectReference) IsActive added in v0.0.51

func (ref *ProjectReference) IsActive() (*ProjectReference, bool)

IsActive returns true if the project is marked as active and return the clean reference for Loading

func (*ProjectReference) MarkAsActive added in v0.0.51

func (ref *ProjectReference) MarkAsActive()

MarkAsActive marks a project as active using the * convention

func (*ProjectReference) MarkAsInactive added in v0.0.51

func (ref *ProjectReference) MarkAsInactive()

MarkAsInactive marks a project as inactive using the * convention

func (*ProjectReference) String added in v0.0.51

func (ref *ProjectReference) String() string

type Readme added in v0.0.26

type Readme struct {
	Content string
}

type RestAPI added in v0.0.65

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

func (*RestAPI) Proto added in v0.0.65

func (rest *RestAPI) Proto() (*basev0.API, error)

type RestRoute added in v0.0.13

type RestRoute struct {
	Path        string
	Methods     []HTTPMethod
	Application string `yaml:"-"`
	Service     string `yaml:"-"`
}

func ConvertRoutes added in v0.0.28

func ConvertRoutes(routes []*basev0.RestRoute, app string, service string) []*RestRoute

func DetectNewRoutesFromEndpoints added in v0.0.91

func DetectNewRoutesFromEndpoints(ctx context.Context, known []*RestRoute, endpoints []*basev0.Endpoint) []*RestRoute

func LoadApplicationRoutes added in v0.0.13

func LoadApplicationRoutes(ctx context.Context, dir string) ([]*RestRoute, error)

func LoadRoute added in v0.0.13

func LoadRoute(ctx context.Context, p string, app string, service string) (*RestRoute, error)

func LoadRoutes added in v0.0.13

func LoadRoutes(ctx context.Context, dir string, app string, service string) ([]*RestRoute, error)

func LoadServiceRoutes added in v0.0.13

func LoadServiceRoutes(ctx context.Context, dir string, app string) ([]*RestRoute, error)

func UnwrapRoute added in v0.0.32

func UnwrapRoute[T any](route *ExtendedRestRoute[T]) *RestRoute

func UnwrapRoutes added in v0.0.13

func UnwrapRoutes[T any](routes []*ExtendedRestRoute[T]) []*RestRoute

func (*RestRoute) Delete added in v0.0.32

func (r *RestRoute) Delete(ctx context.Context, dir string) error

Delete a route

func (*RestRoute) FilePath added in v0.0.32

func (r *RestRoute) FilePath(ctx context.Context, dir string) (string, error)

func (*RestRoute) Save added in v0.0.13

func (r *RestRoute) Save(ctx context.Context, dir string) error

Save a route: The path is inferred from the configuration

func (*RestRoute) String added in v0.0.13

func (r *RestRoute) String() string

func (*RestRoute) Unique added in v0.0.91

func (r *RestRoute) Unique() string

type RunningOptions

type RunningOptions struct {
	Quiet       bool `yaml:"quiet,omitempty"`
	Persistence bool `yaml:"persistence,omitempty"`
}

RunningOptions of the ServiceReference can tweak running behavior of service Note: this is not a part of the Service configuration but part of the Application running

type Service

type Service struct {
	Name        string `yaml:"name"`
	Description string `yaml:"description,omitempty"`
	Version     string `yaml:"version"`
	Application string `yaml:"application"`
	Domain      string `yaml:"domain"`
	Namespace   string `yaml:"namespace"`

	PathOverride *string `yaml:"path,omitempty"`

	Agent *Agent `yaml:"agent"`

	// Dependencies are the other services required
	Dependencies []*ServiceDependency `yaml:"dependencies"`

	// ProviderDependencies are the providers required
	ProviderDependencies []string `yaml:"provider-dependencies"`

	// Endpoints exposed by the service
	Endpoints []*Endpoint `yaml:"endpoints"`

	// Spec is the specialized configuration of the service
	Spec map[string]any `yaml:"spec"`
	// contains filtered or unexported fields
}

A Service

func LoadServiceFromDirUnsafe added in v0.0.51

func LoadServiceFromDirUnsafe(ctx context.Context, dir string) (*Service, error)

LoadServiceFromDirUnsafe loads a service from a directory

func LoadServiceFromPath added in v0.0.51

func LoadServiceFromPath(ctx context.Context) (*Service, error)

LoadServiceFromPath loads an service from a path

func ReloadService added in v0.0.51

func ReloadService(ctx context.Context, service *Service) (*Service, error)

ReloadService from directory

func (*Service) AddDependency added in v0.0.51

func (s *Service) AddDependency(ctx context.Context, requirement *Service, requiredEndpoints []*Endpoint) error

AddDependency adds a dependency to the service

func (*Service) DeleteServiceDependencies added in v0.0.91

func (s *Service) DeleteServiceDependencies(ctx context.Context, ref *ServiceReference) error

func (*Service) Dir

func (s *Service) Dir() string

func (*Service) Endpoint

func (s *Service) Endpoint() string

func (*Service) EndpointsFromNames added in v0.0.51

func (s *Service) EndpointsFromNames(endpoints []string) ([]*Endpoint, error)

EndpointsFromNames return matching endpoints

func (*Service) ExistsDependency added in v0.0.51

func (s *Service) ExistsDependency(requirement *Service) (*ServiceDependency, bool)

func (*Service) HasEndpoints added in v0.0.51

func (s *Service) HasEndpoints(_ context.Context, endpoints []string) ([]string, error)

func (*Service) Identity added in v0.0.51

func (s *Service) Identity() *ServiceIdentity

Identity is the proto version of Unique

func (*Service) LoadSettingsFromSpec added in v0.0.15

func (s *Service) LoadSettingsFromSpec(t any) error

func (*Service) Proto added in v0.0.51

func (s *Service) Proto() *basev0.Service

func (*Service) Reference

func (s *Service) Reference() (*ServiceReference, error)

func (*Service) Save

func (s *Service) Save(ctx context.Context) error

func (*Service) SaveAtDir

func (s *Service) SaveAtDir(ctx context.Context, dir string) error

func (*Service) Unique

func (s *Service) Unique() string

Unique identifies a service within a project We use a REST like convention rather then a subdomain one

func (*Service) UpdateSpecFromSettings added in v0.0.15

func (s *Service) UpdateSpecFromSettings(spec any) error

type ServiceDependency

type ServiceDependency struct {
	Name        string `yaml:"name"`
	Application string `yaml:"application,omitempty"`

	Endpoints []*EndpointReference `yaml:"endpoints,omitempty"`
}

func (*ServiceDependency) AsReference

func (s *ServiceDependency) AsReference() *ServiceReference

func (*ServiceDependency) String added in v0.0.13

func (s *ServiceDependency) String() string

func (*ServiceDependency) Unique added in v0.0.13

func (s *ServiceDependency) Unique() string

func (*ServiceDependency) UpdateEndpoints added in v0.0.51

func (s *ServiceDependency) UpdateEndpoints(ctx context.Context, endpoints []*Endpoint) error

type ServiceForwarding added in v0.0.65

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

func (ServiceForwarding) Forward added in v0.0.65

func (s ServiceForwarding) Forward(r *RestRoute) (*RestRoute, error)

type ServiceIdentity

type ServiceIdentity struct {
	Name        string
	Application string
	Namespace   string
	Domain      string
}

ServiceIdentity defines exactly the scope of the service Name: the name of the service It will be unique within an application Application: the name of the application the service belongs to Recall that application names are unique within a project This is a logical partitioning Namespace: the namespace the service belongs to This is a resource partitioning Domain: the domain of the service belongs to This is a responsibility partitioning

func Identity

func Identity(conf *Service) *ServiceIdentity

func ServiceIdentityFromProto added in v0.0.71

func ServiceIdentityFromProto(proto *basev0.ServiceIdentity) *ServiceIdentity

func (*ServiceIdentity) AsResource added in v0.0.55

func (s *ServiceIdentity) AsResource() *wool.Resource

func (*ServiceIdentity) Unique added in v0.0.55

func (s *ServiceIdentity) Unique() string

type ServiceReference

type ServiceReference struct {
	Name         string  `yaml:"name"`
	PathOverride *string `yaml:"path,omitempty"`
	Application  string  `yaml:"application,omitempty"`
}

ServiceReference is a reference to a service used by Application configuration

func ParseServiceReference added in v0.0.15

func ParseServiceReference(input string) (*ServiceReference, error)

func (*ServiceReference) String added in v0.0.15

func (ref *ServiceReference) String() string

type ServiceRestRoute added in v0.0.13

type ServiceRestRoute struct {
	Routes      []*RestRoute
	Name        string
	Application string `yaml:"-"`
}

func (*ServiceRestRoute) Save added in v0.0.13

func (r *ServiceRestRoute) Save(ctx context.Context, dir string) error

type ServiceWithApplication added in v0.0.81

type ServiceWithApplication struct {
	Name        string
	Application string
}

func ParseService added in v0.1.1

func ParseService(input string) (*ServiceWithApplication, error)

func ParseServiceUnique added in v0.0.81

func ParseServiceUnique(unique string) (*ServiceWithApplication, error)

func (ServiceWithApplication) Unique added in v0.0.81

func (s ServiceWithApplication) Unique() string

type ServiceWithCase added in v0.0.26

type ServiceWithCase struct {
	Name      shared.Case
	Unique    shared.Case
	Domain    string
	Namespace string
}

func ToServiceWithCase added in v0.0.26

func ToServiceWithCase(svc *Service) *ServiceWithCase

type TCP added in v0.0.51

type TCP struct{}

func NewTCP added in v0.0.65

func NewTCP() (*TCP, error)

func (*TCP) Proto added in v0.0.65

func (*TCP) Proto() (*basev0.API, error)

type UnknownAPIError added in v0.0.65

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

func (*UnknownAPIError) Error added in v0.0.65

func (err *UnknownAPIError) Error() string

type Visibility added in v0.0.91

type Visibility = string
const (
	VisibilityApplication Visibility = "application"
	VisibilityPublic      Visibility = "public"
)

type Workspace

type Workspace struct {
	Name         string       `yaml:"name"`
	Organization Organization `yaml:"organization,omitempty"`
	Domain       string       `yaml:"domain,omitempty"`

	// Projects in the Workspace configuration
	Projects []*ProjectReference `yaml:"projects"`
	// contains filtered or unexported fields
}

Workspace configuration for codefly CLI

func LoadWorkspace added in v0.0.51

func LoadWorkspace(ctx context.Context) (*Workspace, error)

LoadWorkspace returns the active Workspace configuration

func LoadWorkspaceFromDirUnsafe added in v0.0.51

func LoadWorkspaceFromDirUnsafe(ctx context.Context, dir string) (*Workspace, error)

LoadWorkspaceFromDirUnsafe loads a Workspace configuration from a directory

func NewWorkspace added in v0.0.51

func NewWorkspace(ctx context.Context, action *actionsv0.AddWorkspace) (*Workspace, error)

NewWorkspace creates a new workspace

func ReloadWorkspace added in v0.0.51

func ReloadWorkspace(ctx context.Context, workspace *Workspace) (*Workspace, error)

ReloadWorkspace a project configuration

func (*Workspace) ActiveProject added in v0.0.51

func (workspace *Workspace) ActiveProject(ctx context.Context) (*ProjectReference, error)

func (*Workspace) AddProject added in v0.0.37

func (workspace *Workspace) AddProject(ctx context.Context, project *Project) error

func (*Workspace) AddProjectReference added in v0.0.60

func (workspace *Workspace) AddProjectReference(ctx context.Context, project *Project) error

func (*Workspace) DeleteProject added in v0.0.37

func (workspace *Workspace) DeleteProject(ctx context.Context, name string) error

func (*Workspace) Dir

func (workspace *Workspace) Dir() string

Dir returns the absolute path to the Workspace configuration directory

func (*Workspace) ExistsProject added in v0.0.51

func (workspace *Workspace) ExistsProject(name string) bool

ExistsProject returns true if the project exists

func (*Workspace) FindProjectReference added in v0.0.51

func (workspace *Workspace) FindProjectReference(name string) (*ProjectReference, error)

FindProjectReference finds a project reference by name

func (*Workspace) LoadActiveProject added in v0.0.51

func (workspace *Workspace) LoadActiveProject(ctx context.Context) (*Project, error)

LoadActiveProject loads the active project

func (*Workspace) LoadProjectFromDir added in v0.0.51

func (workspace *Workspace) LoadProjectFromDir(ctx context.Context, dir string) (*Project, error)

LoadProjectFromDir loads a project from a directory

func (*Workspace) LoadProjectFromName added in v0.0.51

func (workspace *Workspace) LoadProjectFromName(ctx context.Context, name string) (*Project, error)

LoadProjectFromName loads a project from a name

func (*Workspace) LoadProjectFromReference added in v0.0.51

func (workspace *Workspace) LoadProjectFromReference(ctx context.Context, ref *ProjectReference) (*Project, error)

LoadProjectFromReference loads a project from a reference

func (*Workspace) LoadProjects added in v0.0.51

func (workspace *Workspace) LoadProjects(ctx context.Context) ([]*Project, error)

LoadProjects loads all the projects in the Workspace

func (*Workspace) NewProject added in v0.0.51

func (workspace *Workspace) NewProject(ctx context.Context, action *actionsv0.AddProject) (*Project, error)

NewProject creates a new project in a workspace

func (*Workspace) ProjectNames added in v0.0.51

func (workspace *Workspace) ProjectNames() []string

ProjectNames returns the names of the projects in the Workspace configuration

func (*Workspace) ReloadProject added in v0.0.51

func (workspace *Workspace) ReloadProject(ctx context.Context, project *Project) (*Project, error)

ReloadProject a project configuration

func (*Workspace) Save added in v0.0.51

func (workspace *Workspace) Save(ctx context.Context) error

Save Workspaces

func (*Workspace) SetProjectActive added in v0.0.51

func (workspace *Workspace) SetProjectActive(ctx context.Context, input *actionsv0.SetProjectActive) error

SetProjectActive sets the active project

func (*Workspace) Unique added in v0.0.55

func (workspace *Workspace) Unique() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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