Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Factor out a method to parse termination messages #1827

Merged
merged 1 commit into from
Jan 9, 2020

Conversation

imjasonh
Copy link
Member

@imjasonh imjasonh commented Jan 8, 2020

This reduces duplication, and allows us to make future changes to how
termination messages are written in lock-step with how they're parsed.

cc @othomann @chengjingtao

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

See the contribution guide for more details.

@googlebot googlebot added the cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit label Jan 8, 2020
@tekton-robot tekton-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jan 8, 2020
@tekton-robot
Copy link
Collaborator

The following is the coverage report on pkg/.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/termination/parse.go Do not exist 75.0%
pkg/termination/write.go Do not exist 68.4%

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Jan 9, 2020
@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vdemeester

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 9, 2020
@othomann
Copy link
Contributor

othomann commented Jan 9, 2020

@imjasonh I think the ParseMessage function needs to handle an empty string, this might explain the problem in the integration tests. So the parse tests should have a test with an empty string.
Something like this:

// ParseMessage parses a termination message as results.
func ParseMessage(msg string) ([]PipelineResourceResult, error) {
	if len(msg) == 0 {
		return nil, nil
	}
	var r []PipelineResourceResult
	if err := json.Unmarshal([]byte(msg), &r); err != nil {
		return nil, err
	}
	return r, nil
}

Could be nil or an empty slice.

@tekton-robot tekton-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 9, 2020
@imjasonh
Copy link
Member Author

imjasonh commented Jan 9, 2020

@imjasonh I think the ParseMessage function needs to handle an empty string

Thanks, that was definitely the bug. Handled, and tested

@tekton-robot
Copy link
Collaborator

The following is the coverage report on pkg/.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/termination/parse.go Do not exist 83.3%
pkg/termination/write.go Do not exist 68.4%

go.mod Show resolved Hide resolved
pkg/termination/parse.go Outdated Show resolved Hide resolved
This reduces duplication, and allows us to make future changes to how
termination messages are written in lock-step with how they're parsed.
@tekton-robot
Copy link
Collaborator

The following is the coverage report on pkg/.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/termination/parse.go Do not exist 100.0%
pkg/termination/write.go Do not exist 68.4%

Copy link
Collaborator

@bobcatfish bobcatfish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/meow space

@tekton-robot
Copy link
Collaborator

@bobcatfish: cat image

In response to this:

/lgtm
/meow space

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Jan 9, 2020
@othomann
Copy link
Contributor

othomann commented Jan 9, 2020

/test pull-tekton-pipeline-build-tests

@tekton-robot tekton-robot merged commit 2d7d7ee into tektoncd:master Jan 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants