Documentation
¶
Overview ¶
Package appname provides containers for named applications.
Application name foo-bar translate to environment variable prefix FOO_BAR_.
Index ¶
- func Listen(ctx context.Context, container Container, defaultPort uint16) (net.Listener, error)
- func ReadConfig(container Container, value interface{}) error
- func ReadSecret(container Container, name string) (string, error)
- func WriteConfig(container Container, value interface{}) error
- type Container
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReadConfig ¶
ReadConfig reads the configuration from the YAML configuration file config.yaml in the configuration directory.
If the file does not exist, this is a no-op. The value should be a pointer to unmarshal into.
func ReadSecret ¶
ReadSecret returns the contents of the file at path filepath.Join(container.ConfigDirPath(), secretRelDirPath, name).
func WriteConfig ¶
WriteConfig writes the configuration to the YAML configuration file config.yaml in the configuration directory.
The directory is created if it does not exist. The value should be a pointer to marshal.
Types ¶
type Container ¶
type Container interface {
// AppName is the application name.
//
// The name must be in [a-zA-Z0-9-_].
AppName() string
// ConfigDirPath is the config directory path for the named application.
//
// First checks for $APP_NAME_CONFIG_DIR.
// If this is not set, uses app.ConfigDirPath()/app-name.
ConfigDirPath() string
// CacheDirPath is the cache directory path for the named application.
//
// First checks for $APP_NAME_CACHE_DIR.
// If this is not set, uses app.CacheDirPath()/app-name.
CacheDirPath() string
// DataDirPath is the data directory path for the named application.
//
// First checks for $APP_NAME_DATA_DIR.
// If this is not set, uses app.DataDirPath()/app-name.
DataDirPath() string
// Port is the port to use for serving.
//
// First checks for $APP_NAME_PORT.
// If this is not set, checks for $PORT.
// If this is not set, returns 0, which means no port is known.
// Returns error on parse.
Port() (uint16, error)
}
Container is a container.
func NewContainer ¶
func NewContainer(envContainer app.EnvContainer, name string) (Container, error)
NewContainer returns a new Container.
The name must be in [a-zA-Z0-9-_].