mirror of
https://github.com/j3ssie/osmedeus.git
synced 2026-09-09 19:27:48 +02:00
feat: expose platform variables in osmedeus eval command
Export platform detection functions (DetectDocker, DetectKubernetes, DetectCloudProvider) from internal/executor to allow reuse in CLI. Inject PlatformOS, PlatformArch, PlatformInDocker, PlatformInKubernetes, and PlatformCloudProvider variables in func eval command context.
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"io"
|
||||
"os"
|
||||
"os/signal"
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
@@ -13,6 +14,7 @@ import (
|
||||
|
||||
"github.com/j3ssie/osmedeus/v5/internal/config"
|
||||
"github.com/j3ssie/osmedeus/v5/internal/database"
|
||||
"github.com/j3ssie/osmedeus/v5/internal/executor"
|
||||
"github.com/j3ssie/osmedeus/v5/internal/functions"
|
||||
"github.com/j3ssie/osmedeus/v5/internal/template"
|
||||
"github.com/j3ssie/osmedeus/v5/internal/terminal"
|
||||
@@ -290,6 +292,14 @@ func runBulkFunctionEval(printer *terminal.Printer, script string) error {
|
||||
func executeFunctionForTarget(printer *terminal.Printer, script, target string) error {
|
||||
// Build context with target and params
|
||||
ctx := make(map[string]interface{})
|
||||
|
||||
// Inject platform detection variables (always available, even without target)
|
||||
ctx["PlatformOS"] = runtime.GOOS
|
||||
ctx["PlatformArch"] = runtime.GOARCH
|
||||
ctx["PlatformInDocker"] = executor.DetectDocker()
|
||||
ctx["PlatformInKubernetes"] = executor.DetectKubernetes()
|
||||
ctx["PlatformCloudProvider"] = executor.DetectCloudProvider()
|
||||
|
||||
if target != "" {
|
||||
ctx["target"] = target
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user