Documentation
¶
Overview ¶
Package profiles manages the persistent profile configuration of the FTL CLI.
Layout will be something like:
.ftl-project/ project.toml profiles/ <profile>/ profile.toml [secrets.toml] [config.toml]
See the design document for more information.
Index ¶
- type LocalProfileConfig
- type Profile
- type ProfileConfig
- type ProfileConfigKind
- type ProfilePersistence
- type ProfileType
- type Project
- func (p *Project) ActiveProfile() (string, error)
- func (p *Project) DefaultProfile() string
- func (p *Project) List() ([]ProfileConfig, error)
- func (p *Project) Load(ctx context.Context, profile string) (Profile, error)
- func (p *Project) New(profileConfig ProfileConfig) error
- func (p *Project) ProfileRoot() (string, error)
- func (p *Project) Realm() string
- func (p *Project) SetDefault(profile string) error
- func (p *Project) Switch(profile string) error
- type ProjectConfig
- func (p ProjectConfig) AbsModuleDirs() []string
- func (p ProjectConfig) ActiveProfile() (string, error)
- func (p ProjectConfig) ListProfiles() ([]ProfilePersistence, error)
- func (p ProjectConfig) LoadProfile(name string) (ProfilePersistence, error)
- func (p ProjectConfig) ProfileRoot() (string, error)
- func (p ProjectConfig) Save() error
- func (p ProjectConfig) SaveProfile(profile ProfilePersistence) error
- func (p ProjectConfig) SetActiveProfile(profile string) error
- type RemoteProfileConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LocalProfileConfig ¶
type LocalProfileConfig struct {
SecretsProvider config.ProviderKey
ConfigProvider config.ProviderKey
}
type Profile ¶
type Profile struct {
// contains filtered or unexported fields
}
func (*Profile) ConfigurationManager ¶
func (p *Profile) ConfigurationManager() config.Provider[config.Configuration]
ConfigurationManager returns the configuration manager for this profile.
func (*Profile) ProjectConfig ¶
func (p *Profile) ProjectConfig() ProjectConfig
ProjectConfig is the static project-wide configuration shared by all profiles.
type ProfileConfig ¶
type ProfileConfig struct {
Name string
Config ProfileConfigKind
}
func (ProfileConfig) String ¶
func (p ProfileConfig) String() string
type ProfileConfigKind ¶ added in v0.435.0
type ProfileConfigKind interface {
// contains filtered or unexported methods
}
type ProfilePersistence ¶ added in v0.510.0
type ProfilePersistence struct {
Name string `toml:"name"`
Endpoint string `toml:"endpoint"`
Type ProfileType `toml:"type"`
SecretsProvider config.ProviderKey `toml:"secrets-provider"`
ConfigProvider config.ProviderKey `toml:"config-provider"`
}
ProfilePersistence represents the persistent profile data stored in TOML.
func (*ProfilePersistence) EndpointURL ¶ added in v0.510.0
func (p *ProfilePersistence) EndpointURL() (*url.URL, error)
type ProfileType ¶ added in v0.510.0
type ProfileType string
const ( ProfileTypeLocal ProfileType = "local" ProfileTypeRemote ProfileType = "remote" )
type Project ¶
type Project struct {
// contains filtered or unexported fields
}
func Init ¶
func Init( project ProjectConfig, secretsRegistry *config.Registry[config.Secrets], configRegistry *config.Registry[config.Configuration], ) (*Project, error)
Init a new project with a default local profile.
"project.Root" must be a valid directory path.
If "project.Default" is empty a new project will be created with a default "local" profile.
func Open ¶
func Open( root string, secretsRegistry *config.Registry[config.Secrets], configRegistry *config.Registry[config.Configuration], ) (*Project, error)
Open a project.
func (*Project) ActiveProfile ¶
ActiveProfile returns the name of the active profile.
If no profile is active, the default profile is returned.
func (*Project) DefaultProfile ¶
func (*Project) List ¶
func (p *Project) List() ([]ProfileConfig, error)
List all profiles in the project.
func (*Project) New ¶
func (p *Project) New(profileConfig ProfileConfig) error
New creates a new profile in the project.
func (*Project) ProfileRoot ¶ added in v0.466.0
ProfileRoot returns the root directory for the currently active profile.
func (*Project) SetDefault ¶
SetDefault profile for the project.
type ProjectConfig ¶
type ProjectConfig struct {
Realm string `toml:"realm"`
FTLMinVersion string `toml:"ftl-min-version,omitempty"`
// ModuleRoots is a list of directories that contain modules.
ModuleRoots []string `toml:"module-roots,omitempty"`
Git bool `toml:"git,omitempty"`
Hermit bool `toml:"hermit,omitempty"`
DefaultProfile string `toml:"default-profile,omitempty"`
Root string `toml:"-"`
}
ProjectConfig is the static project-wide configuration shared by all profiles.
func (ProjectConfig) AbsModuleDirs ¶ added in v0.435.0
func (p ProjectConfig) AbsModuleDirs() []string
AbsModuleDirs returns the absolute path for the module-dirs field from the ftl-project.toml, unless that is not defined, in which case it defaults to the root directory.
func (ProjectConfig) ActiveProfile ¶ added in v0.510.0
func (p ProjectConfig) ActiveProfile() (string, error)
ActiveProfile returns the name of the active profile.
If no profile is active, it returns the default.
func (ProjectConfig) ListProfiles ¶ added in v0.510.0
func (p ProjectConfig) ListProfiles() ([]ProfilePersistence, error)
ListProfiles returns the names of all profiles in the project.
func (ProjectConfig) LoadProfile ¶ added in v0.510.0
func (p ProjectConfig) LoadProfile(name string) (ProfilePersistence, error)
func (ProjectConfig) ProfileRoot ¶ added in v0.510.0
func (p ProjectConfig) ProfileRoot() (string, error)
ProfileRoot returns the root directory for the project's active profile.
func (ProjectConfig) Save ¶ added in v0.510.0
func (p ProjectConfig) Save() error
func (ProjectConfig) SaveProfile ¶ added in v0.510.0
func (p ProjectConfig) SaveProfile(profile ProfilePersistence) error
SaveProfile saves a profile to the project.
func (ProjectConfig) SetActiveProfile ¶ added in v0.510.0
func (p ProjectConfig) SetActiveProfile(profile string) error