Documentation ¶
Index ¶
- Constants
- func AsEndpointEnvironmentVariable(app string, service string, endpoint *Endpoint, addresses []string) string
- func AsEndpointEnvironmentVariableKey(app string, service string, endpoint *Endpoint) string
- func ExistsAtDir[C Configuration](dir string) bool
- func ExtendDomain(domain string, extension string) string
- func FindUp[C Configuration](cur string) (*C, error)
- func GlobalConfigurationDir() string
- func GlobalProjectRoot() string
- func HomeDir() string
- func InitGlobal(getter GlobalConfigurationInputer, override Override)
- func KnownPluginImplementationKinds() []string
- func KnownProjects() []string
- func LoadFromBytes[C Configuration](content []byte) (*C, error)
- func LoadFromDir[C Configuration](dir string) (*C, error)
- func LoadFromPath[C Configuration](p string) (*C, error)
- func LoadGlobalConfiguration()
- func LoadSpec(content []byte, obj any, override shared.BaseLogger) error
- func OverrideWorkspaceConfigDir(dir string)
- func OverrideWorkspaceProjectRoot(dir string)
- func ParseEndpointEnvironmentVariableKey(key string) (string, error)
- func ParseRestRouteEnvironmentVariable(env string) (string, []string)
- func Path[C Configuration](dir string) string
- func ProjectPath(relativePath string) string
- func RelativeProjectPath(p string) string
- func Reset()
- func RestRouteAsEnvironmentVariable(reference string, addresses []string) string
- func SaveCurrent()
- func SaveToDir[C Configuration](c *C, dir string) error
- func SerializeAddresses(addresses []string) string
- func SerializeSpec(spec any) ([]byte, error)
- func SetCurrentApplication(app *Application)
- func SetCurrentProject(p *Project)
- func SolveDir(dir string) string
- func SolveDirOrCreate(dir string) string
- func SupportedApi(kind string) error
- func TypeName[C Configuration]() string
- func ValidateDomain()
- func ValidateOrganization(org string) error
- func ValidateProjectName(name string) error
- func ValidateServiceName(name string) error
- type Application
- func ApplicationConfiguration(current bool) (*Application, error)
- func CurrentApplication(opts ...Option) (*Application, error)
- func FindApplicationUp(p string) (*Application, error)
- func ListApplications(opts ...Option) ([]*Application, error)
- func LoadApplicationFromDir(dir string) (*Application, error)
- func LoadApplicationFromName(name string, opts ...Option) (*Application, error)
- func MustCurrentApplication() *Application
- func NewApplication(name string) (*Application, error)
- func (app *Application) AddService(service *Service) error
- func (app *Application) Dir(opts ...Option) string
- func (app *Application) GetServiceReferences(name string) (*ServiceReference, error)
- func (app *Application) LoadServiceFromName(name string) (*Service, error)
- func (app *Application) Relative(absolute string, opts ...Option) string
- func (app *Application) Save() error
- func (app *Application) ServiceDomain(name string) string
- type ApplicationReference
- type ApplicationRestRoute
- type ClientEntry
- type Configuration
- type Endpoint
- type EndpointInstance
- type EndpointReference
- type ExtendedRestRoute
- func LoadApplicationExtendedRoutes[T any](dir string, logger shared.BaseLogger) ([]*ExtendedRestRoute[T], error)
- func LoadExtendedRestRoute[T any](p string, app string, service string) (*ExtendedRestRoute[T], error)
- func LoadExtendedRoutes[T any](dir string, app string, service string) ([]*ExtendedRestRoute[T], error)
- func LoadServiceExtendedRoutes[T any](dir string, app string) ([]*ExtendedRestRoute[T], error)
- func NewExtendedRestRoute[T any](rest RestRoute, value T) *ExtendedRestRoute[T]
- type GlobalConfigurationInputer
- type HttpMethod
- type NoApplicationError
- type Option
- type Override
- type Partial
- type Plugin
- func (p *Plugin) ImplementationKind() string
- func (p *Plugin) Key(f string, unique string) string
- func (p *Plugin) Name() string
- func (p *Plugin) Of(kind string) *Plugin
- func (p *Plugin) Patch() (*Plugin, error)
- func (p *Plugin) Path() (string, error)
- func (p *Plugin) Unique() string
- func (p *Plugin) Validate()
- type Project
- func CurrentProject() (*Project, error)
- func ListProjects() ([]*Project, error)
- func LoadCurrentProject() (*Project, error)
- func LoadProjectFromDir(dir string) (*Project, error)
- func LoadProjectFromName(name string) (*Project, error)
- func MustCurrentProject() *Project
- func NewProject(name string) (*Project, error)
- func ProjectConfiguration(current bool) (*Project, error)
- func (project *Project) AddApplication(app *ApplicationReference) error
- func (project *Project) AddPartial(partial Partial) error
- func (project *Project) AddProvider(provider *Provider) error
- func (project *Project) ApplicationByName(override string) (*Application, error)
- func (project *Project) Dir() string
- func (project *Project) GetPartial(name string) (*Partial, error)
- func (project *Project) GetService(name string) (*Service, error)
- func (project *Project) ListApplications() ([]*Application, error)
- func (project *Project) ListServices() ([]*ServiceReference, error)
- func (project *Project) LoadApplicationFromReference(ref *ApplicationReference) (*Application, error)
- func (project *Project) OtherApplications(app *Application) ([]*Application, error)
- func (project *Project) Relative(absolute string) string
- func (project *Project) Save() error
- func (project *Project) SaveToDir(dir string) error
- func (project *Project) Unique() string
- type ProjectBuilder
- type ProjectInput
- type ProjectReference
- type ProjectStyle
- type Provider
- type ProviderReference
- type RestRoute
- func LoadApplicationRoutes(dir string) ([]*RestRoute, error)
- func LoadRoute(p string, app string, service string) (*RestRoute, error)
- func LoadRoutes(dir string, app string, service string) ([]*RestRoute, error)
- func LoadServiceRoutes(dir string, app string) ([]*RestRoute, error)
- func UnwrapRoutes[T any](routes []*ExtendedRestRoute[T]) []*RestRoute
- type RunningOptions
- type Scope
- type Service
- func FindServiceFromReference(ref *ServiceReference) (*Service, error)
- func LoadService(input string) (*Service, error)
- func LoadServiceFromDir(dir string, opts ...Option) (*Service, error)
- func LoadServiceFromReference(ref *ServiceReference, opts ...Option) (*Service, error)
- func LoadServicesFromInput(inputs ...string) ([]*Service, error)
- func NewService(name string, namespace string, plugin *Plugin, ops ...Option) (*Service, error)
- func (s *Service) AddDependencyReference(requirement *Service) error
- func (s *Service) AddSpec(spec any) error
- func (s *Service) Dir(opts ...Option) string
- func (s *Service) Duplicate(name string) *Service
- func (s *Service) Endpoint() string
- func (s *Service) Reference() (*ServiceReference, error)
- func (s *Service) Save() error
- func (s *Service) SaveAtDir(destination string) error
- func (s *Service) Unique() string
- type ServiceDependency
- type ServiceIdentity
- type ServiceReference
- type ServiceRestRoute
- type Workspace
Constants ¶
const ( ApplicationConfigurationName = "application.codefly.yaml" ApplicationKind = "application" )
const ( PluginService = "service" PluginLibrary = "library" )
const ( PluginRuntimeService = "runtime::service" PluginFactoryService = "factory::service" )
const ( Unknown = "unknown" Grpc = "grpc" Rest = "rest" Tcp = "tcp" )
const EndpointPrefix = "CODEFLY_ENDPOINT__"
const GlobalConfigurationName = "codefly.yaml"
const PluginConfigurationName = "plugin.codefly.yaml"
const PluginProvider = "provider"
const ProjectConfigurationName = "project.codefly.yaml"
const ProviderConfigurationName = "provider.codefly.yaml"
const RestRoutePrefix = "CODEFLY-RESTROUTE_"
const ServiceConfigurationName = "service.codefly.yaml"
Variables ¶
This section is empty.
Functions ¶
func AsEndpointEnvironmentVariable ¶ added in v0.0.13
func AsEndpointEnvironmentVariableKey ¶ added in v0.0.13
func ExistsAtDir ¶
func ExistsAtDir[C Configuration](dir string) bool
func ExtendDomain ¶
func FindUp ¶
func FindUp[C Configuration](cur string) (*C, error)
FindUp looks for a service configuration in the current directory and up
func GlobalConfigurationDir ¶
func GlobalConfigurationDir() string
func GlobalProjectRoot ¶
func GlobalProjectRoot() string
func InitGlobal ¶
func InitGlobal(getter GlobalConfigurationInputer, override Override)
InitGlobal initializes the global configuration of codefly GlobalConfigurationInputer: setup the configuration and defaults Override: policy to replace existing configuration
func KnownPluginImplementationKinds ¶
func KnownPluginImplementationKinds() []string
func KnownProjects ¶
func KnownProjects() []string
func LoadFromBytes ¶ added in v0.0.13
func LoadFromBytes[C Configuration](content []byte) (*C, error)
func LoadFromDir ¶
func LoadFromDir[C Configuration](dir string) (*C, error)
func LoadFromPath ¶
func LoadFromPath[C Configuration](p string) (*C, error)
func LoadGlobalConfiguration ¶
func LoadGlobalConfiguration()
func OverrideWorkspaceConfigDir ¶
func OverrideWorkspaceConfigDir(dir string)
func OverrideWorkspaceProjectRoot ¶
func OverrideWorkspaceProjectRoot(dir string)
func ParseEndpointEnvironmentVariableKey ¶ added in v0.0.13
func ParseRestRouteEnvironmentVariable ¶ added in v0.0.13
func Path ¶
func Path[C Configuration](dir string) string
func ProjectPath ¶
func RelativeProjectPath ¶
func RestRouteAsEnvironmentVariable ¶ added in v0.0.13
func SaveCurrent ¶
func SaveCurrent()
func SaveToDir ¶
func SaveToDir[C Configuration](c *C, dir string) error
func SerializeAddresses ¶
func SerializeSpec ¶
func SetCurrentApplication ¶
func SetCurrentApplication(app *Application)
func SetCurrentProject ¶
func SetCurrentProject(p *Project)
func SolveDirOrCreate ¶
func SupportedApi ¶
func TypeName ¶
func TypeName[C Configuration]() string
func ValidateDomain ¶
func ValidateDomain()
func ValidateOrganization ¶
func ValidateProjectName ¶
func ValidateServiceName ¶
Types ¶
type Application ¶
type Application struct { Kind string `yaml:"kind"` Name string `yaml:"name"` RelativePath string `yaml:"relative-path"` Project string `yaml:"project"` Domain string `yaml:"domain"` Services []*ServiceReference `yaml:"services"` }
func ApplicationConfiguration ¶ added in v0.0.13
func ApplicationConfiguration(current bool) (*Application, error)
func CurrentApplication ¶
func CurrentApplication(opts ...Option) (*Application, error)
func FindApplicationUp ¶
func FindApplicationUp(p string) (*Application, error)
func ListApplications ¶
func ListApplications(opts ...Option) ([]*Application, error)
func LoadApplicationFromDir ¶
func LoadApplicationFromDir(dir string) (*Application, error)
func LoadApplicationFromName ¶
func LoadApplicationFromName(name string, opts ...Option) (*Application, error)
func MustCurrentApplication ¶
func MustCurrentApplication() *Application
func NewApplication ¶
func NewApplication(name string) (*Application, error)
func (*Application) AddService ¶
func (app *Application) AddService(service *Service) error
func (*Application) Dir ¶
func (app *Application) Dir(opts ...Option) string
func (*Application) GetServiceReferences ¶
func (app *Application) GetServiceReferences(name string) (*ServiceReference, error)
func (*Application) LoadServiceFromName ¶ added in v0.0.13
func (app *Application) LoadServiceFromName(name string) (*Service, error)
func (*Application) Relative ¶
func (app *Application) Relative(absolute string, opts ...Option) string
func (*Application) Save ¶
func (app *Application) Save() error
func (*Application) ServiceDomain ¶
func (app *Application) ServiceDomain(name string) string
type ApplicationReference ¶ added in v0.0.9
type ApplicationReference struct { Name string `yaml:"name"` RelativePath string `yaml:"relative-path,omitempty"` }
An ApplicationReference
type ApplicationRestRoute ¶ added in v0.0.13
type ApplicationRestRoute struct { ServiceRestRoutes []*ServiceRestRoute Name string }
type ClientEntry ¶
func (*ClientEntry) Validate ¶
func (c *ClientEntry) Validate() error
type Configuration ¶
type Configuration interface{}
type Endpoint ¶
type EndpointInstance ¶ added in v0.0.13
func ParseEndpointEnvironmentVariable ¶ added in v0.0.13
func ParseEndpointEnvironmentVariable(env string) (*EndpointInstance, error)
type EndpointReference ¶ added in v0.0.9
type EndpointReference struct {
Name string `yaml:"name"`
}
A EndpointReference
type ExtendedRestRoute ¶ added in v0.0.13
func LoadApplicationExtendedRoutes ¶ added in v0.0.13
func LoadApplicationExtendedRoutes[T any](dir string, logger shared.BaseLogger) ([]*ExtendedRestRoute[T], error)
func LoadExtendedRestRoute ¶ added in v0.0.13
func LoadExtendedRoutes ¶ added in v0.0.13
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 GlobalConfigurationInputer ¶
type GlobalConfigurationInputer interface { // Fetch instantiates the input Fetch() error // Organization is now global Organization() string // Domain associated with the organization Domain() string // CreateDefaultProject returns true if a default project should be created CreateDefaultProject() bool // ProjectBuilder abstracts away the configuration of Project creation ProjectBuilder() ProjectBuilder }
A GlobalConfigurationInputer abstracts away global configuration and default of project creation
type HttpMethod ¶ added in v0.0.13
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" )
type NoApplicationError ¶
type NoApplicationError struct {
Project string
}
func (NoApplicationError) Error ¶
func (e NoApplicationError) Error() string
type Option ¶
type Option func(scope *Scope)
func WithApplication ¶
func WithApplication(app *Application) Option
func WithProject ¶
type Plugin ¶
type Plugin struct { Kind string `yaml:"kind"` Identifier string `yaml:"name"` Version string `yaml:"version"` Publisher string `yaml:"publisher"` }
func LoadPluginConfiguration ¶ added in v0.0.13
func LoadPluginConfiguration(fs shared.FileSystem) Plugin
func LoadPluginConfigurationFromReader ¶ added in v0.0.13
func (*Plugin) ImplementationKind ¶
type Project ¶
type Project struct { Name string `yaml:"name"` Style ProjectStyle `yaml:"style"` Domain string `yaml:"domain"` Organization string `yaml:"organization"` RelativePath string `yaml:"relative-path,omitempty"` // Applications in the project Applications []*ApplicationReference `yaml:"applications"` CurrentApplication string `yaml:"current-application,omitempty"` // Partials are convenient way to run several applications Partials []Partial `yaml:"partials"` // Providers in the project Providers []ProviderReference `yaml:"providers"` }
func CurrentProject ¶
func ListProjects ¶
func LoadCurrentProject ¶
func LoadProjectFromDir ¶
func LoadProjectFromName ¶
func MustCurrentProject ¶
func MustCurrentProject() *Project
func NewProject ¶
func ProjectConfiguration ¶ added in v0.0.13
func (*Project) AddApplication ¶ added in v0.0.9
func (project *Project) AddApplication(app *ApplicationReference) error
func (*Project) AddPartial ¶ added in v0.0.13
func (*Project) AddProvider ¶ added in v0.0.9
func (*Project) ApplicationByName ¶ added in v0.0.13
func (project *Project) ApplicationByName(override string) (*Application, error)
func (*Project) GetPartial ¶ added in v0.0.13
func (*Project) ListApplications ¶ added in v0.0.13
func (project *Project) ListApplications() ([]*Application, error)
func (*Project) ListServices ¶
func (project *Project) ListServices() ([]*ServiceReference, error)
func (*Project) LoadApplicationFromReference ¶ added in v0.0.13
func (project *Project) LoadApplicationFromReference(ref *ApplicationReference) (*Application, error)
func (*Project) OtherApplications ¶ added in v0.0.9
func (project *Project) OtherApplications(app *Application) ([]*Application, error)
type ProjectBuilder ¶
type ProjectBuilder interface { ProjectName() string RelativePath() string Fetch() error Style() ProjectStyle }
type ProjectInput ¶
type ProjectInput struct {
Name string
}
func (*ProjectInput) Fetch ¶
func (p *ProjectInput) Fetch() error
func (*ProjectInput) ProjectDir ¶
func (p *ProjectInput) ProjectDir() string
func (*ProjectInput) ProjectName ¶
func (p *ProjectInput) ProjectName() string
func (*ProjectInput) RelativePath ¶
func (p *ProjectInput) RelativePath() string
func (*ProjectInput) Style ¶
func (p *ProjectInput) Style() ProjectStyle
type ProjectReference ¶
type ProjectReference struct { Name string `yaml:"name"` RelativePath string `yaml:"relative-path,omitempty"` }
ProjectReference is a reference to a project used by Workspace configuration
func FindProjectReference ¶
func FindProjectReference(name string) (*ProjectReference, error)
type ProjectStyle ¶
type ProjectStyle string
const ( ProjectStyleUnknown ProjectStyle = "unknown" ProjectStyleMonorepo ProjectStyle = "monorepo" ProjectStyleMultirepo ProjectStyle = "multirepo" )
func NewStyle ¶
func NewStyle(style string) ProjectStyle
type Provider ¶ added in v0.0.9
type Provider struct { Kind string `yaml:"kind"` Name string `yaml:"name"` Plugin *Plugin `yaml:"plugin"` }
func (*Provider) Reference ¶ added in v0.0.9
func (p *Provider) Reference() (*ProviderReference, error)
type ProviderReference ¶ added in v0.0.9
type ProviderReference struct { Name string `yaml:"name"` RelativePath string `yaml:"relative-path,omitempty"` }
A ProviderReference
type RestRoute ¶ added in v0.0.13
type RestRoute struct { Path string Methods []HttpMethod Application string `yaml:"-"` Service string `yaml:"-"` }
func LoadApplicationRoutes ¶ added in v0.0.13
func LoadRoutes ¶ added in v0.0.13
func LoadServiceRoutes ¶ added in v0.0.13
func UnwrapRoutes ¶ added in v0.0.13
func UnwrapRoutes[T any](routes []*ExtendedRestRoute[T]) []*RestRoute
type RunningOptions ¶
type RunningOptions struct { Replicas int `yaml:"replicas,omitempty"` 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 Scope ¶
type Scope struct { Project *Project Application *Application }
func WithScopeProjectOnly ¶ added in v0.0.9
func (*Scope) WithApplication ¶
func (s *Scope) WithApplication(app *Application) *Scope
func (*Scope) WithProject ¶ added in v0.0.9
type Service ¶
type Service struct { Kind string `yaml:"kind"` Name string `yaml:"name"` Version string `yaml:"version"` Application string `yaml:"application"` RelativePath string `yaml:"relative-path,omitempty"` Namespace string `yaml:"namespace"` Domain string `yaml:"domain"` Plugin *Plugin `yaml:"plugin"` Dependencies []*ServiceDependency `yaml:"dependencies"` Endpoints []*Endpoint `yaml:"endpoints"` Spec map[string]any `yaml:"spec"` }
A Service
Convention: RelativePath from Application
func FindServiceFromReference ¶ added in v0.0.13
func FindServiceFromReference(ref *ServiceReference) (*Service, error)
func LoadService ¶
func LoadServiceFromReference ¶
func LoadServiceFromReference(ref *ServiceReference, opts ...Option) (*Service, error)
func LoadServicesFromInput ¶
LoadServicesFromInput from string inputs
func NewService ¶
func (*Service) AddDependencyReference ¶
AddDependencyReference adds a dependency to the service
func (*Service) Reference ¶
func (s *Service) Reference() (*ServiceReference, error)
type ServiceDependency ¶
type ServiceDependency struct { Name string `yaml:"name"` RelativePath string `yaml:"relative-path,omitempty"` // Null application means self 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) Validate ¶
func (s *ServiceDependency) Validate() error
type ServiceIdentity ¶
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
type ServiceReference ¶
type ServiceReference struct { Name string `yaml:"name"` RelativePath string `yaml:"relative-path,omitempty"` Application string `yaml:"application,omitempty"` RunningOptions RunningOptions `yaml:"options,omitempty"` }
ServiceReference is a reference to a service used by Application configuration
func ParseServiceInput ¶
func ParseServiceInput(input string) (*ServiceReference, error)
func (*ServiceReference) CreateReplicas ¶
func (ref *ServiceReference) CreateReplicas() []string
func (*ServiceReference) Validate ¶
func (ref *ServiceReference) Validate() error
type ServiceRestRoute ¶ added in v0.0.13
type Workspace ¶
type Workspace struct { Organization string `yaml:"organization"` Domain string `yaml:"domain"` // Projects in the global configuration Projects []*ProjectReference `yaml:"projects"` CurrentProject string `yaml:"current-project,omitempty"` // Internal FullDir string `yaml:"-"` }
Workspace configuration for codefly CLI
func MustCurrent ¶
func MustCurrent() *Workspace
MustCurrent returns the current global configuration