Skip to content

Commit

Permalink
Stop populating resourceName in git-init image
Browse files Browse the repository at this point in the history
The git-init image writes a git commit SHA and URL to a pod's termination message.
Prior to this commit, if these values came from the output of a PipelineResource,
it would also write the name of that PipelineResource to the pod's termination message.

Since PipelineResources have been removed, the environment variable TEKTON_RESOURCE_NAME
is never populated, and the PipelineResource name is never written to termination messages.
This commit removes the check for this environment variable and stops writing this value to
the termination message. The termination message will still be parseable by other code.

Removing this functionality will make it easier to migrate to v1, by allowing us to remove fields
not relevant to our v1 API. Refactoring/renaming PipelineResourceResult will happen in a separate commit.
  • Loading branch information
lbernick committed Mar 9, 2023
1 parent ce2e9b9 commit a06cf2c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
12 changes: 4 additions & 8 deletions cmd/git-init/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package main

import (
"flag"
"os"

"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
"github.com/tektoncd/pipeline/pkg/git"
Expand Down Expand Up @@ -58,17 +57,14 @@ func main() {
if err != nil {
logger.Fatalf("Error parsing revision %s of git repository: %s", fetchSpec.Revision, err)
}
resourceName := os.Getenv("TEKTON_RESOURCE_NAME")
output := []v1beta1.PipelineResourceResult{
{
Key: "commit",
Value: commit,
ResourceName: resourceName,
Key: "commit",
Value: commit,
},
{
Key: "url",
Value: fetchSpec.URL,
ResourceName: resourceName,
Key: "url",
Value: fetchSpec.URL,
},
}

Expand Down
7 changes: 4 additions & 3 deletions pkg/apis/pipeline/v1beta1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions pkg/apis/pipeline/v1beta1/resource_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,16 @@ import (
"github.com/hashicorp/go-multierror"
)

// PipelineResourceResult used to export the image name and digest as json
// PipelineResourceResult is used to write key/value pairs to TaskRun pod termination messages.
// The key/value pairs may come from the entrypoint binary, or represent a TaskRunResult.
// If they represent a TaskRunResult, the key is the name of the result and the value is the
// JSON-serialized value of the result.
// TODO(#6197): Rename this struct
type PipelineResourceResult struct {
Key string `json:"key"`
Value string `json:"value"`
Key string `json:"key"`
Value string `json:"value"`
// ResourceName may be used in tests, but it is not populated in termination messages.
// It is preserved here for backwards compatibility and will not be ported to v1.
ResourceName string `json:"resourceName,omitempty"`
ResultType ResultType `json:"type,omitempty"`
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/apis/pipeline/v1beta1/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@
}
},
"v1beta1.PipelineResourceResult": {
"description": "PipelineResourceResult used to export the image name and digest as json",
"description": "PipelineResourceResult is used to write key/value pairs to TaskRun pod termination messages. The key/value pairs may come from the entrypoint binary, or represent a TaskRunResult. If they represent a TaskRunResult, the key is the name of the result and the value is the JSON-serialized value of the result.",
"type": "object",
"required": [
"key",
Expand All @@ -718,6 +718,7 @@
"default": ""
},
"resourceName": {
"description": "ResourceName may be used in tests, but it is not populated in termination messages. It is preserved here for backwards compatibility and will not be ported to v1.",
"type": "string"
},
"type": {
Expand Down

0 comments on commit a06cf2c

Please sign in to comment.