Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions modules/iacm/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ import (

"go.yaml.in/yaml/v3"

"github.com/harness/cli/modules/pipeline"
"github.com/harness/cli/pkg/auth"
"github.com/harness/cli/pkg/cmdctx"
"github.com/harness/cli/pkg/console"
"github.com/harness/cli/pkg/logstream"
)

const executeWorkspaceHandlerID = "execute_workspace"
Expand Down Expand Up @@ -70,6 +70,9 @@ func executeWorkspaceHandler(ctx *cmdctx.Ctx) error {
a := ctx.Auth

workspaceID := ctx.Id
if workspaceID == "" {
workspaceID = positionalWorkspaceArg()
}
orgID := a.OrgID
projectID := a.ProjectID

Expand Down Expand Up @@ -128,6 +131,22 @@ func loadWorkspaceConfig() (*workspaceConfig, error) {
return &cfg, nil
}

// positionalWorkspaceArg extracts the workspace ID from os.Args.
// Since no_id:true prevents the framework from setting ctx.Id, we parse
// the positional argument manually: "harness execute workspace <id>".
func positionalWorkspaceArg() string {
var found bool
for _, arg := range os.Args[1:] {
if found && !strings.HasPrefix(arg, "-") {
return arg
}
if arg == "workspace" {
found = true
}
}
return ""
}

func executePlan(
bgCtx context.Context,
cmdCtx *cmdctx.Ctx,
Expand Down Expand Up @@ -202,11 +221,8 @@ func executePlan(
}
fmt.Printf("Pipeline execution: %s\n", execURL)

fmt.Println("\n=== Pipeline Execution Logs ===")
return logstream.FollowMulti(cmdCtx, exec.PipelineExecutionID, "", "", logstream.MultiStyleMarkers, map[string]bool{
"IACMIntegrationStageStepPMS": true,
"IACMPrepareExecution": true,
})
fmt.Println("\n=== Launching UI Log Viewer ===")
return pipeline.RunLogViewer(exec.PipelineExecutionID, cmdCtx)
}

// ---- API helpers ----
Expand Down
2 changes: 1 addition & 1 deletion pkg/spec/iacm.spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -468,4 +468,4 @@ commands:
request_headers:
Harness-Account: auth.account
item_expr: it
yaml_pick_expr: it
yaml_pick_expr: it
Loading