Skip to content

Conversation

@NickLarsenNZ
Copy link
Member

@NickLarsenNZ NickLarsenNZ commented Dec 4, 2024

Description

Part of stackabletech/issues#642.

Note

This PR serves as a model for how to convert CRD definitions to stackable-versioned CRDs.
See the explanation of the commits below, and also see the extended commit messages.

  1. 66d9532: (Technically optional) Migrate the crd workspace member crate to be a module of the operator-binary member crate. Run cargo check to make sure everything is fine before continuing.
    • If it is used by other member crates (eg: in this case there is the user-info-fetcher), then export it via a lib.rs in the operator-binary crate.
  2. 3e7291a: Add stackable-versioned as a workspace dependency, and refer to it from relevant crates.
  3. 45ae863: Split impls from the data structures for the CRD (or any types or groups of types that will be versioned). This makes the next step easier...
  4. 4407315: Wrap the CRD data structures in a versioned module. Tweak the top level CRD struct to work with stackable-versioned.
  5. e5ce7e1: Optionally version other data structures. In this case, we independently version the user_info_fetcher types that are used from the main CRD.
  6. b5d1d5f: Fix all of the references to the new versioned types.
    • Ideally we should qualify usages of the structures with the version (eg: v1alpha1::Foo, rather than just Foo to make is clear).
      In some cases this might not be possible, for example if you needed both crd::v1alpha1 and crd::user_info_fetcher::v1alpha1 imported - they would conflict. In that case, import crd::v1alpha1 for the crd, and crd::user_info_fetcher (without the version module) for the other. The code would then use types qualified like: v1alpha1::Foo and user_info_fetcher::v1alpha1::Bar.
  7. 9f5180c: Update refs in doc-comments.
    You can search for ///.*\[

Tip

A separate PR will show how to make changes to versioned types.

@NickLarsenNZ NickLarsenNZ force-pushed the chore/add-crd-versioning branch from f9bea09 to e9d201c Compare December 5, 2024 09:59
@NickLarsenNZ NickLarsenNZ requested a review from Techassi December 5, 2024 12:30
@NickLarsenNZ NickLarsenNZ marked this pull request as ready for review December 5, 2024 12:30
@NickLarsenNZ NickLarsenNZ force-pushed the chore/add-crd-versioning branch 2 times, most recently from 6e061f2 to e319f4b Compare December 5, 2024 16:06
@NickLarsenNZ NickLarsenNZ changed the title chore: version the crd chore: Version CRD Feb 5, 2025
NickLarsenNZ and others added 7 commits February 5, 2025 12:26
This makes way for the versioned module we will soon introduce
At this point, errors will appear in any crates using the crd.
It has only been done separately to illustrate the ease in versioning a CRD without all of the other necessary changes.
This is helpful for later crd version sharing substructures that might not change.
For example: v1alpha2::OpaCluster might still use user_info_fetcher::v1alpha1::Config,
or perhaps it uses user_info_fetcher::v1beta1::Config.

Similarly, shared structures from stackable-operators can then be
versioned in the same way.
The versioned module is imported rather than the individual structs and enums (when there is no conflict, eg: if also importing a versioned shared struct) so that that usages show the version explicitly.

There might be times where this isn't possible, for example, once structs and enums are versioned in stackable-operator, there could be multiple modules with the same name.

In this case, user-info-fetcher is also versioned with v1alpha1, so it is referred to as user_info_fetcher::v1alpha1 in crd/mod.rs so as to not conflict with the crds v1alpha1.
Co-authored-by: Techassi <git@techassi.dev>
@NickLarsenNZ NickLarsenNZ force-pushed the chore/add-crd-versioning branch from e319f4b to d72ad6f Compare February 5, 2025 12:13
@NickLarsenNZ NickLarsenNZ self-assigned this Feb 5, 2025
@NickLarsenNZ NickLarsenNZ added this pull request to the merge queue Feb 5, 2025
Merged via the queue into main with commit 25f4e2b Feb 5, 2025
17 checks passed
@NickLarsenNZ NickLarsenNZ deleted the chore/add-crd-versioning branch February 5, 2025 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants