@@ -66,20 +66,17 @@ func (y *yamlMerger) run(
66
66
cfg builtin.YAMLMergeConfig ,
67
67
) (promotion.StepResult , error ) {
68
68
69
- result := promotion.StepResult {Status : kargoapi .PromotionStepStatusSucceeded }
70
- failure := promotion.StepResult {Status : kargoapi .PromotionStepStatusErrored }
71
-
72
69
// sanity check
73
70
if len (cfg .InFiles ) == 0 || cfg .OutFile == "" {
74
- return failure , fmt .Errorf ("inFiles and OutFile must not be empty" )
71
+ return promotion. StepResult { Status : kargoapi . PromotionStepStatusErrored } , fmt .Errorf ("inFiles and OutFile must not be empty" )
75
72
}
76
73
77
74
// Secure join the input paths to prevent path traversal attacks.
78
75
filePaths := []string {}
79
76
for _ , path := range cfg .InFiles {
80
77
inFile , err := securejoin .SecureJoin (stepCtx .WorkDir , path )
81
78
if err != nil {
82
- return failure , fmt .Errorf ("could not secure join input file %q: %w" , path , err )
79
+ return promotion. StepResult { Status : kargoapi . PromotionStepStatusErrored } , fmt .Errorf ("could not secure join input file %q: %w" , path , err )
83
80
}
84
81
85
82
// only add existing files
@@ -88,7 +85,7 @@ func (y *yamlMerger) run(
88
85
if cfg .IgnoreMissingFiles {
89
86
continue
90
87
}
91
- return failure , fmt .Errorf ("input file not found: %s" , inFile )
88
+ return promotion. StepResult { Status : kargoapi . PromotionStepStatusErrored } , fmt .Errorf ("input file not found: %s" , inFile )
92
89
93
90
}
94
91
filePaths = append (filePaths , inFile )
@@ -98,21 +95,22 @@ func (y *yamlMerger) run(
98
95
// Secure join the output path to prevent path traversal attacks.
99
96
outFile , err := securejoin .SecureJoin (stepCtx .WorkDir , cfg .OutFile )
100
97
if err != nil {
101
- return failure , fmt .Errorf ("could not secure join outFile %q: %w" , cfg .OutFile , err )
98
+ return promotion. StepResult { Status : kargoapi . PromotionStepStatusErrored } , fmt .Errorf ("could not secure join outFile %q: %w" , cfg .OutFile , err )
102
99
}
103
100
104
101
// ensure output path fully exist
105
102
if err = os .MkdirAll (filepath .Dir (outFile ), 0o700 ); err != nil {
106
- return failure , fmt .Errorf ("error creating directory structure %s: %w" , filepath .Dir (outFile ), err )
103
+ return promotion. StepResult { Status : kargoapi . PromotionStepStatusErrored } , fmt .Errorf ("error creating directory structure %s: %w" , filepath .Dir (outFile ), err )
107
104
}
108
105
109
106
// Merge files
110
107
err = yaml .MergeYAMLFiles (filePaths , outFile )
111
108
if err != nil {
112
- return failure , fmt .Errorf ("could not merge YAML files: %w" , err )
109
+ return promotion. StepResult { Status : kargoapi . PromotionStepStatusErrored } , fmt .Errorf ("could not merge YAML files: %w" , err )
113
110
}
114
111
115
112
// Add a commit message fragment to the step's output.
113
+ result := promotion.StepResult {Status : kargoapi .PromotionStepStatusSucceeded }
116
114
if commitMsg := y .generateCommitMessage (cfg .OutFile , filePaths ); commitMsg != "" {
117
115
result .Output = map [string ]any {
118
116
"commitMessage" : commitMsg ,
0 commit comments