#1205·litestream

Add ability to pass in configuration via STDIN

Author: akoutmosCreated Mar 23, 2026Updated Sep 22, 2026
Labelsenhancementstale

Feature Description

First off hello and thanks for this great piece of tech! I brought up this feature idea a little while ago but never got a definitive yes/no on adding an additional flag so that configurations can be passed into Litestream via STDIN (https://github.com/benbjohnson/litestream/issues/356#issuecomment-1292855333).

I have already put together a proof-of-concept and have it working in my fork. All things considered it is not a very intrusive change and doesn't change a lot outside of main.go.

Use Cases

I maintain the https://github.com/akoutmos/litestream library which allows you to easily run Litestream inside of your Elixir application. For most of the Object Storage backup destinations a configuration file is required and having the library create/cleanup temp files for configs feels a little messy. Being able to just pass in a dynamically generated config via STDIN definitely cleans up the integration.

Attempted Solutions

Workaround for now is creating temp config files and then deleting them as part of app tear down. Not the cleanest experience as cleanup may not happen and then config files with credentials can linger.

Proposal

The main change here would be to add an additional function in main.go:

go
func ReadConfig(configPath string, fromStdin, expandEnv bool) (Config, error) {
	if fromStdin {
		if configPath != "" {
			return DefaultConfig(), fmt.Errorf("cannot specify both -config and -stdin flags")
		}
		return ParseConfig(os.Stdin, expandEnv)
	}
	if configPath == "" {
		configPath = DefaultConfigPath()
	}
	return ReadConfigFile(configPath, expandEnv)
}

This function would delegate to the existing ReadConfigFile function so things work as they already do when a config file is available. But then if the -stdin flag is passed then os.Stdin is passed to ParseConfig instead.

Appreciate you taking the time to read through my idea!