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

use api override and merging utils to get flatterned devfile #48

Merged
merged 14 commits into from
Dec 22, 2020

Conversation

yangcao77
Copy link
Collaborator

@yangcao77 yangcao77 commented Dec 11, 2020

What does this PR do?

use api override and merging utils to get flatterned devfile
this pr also adds plugin components parsing

What issues does this PR fix or reference?

devfile/api#198
devfile/api#240

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

unit test created

maysunfaisal and others added 6 commits November 23, 2020 14:49
Signed-off-by: Maysun J Faisal <[email protected]>
Signed-off-by: Maysun J Faisal <[email protected]>
Signed-off-by: Stephanie <[email protected]>
Signed-off-by: Stephanie <[email protected]>
Signed-off-by: Stephanie <[email protected]>
Signed-off-by: Stephanie <[email protected]>
@yangcao77
Copy link
Collaborator Author

blocked by: devfile/api#276

Signed-off-by: Stephanie <[email protected]>
Signed-off-by: Stephanie <[email protected]>
Signed-off-by: Stephanie <[email protected]>
Copy link
Member

@maysunfaisal maysunfaisal left a comment

Choose a reason for hiding this comment

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

Thanks for the changes. 👍

First pass of review..

pkg/devfile/parser/data/v2/common/options.go Outdated Show resolved Hide resolved
pkg/devfile/parser/data/v2/common/options.go Outdated Show resolved Hide resolved
pkg/devfile/parser/data/v2/types.go Outdated Show resolved Hide resolved
pkg/devfile/parser/data/v2/components.go Outdated Show resolved Hide resolved
pkg/devfile/parser/parse.go Outdated Show resolved Hide resolved
pkg/devfile/parser/parse.go Outdated Show resolved Hide resolved
pkg/devfile/parser/parse.go Outdated Show resolved Hide resolved
pkg/devfile/parser/parse.go Show resolved Hide resolved
pkg/devfile/parser/parse.go Outdated Show resolved Hide resolved
if err != nil {
return err
}
parentData, err := ParseFromURL(parent.Uri)
Copy link
Member

@maysunfaisal maysunfaisal Dec 15, 2020

Choose a reason for hiding this comment

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

One thing to think about is, you are calling func ParseFromURL with both parent and plugin. We need to avoid infinite loops if the parent or plugin references back to the main devfile. Do we allow such situations acc to the schema?

because it is parseDevfile(d, true) inside func ParseFromURL

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it would error out since reference back would result in duplication in flattened devfile?

Signed-off-by: Stephanie <[email protected]>
Copy link
Member

@maysunfaisal maysunfaisal left a comment

Choose a reason for hiding this comment

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

can we add a couple more test cases?

try a test case where there are

  • multiple events of diff type in main, parent and plugin devfile - preStart1 preStart2 in main, preStart1, postStart1 in parent, postStart1, postSart2 in plugin, etc. and see if it holds up nicely. You can probably update the currrent test for events
  • different type of overrides - for example, if the plugin devfile has a container component, what happens if the plugin overrides of the same name is of type volume component
  • can we also add a test case for this use api override and merging utils to get flatterned devfile #48 (comment)

Id: "devrun",
CommandUnion: v1.CommandUnion{
Exec: &v1.ExecCommand{
WorkingDir: "/projects/nodejs-starter",
Copy link
Member

Choose a reason for hiding this comment

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

this is a nit, but can we just randomize the commands for plugin and parent, so that other ppl looking at this dont get confused with how overriding works. They might think it should be the exact same. Could you pls do this for projects and component tests as well as other tests?

pkg/devfile/parser/parse.go Outdated Show resolved Hide resolved
wantErr: true,
},
{
name: "case 14: error out if the same command is defined in both plugin devfile and parent devfile",
Copy link
Member

Choose a reason for hiding this comment

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

case 14 number is repeated twice even tho its a diff test

wantErr: true,
},
{
name: "case 13: error out if the same project is defined again in the local devfile",
Copy link
Member

Choose a reason for hiding this comment

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

nit: can we say name: "case 13: error out if the plugin project is defined again in the local devfile",

Copy link
Member

Choose a reason for hiding this comment

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

Also this is dup with case 7 tho case 7 is with parent, same for case 4

main.go Show resolved Hide resolved
pkg/devfile/parser/data/interface.go Show resolved Hide resolved
Copy link
Member

@maysunfaisal maysunfaisal left a comment

Choose a reason for hiding this comment

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

/lgtm
thanks!

@openshift-ci-robot
Copy link

[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 9693dd0 into devfile:master Dec 22, 2020
@yangcao77 yangcao77 mentioned this pull request Dec 24, 2020
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.

3 participants