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

Add support for artifact branches #4190

Merged
merged 12 commits into from
Jan 25, 2024
Merged

Conversation

jsenko
Copy link
Member

@jsenko jsenko commented Jan 9, 2024

Notes and highlights:

  • I've introduced new wrapper types for group, artifact, version and branch identifiers. I believe it makes the code more clear when a more specific type is used in the method parameter list instead of a bunch of String parameters. It also centralizes default group handling and validation. We can start using it gradually.
  • Users can use branch name instead of a specific version in any REST calls where a version must be specified. I named that versionExpression to differentiate between cases where user has to specify plain version directly. This replaces the special keyword latest that we have currently. Users can use the latest branch, that is always available, by specifying .../branch=latest/....
  • As a result of supporting version expressions, I was considering restricting the format of group, artifact, version and branch identifiers, but I'm not 100% sure about this yet. It would require handling during migration process to v3.
  • I've disabled some migration tests, because they import v2 migration files which do not support branches. I've been working on a migration tool that would convert these to v3 migration files, and can run before the tests, but this will happen in a separate PR.
  • I also plan to introduce a use-case for branches in a next PR - automated creation of branches based on semantic versioning.

@jsenko

This comment was marked as resolved.

@jsenko jsenko force-pushed the artifact-branches-3 branch from b06cc65 to e571c63 Compare January 15, 2024 19:38
@EricWittmann
Copy link
Member

Why restrict groupId and artifactId to use [a-zA-Z0-9._-]{1,512} ? I can see why we'd want to do that for Version, but for the other two it doesn't seem necessary and just introduces a new limitation to 3.0 that we didn't have before, with no clear benefit that I'm seeing.

@jsenko
Copy link
Member Author

jsenko commented Jan 16, 2024

Why restrict groupId and artifactId to use [a-zA-Z0-9._-]{1,512} ? I can see why we'd want to do that for Version, but for the other two it doesn't seem necessary and just introduces a new limitation to 3.0 that we didn't have before, with no clear benefit that I'm seeing.

yeah, I wasn't convinced of this myself, just that now would be a good opportunity to do it, in case we do something similar as with version. The length should remain restricted though, based on the database column size.

@EricWittmann
Copy link
Member

Agree on the length restriction, as that always existed but wasn't documented in the openapi. But I don't think restricting the characters for those two fields makes sense unless we can find a reason for it.

@jsenko
Copy link
Member Author

jsenko commented Jan 16, 2024

got it, I'll update it.

@EricWittmann
Copy link
Member

EricWittmann commented Jan 16, 2024

Can you explain in this PR, at a high level, how the branches API is designed to work? Or how a user is expected to use branches in the "manual" use-case? I can see how this would work in the case of automatic branches (latest + semantic versioning).

Looking at the openapi, it looks like I can do the following:

  1. List all the branches for an artifact
  2. List all versions on a branch of an artifact
  3. Delete a branch - deletes all versions in the branch??
  4. Add (existing?) version to branch

Is this right? If yes, what's the flow for manual curation of a branch? I assume:

  1. Create a new artifact with version 1.0
  2. Create a new branch called 1.x
  3. Add existing 1.0 version to branch 1.x
  4. Create a new version 1.1
  5. Add existing 1.1 version to branch 1.x

I suppose I could add the same version to multiple branches as well, right?

There isn't an explicit Create Branch I don't think? Maybe there should be one?

What about automatic branch creation for semantic versioning? Will I be able to delete those branches? Can I change the versions available on them?

Can I remove a version from a branch if I added it by mistake?

@EricWittmann
Copy link
Member

Can I add a version to a branch during version creation? That would be interesting.

@EricWittmann
Copy link
Member

Do you have new tests for the branch API? This is a big PR but I looked and didn't see anything.

@jsenko
Copy link
Member Author

jsenko commented Jan 16, 2024

Do you have new tests for the branch API? This is a big PR but I looked and didn't see anything.

I think only on the storage level. I'll add one on the REST layer.

@jsenko
Copy link
Member Author

jsenko commented Jan 16, 2024

Can I add a version to a branch during version creation? That would be interesting.

Good idea, will try to implement this.

@jsenko jsenko force-pushed the artifact-branches-3 branch from e571c63 to d2ebd57 Compare January 24, 2024 21:07
@jsenko jsenko force-pushed the artifact-branches-3 branch from d2ebd57 to 9f31425 Compare January 24, 2024 21:25
Resolved:
- remove format restrictions on group and artifact ID
- more consistent naming
- support specifying branches on artifact (version) creation
- support branch "rebase"
- add tests
- small bug fixes
@jsenko jsenko force-pushed the artifact-branches-3 branch from 9f31425 to 499213e Compare January 24, 2024 21:39
@jsenko
Copy link
Member Author

jsenko commented Jan 24, 2024

So, I've added the following changes based on the review:

  • Remove format restrictions on group ID and artifact ID
  • REST API level tests
  • More consistent naming
  • Improve UX by adding the following features:
    • Support creating a version and adding it to a branch (or multiple branches) in the same operation
    • Support a dedicated "rebase"-type operation, whereby the user can replace the branch with a different sequence of versions. This allows users to edit full branch history.
  • Some small bug fixes

Can you explain in this PR, at a high level, how the branches API is designed to work?

Branches represent a sequence of versions. Currently, the main use-case is that they can be referenced in endpoints where a version name is expected. Instead of specifying a version directly, users can provide a version expression, e.g. branch=latest or branch=1.1.x, and the version on the tip of that branch is used for the given operation. There is a special branch named latest, which replaces the bespoke code we have used to support referencing the latest version. This branch is protected from updates and deletions, because it is intended for use in other features, replacing the versionOrder column we have at the moment. There are multiple operations for users to manage branches, with the following constraints:

  • Branch cannot reference a non-existing version. When a version is deleted, it is removed from all branches. Vice-versa, if no branch references a version, it is also deleted. Effectively, however, since the latest branch always contains all versions (curretly at least) this does not happen (but is implemented).
  • Branch may reference the same version multiple times.

Or how a user is expected to use branches in the "manual" use-case? I can see how this would work in the case of automatic branches (latest + semantic versioning)

Semantic versioning is the main use-case at the moment. The GroupsResourceTest provides a good showcase for available operations. Most common, I assume, will be the new feature, where users can specify the branch when creating a new version.

I suppose I could add the same version to multiple branches as well, right?

Correct!

There isn't an explicit Create Branch I don't think? Maybe there should be one?

I went with the create or update-style design, where a branch is created automatically as soon the first version is added to it. I think it fits the lightweight nature of branches, since they currently don't have a dedicated table for metadata. This can change in the future of course, e.g. if we need to track branch author, properties etc.

What about automatic branch creation for semantic versioning? Will I be able to delete those branches? Can I change the versions available on them?

yes, the plan is that they will work as any other branch, the only difference is that versions will be added to them automatically, based on content or provided metadata.

Can I remove a version from a branch if I added it by mistake?

yes, using the "rebase" (create or replace) operation.

@jsenko jsenko merged commit e6bde8c into Apicurio:main Jan 25, 2024
19 checks passed
@jsenko jsenko deleted the artifact-branches-3 branch January 25, 2024 15:15
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.

2 participants