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

Proposal: @ytt:semver #539

Draft
wants to merge 35 commits into
base: develop
Choose a base branch
from

Conversation

mamachanko
Copy link
Contributor

Thanks to the encouragement of @jtigger, I would like to propose that ytt's standard library offers support for semver.

This was initially inspired by carvel-dev/ytt#705

🔗 Carvel's proposal process

todo

  • draft proposal
  • open draft PR
  • iterate with the Carvel team
  • mark the PR as "Ready for Review"
  • iterate with the community
  • eventually, hopefull, reach rough consensus

@mamachanko mamachanko force-pushed the proposal-ytt-semver branch 2 times, most recently from 54b1cdf to ad11f05 Compare September 1, 2022 07:28
Comment on lines 210 to 212
* There's a host of conceivable additional operations available for semver, e.g. test against range, sort list of
versions, bumping, etc. It is debatable if that should be part of the standard library. Testing against a range and
sorting are likelier candidates for a standard library. Bumping is possible with the primitives presented.
Copy link
Contributor

Choose a reason for hiding this comment

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

One solid data point for validating absorbing logic like this is that it already exists. Having examples of these in hand not only provide great use cases, they also can help steer questions of scope like this one.

What custom code have configuration authors already written? (and I'm thinking about other systems as well: Helm chart templating, CUE libs, etc...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

One solid data point for validating absorbing logic like this is that it already exists.

Cool! I read this as "consider extending the proposal with sorting, range tests and modifications". Am I right?

Having examples of these in hand not only provide great use cases, they also can help steer questions of scope like this one.

In other words, you are saying "find data, act on it", aren't you?

Comment on lines 107 to 132
#@ d.update(major=d["major"]+1)
#@ next_major = semver.version(**d)
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting to propose keeping modifications outside of the semver API, itself. It certainly keeps things simpler language-wise. But I also wonder how frequently version modification (will) occur in templated configuration. 🤔

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 held back on modifications, because the spec only defines bumping major, minor and patch versions. What would be the next prerelease? Some tools like semantic release have opinions.

However, it would still be interesting to explore modifications in the API. It would help the discussion too I think, when there's something concrete to talk about. I will amend the proposal.

* Education around and proliferation of the semver scheme is not considered to be `ytt`'s responsibility.

### Specification / Use Cases

Copy link
Contributor

Choose a reason for hiding this comment

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

TODO: fold in any new use case / needs from Package Version Constraints in kapp-controller

@cppforlife
Copy link
Contributor

within vendir and kapp-controller we needed a way to deterministically sort semvers even if they are "equal" according to spec (e.g. version is same but buildmeta is different). we did create a fork of blang/semver, stored in https://github.com/k14s/semver/, to impl deterministic sorting. i would recommend to use this impl within ytt as well to provide similar deterministic behaviour. (even though technically it's against semver 2.0 spec).

@pivotaljohn
Copy link
Contributor

pivotaljohn commented Sep 15, 2022

within vendir and kapp-controller we needed a way to deterministically sort semvers even if they are "equal" according to spec (e.g. version is same but buildmeta is different). we did create a fork of blang/semver, stored in https://github.com/k14s/semver/, to impl deterministic sorting. i would recommend to use this impl within ytt as well to provide similar deterministic behaviour. (even though technically it's against semver 2.0 spec).

@cppforlife Which branch/commit? there are three branches.

@mamachanko mamachanko force-pushed the proposal-ytt-semver branch 2 times, most recently from 67a8aa0 to 7e0911c Compare September 24, 2022 14:35
@mamachanko
Copy link
Contributor Author

@pivotaljohn I iterated on the proposal, consolidated (hopefully representative and not too fantastic) use cases, improved bits and bops and beautify'd.

@cppforlife Your suggestion to use k14s/semver is incorporated.

pivotaljohn and others added 23 commits October 11, 2022 09:40
Co-Authored-by: Varsha Munishwar <vmunishwar@vmware.com>
Co-Authored-by: Varsha Munishwar <vmunishwar@vmware.com>
Following discussions with
[gcheadle-vmware](carvel-dev/ytt#604 (comment))
and @cppforlife, it became clear that @assert/validate ought to always
be consumed in a step after overlays are applied for the current
pipeline.

When writing schema, the author intends not for the schema document
_itself_ to be validated, but to validate the _produced_ document (of
which the schema is a basis for).

Authors need a way to declare the intention for a validation to be
attached to the type composite: @schema/validation.
The former is a predicate (expected to return True or False), the later
is an assertion.
It seems quite likely that we'll need such a facility for more advanced
cases. Placed in the "Other approaches considered" means that the ideas
are found without sufficient merit; not the case here.
(from conversation with @vrabbi; that you Scott!)
Signed-off-by: Joao Pereira <joaod@vmware.com>
- Add Joao as a Lead for `imgpkg`

Signed-off-by: Joao Pereira <joaod@vmware.com>
Signed-off-by: Joao Pereira <joaod@vmware.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet