diff --git a/.claude/commands/commit-with-message.md b/.claude/commands/commit-with-message.md new file mode 100644 index 00000000..5c2ca7b1 --- /dev/null +++ b/.claude/commands/commit-with-message.md @@ -0,0 +1,25 @@ +--- +name: commit-with-message +description: Create a commit with a message based on the staged changes + +--- + +1. Pre-check + +Abort if there is no staged changes +Abort if there are openspec changes that have not been archived (ie, there are sibling folders to `openspec/changes/archive`) + +2. Prepare a commit message for the staged changes + +- Suggest a commit message based on the **staged only** changes +- Do not mention the changes in the `/openspec` folder +- Surround folder names, file names, variable names, function and method names by backticks (`) +- Use the Conventional Commits from https://www.conventionalcommits.org/en/v1.0.0/ +- Include the "Assisted-by:" trail with the name of the current model + +Show the suggested message and prompt the user to confirm that we shall proceed with committing the staged changes +Abort if the user is not happy with the message + +3. Commit + +run the `git commit -s` command with the message prepared above \ No newline at end of file diff --git a/.govulncheck.yaml b/.govulncheck.yaml index 6b3a6b08..f1c3aaed 100644 --- a/.govulncheck.yaml +++ b/.govulncheck.yaml @@ -1,2 +1,19 @@ -ignored-vulnerabilities: [] - \ No newline at end of file +ignored-vulnerabilities: + # Incorrect parsing of IPv6 host literals in net/url + # Found in: net/url@go1.24.13 + # Fixed in: net/url@go1.25.8 + - id: GO-2026-4601 + silence-until: 2026-09-03 + info: https://pkg.go.dev/vuln/GO-2026-4601 + # Inefficient candidate hostname parsing in crypto/x509 + # Found in: crypto/x509@go1.24.13 + # Fixed in: crypto/x509@go1.25.11 + - id: GO-2026-5037 + silence-until: 2026-09-03 + info: https://pkg.go.dev/vuln/GO-2026-5037 + # FileInfo can escape from a Root in os + # Found in: os@go1.24.13 + # Fixed in: os@go1.25.8 + - id: GO-2026-4602 + info: https://pkg.go.dev/vuln/GO-2026-4602 + silence-until: 2026-09-03 diff --git a/README.adoc b/README.adoc deleted file mode 100644 index 8345663c..00000000 --- a/README.adoc +++ /dev/null @@ -1,24 +0,0 @@ -= ToolChain API - -image:https://goreportcard.com/badge/github.com/codeready-toolchain/api[Go Report Card, link="https://goreportcard.com/report/github.com/codeready-toolchain/api"] -image:https://godoc.org/github.com/codeready-toolchain/api?status.png[GoDoc,link="https://godoc.org/github.com/codeready-toolchain/api"] - -For the API reference docs go xref:api/v1alpha1/docs/apiref.adoc[here] - -== Building -Requires: - -* Go version 1.24.x (1.24.13 or higher) - download for your development environment https://golang.org/dl/[here]. - -CodeReady ToolChain API is built using https://github.com/golang/go/wiki/Modules[Go modules]. - -To re-generate the `zz_generated.deepcopy.go` and `zz_generated.openapi.go` files as well as the CRD files, run the following command: - -```sh -make generate -``` - -NOTE: the `make generate` will generate the CRD files in the local `config/crd/bases` directory and then dispatch the `.yaml` files in the `host-operator` and `member-operator` repositories, assuming they have been checked out and that *they are in a clean state*, meaning that they have no pending changes, besides previous versions of the CRD files. - -NOTE: Then you are supposed to create PRs also in the repos where the change was propagated ( host | member-operator ). Please do not mix other changes to the code with those CRD changes. While it would work technically , it’s always preferred to promote the CRD changes separately for easier PR review. - diff --git a/README.md b/README.md new file mode 100644 index 00000000..21d1861e --- /dev/null +++ b/README.md @@ -0,0 +1,31 @@ +# ToolChain API + +[![Go Report Card](https://goreportcard.com/badge/github.com/codeready-toolchain/api)](https://goreportcard.com/report/github.com/codeready-toolchain/api) +[![GoDoc](https://godoc.org/github.com/codeready-toolchain/api?status.png)](https://godoc.org/github.com/codeready-toolchain/api) + +For the API reference docs go [here](api/v1alpha1/docs/apiref.adoc) + +## Prerequisites + +* Go version 1.24.x (1.24.4 or higher) - download for your development environment [here](https://golang.org/dl/). + +CodeReady ToolChain API is built using [Go modules](https://github.com/golang/go/wiki/Modules). + +## Modifying the API Types + +The API types are defined in the `api/v1alpha1/*_types.go` files. After modifying these files, you must regenerate the derived files (deepcopy, OpenAPI, CRD manifests, and API reference docs) by running: + +```sh +make generate +``` + +This command runs the following steps: + +1. **Generate deepcopy and CRDs** — uses [controller-gen](https://github.com/kubernetes-sigs/controller-tools) to regenerate `zz_generated.deepcopy.go` and the CRD manifests in `config/crd/bases/`. +2. **Generate OpenAPI** — uses [openapi-gen](https://github.com/kubernetes/kube-openapi) to regenerate `zz_generated.openapi.go`. +3. **Generate API reference docs** — uses [crd-ref-docs](https://github.com/elastic/crd-ref-docs) to regenerate `api/v1alpha1/docs/apiref.adoc`. +4. **Dispatch CRDs** — copies the generated CRD `.yaml` files to the `host-operator` and `member-operator` repositories. + +> **Note:** The CRD dispatch step assumes the `host-operator` and `member-operator` repositories have been checked out alongside this repository and that *they are in a clean state*, meaning that they have no pending changes besides previous versions of the CRD files. + +> **Note:** After running `make generate`, you are expected to create PRs in this repository as well as in the `host-operator` and `member-operator` repositories where the CRD changes were propagated. Please do not mix other code changes with CRD changes — it is always preferred to promote CRD changes separately for easier PR review. diff --git a/api/v1alpha1/banneduser_types.go b/api/v1alpha1/banneduser_types.go index a73a5ed9..856ec998 100644 --- a/api/v1alpha1/banneduser_types.go +++ b/api/v1alpha1/banneduser_types.go @@ -20,7 +20,7 @@ const ( // BannedUserSpec defines the desired state of BannedUser // +k8s:openapi-gen=true type BannedUserSpec struct { - // Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file + // Important: Run "make generate" to regenerate code after modifying this file // Add custom validation using kubebuilder tags: https://book.kubebuilder.io/beyond_basics/generating_crd.html // The e-mail address of the account that has been banned diff --git a/api/v1alpha1/idler_types.go b/api/v1alpha1/idler_types.go index 98e17562..4ddb08f1 100644 --- a/api/v1alpha1/idler_types.go +++ b/api/v1alpha1/idler_types.go @@ -23,7 +23,7 @@ const ( // IdlerSpec defines the desired state of Idler // +k8s:openapi-gen=true type IdlerSpec struct { - // Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file + // Important: Run "make generate" to regenerate code after modifying this file // Add custom validation using kubebuilder tags: https://book.kubebuilder.io/beyond_basics/generating_crd.html // TimeoutSeconds is the number of seconds before the running pods will be deleted @@ -33,7 +33,7 @@ type IdlerSpec struct { // IdlerStatus defines the observed state of Idler // +k8s:openapi-gen=true type IdlerStatus struct { - // Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file + // Important: Run "make generate" to regenerate code after modifying this file // Add custom validation using kubebuilder tags: https://book.kubebuilder.io/beyond_basics/generating_crd.html // Conditions is an array of current Idler conditions diff --git a/api/v1alpha1/masteruserrecord_types.go b/api/v1alpha1/masteruserrecord_types.go index de639e4a..ce89289a 100644 --- a/api/v1alpha1/masteruserrecord_types.go +++ b/api/v1alpha1/masteruserrecord_types.go @@ -48,7 +48,7 @@ const ( // MasterUserRecordSpec defines the desired state of MasterUserRecord // +k8s:openapi-gen=true type MasterUserRecordSpec struct { - // Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file + // Important: Run "make generate" to regenerate code after modifying this file // Add custom validation using kubebuilder tags: https://book.kubebuilder.io/beyond_basics/generating_crd.html // If set to true then the corresponding user should not be able to login (but the underlying UserAccounts still exists) @@ -83,7 +83,7 @@ type UserAccountEmbedded struct { // MasterUserRecordStatus defines the observed state of MasterUserRecord // +k8s:openapi-gen=true type MasterUserRecordStatus struct { - // Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file + // Important: Run "make generate" to regenerate code after modifying this file // Add custom validation using kubebuilder tags: https://book.kubebuilder.io/beyond_basics/generating_crd.html // Conditions is an array of current Master User Record conditions diff --git a/api/v1alpha1/memberstatus_types.go b/api/v1alpha1/memberstatus_types.go index af7bc2ac..1097cfa7 100644 --- a/api/v1alpha1/memberstatus_types.go +++ b/api/v1alpha1/memberstatus_types.go @@ -9,7 +9,7 @@ import ( // MemberStatusSpec defines the desired state of MemberStatus // +k8s:openapi-gen=true type MemberStatusSpec struct { - // Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file + // Important: Run "make generate" to regenerate code after modifying this file // Add custom validation using kubebuilder tags: https://book.kubebuilder.io/beyond_basics/generating_crd.html // spec is intentionally empty since only the status fields will be used for reporting status of the toolchain @@ -18,7 +18,7 @@ type MemberStatusSpec struct { // MemberStatusStatus defines the observed state of the toolchain member status // +k8s:openapi-gen=true type MemberStatusStatus struct { - // Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file + // Important: Run "make generate" to regenerate code after modifying this file // Add custom validation using kubebuilder tags: https://book.kubebuilder.io/beyond_basics/generating_crd.html // MemberOperator is the status of a toolchain member operator @@ -78,7 +78,7 @@ type ResourceUsage struct { // HostStatus defines the status of the connection with the host cluster type HostStatus struct { - // Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file + // Important: Run "make generate" to regenerate code after modifying this file // Add custom validation using kubebuilder tags: https://book.kubebuilder.io/beyond_basics/generating_crd.html // Conditions is an array of current member operator status conditions @@ -93,7 +93,7 @@ type HostStatus struct { // MemberOperatorStatus defines the observed state of a toolchain's member operator type MemberOperatorStatus struct { - // Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file + // Important: Run "make generate" to regenerate code after modifying this file // Add custom validation using kubebuilder tags: https://book.kubebuilder.io/beyond_basics/generating_crd.html // The version of the operator diff --git a/api/v1alpha1/notification_types.go b/api/v1alpha1/notification_types.go index d36b2d74..c85d7608 100644 --- a/api/v1alpha1/notification_types.go +++ b/api/v1alpha1/notification_types.go @@ -37,7 +37,7 @@ const ( // NotificationSpec defines the desired state of Notification // +k8s:openapi-gen=true type NotificationSpec struct { - // Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file + // Important: Run "make generate" to regenerate code after modifying this file // Add custom validation using kubebuilder tags: https://book.kubebuilder.io/beyond_basics/generating_crd.html // UserID is the user ID from RHD Identity Provider token (“sub” claim). The UserID is used by @@ -72,7 +72,7 @@ type NotificationSpec struct { // NotificationStatus defines the observed state of Notification // +k8s:openapi-gen=true type NotificationStatus struct { - // Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file + // Important: Run "make generate" to regenerate code after modifying this file // Add custom validation using kubebuilder tags: https://book.kubebuilder.io/beyond_basics/generating_crd.html // Conditions is an array of current Notification conditions diff --git a/api/v1alpha1/nstemplateset_types.go b/api/v1alpha1/nstemplateset_types.go index b5d376ac..e32e5cf7 100644 --- a/api/v1alpha1/nstemplateset_types.go +++ b/api/v1alpha1/nstemplateset_types.go @@ -35,7 +35,7 @@ const ( // NSTemplateSetSpec defines the desired state of NSTemplateSet // +k8s:openapi-gen=true type NSTemplateSetSpec struct { - // Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file + // Important: Run "make generate" to regenerate code after modifying this file // Add custom validation using kubebuilder tags: https://book.kubebuilder.io/beyond_basics/generating_crd.html // The name of the tier represented by this template set diff --git a/api/v1alpha1/nstemplatetier_types.go b/api/v1alpha1/nstemplatetier_types.go index 5822d8b4..eb9738e0 100644 --- a/api/v1alpha1/nstemplatetier_types.go +++ b/api/v1alpha1/nstemplatetier_types.go @@ -16,7 +16,7 @@ const ( // NSTemplateTierSpec defines the desired state of NSTemplateTier // +k8s:openapi-gen=true type NSTemplateTierSpec struct { - // Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file + // Important: Run "make generate" to regenerate code after modifying this file // Add custom validation using kubebuilder tags: https://book.kubebuilder.io/beyond_basics/generating_crd.html // The namespace templates @@ -86,7 +86,7 @@ type NSTemplateTierSpaceRole struct { // NSTemplateTierStatus defines the observed state of NSTemplateTier // +k8s:openapi-gen=true type NSTemplateTierStatus struct { - // Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file + // Important: Run "make generate" to regenerate code after modifying this file // Add custom validation using kubebuilder tags: https://book.kubebuilder.io/beyond_basics/generating_crd.html // Conditions is an array of current NSTemplateTier conditions diff --git a/api/v1alpha1/proxyplugin_types.go b/api/v1alpha1/proxyplugin_types.go index 7152492f..0292b45b 100644 --- a/api/v1alpha1/proxyplugin_types.go +++ b/api/v1alpha1/proxyplugin_types.go @@ -11,7 +11,7 @@ type OpenShiftRouteTarget struct { // ProxyPluginSpec defines the desired state of ProxyPlugin // +k8s:openapi-gen=true type ProxyPluginSpec struct { - // Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file + // Important: Run "make generate" to regenerate code after modifying this file // Add custom validation using kubebuilder tags: https://book.kubebuilder.io/beyond_basics/generating_crd.html // OpenShiftRouteTargetEndpoint is an optional field that represents the look up information for an OpenShift Route @@ -25,7 +25,7 @@ type ProxyPluginSpec struct { // ProxyPluginStatus defines the observed state of ProxyPlugin // +k8s:openapi-gen=true type ProxyPluginStatus struct { - // Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file + // Important: Run "make generate" to regenerate code after modifying this file // Add custom validation using kubebuilder tags: https://book.kubebuilder.io/beyond_basics/generating_crd.html // Conditions is an array of current Proxy Plugin conditions diff --git a/api/v1alpha1/socialevent_types.go b/api/v1alpha1/socialevent_types.go index 846b9479..4cb00d1b 100644 --- a/api/v1alpha1/socialevent_types.go +++ b/api/v1alpha1/socialevent_types.go @@ -22,7 +22,7 @@ const ( // // +k8s:openapi-gen=true type SocialEventSpec struct { - // Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file + // Important: Run "make generate" to regenerate code after modifying this file // Add custom validation using kubebuilder tags: https://book.kubebuilder.io/beyond_basics/generating_crd.html // The timestamp from which users may register via this event's activation code @@ -59,7 +59,7 @@ type SocialEventSpec struct { // SocialEventStatus defines the observed state of SocialEvent // +k8s:openapi-gen=true type SocialEventStatus struct { - // Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file + // Important: Run "make generate" to regenerate code after modifying this file // Add custom validation using kubebuilder tags: https://book.kubebuilder.io/beyond_basics/generating_crd.html // Conditions is an array of current SocialEventStatus conditions diff --git a/api/v1alpha1/toolchainstatus_types.go b/api/v1alpha1/toolchainstatus_types.go index bded95d7..035bd86a 100644 --- a/api/v1alpha1/toolchainstatus_types.go +++ b/api/v1alpha1/toolchainstatus_types.go @@ -56,7 +56,7 @@ const ( // ToolchainStatusSpec defines the desired state of ToolchainStatus // +k8s:openapi-gen=true type ToolchainStatusSpec struct { - // Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file + // Important: Run "make generate" to regenerate code after modifying this file // Add custom validation using kubebuilder tags: https://book.kubebuilder.io/beyond_basics/generating_crd.html // spec is intentionally empty since only the status fields will be used for reporting status of the toolchain @@ -65,7 +65,7 @@ type ToolchainStatusSpec struct { // ToolchainStatusStatus defines the observed state of the toolchain, including host cluster and member cluster components // +k8s:openapi-gen=true type ToolchainStatusStatus struct { - // Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file + // Important: Run "make generate" to regenerate code after modifying this file // Add custom validation using kubebuilder tags: https://book.kubebuilder.io/beyond_basics/generating_crd.html // HostOperator is the status of a toolchain host operator @@ -119,7 +119,7 @@ type HostRoutes struct { // +k8s:openapi-gen=true // DEPRECATED: using metrics instead of this status type HostOperatorStatus struct { - // Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file + // Important: Run "make generate" to regenerate code after modifying this file // Add custom validation using kubebuilder tags: https://book.kubebuilder.io/beyond_basics/generating_crd.html // The version of the operator @@ -147,7 +147,7 @@ type HostOperatorStatus struct { // HostRegistrationServiceStatus defines the observed state of a toolchain's registration service // +k8s:openapi-gen=true type HostRegistrationServiceStatus struct { - // Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file + // Important: Run "make generate" to regenerate code after modifying this file // Add custom validation using kubebuilder tags: https://book.kubebuilder.io/beyond_basics/generating_crd.html // Deployment is the status of the registration service's deployment diff --git a/api/v1alpha1/useraccount_types.go b/api/v1alpha1/useraccount_types.go index 497f45df..6234f0bf 100644 --- a/api/v1alpha1/useraccount_types.go +++ b/api/v1alpha1/useraccount_types.go @@ -38,7 +38,7 @@ const ( // UserAccountSpec defines the desired state of UserAccount // +k8s:openapi-gen=true type UserAccountSpec struct { - // Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file + // Important: Run "make generate" to regenerate code after modifying this file // Add custom validation using kubebuilder tags: https://book.kubebuilder.io/beyond_basics/generating_crd.html // If set to true then the corresponding user should not be able to login @@ -55,7 +55,7 @@ type UserAccountSpec struct { // UserAccountStatus defines the observed state of UserAccount // +k8s:openapi-gen=true type UserAccountStatus struct { - // Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file + // Important: Run "make generate" to regenerate code after modifying this file // Add custom validation using kubebuilder tags: https://book.kubebuilder.io/beyond_basics/generating_crd.html // Conditions is an array of current User Account conditions diff --git a/api/v1alpha1/usersignup_types.go b/api/v1alpha1/usersignup_types.go index 91f063dc..465fa0d8 100644 --- a/api/v1alpha1/usersignup_types.go +++ b/api/v1alpha1/usersignup_types.go @@ -212,7 +212,7 @@ type UserSignupState string // UserSignupSpec defines the desired state of UserSignup // +k8s:openapi-gen=true type UserSignupSpec struct { - // Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file + // Important: Run "make generate" to regenerate code after modifying this file // Add custom validation using kubebuilder tags: https://book.kubebuilder.io/beyond_basics/generating_crd.html // The cluster in which the user is provisioned in @@ -281,7 +281,7 @@ type PropagatedClaims struct { // UserSignupStatus defines the observed state of UserSignup // +k8s:openapi-gen=true type UserSignupStatus struct { - // Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file + // Important: Run "make generate" to regenerate code after modifying this file // Add custom validation using kubebuilder tags: https://book.kubebuilder.io/beyond_basics/generating_crd.html // Conditions is an array of current UserSignup conditions diff --git a/api/v1alpha1/usertier_types.go b/api/v1alpha1/usertier_types.go index 29a9740d..896d5a17 100644 --- a/api/v1alpha1/usertier_types.go +++ b/api/v1alpha1/usertier_types.go @@ -21,7 +21,7 @@ type UserTier struct { // UserTierSpec defines the desired state of UserTier // +k8s:openapi-gen=true type UserTierSpec struct { - // Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file + // Important: Run "make generate" to regenerate code after modifying this file // Add custom validation using kubebuilder tags: https://book.kubebuilder.io/beyond_basics/generating_crd.html // the period (in days) after which users within the tier will be deactivated diff --git a/cmd/manager/main.go b/cmd/manager/main.go deleted file mode 100644 index 75bea1ab..00000000 --- a/cmd/manager/main.go +++ /dev/null @@ -1,5 +0,0 @@ -package main - -func main() { - // A dummy main function to make `operator-sdk generate csv` happy. -} diff --git a/go.mod b/go.mod index 25892b66..85a94569 100644 --- a/go.mod +++ b/go.mod @@ -5,13 +5,11 @@ go 1.24.4 toolchain go1.24.13 require ( - github.com/go-bindata/go-bindata v3.1.2+incompatible // using latest commit from 'github.com/openshift/api branch release-4.20' github.com/openshift/api v0.0.0-20251202204302-1cb53e34ca33 k8s.io/api v0.33.4 k8s.io/apimachinery v0.33.4 - k8s.io/code-generator v0.33.4 - k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01 + k8s.io/code-generator v0.33.4 // indirect k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff sigs.k8s.io/controller-runtime v0.21.0 sigs.k8s.io/controller-tools v0.18.0 diff --git a/go.sum b/go.sum index 96c34986..47573d27 100644 --- a/go.sum +++ b/go.sum @@ -12,9 +12,6 @@ github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nos github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E= github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ= -github.com/go-bindata/go-bindata v3.1.2+incompatible h1:5vjJMVhowQdPzjE1LdxyFF7YFTXg5IgGVW4gBr5IbvE= -github.com/go-bindata/go-bindata v3.1.2+incompatible/go.mod h1:xK8Dsgwmeed+BBsSy2XTopBn/8uK2HWuGSnA11C3Joo= -github.com/go-logr/logr v0.2.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU= github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= @@ -33,12 +30,10 @@ github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/google/gnostic-models v0.6.9 h1:MU/8wDLif2qCXZmzncUQ/BOfxWfthHi63KqpoNbWqVw= github.com/google/gnostic-models v0.6.9/go.mod h1:CiWsm0s6BSQd1hRn8/QmxqB6BesYcbSZxsz9b0KuDBw= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db h1:097atOisP2aRj7vFgYQBbFN4U4JNXUNYpxael3UzMyo= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= @@ -49,7 +44,6 @@ github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnr github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= @@ -86,7 +80,6 @@ github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWN github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo= github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0= -github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o= github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -133,7 +126,6 @@ golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0= golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200505023115-26f46d2f7ef8/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.32.0 h1:Q7N1vhpkQv7ybVzLFtTjvQya2ewbwNDZzUgfXGqtMWU= @@ -145,14 +137,12 @@ golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8T google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM= google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= @@ -166,11 +156,8 @@ k8s.io/apimachinery v0.33.4 h1:SOf/JW33TP0eppJMkIgQ+L6atlDiP/090oaX0y9pd9s= k8s.io/apimachinery v0.33.4/go.mod h1:BHW0YOu7n22fFv/JkYOEfkUYNRN0fj0BlvMFWA7b+SM= k8s.io/code-generator v0.33.4 h1:DiA801QxqApRIBh3OWULasVAUA237XnYvFNMh+E34Y8= k8s.io/code-generator v0.33.4/go.mod h1:ifWxKWhEl/Z1K7WmWAyOBEf3ex/i546ingCzLC8YVIY= -k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01 h1:pWEwq4Asjm4vjW7vcsmijwBhOr1/shsbSYiWXmNGlks= -k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= k8s.io/gengo/v2 v2.0.0-20250207200755-1244d31929d7 h1:2OX19X59HxDprNCVrWi6jb7LW1PoqTlYqEq5H2oetog= k8s.io/gengo/v2 v2.0.0-20250207200755-1244d31929d7/go.mod h1:EJykeLsmFC60UQbYJezXkEsG2FLrt0GPNkU5iK5GWxU= -k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff h1:/usPimJzUKKu+m+TE36gUyGcf03XZEP0ZIKgKj35LS4= @@ -188,6 +175,5 @@ sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= sigs.k8s.io/structured-merge-diff/v4 v4.6.0 h1:IUA9nvMmnKWcj5jl84xn+T5MnlZKThmUW1TdblaLVAc= sigs.k8s.io/structured-merge-diff/v4 v4.6.0/go.mod h1:dDy58f92j70zLsuZVuUX5Wp9vtxXpaZnkPGWeqDfCps= -sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/make/clean.mk b/make/clean.mk index 06969515..24d4c5df 100644 --- a/make/clean.mk +++ b/make/clean.mk @@ -5,7 +5,7 @@ clean: remove-bin remove-config .PHONY: remove-bin remove-bin: - $(Q)rm -rf ./bin + $(Q)rm -rf $(LOCALBIN) .PHONY: remove-config remove-config: diff --git a/make/generate.mk b/make/generate.mk index 0c1b53ae..598a0c3a 100644 --- a/make/generate.mk +++ b/make/generate.mk @@ -3,31 +3,50 @@ API_GROUPNAME=toolchain API_FULL_GROUPNAME=toolchain.dev.openshift.com API_VERSION:=v1alpha1 -# how to dispatch the CRD files per repository (space-separated lists) -HOST_CLUSTER_CRDS:=masteruserrecords nstemplatetiers usersignups bannedusers notifications spaces spacebindings socialevents tiertemplates tiertemplaterevisions toolchainstatuses toolchainclusters toolchainconfigs usertiers proxyplugins spacerequests spacebindingrequests spaceprovisionerconfigs -MEMBER_CLUSTER_CRDS:=useraccounts nstemplatesets memberstatuses idlers toolchainclusters memberoperatorconfigs spacerequests workspaces spacebindingrequests +## Location to install dependencies to +LOCALBIN ?= $(shell pwd)/bin +$(LOCALBIN): + mkdir -p $(LOCALBIN) + +## Tool Binaries +CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen +OPENAPI_GEN ?= $(LOCALBIN)/openapi-gen +CRD_REF_DOCS ?= $(LOCALBIN)/crd-ref-docs +CRD_REF_DOCS_VERSION ?= v0.3.0 PATH_TO_CRD_BASES=config/crd/bases -PROJECT_DIR := $(shell pwd) +$(CONTROLLER_GEN): go.mod | $(LOCALBIN) ## install controller-gen locally if necessary. Version is pinned in go.mod. + GOBIN=$(LOCALBIN) $(GO) install sigs.k8s.io/controller-tools/cmd/controller-gen + +$(OPENAPI_GEN): go.mod | $(LOCALBIN) ## install openapi-gen locally if necessary. Version is pinned in go.mod. + GOBIN=$(LOCALBIN) $(GO) install k8s.io/kube-openapi/cmd/openapi-gen + +$(CRD_REF_DOCS): go.mod | $(LOCALBIN) ## install crd-ref-docs locally if necessary. Version is pinned in go.mod. + GOBIN=$(LOCALBIN) $(GO) install github.com/elastic/crd-ref-docs@$(CRD_REF_DOCS_VERSION) + +.PHONY: manifests +manifests: $(CONTROLLER_GEN) ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects. + $(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./api/..." output:crd:artifacts:config=config/crd/bases .PHONY: generate -## Generate deepcopy, openapi and CRD files after the API was modified -generate: generate-deepcopy-and-crds generate-openapi gen-crd-ref-docs dispatch-crds - -.PHONY: generate-deepcopy-and-crds -generate-deepcopy-and-crds: remove-config controller-gen - @echo "Re-generating the deepcopy go file & the Toolchain CRD files... " - $(Q)$(CONTROLLER_GEN) crd \ - object paths="./..." output:crd:artifacts:config=$(PATH_TO_CRD_BASES) +generate: generate-object generate-crd gen-crd-ref-docs generate-openapi dispatch-crds ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations. + +.PHONY: generate-object +generate-object: $(CONTROLLER_GEN) ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations. + $(CONTROLLER_GEN) object paths="./api/..." + +.PHONY: generate-crd +generate-crd: $(CONTROLLER_GEN) remove-config ## Generate CRD manifests. + $(CONTROLLER_GEN) crd paths="./api/..." output:crd:artifacts:config=config/crd/bases .PHONY: gen-crd-ref-docs -gen-crd-ref-docs: crd-ref-docs +gen-crd-ref-docs: $(CRD_REF_DOCS) @echo "Re-generating the api doc ref: ./api/$(API_VERSION)/docs/apiref.adoc " $(CRD_REF_DOCS) --source-path ./api/$(API_VERSION) --config ./crdrefdocs.config.yaml --output-path ./api/$(API_VERSION)/docs/apiref.adoc .PHONY: generate-openapi -generate-openapi: openapi-gen +generate-openapi: $(OPENAPI_GEN) @echo "re-generating the openapi go file..." $(OPENAPI_GEN) ./api/$(API_VERSION)/ \ --output-pkg github.com/codeready-toolchain/api/api/$(API_VERSION) \ @@ -35,7 +54,6 @@ generate-openapi: openapi-gen --output-dir ./api/$(API_VERSION) \ --go-header-file=make/go-header.txt - # make sure that that the `host-operator` and `member-operator` repositories exist locally # and that they don't have any pending changes (except for the CRD files). # The reasonning here is that when a change is made in the `api` repository, the resulting changes @@ -48,29 +66,9 @@ generate-openapi: openapi-gen host_repo_status := $(shell cd ../host-operator && git status -s | grep -v ${PATH_TO_CRD_BASES}) member_repo_status := $(shell cd ../member-operator && git status -s | grep -v ${PATH_TO_CRD_BASES}) -PHONY: prepare-host-operator -prepare-host-operator: ../host-operator -ifdef host_repo_status - @echo "The local '../host-operator' repository has pending changes. Please stash them or commit them, first." - @exit 1 -endif -ifneq ($(wildcard ../host-operator/${PATH_TO_CRD_BASES}/*.yaml),) - @-find ../host-operator/${PATH_TO_CRD_BASES} -type f | grep -v "cr\.yaml" | xargs rm || true -else - @-mkdir -p ../host-operator/${PATH_TO_CRD_BASES} -endif - -PHONY: prepare-member-operator -prepare-member-operator: ../member-operator -ifdef member_repo_status - @echo "The local '../member-operator' repository has pending changes. Please stash them or commit them, first." - @exit 1 -endif -ifneq ($(wildcard ../member-operator/${PATH_TO_CRD_BASES}/*.yaml),) - @-find ../member-operator/${PATH_TO_CRD_BASES} -type f | grep -v "cr\.yaml" | xargs rm || true -else - @-mkdir -p ../member-operator/${PATH_TO_CRD_BASES} -endif +# how to dispatch the CRD files per repository (space-separated lists) +HOST_CLUSTER_CRDS:=masteruserrecords nstemplatetiers usersignups bannedusers notifications spaces spacebindings socialevents tiertemplates tiertemplaterevisions toolchainstatuses toolchainclusters toolchainconfigs usertiers proxyplugins spacerequests spacebindingrequests spaceprovisionerconfigs +MEMBER_CLUSTER_CRDS:=useraccounts nstemplatesets memberstatuses idlers toolchainclusters memberoperatorconfigs spacerequests workspaces spacebindingrequests .PHONY: dispatch-crds dispatch-crds: prepare-host-operator prepare-member-operator @@ -93,14 +91,26 @@ dispatch-crds: prepare-host-operator prepare-member-operator fi @echo "Dispatch successfully finished \o/" -CONTROLLER_GEN = $(PROJECT_DIR)/bin/controller-gen -controller-gen: ## Download controller-gen locally if necessary. - GOBIN=$(PROJECT_DIR)/bin $(GO) install sigs.k8s.io/controller-tools/cmd/controller-gen - -OPENAPI_GEN = $(PROJECT_DIR)/bin/openapi-gen -openapi-gen: ## Download openapi-gen locally if necessary. - GOBIN=$(PROJECT_DIR)/bin $(GO) install k8s.io/kube-openapi/cmd/openapi-gen +PHONY: prepare-host-operator +prepare-host-operator: ../host-operator +ifdef host_repo_status + @echo "The local '../host-operator' repository has pending changes. Please stash them or commit them, first." + @exit 1 +endif +ifneq ($(wildcard ../host-operator/${PATH_TO_CRD_BASES}/*.yaml),) + @-find ../host-operator/${PATH_TO_CRD_BASES} -type f | grep -v "cr\.yaml" | xargs rm || true +else + @-mkdir -p ../host-operator/${PATH_TO_CRD_BASES} +endif -CRD_REF_DOCS = $(PROJECT_DIR)/bin/crd-ref-docs -crd-ref-docs: ## Download crd-ref-docs locally if necessary. - GOBIN=$(PROJECT_DIR)/bin $(GO) install github.com/elastic/crd-ref-docs@latest \ No newline at end of file +PHONY: prepare-member-operator +prepare-member-operator: ../member-operator +ifdef member_repo_status + @echo "The local '../member-operator' repository has pending changes. Please stash them or commit them, first." + @exit 1 +endif +ifneq ($(wildcard ../member-operator/${PATH_TO_CRD_BASES}/*.yaml),) + @-find ../member-operator/${PATH_TO_CRD_BASES} -type f | grep -v "cr\.yaml" | xargs rm || true +else + @-mkdir -p ../member-operator/${PATH_TO_CRD_BASES} +endif \ No newline at end of file diff --git a/tools.go b/tools.go index c0f44b2b..570c685c 100644 --- a/tools.go +++ b/tools.go @@ -5,13 +5,6 @@ package tools import ( // Code generators built at runtime. - _ "github.com/go-bindata/go-bindata" - _ "k8s.io/code-generator/cmd/client-gen" - _ "k8s.io/code-generator/cmd/conversion-gen" - _ "k8s.io/code-generator/cmd/deepcopy-gen" - _ "k8s.io/code-generator/cmd/informer-gen" - _ "k8s.io/code-generator/cmd/lister-gen" - _ "k8s.io/gengo/args" _ "k8s.io/kube-openapi/cmd/openapi-gen" _ "sigs.k8s.io/controller-tools/cmd/controller-gen" )