Skip to content

Allow openapi to act only on specific GKV #1633

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

Closed
jpkrohling opened this issue Jul 2, 2019 · 7 comments
Closed

Allow openapi to act only on specific GKV #1633

jpkrohling opened this issue Jul 2, 2019 · 7 comments
Assignees
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. kind/feature Categorizes issue or PR as related to a new feature.

Comments

@jpkrohling
Copy link

jpkrohling commented Jul 2, 2019

Feature Request

In the Jaeger Operator, we have a legacy CRD (io.jaegertracing/v1alpha1) which we deprecated some months ago. When running the generate openapi command, I'd like to keep the CRD deploy/crds/io_v1alpha1_jaeger_crd.yaml untouched, as I don't want to bring new features or bugs to it.

Currently, the mentioned command will regenerate all the CRDs that it can find. From the command documentation:

generate openapi generates OpenAPI validation specs in Go from tagged types
in all pkg/apis/<group>/<version> directories. Go code is generated under
pkg/apis/<group>/<version>/zz_generated.openapi.go. CRD's are generated, or
updated if they exist for a particular group + version + kind, under
deploy/crds/<group>_<version>_<kind>_crd.yaml; OpenAPI V3 validation YAML
is generated as a 'validation' object.

Example:
	$ operator-sdk generate openapi
	$ tree pkg/apis
	pkg/apis/
	└── app
		└── v1alpha1
			├── zz_generated.openapi.go
	$ tree deploy/crds
	├── deploy/crds/app_v1alpha1_appservice_cr.yaml
	├── deploy/crds/app_v1alpha1_appservice_crd.yaml

Usage:
  operator-sdk generate openapi [flags]

Flags:
  -h, --help   help for openapi

Global Flags:
      --verbose   Enable verbose logging
@lilic lilic added the kind/feature Categorizes issue or PR as related to a new feature. label Jul 4, 2019
@lilic
Copy link
Member

lilic commented Jul 4, 2019

We could add a flag of some sort to ignore certain APIs that are passed via that flag. cc @estroz

@estroz
Copy link
Member

estroz commented Jul 9, 2019

I'm thinking of a flag -i/--ignore for all generate subcommands that takes a slice of API group versions and skips generating their OpenAPI or deepcopy code. I chose a brief name because the commands are specific to API's so it should be obvious what is being ignored (with good CLI help text of course). We should not expose the ability to ignore kinds; that will take a lot more work because the generator runs at a package level.

@lilic @hasbro17 @joelanford @AlexNPavel @jmrodri @fabianvf WDYT

@lilic
Copy link
Member

lilic commented Jul 10, 2019

@estroz that sounds good to me! 👍

Would that solve your usecase @jpkrohling ?

@jpkrohling
Copy link
Author

I believe so: at the moment, I don't need to ignore specific Kind, but entire groups.

@openshift-bot
Copy link

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci-robot openshift-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 9, 2019
@camilamacedo86
Copy link
Contributor

camilamacedo86 commented Oct 9, 2019

To solve this one we could does as it was done for:

Added new --skip-generation flag to the operator-sdk add api command to support skipping generation of deepcopy and OpenAPI code and OpenAPI CRD specs. (#1890)

Then, it means that:

operator-sdk openapi --skip-generation --group <group> would do all that it does unless for th group informed.

@camilamacedo86 camilamacedo86 added good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Oct 9, 2019
@camilamacedo86
Copy link
Contributor

HI @jpkrohling,

As described in the comment #2054 (comment) was decided not to move forward with this kind of request. The reason for that is because we are looking for to design changes to give more flexibility to our users. Then, for customizations like this one, we would like to suggest the usage of controller-gen directly by a Makefile. Following an example of a Makefile with targets to generate/update the CRD's in the SDK structure.

# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:trivialVersions=true"

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif

# Generate manifests e.g. CRD, RBAC etc.
manifests: controller-gen
	$(CONTROLLER_GEN) paths=./... crd:trivialVersions=true output:crd:artifacts:config=deploy/crds

# find or download controller-gen
# download controller-gen if necessary
controller-gen:
ifeq (, $(shell which controller-gen))
	go get sigs.k8s.io/controller-tools/cmd/[email protected]
CONTROLLER_GEN=$(GOBIN)/controller-gen
else
CONTROLLER_GEN=$(shell which controller-gen)
endif

Then, when the command make manifests be called the CRD's in the path deploy/crds will be created/updated.

For further information about how to use the controller-gen options/commands see its [docs]
(https://book.kubebuilder.io/reference/controller-gen.html).

In this way, I am closing this one. However, please feel free to re-open if you feel that would be required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. kind/feature Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

No branches or pull requests

6 participants