-
Notifications
You must be signed in to change notification settings - Fork 38
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
make specs-go a module #170
Conversation
3e427f2
to
dbb8234
Compare
go.sum
Outdated
@@ -13,6 +13,7 @@ github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9 | |||
github.com/mndrix/tap-go v0.0.0-20171203230836-629fa407e90b/go.mod h1:pzzDgJWZ34fGzaAZGFW22KVZDfyrYW+QABMrWnJBnSs= | |||
github.com/mrunalp/fileutils v0.5.0/go.mod h1:M1WthSahJixYnrXQl/DFQuteStB1weuxD2QJNHXfbSQ= | |||
github.com/opencontainers/runtime-spec v1.0.3-0.20220825212826-86290f6a00fb/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= | |||
github.com/opencontainers/runtime-spec v1.0.3-0.20220909204839-494a5a6aca78/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE: this is the version used in k/k: https://github.com/kubernetes/kubernetes/blob/v1.29.0-alpha.2/go.mod#L206
I guess a lot of deps were removed from cmd/cdi/go.sum because of this change, which looks rather good.
One question: Does this mean we need to update the |
So I guess after merging this we should start tagging also the specs-go golang sub-module ? |
Yes, I think so. Maybe we should replace the current, manually spelt out tidying and verifying rules with something more simple and automatic like, for instance: diff --git a/Makefile b/Makefile
index 6fc1836..9f70ee7 100644
--- a/Makefile
+++ b/Makefile
@@ -64,30 +64,18 @@ $(BINARIES): bin/%:
#
# go module tidy and verify targets
#
-.PHONY: mod-tidy $(CMD_MOD_TIDY_TARGETS) mod-tidy-root
-.PHONY: mod-verify $(CMD_MOD_VERIFY_TARGETS) mod-verify-root
-
-CMD_MOD_TIDY_TARGETS := mod-tidy-cdi mod-tidy-validate
-CMD_MOD_VERIFY_TARGETS := mod-verify-cdi mod-verify-validate
-
-mod-tidy-root:
- $(Q)echo "Running $@..."; \
- $(GO_CMD) mod tidy
-
-$(CMD_MOD_TIDY_TARGETS): mod-tidy-%: mod-tidy-root
- $(Q)echo "Running $@... in $(abspath ./cmd/$(*))"; \
- (cd $(abspath ./cmd/$(*)) && $(GO_CMD) mod tidy)
-
-mod-verify-root: mod-tidy-root
- $(Q)echo "Running $@..."; \
- $(GO_CMD) mod verify
-
-$(CMD_MOD_VERIFY_TARGETS): mod-verify-%: mod-tidy-% mod-verify-root
- $(Q)echo "Running $@... in $(abspath ./cmd/$(*))"; \
- (cd $(abspath ./cmd/$(*)) && pwd && $(GO_CMD) mod verify)
-
-mod-verify: $(CMD_MOD_VERIFY_TARGETS)
-mod-tidy: $(CMD_MOD_TIDY_TARGETS)
+.PHONY: mod-tidy
+.PHONY: mod-verify
+
+mod-tidy:
+ $(Q)for mod in $$(find . -name go.mod); do \
+ (echo "Tidying $$mod..."; cd $$(dirname $$mod) && go mod tidy) || exit 1; \
+ done
+
+mod-verify:
+ $(Q)for mod in $$(find . -name go.mod); do \
+ (echo "Verifying $$mod..."; cd $$(dirname $$mod) && go mod verify) || exit 1; \
+ done
#
# cleanup targets And in addition to doing so, I would also add github workflow job to reject any PR where a @elezar @bart0sh If you guys agree, I can file a PR to these effects... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bart0sh I'm fine with turning this into a sub-module of its own.
That would make sense from my point of view. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What does "tagging the sub-module" mean in this context. We only have a single tag associated with this repository. |
https://go.dev/doc/modules/managing-source#multiple-module-source |
OK. So if we create a git tag: |
I think consumers continue to import "github.com/container-orchestrated-devices/container-device-interface/specs-go", it just will have a different version than "github.com/container-orchestrated-devices/container-device-interface". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dbb8234
to
3a75cb1
Compare
This should allow to import CDI spec structures without adding a lot of CDI runtime deps. It should partly fix cncf-tags#97 and allow Kubernetes to refer this module directly. There are at least 2 places in the k/k codebase that would benefit from this change: - this can be replaced by the specs-go import: https://github.com/kubernetes/kubernetes/blob/master/test/e2e/dra/test-driver/app/cdi.go - this can import specs-go and use JSON marshalling instead of quite ugly approach it uses to write CDI files: https://github.com/kubernetes/kubernetes/blob/master/test/images/sample-device-plugin/sampledeviceplugin.go#L237 Signed-off-by: Ed Bartosh <[email protected]>
Signed-off-by: Evan Lezar <[email protected]>
3a75cb1
to
85e2e5b
Compare
/lgtm @bart0sh for your info. I rebased on |
This should allow to import CDI spec structures without adding a lot of CDI runtime deps.
It should partly fix #97 and allow Kubernetes to refer this module directly. There are at least 2 places in the k/k codebase that would benefit from this change: