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

Migrate devfile cmd validation to validate pkg #3912

Merged
merged 7 commits into from
Sep 17, 2020

Conversation

maysunfaisal
Copy link
Contributor

@maysunfaisal maysunfaisal commented Sep 8, 2020

What type of PR is this?
/kind cleanup
/kind code-refactoring

What does does this PR do / why we need it:

  • migrates devfile command validation to validate pkg along with other devfile validation
  • devfile commands are now validated anytime we parse devfile and not only during odo push when using the command
  • cleaned up some code
  • updated unit tests

Which issue(s) this PR fixes:

Fixes #3703

PR acceptance criteria:

How to test changes / Special notes to the reviewer:

  • Make invalid changes to the devfile command and any odo command that parses the devfile should err out

@openshift-ci-robot openshift-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. Required by Prow. kind/cleanup labels Sep 8, 2020
@openshift-ci-robot
Copy link
Collaborator

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@codecov
Copy link

codecov bot commented Sep 8, 2020

Codecov Report

Merging #3912 into master will decrease coverage by 0.02%.
The diff coverage is 73.40%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3912      +/-   ##
==========================================
- Coverage   44.55%   44.53%   -0.03%     
==========================================
  Files         143      145       +2     
  Lines       13979    14005      +26     
==========================================
+ Hits         6229     6237       +8     
- Misses       7158     7176      +18     
  Partials      592      592              
Impacted Files Coverage Δ
pkg/devfile/parser/data/2.0.0/components.go 38.37% <ø> (ø)
pkg/devfile/validate/validate.go 0.00% <0.00%> (ø)
pkg/devfile/validate/errors.go 40.00% <33.33%> (-10.00%) ⬇️
pkg/devfile/validate/events.go 85.71% <71.42%> (-0.57%) ⬇️
pkg/devfile/validate/commands.go 95.55% <95.55%> (ø)
pkg/devfile/adapters/common/command.go 95.48% <100.00%> (+0.08%) ⬆️
pkg/devfile/adapters/common/utils.go 94.36% <100.00%> (-0.70%) ⬇️
pkg/devfile/parser/data/common/component_helper.go 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0730745...7bc997d. Read the comment docs.

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. Required by Prow. label Sep 9, 2020
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. Required by Prow. label Sep 10, 2020
@maysunfaisal maysunfaisal marked this pull request as ready for review September 10, 2020 21:10
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. Required by Prow. label Sep 10, 2020
Comment on lines 340 to 352
// func TestIsContainer(t *testing.T) {

// tests := []struct {
// name string
// component common.DevfileComponent
// wantIsSupported bool
// }{
// {
// name: "Case 1: Container component",
// component: testingutil.GetFakeContainerComponent("comp1"),
// wantIsSupported: true,
// },
// {
Copy link
Contributor

Choose a reason for hiding this comment

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

these comments need to be removed


// Successful
return d, nil
return d, err
Copy link
Contributor

Choose a reason for hiding this comment

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

I think these changes can be applied in the above functions as well

// validateCommands validates all the devfile commands
func validateCommands(commands map[string]common.DevfileCommand, components []common.DevfileComponent) (err error) {

// commandsMap := adapterCommon.GetCommandsMap(commands)
Copy link
Contributor

@mik-dass mik-dass Sep 11, 2020

Choose a reason for hiding this comment

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

I think this can be removed

// If the command is a composite command, need to validate that it is valid
if command.Composite != nil {
parentCommands := make(map[string]string)
// commandsMap := adapterCommon.GetCommandsMap(commands)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this comment can be removed

@mik-dass
Copy link
Contributor

Tests seem to be failing on Travis
https://travis-ci.com/github/openshift/odo/jobs/383364891#L2065

@maysunfaisal
Copy link
Contributor Author

/retest

@mik-dass
Copy link
Contributor

CI seems to be failing

e "runtime"
         ✗  the command "mkdir" does not map to a container component
        
    to contain substring
        <string>: references an invalid command

@maysunfaisal
Copy link
Contributor Author

CI seems to be failing

e "runtime"
         ✗  the command "mkdir" does not map to a container component
        
    to contain substring
        <string>: references an invalid command

@mik-dass yep, I noticed this yesterday

@maysunfaisal
Copy link
Contributor Author

/retest

Copy link
Contributor

@mik-dass mik-dass left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Sep 16, 2020
@girishramnani
Copy link
Contributor

/approve

@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: girishramnani

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

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. Required by Prow. label Sep 16, 2020
Signed-off-by: Maysun J Faisal <maysunaneek@gmail.com>
Signed-off-by: Maysun J Faisal <maysunaneek@gmail.com>
Signed-off-by: Maysun J Faisal <maysunaneek@gmail.com>
Signed-off-by: Maysun J Faisal <maysunaneek@gmail.com>
Signed-off-by: Maysun J Faisal <maysunaneek@gmail.com>
Signed-off-by: Maysun J Faisal <maysunaneek@gmail.com>
Signed-off-by: Maysun J Faisal <maysunaneek@gmail.com>
@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Sep 16, 2020
Copy link
Member

@johnmcollier johnmcollier left a comment

Choose a reason for hiding this comment

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

Readding the lgtm label due to rebase

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Sep 16, 2020
@openshift-merge-robot openshift-merge-robot merged commit efb0448 into redhat-developer:master Sep 17, 2020
@rm3l rm3l added the area/refactoring Issues or PRs related to code refactoring label Jun 16, 2023
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. Required by Prow. area/refactoring Issues or PRs related to code refactoring lgtm Indicates that a PR is ready to be merged. Required by Prow.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move devfile command validation to validate pkg
7 participants