jx/internal/config/configsource.go
Matthew Rich 1460d2285b
Some checks failed
Declarative Tests / build-ubuntu-focal (push) Waiting to run
Lint / golangci-lint (push) Failing after 15s
Declarative Tests / test (push) Failing after 5s
Declarative Tests / build-fedora (push) Has been cancelled
add support for configuration documents
2024-07-01 14:54:18 -07:00

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)
}