diff --git a/Makefile b/Makefile index 9755b49..34c9b56 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: build run test test-unit test-integration test-workflow-integration test-e2e test-e2e-verbose test-e2e-ssh test-e2e-api test-e2e-nix test-e2e-install test-docker test-ssh test-distributed test-all test-summary test-ci clean install install-gotestsum lint fmt db-seed db-clean db-migrate run-server-debug swagger update-ui snapshot-release github-release docker-toolbox docker-toolbox-run docker-toolbox-shell docker-publish +.PHONY: build run test test-unit test-integration test-workflow-integration test-e2e test-e2e-verbose test-e2e-ssh test-e2e-api test-e2e-nix test-e2e-install test-docker test-ssh test-distributed test-all test-summary test-ci clean install install-gotestsum lint fmt db-seed db-clean db-migrate run-server-debug swagger update-ui snapshot-release github-release github-action docker-toolbox docker-toolbox-run docker-toolbox-shell docker-publish # Go parameters GOCMD=go @@ -317,6 +317,9 @@ github-release: @echo "$(PREFIX) Building and publishing GitHub release..." export GORELEASER_CURRENT_TAG="$(VERSION)" && goreleaser release --clean +github-action: + gh workflow run manual-release.yaml && gh workflow run nightly-release.yaml + # Database commands db-seed: build @echo "$(PREFIX) Seeding database..." @@ -390,6 +393,7 @@ help: @echo " make snapshot-release Build local snapshot release (no publish)" @echo " make local-release Build local snapshot for mac/linux arm (testing)" @echo " make github-release Build and publish GitHub release" + @echo " make github-action Trigger manual and nightly GitHub workflows" @echo "" @echo "\033[33m DATABASE\033[0m" @echo " make db-seed Seed database with sample data" diff --git a/internal/executor/executor.go b/internal/executor/executor.go index bb3ca33..0efdf77 100644 --- a/internal/executor/executor.go +++ b/internal/executor/executor.go @@ -84,6 +84,19 @@ func NewExecutor() *Executor { } } +func BuildBuiltinVariables(cfg *config.Config, params map[string]string) map[string]interface{} { + if cfg == nil { + cfg = config.DefaultConfig() + cfg.ResolvePaths() + } + + exec := NewExecutor() + runUUID := uuid.New().String() + execCtx := core.NewExecutionContext("func-eval", core.KindModule, runUUID, params["target"]) + exec.injectBuiltinVariables(cfg, params, execCtx) + return execCtx.GetVariables() +} + // SetSpinner enables or disables spinner display func (e *Executor) SetSpinner(show bool) { e.showSpinner = show @@ -293,7 +306,7 @@ func (e *Executor) injectBuiltinVariables(cfg *config.Config, params map[string] execCtx.SetVariable("TimeStamp", fmt.Sprintf("%d", now.Unix())) execCtx.SetVariable("CurrentTime", now.Format("2006-01-02T15:04:05")) execCtx.SetVariable("Today", now.Format("2006-01-02")) - execCtx.SetVariable("RandomString", generateRandomString(8)) + execCtx.SetVariable("RandomString", generateRandomString(6)) // Chunk-related variables (when running in chunk mode) if v, ok := params["chunk_index"]; ok && v != "" { @@ -462,7 +475,7 @@ func sanitizeTargetSpace(target string) string { // generateRandomString generates a random alphanumeric string func generateRandomString(length int) string { - const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" + const charset = "abcdefghijklmnopqrstuvwxyz" b := make([]byte, length) for i := range b { b[i] = charset[rand.Intn(len(charset))] diff --git a/pkg/cli/function.go b/pkg/cli/function.go index 0c2e016..0df0df9 100644 --- a/pkg/cli/function.go +++ b/pkg/cli/function.go @@ -6,7 +6,6 @@ import ( "io" "os" "os/signal" - "runtime" "strings" "sync" "syscall" @@ -294,16 +293,16 @@ func runBulkFunctionEval(printer *terminal.Printer, script string) error { // executeFunctionForTarget executes the script for a single target 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() + params := map[string]string{} + if target != "" { + params["target"] = target + } + if funcTargetsFile != "" { + params["target_file"] = funcTargetsFile + } + cfg := config.Get() + ctx := executor.BuildBuiltinVariables(cfg, params) if target != "" { ctx["target"] = target } diff --git a/pkg/cli/workflow.go b/pkg/cli/workflow.go index 5c64b53..a06350c 100644 --- a/pkg/cli/workflow.go +++ b/pkg/cli/workflow.go @@ -1106,7 +1106,7 @@ var workflowShowCmd = &cobra.Command{ {terminal.Cyan("{{Today}}"), "Current date (YYYY-MM-DD)", terminal.Yellow("")}, {terminal.Cyan("{{TimeStamp}}"), "Unix timestamp", terminal.Yellow("")}, {terminal.Cyan("{{CurrentTime}}"), "Current time (ISO 8601)", terminal.Yellow("")}, - {terminal.Cyan("{{RandomString}}"), "Random 8-char alphanumeric", terminal.Yellow("")}, + {terminal.Cyan("{{RandomString}}"), "Random 6-char lowercase letters", terminal.Yellow("")}, } printMarkdownTable([]string{"Variable", "Description", "Default Value"}, builtinVars) } else {