smartconfig/resolver_file.go
sneak 8a38afba5e passes tests, has cli filter now.
* still has not been *really* tested yet
2025-07-20 15:29:06 +02:00

21 lines
435 B
Go

package smartconfig
import (
"fmt"
"os"
"strings"
)
// FileResolver reads file contents.
// Usage: ${FILE:/path/to/file}
type FileResolver struct{}
// Resolve reads the file and returns its contents.
func (r *FileResolver) Resolve(value string) (string, error) {
data, err := os.ReadFile(value)
if err != nil {
return "", fmt.Errorf("failed to read file %s: %w", value, err)
}
return strings.TrimSpace(string(data)), nil
}