refactor(build): align release workflow comments with AX
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
2b9369f6ab
commit
489608aaa4
3 changed files with 22 additions and 31 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue