Documentation ¶
Index ¶
- Constants
- func AsEnvironmentVariable(reference string, addresses []string) 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 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 NewProject(builder ProjectBuilder) error
- func OverrideWorkspaceConfigDir(dir string)
- func OverrideWorkspaceProjectRoot(dir string)
- func ParseEnvironmentVariable(env string) (string, []string)
- func ParseServiceInput(input string) (string, string, error)
- func Path[C Configuration](dir string) string
- func ProjectPath(relativePath string) string
- func RelativeProjectPath(p string) string
- func Reset()
- 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 Api
- type ApiFramework
- type Application
- 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) Relative(absolute string, opts ...Option) string
- func (app *Application) Save() error
- func (app *Application) ServiceDomain(name string) string
- func (app *Application) Unique() string
- type ApplicationReference
- type ClientEntry
- type Configuration
- type Endpoint
- type EndpointReference
- type GlobalConfigurationInputer
- type NoApplicationError
- type Option
- type Override
- type Plugin
- type Project
- func (p *Project) AddApplication(app *ApplicationReference) error
- func (p *Project) AddProvider(provider *Provider) error
- func (p *Project) Dir() string
- func (p *Project) GetService(name string) (*Service, error)
- func (p *Project) ListServices() ([]*ServiceReference, error)
- func (p *Project) OtherApplications(app *Application) ([]*Application, error)
- func (p *Project) Relative(absolute string) string
- func (p *Project) Save() error
- func (p *Project) SaveToDir(dir string) error
- func (p *Project) Unique() string
- type ProjectBuilder
- type ProjectInput
- type ProjectReference
- type ProjectStyle
- type Protocol
- type Provider
- type ProviderReference
- type RunningOptions
- type Scope
- type Service
- func FindServiceFromName(name string, opts ...Option) (*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 Workspace
Constants ¶
const ApplicationConfigurationName = "application.codefly.yaml"
const ApplicationKind = "application"
const GlobalConfigurationName = "codefly.yaml"
const Grpc = "grpc"
const Http = "http"
const NetworkPrefix = "CODEFLY-NETWORK_"
const PluginFactoryService = "factory::service"
const PluginLibrary = "library"
const PluginProvider = "provider"
const PluginRuntimeService = "runtime::service"
const PluginService = "service"
const ProjectConfigurationName = "project.codefly.yaml"
const ProviderConfigurationName = "provider.codefly.yaml"
const RestFramework = "rest"
const ServiceConfigurationName = "service.codefly.yaml"
const Tcp = "tcp"
const Unknown = "unknown"
Variables ¶
This section is empty.
Functions ¶
func AsEnvironmentVariable ¶
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 LoadFromDir ¶
func LoadFromDir[C Configuration](dir string) (*C, error)
func LoadFromPath ¶
func LoadFromPath[C Configuration](p string) (*C, error)
func LoadGlobalConfiguration ¶
func LoadGlobalConfiguration()
func NewProject ¶
func NewProject(builder ProjectBuilder) error
func OverrideWorkspaceConfigDir ¶
func OverrideWorkspaceConfigDir(dir string)
func OverrideWorkspaceProjectRoot ¶
func OverrideWorkspaceProjectRoot(dir string)
func Path ¶
func Path[C Configuration](dir string) string
func ProjectPath ¶
func RelativeProjectPath ¶
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 Api ¶
type Api struct { Protocol Protocol `yaml:"protocol"` Framework ApiFramework `yaml:"framework,omitempty"` }
type ApiFramework ¶
type ApiFramework string
const ( RestApiFramework ApiFramework = "rest" GraphQLApiFramework ApiFramework = "graphql" )
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 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) 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
func (*Application) Unique ¶
func (app *Application) Unique() string
type ApplicationReference ¶ added in v0.0.9
type ApplicationReference struct { Name string `yaml:"name"` RelativePath string `yaml:"relative-path,omitempty"` }
An ApplicationReference
type ClientEntry ¶
func (*ClientEntry) Validate ¶
func (c *ClientEntry) Validate() error
type Configuration ¶
type Configuration interface { }
type Endpoint ¶
type Endpoint struct { Name string `yaml:"name"` Description string `yaml:"description,omitempty"` Public bool `yaml:"public,omitempty"` Api *Api `yaml:"api,omitempty"` // FailOver indicates that this endpoint should fail over to another endpoint FailOver *Endpoint `yaml:"fail-over,omitempty"` }
func (*Endpoint) Reference ¶ added in v0.0.9
func (e *Endpoint) Reference() *EndpointReference
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 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 (*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"` // Providers in the project Providers []ProviderReference `yaml:"providers"` }
func CurrentProject ¶
func ListProjects ¶
func LoadCurrentProject ¶
func LoadProjectFromDir ¶
func LoadProjectFromName ¶
func MustCurrentProject ¶
func MustCurrentProject() *Project
func (*Project) AddApplication ¶ added in v0.0.9
func (p *Project) AddApplication(app *ApplicationReference) error
func (*Project) AddProvider ¶ added in v0.0.9
func (*Project) ListServices ¶
func (p *Project) ListServices() ([]*ServiceReference, error)
func (*Project) OtherApplications ¶ added in v0.0.9
func (p *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 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 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"` ApplicationOverride string `yaml:"applications,omitempty"` Endpoints []*EndpointReference `yaml:"uses,omitempty"` }
func (*ServiceDependency) AsReference ¶
func (s *ServiceDependency) AsReference() *ServiceReference
func (*ServiceDependency) Validate ¶
func (s *ServiceDependency) Validate() error
type ServiceIdentity ¶
func Identity ¶
func Identity(conf *Service) *ServiceIdentity
type ServiceReference ¶
type ServiceReference struct { Name string `yaml:"name"` RelativePath string `yaml:"relative-path,omitempty"` ApplicationOverride string `yaml:"applications,omitempty"` RunningOptions RunningOptions `yaml:"options,omitempty"` }
ServiceReference is a reference to a service used by Application configuration
func (*ServiceReference) CreateReplicas ¶
func (ref *ServiceReference) CreateReplicas() []string
func (*ServiceReference) Validate ¶
func (ref *ServiceReference) Validate() error
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