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

Allow directory names with hyphens in _dev directories #270

Merged
merged 5 commits into from
Feb 9, 2022

Conversation

jsoriano
Copy link
Member

@jsoriano jsoriano commented Feb 8, 2022

Add new flag developmentFolder to indicate if a directory contains development files. Inside these directories it is allowed to have files with hyphens.

Follow up to #259.

Solves issue mentioned in #259 (comment):

[2022-02-08T13:53:46.969Z] Error: checking package failed: linting package failed: found 1 validation error:
[2022-02-08T13:53:46.969Z]    1. file "/var/lib/jenkins/workspace/est-manager_integrations_PR-2651/src/github.com/elastic/integrations/packages/postgresql/_dev/deploy/docker/docker-entrypoint-initdb.d" is invalid: directory name inside package postgresql contains -: docker-entrypoint-initdb.d

@jsoriano jsoriano requested a review from a team February 8, 2022 20:52
@jsoriano jsoriano self-assigned this Feb 8, 2022
@elasticmachine
Copy link

elasticmachine commented Feb 8, 2022

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2022-02-09T16:20:54.957+0000

  • Duration: 5 min 7 sec

🤖 GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

@jsoriano jsoriano force-pushed the ignore-validation-dev-directories branch from 07eaa21 to b1b7c6e Compare February 8, 2022 21:04
@@ -85,7 +85,7 @@ func (s *folderSpec) validate(packageName string, folderPath string) ve.Validati
if itemSpec == nil && s.AdditionalContents {
// No spec found for current folder item but we do allow additional contents in folder.
if file.IsDir() {
if strings.Contains(fileName, "-") {
if !s.DevelopmentFolder && strings.Contains(fileName, "-") {
Copy link
Contributor

Choose a reason for hiding this comment

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

A short challenge:

Do you agree that it is unusual to forbid - in dirnames? If so, maybe we should forbid it only for specific Kibana/Elasticsearch items. For example, I don't think that - should be forbidden for subdirectories in docs or images, or any other extra content, the developer would like to put there.

Long story short - instead of introducing DevelopmentFolder flag, I would consider a StackInstalledFlag, which forbids dashes.

Let me know what you think.

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you agree that it is unusual to forbid - in dirnames?

Yeah, I fully agree :)

But if we forbid them I think it'd be less confusing to forbid them everywhere (as proposed in elastic/package-registry#517) instead of on specific directories.
The exception in development directories (or at least in deploy directories) can make sense because there can be files there that have hyphens by convention in other systems (as the hyphens to separate words in some files in docker images).

Btw, if we allow hyphens everywhere except for directories containing stack files, we have to reconsider the removal of the check in the package registry that originated #259.

Copy link
Contributor

Choose a reason for hiding this comment

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

But if we forbid them I think it'd be less confusing to forbid them everywhere (as proposed in elastic/package-registry#517) instead of on specific directories.

I admit I follow the intuition here and it would be confusing no matter which option we follow. I'm rather thinking about what's better for future use cases. I can imagine extra directories with docs, resources, extra scripts for testing.

Btw, if we allow hyphens everywhere except for directories containing stack files, we have to reconsider the removal of the check in the package registry that originated #259.

Yeah, I'm thinking about this. Maybe this is the right timing to adjust it to match only relevant directories.

Anyway, back to this PR. We have only development resources, which are affected by this, so I would say it's fine to push this one and come back to the discussion when somebody else tries to a folder with a hyphen.

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe this is the right timing to adjust it to match only relevant directories.

I would remove instead of adding validation logic from the registry 🙂

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, we have spec now, so maybe we can make the Package Registry a bit more stupid :)

@@ -1,5 +1,6 @@
spec:
additionalContents: false
developmentFolder: true
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: _dev is also in data_stream. You may add a test case that verifies that one too.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch, for some reason I thought they shared the same spec. Fixed.

@mtojek mtojek self-requested a review February 9, 2022 16:29
@jsoriano jsoriano merged commit 8b005d3 into elastic:main Feb 9, 2022
@jsoriano jsoriano deleted the ignore-validation-dev-directories branch February 9, 2022 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants