-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Clean code near Loader
#4702
Clean code near Loader
#4702
Conversation
Hi @annasong20. Thanks for your PR. I'm waiting for a kubernetes-sigs 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. |
api/ifc/ifc.go
Outdated
@@ -28,12 +28,23 @@ type KvLoader interface { | |||
|
|||
// Loader interface exposes methods to read bytes. | |||
type Loader interface { | |||
|
|||
// IsRemote returns whether this Loader was created from a url | |||
IsRemote() bool |
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 don't think this is needed. We can make an assumption that if Repo
is "", then this wasn't created from a url.
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 was thinking this would make future code easier to read. For example, if ldr.IsRemote()
reads better than if ldr.Repo() == ""
.
However, I really like your point. I'll collapse the 2 methods into Repo() string, bool
, where the 1st argument is the repo and the second indicates whether there is a repo.
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.
Will address this in #4652
api/ifc/ifc.go
Outdated
|
||
// Repo returns the repo location of this Loader if IsRemote is true, | ||
// and an empty string otherwise | ||
Repo() string |
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.
It would be helpful if you could explain why this is needed and where would you use this. In general, there isn't a big issue with adding methods to our interfaces, but this seems like it could potentially be a field in a struct or a local variable that is passed around. With some more context, we can make a better judgment about the recommendation.
IIRC this change was a prerequisite for #4652, so maybe it makes sense for you to include this change in that PR, as that will provide the context and help reviewers to see how you are planning to use 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.
I will move the Repo()
change into #4652 and keep auxiliary changes here.
t.Fatalf("incorrect resources: %v", resources) | ||
} | ||
resources, err := globPatternsWithLoader(fSys, ldr, []string{httpPath}) | ||
req.NoError(err) |
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 seem to be some test changes here that are relevant to the Loader
change, and some that aren't. Could you move the extra test fixes to their own PR?
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.
Done. Only the extra fixes remain in this PR. The actual Loader
change will go in #4652
Fix and clean code encountered while adding Repo() to Loader
813c359
to
e9e8f7a
Compare
@annasong20: PR needs rebase. 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. |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten |
// cloneDir field in the repoSpec. It's assumed that | ||
// the cloneDir is associated with some fake filesystem | ||
// the Dir field in the repoSpec. It's assumed that | ||
// the Dir is associated with some fake filesystem | ||
// used in a test. | ||
func DoNothingCloner(dir filesys.ConfirmedDir) Cloner { |
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.
Just realized this. It's an interesting name 😆 . Is this for test only? like "TestOnlyCloner" "ForTestingPurposeOnlyCloner".
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: annasong20, yuwenma The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/lgtm @natasha41575 can you take another pass on this PR? It looks good on my side |
/ok-to-test |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /close |
@k8s-triage-robot: Closed this PR. In response to this:
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. |
Fix
edit add
command TestAddKustomizationFileAs* adds normal config instead of kustomization fileClean