From 7711b8f84067ff04fe4dc5dc0213c76bb8e9d14a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan-Luis=20de=20Sousa-Valadas=20Casta=C3=B1o?= Date: Wed, 10 May 2023 16:01:48 +0200 Subject: [PATCH] doc: Fix multigroup migration guide for v4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Varsha Co-authored-by: Camila Macedo <7708031+camilamacedo86@users.noreply.github.com> Signed-off-by: Juan-Luis de Sousa-Valadas CastaƱo --- docs/book/src/migration/multi-group.md | 108 ++++++++++++++----------- 1 file changed, 63 insertions(+), 45 deletions(-) diff --git a/docs/book/src/migration/multi-group.md b/docs/book/src/migration/multi-group.md index fd6a15266c..6fcd1cd4aa 100644 --- a/docs/book/src/migration/multi-group.md +++ b/docs/book/src/migration/multi-group.md @@ -4,32 +4,32 @@

Note

-Multi-group scaffolding support was not present in the initial version of -the Kubebuilder v2 scaffolding (as of Kubebuilder v2.0.0). +While Kubebuilder will not scaffold out a project structure compatible +with multiple API groups in the same repository by default, it's possible +to modify the default project structure to support it. -To change the layout of your project to support Multi-Group run the command -`kubebuilder edit --multigroup=true`. Once you switch to a multi-group layout, the new Kinds -will be generated in the new layout but additional manual work is needed -to move the old API groups to the new layout. +Note that the process mainly is to ensure that your API(s) and controller(s) will be moved under new directories with their respective group name. -While Kubebuilder v2 will not scaffold out a project structure compatible -with multiple API groups in the same repository by default, it's possible -to modify the default project structure to support it. - Let's migrate the [CronJob example][cronjob-tutorial]. +To change the layout of your project to support Multi-Group run the command +`kubebuilder edit --multigroup=true`. Once you switch to a multi-group layout, the new Kinds +will be generated in the new layout but additional manual work is needed +to move the old API groups to the new layout. + Generally, we use the prefix for the API group as the directory name. We can check `api/v1/groupversion_info.go` to find that out: @@ -38,58 +38,75 @@ can check `api/v1/groupversion_info.go` to find that out: package v1 ``` -Then, we'll rename `api` to `apis` to be more clear, and we'll move our -existing APIs into a new subdirectory, "batch": +Then, we'll rename move our existing APIs into a new subdirectory, "batch": ```bash -mkdir apis/batch -mv api/* apis/batch -# After ensuring that all was moved successfully remove the old directory `api/` -rm -rf api/ +mkdir api/batch +mv api/* api/batch ``` - -After moving the APIs to a new directory, the same needs to be applied to the controllers: +After moving the APIs to a new directory, the same needs to be applied to the controllers. For go/v4: ```bash -mkdir controllers/batch -mv controllers/* controllers/batch/ +mkdir internal/controller/batch +mv internal/controller/* internal/controller/batch/ ``` +