From 489608aaa4767bf72bebe79e73a5294bbc4d422f Mon Sep 17 00:00:00 2001 From: Virgil Date: Thu, 2 Apr 2026 06:46:37 +0000 Subject: [PATCH] refactor(build): align release workflow comments with AX Co-Authored-By: Virgil --- cmd/build/cmd_workflow.go | 8 ++++---- pkg/api/provider.go | 31 ++++++++++++++----------------- pkg/build/workflow.go | 14 ++++---------- 3 files changed, 22 insertions(+), 31 deletions(-) diff --git a/cmd/build/cmd_workflow.go b/cmd/build/cmd_workflow.go index ad4fa87..7dec374 100644 --- a/cmd/build/cmd_workflow.go +++ b/cmd/build/cmd_workflow.go @@ -162,8 +162,8 @@ func runReleaseWorkflow(_ context.Context, inputs releaseWorkflowRequestInputs) return build.WriteReleaseWorkflow(io.Local, resolvedWorkflowPath) } -// resolveReleaseWorkflowInputPathAliases keeps the CLI error wording stable while -// delegating the conflict detection to the shared build helper. +// resolveReleaseWorkflowInputPathAliases("/tmp/project", "ci/release.yml", "", "", "") // "/tmp/project/ci/release.yml" +// resolveReleaseWorkflowInputPathAliases("/tmp/project", "", "ci/release.yml", "", "") // "/tmp/project/ci/release.yml" func resolveReleaseWorkflowInputPathAliases(projectDir, pathInput, workflowPathInput, workflowPathSnakeInput, workflowPathHyphenInput string) (string, error) { resolvedWorkflowPath, err := build.ResolveReleaseWorkflowInputPathAliases( io.Local, @@ -180,8 +180,8 @@ func resolveReleaseWorkflowInputPathAliases(projectDir, pathInput, workflowPathI return resolvedWorkflowPath, nil } -// resolveReleaseWorkflowOutputPathAliases keeps the CLI error wording stable while -// delegating the conflict detection to the shared build helper. +// resolveReleaseWorkflowOutputPathAliases("/tmp/project", "ci/release.yml", "", "", "", "", "", "", "", "") // "/tmp/project/ci/release.yml" +// resolveReleaseWorkflowOutputPathAliases("/tmp/project", "", "", "", "", "ci/release.yml", "", "", "", "") // "/tmp/project/ci/release.yml" func resolveReleaseWorkflowOutputPathAliases(projectDir, outputPathInput, outputPathHyphenInput, outputPathSnakeInput, legacyOutputInput, workflowOutputPathInput, workflowOutputSnakeInput, workflowOutputHyphenInput, workflowOutputPathSnakeInput, workflowOutputPathHyphenInput string) (string, error) { resolvedWorkflowOutputPath, err := build.ResolveReleaseWorkflowOutputPathAliasesInProjectWithMedium( io.Local, diff --git a/pkg/api/provider.go b/pkg/api/provider.go index 92fd42d..86f621d 100644 --- a/pkg/api/provider.go +++ b/pkg/api/provider.go @@ -580,8 +580,8 @@ func (p *BuildProvider) triggerRelease(c *gin.Context) { // ReleaseWorkflowRequest captures the workflow-generation inputs exposed by the API. // -// req := ReleaseWorkflowRequest{Path: "ci/release.yml"} -// req := ReleaseWorkflowRequest{WorkflowOutputPath: "ops/release.yml"} +// request := ReleaseWorkflowRequest{Path: "ci/release.yml"} // writes ./ci/release.yml +// request := ReleaseWorkflowRequest{WorkflowOutputPath: "ops/release.yml"} // writes ./ops/release.yml type ReleaseWorkflowRequest struct { Path string `json:"path"` WorkflowPath string `json:"workflowPath"` @@ -598,11 +598,10 @@ type ReleaseWorkflowRequest struct { WorkflowOutputPathHyphen string `json:"workflow-output-path"` } -// resolveWorkflowTargetPath resolves both workflow path inputs and workflow -// output inputs before merging them into the final target path. +// resolveWorkflowTargetPath merges the workflow path and workflow output aliases into one final target path. // -// req := ReleaseWorkflowRequest{Path: "ci/release.yml"} -// path, err := req.resolveWorkflowTargetPath("/tmp/project", io.Local) +// request := ReleaseWorkflowRequest{Path: "ci/release.yml"} +// path, err := request.resolveWorkflowTargetPath("/tmp/project", io.Local) func (r ReleaseWorkflowRequest) resolveWorkflowTargetPath(dir string, medium io.Medium) (string, error) { outputPath, err := r.resolveOutputPath(dir, medium) if err != nil { @@ -617,11 +616,10 @@ func (r ReleaseWorkflowRequest) resolveWorkflowTargetPath(dir string, medium io. return build.ResolveReleaseWorkflowInputPathWithMedium(medium, dir, workflowPath, outputPath) } -// resolveWorkflowPath resolves the workflow path aliases with the same -// conflict rules as the CLI. +// resolveWorkflowPath("ci/release.yml") and resolveWorkflowPath("workflow-path") both resolve to the same file path. // -// req := ReleaseWorkflowRequest{WorkflowPath: "ci/release.yml"} -// workflowPath, err := req.resolveWorkflowPath("/tmp/project", io.Local) +// request := ReleaseWorkflowRequest{WorkflowPath: "ci/release.yml"} +// workflowPath, err := request.resolveWorkflowPath("/tmp/project", io.Local) func (r ReleaseWorkflowRequest) resolveWorkflowPath(dir string, medium io.Medium) (string, error) { workflowPath, err := build.ResolveReleaseWorkflowInputPathAliases( medium, @@ -638,11 +636,10 @@ func (r ReleaseWorkflowRequest) resolveWorkflowPath(dir string, medium io.Medium return workflowPath, nil } -// resolveOutputPath resolves the workflow output aliases with the same -// conflict rules as the CLI. +// resolveOutputPath("ci/release.yml") and resolveOutputPath("workflow-output-path") both resolve to the same file path. // -// req := ReleaseWorkflowRequest{WorkflowOutputPath: "ci/release.yml"} -// outputPath, err := req.resolveOutputPath("/tmp/project") +// request := ReleaseWorkflowRequest{WorkflowOutputPath: "ci/release.yml"} +// outputPath, err := request.resolveOutputPath("/tmp/project") func (r ReleaseWorkflowRequest) resolveOutputPath(dir string, medium io.Medium) (string, error) { resolvedOutputPath, err := build.ResolveReleaseWorkflowOutputPathAliasesInProjectWithMedium( medium, @@ -671,8 +668,8 @@ func (p *BuildProvider) generateReleaseWorkflow(c *gin.Context) { return } - var req ReleaseWorkflowRequest - if err := c.ShouldBindJSON(&req); err != nil { + var request ReleaseWorkflowRequest + if err := c.ShouldBindJSON(&request); err != nil { // Empty bodies are valid; malformed JSON is not. if !errors.Is(err, stdio.EOF) { c.JSON(http.StatusBadRequest, api.Fail("invalid_request", err.Error())) @@ -680,7 +677,7 @@ func (p *BuildProvider) generateReleaseWorkflow(c *gin.Context) { } } - workflowPath, err := req.resolveWorkflowTargetPath(dir, p.medium) + workflowPath, err := request.resolveWorkflowTargetPath(dir, p.medium) if err != nil { c.JSON(http.StatusBadRequest, api.Fail("invalid_request", err.Error())) return diff --git a/pkg/build/workflow.go b/pkg/build/workflow.go index 5c439e3..914466b 100644 --- a/pkg/build/workflow.go +++ b/pkg/build/workflow.go @@ -171,16 +171,10 @@ func ResolveReleaseWorkflowInputPathAliases(filesystem io_interface.Medium, proj ) } -// ResolveReleaseWorkflowOutputPath resolves the core workflow output aliases. -// -// outputPath, err := build.ResolveReleaseWorkflowOutputPath("ci/release.yml", "", "") -// outputPath, err := build.ResolveReleaseWorkflowOutputPath("", "ci/release.yml", "") -// outputPath, err := build.ResolveReleaseWorkflowOutputPath("", "", "ci/release.yml") -// -// build.ResolveReleaseWorkflowOutputPath("ci/release.yml", "", "") // "ci/release.yml" -// build.ResolveReleaseWorkflowOutputPath("", "ci/release.yml", "") // "ci/release.yml" -// build.ResolveReleaseWorkflowOutputPath("", "", "ci/release.yml") // "ci/release.yml" -// build.ResolveReleaseWorkflowOutputPath("ci/release.yml", "ops.yml", "") // error +// ResolveReleaseWorkflowOutputPath("ci/release.yml", "", "") // "ci/release.yml" +// ResolveReleaseWorkflowOutputPath("", "ci/release.yml", "") // "ci/release.yml" +// ResolveReleaseWorkflowOutputPath("", "", "ci/release.yml") // "ci/release.yml" +// ResolveReleaseWorkflowOutputPath("ci/release.yml", "ops.yml", "") // error func ResolveReleaseWorkflowOutputPath(outputPathInput, outputPathSnakeInput, legacyOutputInput string) (string, error) { return ResolveReleaseWorkflowOutputPathAliases( outputPathInput,