Documentation
¶
Overview ¶
Package project manages the per-project .morth.json configuration file. Each project directory contains a .morth.json that defines which services the project uses and their port assignments.
Index ¶
Constants ¶
const ConfigFile = ".morth.json"
ConfigFile is the name of the per-project configuration file.
Variables ¶
This section is empty.
Functions ¶
func DefaultPath ¶
func DefaultPath() string
DefaultPath returns the default config file path: .morth.json in the current working directory.
Types ¶
type Config ¶
type Config struct {
ProjectID string `json:"project_id"`
Services map[string]ServiceConfig `json:"services"`
// contains filtered or unexported fields
}
Config represents the per-project .morth.json configuration.
func Init ¶
Init creates a new project configuration at the given path. The project ID is derived from the directory name containing the config file. Returns an error if a config file already exists at the path.
func Load ¶
Load reads a project configuration from the given file path. Returns an error if the file does not exist.
func (*Config) AddService ¶
AddService adds a service to the configuration with the given preferred port. Use preferredPort of 0 for automatic port assignment.
func (*Config) GetService ¶
func (c *Config) GetService(name string) (ServiceConfig, bool)
GetService returns the service configuration for the named service. The second return value indicates whether the service was found.
func (*Config) RemoveService ¶
RemoveService removes a service from the configuration. If the service does not exist, this is a no-op.
func (*Config) Save ¶
Save writes the configuration to disk with 0644 permissions. The JSON is pretty-printed with indentation.
func (*Config) SetAssigned ¶
SetAssigned sets the assigned port for the named service. If the service does not exist in the configuration, this is a no-op.
type ServiceConfig ¶
type ServiceConfig struct {
Port int `json:"port,omitempty"` // preferred port (0 = auto)
Assigned int `json:"assigned,omitempty"` // actually assigned port
}
ServiceConfig holds the port configuration for a single service.