Skip to content

Commit f317e68

Browse files
committed
FilterReservedPathFromOutputDirPath
1 parent 69884d1 commit f317e68

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

pkg/pipeline/PipelineStageService.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
"github.com/devtron-labs/devtron/internal/util"
2626
"github.com/devtron-labs/devtron/pkg/pipeline/adapter"
2727
"github.com/devtron-labs/devtron/pkg/pipeline/bean"
28-
"github.com/devtron-labs/devtron/pkg/pipeline/constants"
28+
"github.com/devtron-labs/devtron/pkg/pipeline/helper"
2929
"github.com/devtron-labs/devtron/pkg/pipeline/repository"
3030
"github.com/devtron-labs/devtron/pkg/plugin"
3131
repository2 "github.com/devtron-labs/devtron/pkg/plugin/repository"
@@ -37,7 +37,6 @@ import (
3737
"github.com/go-pg/pg"
3838
"go.uber.org/zap"
3939
"net/http"
40-
"strings"
4140
"time"
4241
)
4342

@@ -681,13 +680,7 @@ func (impl *PipelineStageServiceImpl) CreateStageSteps(steps []*bean.PipelineSta
681680
impl.logger.Errorw("error in creating script and mapping for inline step", "err", err, "inlineStepDetail", inlineStepDetail)
682681
return err
683682
}
684-
for _, path := range step.OutputDirectoryPath {
685-
if strings.HasPrefix(path, constants.CiRunnerWorkingDir) {
686-
errMsg := fmt.Sprintf("output directory path cannot start with reserved path %s", constants.CiRunnerWorkingDir)
687-
return util.NewApiError(http.StatusBadRequest, errMsg, errMsg)
688-
}
689-
}
690-
683+
step.OutputDirectoryPath = helper.FilterReservedPathFromOutputDirPath(step.OutputDirectoryPath)
691684
inlineStep := &repository.PipelineStageStep{
692685
PipelineStageId: stageId,
693686
Name: step.Name,
@@ -1253,6 +1246,7 @@ func (impl *PipelineStageServiceImpl) UpdateStageStepsWithTx(steps []*bean.Pipel
12531246
outputVariables = step.RefPluginStepDetail.OutputVariables
12541247
conditionDetails = step.RefPluginStepDetail.ConditionDetails
12551248
} else if step.StepType == repository.PIPELINE_STEP_TYPE_INLINE {
1249+
step.OutputDirectoryPath = helper.FilterReservedPathFromOutputDirPath(step.OutputDirectoryPath)
12561250
if savedStep.StepType == repository.PIPELINE_STEP_TYPE_REF_PLUGIN {
12571251
//step changed from ref plugin to inline, create script and mapping
12581252
scriptEntryId, err := impl.CreateScriptAndMappingForInlineStep(step.InlineStepDetail, userId, tx)

pkg/pipeline/helper/helper.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package helper
2+
3+
import (
4+
"github.com/devtron-labs/devtron/pkg/pipeline/constants"
5+
"strings"
6+
)
7+
8+
func FilterReservedPathFromOutputDirPath(outputDirectoryPath []string) []string {
9+
var newOutputDirPath []string
10+
for _, path := range outputDirectoryPath {
11+
if !strings.HasPrefix(path, constants.CiRunnerWorkingDir) {
12+
newOutputDirPath = append(newOutputDirPath, path)
13+
}
14+
}
15+
return newOutputDirPath
16+
}

0 commit comments

Comments
 (0)