Skip to content
Snippets Groups Projects
Commit 63efefed authored by ale's avatar ale
Browse files

Implement a filesystem storage backend

Fixes #8.
parent 3f268ee3
No related branches found
No related tags found
1 merge request!34V3
Pipeline #57374 failed
......@@ -58,6 +58,8 @@ func defaultConfig() *Config {
config.ACME.HTTP.Enabled = true
config.ACME.AccountKeyPath = "/var/lib/acme/account.key"
config.ACME.KeyType = common.KeyTypeECDSA
config.Output.Type = "file"
config.Output.FS.Path = "/var/lib/acme/certs"
return &config
}
......
package upload
// Config for the output storage layer.
type Config struct {
import (
"context"
"fmt"
"git.autistici.org/ai3/tools/acmeserver/common"
)
type ReplDSConfig struct {
Endpoint string `yaml:"endpoint"`
Prefix string `yaml:"prefix"`
TLS struct {
......@@ -10,3 +16,35 @@ type Config struct {
CA string `yaml:"ca"`
} `yaml:"tls"`
}
type FSConfig struct {
Path string `yaml:"path"`
}
const (
configTypeFS = "file"
configTypeReplDS = "replds"
)
// Config for the output storage layer.
type Config struct {
Type string `yaml:"type"`
ReplDS ReplDSConfig `yaml:"replds"`
FS FSConfig `yaml:"file"`
}
// Uploader is the interface to the storage backend.
type Uploader interface {
Upload(context.Context, string, *common.Credentials) error
}
func New(config *Config) (Uploader, error) {
switch config.Type {
case configTypeFS:
return newFS(&config.FS)
case configTypeReplDS:
return newReplDS(&config.ReplDS)
default:
return nil, fmt.Errorf("unknown storage type '%s'", config.Type)
}
}
......@@ -40,8 +40,8 @@ type ReplStorage struct {
conn *grpc.ClientConn
}
// New creates a new ReplStorage.
func New(config *Config) (*ReplStorage, error) {
// newReplDS creates a new ReplStorage.
func newReplDS(config *ReplDSConfig) (*ReplStorage, error) {
var creds credentials.TransportCredentials
if config.TLS.Cert != "" && config.TLS.Key != "" && config.TLS.CA != "" {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment