46 lines
755 B
Go
46 lines
755 B
Go
|
// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
|
||
|
|
||
|
package config
|
||
|
|
||
|
import (
|
||
|
_ "context"
|
||
|
_ "encoding/json"
|
||
|
_ "fmt"
|
||
|
_ "gopkg.in/yaml.v3"
|
||
|
_ "net/url"
|
||
|
_ "regexp"
|
||
|
_ "strings"
|
||
|
_ "os"
|
||
|
_ "io"
|
||
|
_ "compress/gzip"
|
||
|
_ "archive/tar"
|
||
|
_ "errors"
|
||
|
_ "path/filepath"
|
||
|
_ "decl/internal/codec"
|
||
|
"embed"
|
||
|
)
|
||
|
|
||
|
type ConfigurationSelector func(b *Block) bool
|
||
|
|
||
|
type ConfigSource interface {
|
||
|
Type() string
|
||
|
|
||
|
Extract(filter ConfigurationSelector) ([]*Document, error)
|
||
|
}
|
||
|
|
||
|
func NewConfigSource(uri string) ConfigSource {
|
||
|
s, e := ConfigSourceTypes.New(uri)
|
||
|
if e == nil {
|
||
|
return s
|
||
|
}
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
//go:embed configs/*.yaml
|
||
|
var configFiles embed.FS
|
||
|
|
||
|
func Configurations() ([]*Document, error) {
|
||
|
fs := NewConfigFS(configFiles)
|
||
|
return fs.Extract(nil)
|
||
|
}
|