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

Release input package spec as GA #485

Merged
merged 14 commits into from
Mar 22, 2023
Merged

Release input package spec as GA #485

merged 14 commits into from
Mar 22, 2023

Conversation

hop-dev
Copy link
Contributor

@hop-dev hop-dev commented Mar 1, 2023

What does this PR do?

Removes release: beta from the input package spec.

Adds validation to check that a GA input package enforces kibana version must be ^8.8.0.

Changes the test input packages to test this new behaviour.

Why is it important?

This allows input packages to have release versions >= 1.0.0. For example the custom logs integration

Checklist

Related issues

Closes #480

@hop-dev hop-dev self-assigned this Mar 1, 2023
@elasticmachine
Copy link

elasticmachine commented Mar 1, 2023

💚 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: 2023-03-21T15:57:04.164+0000

  • Duration: 7 min 12 sec

Test stats 🧪

Test Results
Failed 0
Passed 748
Skipped 0
Total 748

🤖 GitHub comments

Expand to view the GitHub comments

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

  • /test : Re-trigger the build.


func getKibanaVersionCondition(manifest pkgpath.File) (string, error) {

val, err := manifest.Values("$.conditions[\"kibana.version\"]")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

do we need to handle:

conditions:
    kibana.version: 1234

and

conditions:
    kibana:
        version: 1234

here? It seems the lib treats them differently, all packages use kibana.version

Copy link
Member

Choose a reason for hiding this comment

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

This actually looks like an issue with this Values helper. The spec allows both kibana.version, or version as an attribute inside kibana.

It should probably use ucfg to parse these files instead of plain yaml. See https://github.com/elastic/go-ucfg#dot-notations

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll have a go at this 👌

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@hop-dev hop-dev Mar 6, 2023

Choose a reason for hiding this comment

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

I have put a temporary workaround in this PR (9840df4)and have a draft PR for using ucfg https://github.com/elastic/package-spec/pull/487/files

@elasticmachine
Copy link

elasticmachine commented Mar 1, 2023

🌐 Coverage report

Name Metrics % (covered/total) Diff
Packages 100.0% (8/8) 💚
Files 70.37% (19/27) 👍 1.14
Classes 77.778% (28/36) 👍 0.635
Methods 55.172% (64/116) 👎 -1.584
Lines 42.437% (592/1395) 👎 -0.29
Conditionals 100.0% (0/0) 💚

@hop-dev hop-dev marked this pull request as ready for review March 1, 2023 11:18
@hop-dev hop-dev requested a review from a team as a code owner March 1, 2023 11:18
Comment on lines 21 to 34
manifest, err := readManifest(fsys)
if err != nil {
return ve.ValidationErrors{err}
}

packageType, err := getPackageType(*manifest)
if err != nil {
return ve.ValidationErrors{err}
}

packageVersion, err := getPackageVersion(*manifest)
if err != nil {
return ve.ValidationErrors{err}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably, these fields can be retrieved from the Package struct that it is returned in NewPackageFromFS function https://github.com/elastic/package-spec/blob/main/code/go/internal/validator/package.go#L55

But Kibana version condition is not available from there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah I missed this util, thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cyclic dependency prevents me from doing this unfortunately

Copy link
Contributor

Choose a reason for hiding this comment

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

An option to break this cyclic dependency could be move all the code/go/internal/validator/package*.go files to its own package. For instance it could be created a new package like code/go/internal/packages/ and update all the references.


func getKibanaVersionCondition(manifest pkgpath.File) (string, error) {

val, err := manifest.Values("$.conditions[\"kibana.version\"]")
Copy link
Contributor

Choose a reason for hiding this comment

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

@hop-dev hop-dev requested a review from mrodm March 6, 2023 15:50
Comment on lines 21 to 34
manifest, err := readManifest(fsys)
if err != nil {
return ve.ValidationErrors{err}
}

packageType, err := getPackageType(*manifest)
if err != nil {
return ve.ValidationErrors{err}
}

packageVersion, err := getPackageVersion(*manifest)
if err != nil {
return ve.ValidationErrors{err}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

An option to break this cyclic dependency could be move all the code/go/internal/validator/package*.go files to its own package. For instance it could be created a new package like code/go/internal/packages/ and update all the references.

spec/changelog.yml Outdated Show resolved Hide resolved
Comment on lines 107 to 108
sVersion, err := semver.NewVersion(sVal)
return sVersion, nil
Copy link
Contributor

Choose a reason for hiding this comment

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

you can return directly the value from semver.NewVersion function

Suggested change
sVersion, err := semver.NewVersion(sVal)
return sVersion, nil
return semver.NewVersion(sVal)

.gitignore Outdated Show resolved Hide resolved
@hop-dev
Copy link
Contributor Author

hop-dev commented Mar 21, 2023

@mrodm I have resolved the cyclic dependency issue, my validator now uses NewPackageFromFS, just resolving the merge conflict now

Copy link
Contributor

@mrodm mrodm left a comment

Choose a reason for hiding this comment

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

LGTM

@mrodm mrodm merged commit 2bec363 into main Mar 22, 2023
@mrodm mrodm deleted the make-input-pkg-spec-ga branch March 22, 2023 08:10
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.

Release input packages spec as GA
4 participants