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

Devfile parser copies whole parent directory content to child directory #1118

Closed
rm3l opened this issue May 5, 2023 · 1 comment
Closed
Labels
area/library Common devfile library for interacting with devfiles kind/bug Something isn't working

Comments

@rm3l
Copy link
Member

rm3l commented May 5, 2023

Which area this feature is related to?

/kind bug

Which area this bug is related to?

/area library

What versions of software are you using?

Go project

Operating System and version:
Fedora 38

Go Pkg Version:

Bug Summary

Describe the bug:

To Reproduce:

$ mkdir -p /tmp/bug-devfile-parser/parent

$ touch  /tmp/bug-devfile-parser/parent/some-additional-file.txt

$ cat << EOF > /tmp/bug-devfile-parser/child-devfile.yaml
schemaVersion: 2.1.0
metadata:
  name: child
parent:
  uri: "parent/parent-devfile.yaml"
EOF                                                   

$ cat << EOF > /tmp/bug-devfile-parser/parent/parent-devfile.yaml
components:
- container:
    image: quay.io/devfile/golang:latest
  name: runtime
metadata:
  name: my-go-app
schemaVersion: 2.1.0
EOF

Initialize a local Git repo to easily see the issue:

$ git init /tmp/bug-devfile-parser
$ git -C /tmp/bug-devfile-parser add -A 
$ git -C /tmp/bug-devfile-parser commit -m "initial commit" 

When parsing the child Devfile, we can see that the whole content of /tmp/bug-devfile-parser/parent/ has been copied into /tmp/bug-devfile-parser/. I tested this by running main.go:

# clean working tree before running the parser
$ git -C /tmp/bug-devfile-parser/ status
On branch main
nothing to commit, working tree clean

# Parsing the child Devfile
$ go run . /tmp/bug-devfile-parser/child-devfile.yaml
parsing devfile from /tmp/bug-devfile-parser/child-devfile.yaml
[...]

# dirty working tree
$ git -C /tmp/bug-devfile-parser/ status
On branch main
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        parent-devfile.yaml
        some-additional-file.txt

nothing added to commit but untracked files present (use "git add" to track)

Expected behavior

Maybe I missed something, but I don't understand why the directory content of the parent Devfile is being copied into the child directory.

Any logs, error output, screenshots etc? Provide the devfile that sees this bug, if applicable

Additional context

We ran into this issue in the odo tests, where our local Git repos started to have untracked files every time we run our unit tests - see redhat-developer/odo#6539

This behavior seems to have been introduced in devfile/library#139

Any workaround?

Suggestion on how to fix the bug

@openshift-ci openshift-ci bot added kind/bug Something isn't working area/library Common devfile library for interacting with devfiles labels May 5, 2023
@mike-hoang
Copy link
Contributor

Devfile Community Call - 05/15

Expected behaviour for loading devfiles with parent is that devfile library will load the content of resources from the devfile parent location.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/library Common devfile library for interacting with devfiles kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants