refactor: move gateway and vault packages to internal directory

This commit is contained in:
Prad Nukala
2024-12-10 12:52:19 -05:00
parent b81bdebd64
commit dc6f02a000
73 changed files with 58 additions and 59 deletions
+45
View File
@@ -0,0 +1,45 @@
package config
import (
"context"
"github.com/apple/pkl-go/pkl"
)
// LoadFromBytes loads the environment from the given bytes
func LoadFromBytes(data []byte) (Env, error) {
text := string(data)
return LoadFromString(text)
}
// LoadFromString loads the environment from the given string
func LoadFromString(text string) (Env, error) {
evaluator, err := pkl.NewEvaluator(context.Background(), pkl.PreconfiguredOptions)
if err != nil {
return nil, err
}
defer func() {
cerr := evaluator.Close()
if err == nil {
err = cerr
}
}()
ret, err := Load(context.Background(), evaluator, pkl.TextSource(text))
return ret, err
}
// LoadFromURL loads the environment from the given URL
func LoadFromURL(url string) (Env, error) {
evaluator, err := pkl.NewEvaluator(context.Background(), pkl.PreconfiguredOptions)
if err != nil {
return nil, err
}
defer func() {
cerr := evaluator.Close()
if err == nil {
err = cerr
}
}()
ret, err := Load(context.Background(), evaluator, pkl.UriSource(url))
return ret, err
}