Skip to content

Commit

Permalink
test-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ericzzzzzzz committed Mar 18, 2024
1 parent 7ed2cd9 commit be15315
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
23 changes: 12 additions & 11 deletions pkg/entrypoint/entrypointer.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,14 +501,15 @@ func (e Entrypointer) outputRunResult(terminationReason string) result.RunResult
}

// getStepArtifactsPath gets the path to the step artifacts
func getStepArtifactsPath(stepDir string, stepName string) string {
return filepath.Join(stepDir, stepName, "artifacts", "provenance.json")
func getStepArtifactsPath(stepDir string, containerName string) string {
return filepath.Join(stepDir, containerName, "artifacts", "provenance.json")
}

// loadStepArtifacts loads and parses the artifacts file for a specified step.
func loadStepArtifacts(stepDir string, stepName string) (v1.Artifacts, error) {
func loadStepArtifacts(stepDir string, containerName string) (v1.Artifacts, error) {
v := v1.Artifacts{}
fp := getStepArtifactsPath(stepDir, stepName)
fp := getStepArtifactsPath(stepDir, containerName)

fileContents, err := os.ReadFile(fp)
if err != nil {
return v, err
Expand All @@ -531,7 +532,7 @@ func getArtifactValues(dir string, template string) (string, error) {
return "", err
}

artifacts, err := loadStepArtifacts(dir, artifactTemplate.StepName)
artifacts, err := loadStepArtifacts(dir, artifactTemplate.ContainerName)
if err != nil {
return "", err
}
Expand Down Expand Up @@ -577,8 +578,8 @@ func parseArtifactTemplate(template string) (ArtifactTemplate, error) {
template = strings.TrimSuffix(strings.TrimPrefix(template, "$("), ")")
split := strings.Split(template, ".")
at := ArtifactTemplate{
StepName: fmt.Sprintf("step-%s", split[1]),
Type: split[2],
ContainerName: fmt.Sprintf("step-%s", split[1]),
Type: split[2],
}
if len(split) == 4 {
at.ArtifactName = split[3]
Expand All @@ -587,9 +588,9 @@ func parseArtifactTemplate(template string) (ArtifactTemplate, error) {
}

type ArtifactTemplate struct {
StepName string
Type string // inputs or outputs
ArtifactName string
ContainerName string
Type string // inputs or outputs
ArtifactName string
}

// applyStepArtifactSubstitutions replaces artifact references within a step's command and environment variables with their corresponding values.
Expand Down Expand Up @@ -621,7 +622,7 @@ func (e *Entrypointer) applyStepArtifactSubstitutions(stepDir string, scriptDir
return err
}
if v != fileContent {
e.Command = []string{"sh", "-c", fileContent}
e.Command = []string{"sh", "-c", v}
}
} else {
command := e.Command
Expand Down
21 changes: 10 additions & 11 deletions pkg/entrypoint/entrypointer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1198,34 +1198,34 @@ func TestParseArtifactTemplate(t *testing.T) {
desc: "valid outputs template with artifact name",
input: "$(steps.name.outputs.aaa)",
want: ArtifactTemplate{
StepName: "step-name",
Type: "outputs",
ArtifactName: "aaa",
ContainerName: "step-name",
Type: "outputs",
ArtifactName: "aaa",
},
},
{
desc: "valid outputs template without artifact name",
input: "$(steps.name.outputs)",
want: ArtifactTemplate{
Type: "outputs",
StepName: "step-name",
Type: "outputs",
ContainerName: "step-name",
},
},
{
desc: "valid inputs template with artifact name",
input: "$(steps.name.inputs.aaa)",
want: ArtifactTemplate{
StepName: "step-name",
Type: "inputs",
ArtifactName: "aaa",
ContainerName: "step-name",
Type: "inputs",
ArtifactName: "aaa",
},
},
{
desc: "valid outputs template without artifact name",
input: "$(steps.name.inputs)",
want: ArtifactTemplate{
Type: "inputs",
StepName: "step-name",
Type: "inputs",
ContainerName: "step-name",
},
},
{
Expand Down Expand Up @@ -1402,7 +1402,6 @@ func TestGetArtifactValues(t *testing.T) {
}

func TestApplyStepArtifactSubstitutionsCommand(t *testing.T) {

stepName := "name"
scriptDir := createTmpDir(t, "script")
tests := []struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/pod/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ func filterResults(results []result.RunResult, specResults []v1.TaskResult, step
taskRunStepResults = append(taskRunStepResults, taskRunStepResult)
filteredResults = append(filteredResults, r)
case result.ArtifactsResultType:
// not defined in spec
filteredResults = append(filteredResults, r)
continue
case result.InternalTektonResultType:
// Internal messages are ignored because they're not used as external result
Expand Down

0 comments on commit be15315

Please sign in to comment.