22 lines
495 B
Go
22 lines
495 B
Go
package smartconfig
|
|
|
|
import (
|
|
"fmt"
|
|
"os/exec"
|
|
"strings"
|
|
)
|
|
|
|
// ExecResolver executes shell commands and returns their output.
|
|
// Usage: ${EXEC:command}
|
|
type ExecResolver struct{}
|
|
|
|
// Resolve executes the command and returns its output.
|
|
func (r *ExecResolver) Resolve(value string) (string, error) {
|
|
cmd := exec.Command("sh", "-c", value)
|
|
output, err := cmd.Output()
|
|
if err != nil {
|
|
return "", fmt.Errorf("exec command failed: %w", err)
|
|
}
|
|
return strings.TrimSpace(string(output)), nil
|
|
}
|