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

fix: check overlapping paths separately for directories and contents #343

Merged
merged 5 commits into from Feb 9, 2024

Conversation

Zebradil
Copy link
Member

This PR fixes the logic of the overlapping paths check. In the original versions, paths of directories were joined with paths of their contents before the check. This allowed the following configuration to be accepted:

apiVersion: vendir.k14s.io/v1alpha1
kind: Config
directories:
  - path: charts
    contents:
      - path: foo
        inline:
          paths:
            foo.txt: file-content
  - path: charts
    contents:
      - path: bar
        inline:
          paths:
            bar.txt: file-content

The result of vendir sync would be:

❯ vendir sync
Fetching: charts + foo (inline)

Fetching: charts + bar (inline)

Lock config

apiVersion: vendir.k14s.io/v1alpha1
directories:
- contents:
  - inline: {}
    path: foo
  path: charts
- contents:
  - inline: {}
    path: bar
  path: charts
kind: LockConfig

Succeeded

❯ exa -T
.
├── charts
│  └── bar
│     └── bar.txt
├── vendir.lock.yml
└── vendir.yml

One of the contents is overwritten by the other.

With this PR, having the same paths for two directories will result in an error.

Signed-off-by: German Lashevich <german.lashevich@gmail.com>
Signed-off-by: German Lashevich <german.lashevich@gmail.com>
@Zebradil Zebradil marked this pull request as ready for review December 24, 2023 20:05
@kumaritanushree
Copy link
Contributor

@Zebradil I think you are trying to do the same thing what @fritzduchardt has done in this PR #325

I have added a solution as well there if that fulfil your requirements. Else we will have more discussion on this in next community meeting to have a final decision wether we want this change or not.
Thanks

@Zebradil
Copy link
Member Author

Hi @kumaritanushree, thank you for looking into this.

I saw #325 before creating this PR, but my proposal differs. The PR from @fritzduchardt proposes to allow the same paths to be managed by different directory entities in the vendir configuration. My PR proposes to disallow duplicated paths.

I've been using vendir for more than three years and I always was sure that one path could be managed only by one directory. I can be wrong about that. Maybe @cppforlife can share the initial idea behind this.

@joaopapereira
Copy link
Member

Let us talk about this in tomorrow's community meeting @fritzduchardt @Zebradil if yll can attend

Signed-off-by: German Lashevich <german.lashevich@gmail.com>
Signed-off-by: German Lashevich <german.lashevich@gmail.com>
Signed-off-by: German Lashevich <german.lashevich@gmail.com>
@Zebradil
Copy link
Member Author

Zebradil commented Jan 10, 2024

@joaopapereira as we agreed in the community meeting, I went ahead and:

  • replaced the old e2e test for overlapping paths with the new one with more test cases,
  • reverted ordering changes to the imports block,
  • removed the overlapping-dir example (it was used in the old e2e test).

I'm unsure about the last point, but I don't see much value in having an example of incorrect configuration (I bet, code copilots learn from it 😄).

@kumaritanushree
Copy link
Contributor

Changes looks good to me. Tested, error message also looks good.

Copy link
Member

@joaopapereira joaopapereira left a comment

Choose a reason for hiding this comment

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

LGTM

@joaopapereira joaopapereira merged commit 6329f9f into carvel-dev:develop Feb 9, 2024
4 checks passed
@Zebradil Zebradil deleted the fix-overlapping-paths-check branch February 9, 2024 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

3 participants