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

update add apis - process everything before return an error #86

Merged
merged 3 commits into from
May 12, 2021

Conversation

yangcao77
Copy link
Collaborator

@yangcao77 yangcao77 commented May 10, 2021

Signed-off-by: Stephanie [email protected]

What does this PR do?

This PR updates add apis to process everything before return an error.
The error returned is a total error which contains error of all invalid elements during that add action

What issues does this PR fix or reference?

Fixes devfile/api#449

Is your PR tested? Consider putting some instruction how to test your changes

update unit tests to check for error message

Signed-off-by: Stephanie <[email protected]>
@yangcao77 yangcao77 requested a review from maysunfaisal May 10, 2021 17:53
@openshift-ci openshift-ci bot requested a review from elsony May 10, 2021 17:53
@@ -51,15 +52,19 @@ func (d *DevfileV2) GetCommands(options common.DevfileOptions) ([]v1.Command, er
// AddCommands adds the slice of Command objects to the Devfile's commands
// if a command is already defined, error out
Copy link
Member

Choose a reason for hiding this comment

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

could you pls update the func desc for all the Add funcs, it errors out after processing everything

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated

Comment on lines +59 to +60
errorsList = append(errorsList, (&common.FieldAlreadyExistError{Name: command.Id, Field: "command"}).Error())
continue
Copy link
Member

Choose a reason for hiding this comment

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

IMO we should update teh test to see if all these ids are being returned in the err. Previously we didnt care as it was just return on first error. But since we are updating it for a specific purpose we should probably test it. We can use regex to match err strings like we do in devfile/api 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated

@openshift-ci
Copy link

openshift-ci bot commented May 12, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: maysunfaisal, yangcao77

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:
  • OWNERS [maysunfaisal,yangcao77]

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

@yangcao77 yangcao77 merged commit 5d88bd3 into devfile:master May 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Library add apis should process everything before return an error
2 participants