-
Notifications
You must be signed in to change notification settings - Fork 331
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
Avoid importing apis/duck from apis/duck/<<version>> #1388
Conversation
Welcome @alvaroaleman! It looks like this is your first PR to knative/pkg 🎉 |
Hi @alvaroaleman. Thanks for your PR. I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/assign @mattmoor |
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.
Produced via:
gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print)
|
||
"knative.dev/pkg/apis/duck/v1" |
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.
This would break compilation
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.
This is the output of goimports
, you need:
"knative.dev/pkg/apis/duck/v1" | |
v1 "knative.dev/pkg/apis/duck/v1" |
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.
I have no idea what you are talking about, the change you are suggesting looks like you have some broken tooling. Aliasing an import with its own name is useless mental overhead.
"knative.dev/pkg/apis/duck" | ||
v1 "knative.dev/pkg/apis/duck/v1" | ||
"knative.dev/pkg/apis/duck/ducktypes" | ||
"knative.dev/pkg/apis/duck/v1" |
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.
This would break compilation
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.
why would it?
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.
Because it removes an import that is being referenced?
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.
I guess we need to call it duckv1
to conform to our repository conventions.
I think at some point it saw both named and unnamed import.
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.
there is already a duckv1
. My PR does not change anything about the existing imports other than removing the useless v1
prefix.
@mattmoor sorry, I don't understand your comments. According to your suggestions I should remove imports which would break the code. The code in this PR is properly formatted via
|
|
||
"knative.dev/pkg/apis/duck/v1" |
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.
This would break compilation
"knative.dev/pkg/apis/duck" | ||
v1 "knative.dev/pkg/apis/duck/v1" | ||
"knative.dev/pkg/apis/duck/ducktypes" | ||
"knative.dev/pkg/apis/duck/v1" |
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.
This would break compilation
/ok-to-test |
@markusthoemmes is there anything I have to do regarding the failing presubmit? I just moved code around so the test coverage shouldn't change to how it was before |
@markusthoemmes @mattmoor @vagababov the issue this PR fixes is pretty problematic for downstream projects that import the knative api. The PR is apicompatible thanks to the alias so it shouldn't cause any issue. Can you please take another look? |
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.
Produced via:
gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -name '*.pb.go' -prune -o -type f -name '*.go' -print)
goimports -w $(find -name '*.go' | grep -v vendor | grep -v third_party | grep -v .pb.go | grep -v wire_gen.go)
Can someone please have a look? The fact that we import these types blocks us from being able to upgrade kube dependencies. There is zero reason to import apimachinery into an api package. |
The following is the coverage report on the affected files.
|
@alvaroaleman: The following test failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
/lgtm |
@alvaroaleman re: coverage, you're fine nothing else to do, not your fault :) |
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
I don't understand why this is needed. the stuff in duck/ defines interfaces that are used in the versions. Now ducktype is a pseudo version but the code is the same. Why is this better? |
@n3wscott the problem is that Because there are implementations in diff --git a/apis/duck/v1/addressable_types.go b/apis/duck/v1/addressable_types.go
index 3cfcac33..e53daaf0 100644
--- a/apis/duck/v1/addressable_types.go
+++ b/apis/duck/v1/addressable_types.go
@@ -24,7 +24,6 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"knative.dev/pkg/apis"
- "knative.dev/pkg/apis/duck/ducktypes"
)
// +genduck
@@ -68,7 +67,7 @@ var (
)
// GetFullType implements duck.Implementable
-func (*Addressable) GetFullType() ducktypes.Populatable {
+func (*Addressable) GetFullType() *AddressableType {
return &AddressableType{}
} fails to compile:
Hence, those interfaces had to be moved to a new package that is imported by both |
Sounds like you have a dep problem and the repo is not the problem. Duck/v1 also imports api machinery so it is not clear how moving the interfaces changes anything. Are you using a very very new version of golang? Use compile this arrangement all the time in Knative and numerous other projects. What is the exact compile issue? And are you using go mod? |
@n3wscott Thanks for your feedback.
Yes I have a dep problem because of this repo.
Yes it imports some from apimachinery but much less, just
1.13 but that should be irrelevant for this
I don't understand what you mean by this, can you elaborate?
https://prow.k8s.io/view/gcs/kubernetes-jenkins/pr-logs/pull/test-infra/17869/pull-test-infra-bazel/1269424108739760128#1:build-log.txt%3A4846 That pull does not fail on knative anymore with the changes in this PR.
Yes, but I doubt that is relevant. |
@n3wscott does that explanation make sense to you? Is there anything further you would like to know? If not, I would appreciate a |
@n3wscott ping |
@n3wscott Can you please respond? This is still blocking us from upgrading the version of our kube dependencies even though the absolute only thing we want from this repo are the types. It is not sustainable for downstream projects if their dependencies force them to use a specific kube client-go version. |
/unhold Sorry looks like you are trying to cherry pick a single class and it is at a package that pulls a ton of other stuff. Sorry for the delay, my GitHub notifications are a... challenge 😭 Thanks for the ping! /Lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alvaroaleman, n3wscott, vaikas 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 |
Fixes #1387