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

Use new crd-schema-gen in Makefile #514

Merged
merged 4 commits into from
Jul 9, 2019

Conversation

damemi
Copy link

@damemi damemi commented Jul 1, 2019

This is an example of how we could use the crd-schema-gen hosted image in our makefiles, and ultimately remove the dependency on the library-go scripts which were based on hacked and patched forks of dependencies. Ideally I think we could just add these commands to library-go's alpha-build-machinery helpers and import from there.

@damemi damemi requested a review from sttts July 1, 2019 20:46
@openshift-ci-robot openshift-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Jul 1, 2019
@damemi
Copy link
Author

damemi commented Jul 1, 2019

Note that this won't work right now because of openshift/api#362

Makefile Outdated Show resolved Hide resolved
@damemi damemi force-pushed the crd-gen-makefile branch 2 times, most recently from 4db1e86 to ba1adbb Compare July 2, 2019 15:23
@damemi
Copy link
Author

damemi commented Jul 2, 2019

make: podman: Command not found, also tried with docker, what command should I use to run containers in makefiles?

@tnozicka
Copy link
Contributor

tnozicka commented Jul 3, 2019

It's not about makefiles, but CI infra. Given our tests run as containers, it sounds like you are trying to do nested docker which you can't (easily), it may be possible with podman

We'd need to extend the golang image with podman in a step or ask it to be included there (which I am not sure of, but there are already other tools there)
https://github.com/openshift/release/blob/master/ci-operator/config/openshift/cluster-kube-apiserver-operator/openshift-cluster-kube-apiserver-operator-master.yaml#L7

I'd like to see the nested podman tested manually first

@damemi damemi force-pushed the crd-gen-makefile branch 2 times, most recently from 5ddf565 to f5929ed Compare July 8, 2019 17:02
@openshift-ci-robot openshift-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jul 8, 2019
@damemi
Copy link
Author

damemi commented Jul 8, 2019

bumped this to pull in API fixes and ran the new generator, looks like the missing top-level descriptions are there now but this also seemed to generate validations for ObjectMeta, which was apparently missing before. Does that look right?

@damemi
Copy link
Author

damemi commented Jul 8, 2019

/retest

@damemi
Copy link
Author

damemi commented Jul 8, 2019

/retest

Makefile Outdated Show resolved Hide resolved
Makefile Outdated
@@ -44,8 +44,10 @@ PKG := ${PWD:${GOPATH}/%=%}
update-codegen-crds:
docker run -v ${PWD}:/go/$(PKG):Z -w /go/$(PKG) registry.svc.ci.openshift.org/ocp/4.2:crd-schema-gen --apis-dir vendor/github.com/openshift/api/operator/v1
update-codegen: update-codegen-crds

TMP_GOPATH :=$(shell mktemp -d)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

who deletes it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

systemd

Makefile Outdated
verify-codegen-crds:
go get github.com/openshift/crd-schema-gen/... && go install github.com/openshift/crd-schema-gen/...
export GOPATH=$(TMP_GOPATH) && export GOBIN=$(TMP_GOPATH)/bin && git clone -b release-4.2 --single-branch --depth 1 https://github.com/openshift/crd-schema-gen.git $(TMP_GOPATH)/src/github.com/openshift/crd-schema-gen && go install $(TMP_GOPATH)/src/github.com/openshift/crd-schema-gen/cmd/crd-schema-gen
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GOPATH=$(TMP_GOPATH) GOBIN=... go install ... is enough. No need to export. git does not use them.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure about GOBIN? We have to call it from there as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some people like @stlaz have set GOBIN explicitly and without setting it to temp we install it to the global GOBIN instead the one in temporary GOPATH

Makefile Outdated
verify-codegen-crds:
go run ./vendor/github.com/openshift/library-go/cmd/crd-schema-gen/main.go --domain openshift.io --apis-dir vendor/github.com/openshift/api --verify-only
git clone -b release-4.2 --single-branch --depth 1 https://github.com/openshift/crd-schema-gen.git $(TMP_GOPATH)/src/github.com/openshift/crd-schema-gen
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the line breaks :)

Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Makefile Outdated
@@ -44,8 +44,10 @@ PKG := ${PWD:${GOPATH}/%=%}
update-codegen-crds:
docker run -v ${PWD}:/go/$(PKG):Z -w /go/$(PKG) registry.svc.ci.openshift.org/ocp/4.2:crd-schema-gen --apis-dir vendor/github.com/openshift/api/operator/v1
update-codegen: update-codegen-crds

TMP_GOPATH :=$(shell mktemp -d)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

systemd

Makefile Outdated
crd-schema-gen:
git clone -b release-4.2 --single-branch --depth 1 https://github.com/openshift/crd-schema-gen.git $(TMP_GOPATH)/src/github.com/openshift/crd-schema-gen
GOPATH=$(TMP_GOPATH) go install $(TMP_GOPATH)/src/github.com/openshift/crd-schema-gen/cmd/crd-schema-gen
crd-schema-gen --apis-dir vendor/github.com/openshift/api/operator/v1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by convention we end phony target with `.PHONY: target-name

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that was preexisting, so it's up to you to fix it

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is adding it to the .PHONY list at the end good?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it works the same way, our convention is to use it as {} to scope the target

Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
@damemi damemi force-pushed the crd-gen-makefile branch 2 times, most recently from 8b9737e to a513b43 Compare July 9, 2019 17:54
Makefile Outdated Show resolved Hide resolved
Copy link
Contributor

@tnozicka tnozicka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the makefile structure looks good now, thx

@@ -40,11 +40,18 @@ test-e2e: GO_TEST_PACKAGES :=./test/e2e/...
test-e2e: GO_TEST_FLAGS += -v
test-e2e: test-unit

update-codegen-crds:
go run ./vendor/github.com/openshift/library-go/cmd/crd-schema-gen/main.go --domain openshift.io --apis-dir vendor/github.com/openshift/api
crd-schema-gen:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

install-crd-schema-gen?

@damemi damemi changed the title Use crd-schema-gen image in Makefile Use new crd-schema-gen in Makefile Jul 9, 2019
@damemi damemi force-pushed the crd-gen-makefile branch 3 times, most recently from 08b71d9 to d66e166 Compare July 9, 2019 19:44
Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
@sttts
Copy link
Contributor

sttts commented Jul 9, 2019

/lgtm
/approve

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 9, 2019
@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: damemi, sttts

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 9, 2019
@damemi
Copy link
Author

damemi commented Jul 9, 2019

/test e2e-aws

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants