Skip to content

Updates name and id field in the devfile schema#3872

Merged
openshift-merge-robot merged 2 commits intoredhat-developer:masterfrom
mik-dass:name_update
Sep 9, 2020
Merged

Updates name and id field in the devfile schema#3872
openshift-merge-robot merged 2 commits intoredhat-developer:masterfrom
mik-dass:name_update

Conversation

@mik-dass
Copy link
Contributor

@mik-dass mik-dass commented Aug 31, 2020

What type of PR is this?

/kind api-change

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

Updates the schema and changes the code according to it.

Which issue(s) this PR fixes:

Fixes #3822

PR acceptance criteria:

How to test changes / Special notes to the reviewer:

  • Tests should pass.

@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/api-change labels Aug 31, 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

@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 6, 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 7, 2020
@mik-dass mik-dass marked this pull request as ready for review September 9, 2020 05:13
@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 9, 2020
@mik-dass mik-dass added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. Required by Prow. label Sep 9, 2020
@mik-dass mik-dass force-pushed the name_update branch 4 times, most recently from f85b4cc to ec7ae47 Compare September 9, 2020 07:56
func validateCompositeCommand(data data.DevfileData, compositeCommand *common.Composite, parentCommands map[string]string, devfileCommands map[string]common.DevfileCommand) error {
if compositeCommand.Group != nil && compositeCommand.Group.Kind == common.RunCommandGroupType {
func validateCompositeCommand(data data.DevfileData, compositeCommand *common.DevfileCommand, parentCommands map[string]string, devfileCommands map[string]common.DevfileCommand) error {
if compositeCommand.Composite.Group != nil && compositeCommand.Composite.Group.Kind == common.RunCommandGroupType {
Copy link
Contributor

Choose a reason for hiding this comment

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

not important currently, compositeCommand.Composite.Group looking repetitive, parameter compositeCommand could be renamed to command.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK let's handle this in a separate issue.

@mik-dass mik-dass force-pushed the name_update branch 3 times, most recently from 2529968 to de7d6bc Compare September 9, 2020 12:02
@kadel
Copy link
Member

kadel commented Sep 9, 2020

/approve

@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 9, 2020
@kadel
Copy link
Member

kadel commented Sep 9, 2020

/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. Required by Prow. label Sep 9, 2020
isComponentValid := false
for _, component := range components {
if command.Exec.Component == component.Container.Name {
if command.Exec.Component == component.Name {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm sorry, I was just glancing through. But does this mean the above statement is true if i have a volume component whose name matches the command exec component?

Copy link
Contributor

@maysunfaisal maysunfaisal Sep 9, 2020

Choose a reason for hiding this comment

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

Because i was working on a clean up PR #3912 that was touching these files

Copy link
Member

Choose a reason for hiding this comment

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

@maysunfaisal Because of the new format for component names, I don't believe it's valid any more to have two components of different types, but with the same name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@maysunfaisal As mentioned by @johnmcollier, I don't think it will be possible with the new schema.

Copy link
Contributor

Choose a reason for hiding this comment

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

No i meant what if I have an invalid devfile like this:

components:
  - name: tools
    container:
      image: maysunfaisal/springbootbuild
      memoryLimit: 768Mi
      command: ['tail']
      args: [ '-f', '/dev/null']
      volumeMounts:
        - name: springbootpvc
          path: /data
      mountSources: true
  - name: springbootpvc
    volume: {}
commands:
  - id: defaultBuild
    exec:
      component: springbootpvc
      commandLine: "/artifacts/bin/build-container-full.sh"
      workingDir: /projects
      group:
        kind: build
        isDefault: true

but i realized that component is coming from components := GetDevfileContainerComponents(data), so we're good :)

@@ -4,10 +4,8 @@ import "strings"

// GetID returns the ID of the command
func (dc DevfileCommand) GetID() string {
Copy link
Member

Choose a reason for hiding this comment

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

Wondering if we even need GetID anymore? It was mostly needed when the ID wasn't stored at the top level part of the command and we had to check either Composite or Exec to get it.

But TBH, we can remove in a later PR. It's fine to leave in now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, let's remove that in a later PR

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 we can keep it in, its always neat to have helper funcs even if we can get it directly now :)

@cdrage
Copy link
Member

cdrage commented Sep 9, 2020

Just so everyone else knows, this explains the errors I've been getting:

[odo]  ✗  invalid devfile schema. errors :
[odo] - commands.0: Additional property id is not allowed
[odo] - commands.0.exec: id is required
[odo] - commands.1: Additional property id is not allowed
[odo] - commands.1.exec: id is required
[odo] - commands.2: Additional property id is not allowed
[odo] - commands.2.exec: id is required
[odo] - commands.3: Additional property id is not allowed
[odo] - commands.3.exec: id is required
[odo] - components.0: Additional property name is not allowed
[odo] - components.0.container: name is required                                                                                                                                                                                                                                 
[odo]

@cdrage
Copy link
Member

cdrage commented Sep 9, 2020

/approve

Went through the code and all of this looks good to me.

Tests pass.

Lets get this merged!

@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cdrage, kadel

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

The pull request process is described here

Details 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

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.

Looked through changes, all looks fine to me, don't see anything glaring that couldn't wait for another PR later. Also tested manually seems to work fine.

Let's get this one in if there's no objections.

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Sep 9, 2020
@GeekArthur GeekArthur mentioned this pull request Sep 9, 2020
2 tasks
@codecov
Copy link

codecov bot commented Sep 9, 2020

Codecov Report

Merging #3872 into master will increase coverage by 0.18%.
The diff coverage is 61.08%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3872      +/-   ##
==========================================
+ Coverage   44.60%   44.78%   +0.18%     
==========================================
  Files         143      143              
  Lines       13860    13911      +51     
==========================================
+ Hits         6182     6230      +48     
  Misses       7089     7089              
- Partials      589      592       +3     
Impacted Files Coverage Δ
pkg/component/component.go 25.76% <0.00%> (ø)
pkg/devfile/parser/representation.go 0.00% <0.00%> (ø)
pkg/envinfo/envinfo.go 43.93% <0.00%> (-0.52%) ⬇️
pkg/odo/cli/storage/create.go 0.00% <0.00%> (ø)
pkg/odo/cli/utils/convert.go 0.00% <0.00%> (ø)
pkg/testingutil/devfile.go 0.00% <0.00%> (ø)
...g/devfile/adapters/kubernetes/component/adapter.go 32.93% <9.09%> (-0.41%) ⬇️
pkg/devfile/parser/data/common/command_helper.go 81.81% <40.00%> (+5.50%) ⬆️
pkg/devfile/adapters/docker/component/utils.go 69.66% <46.15%> (ø)
pkg/devfile/parser/data/2.0.0/components.go 38.37% <50.00%> (-0.66%) ⬇️
... and 10 more

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 7831c92...84637af. Read the comment docs.

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. 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.

Update Devfiles and odo to work with breaking changes in devfile spec

8 participants