-
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
Support various target and resource with go-getter #2278
Conversation
yujunz
commented
Mar 15, 2020
•
edited
Loading
edited
- getter is inserted before git cloner
- local file is NOT handled by getter
- tested against existing examples
Backward compatible with existing examples
|
/test kustomize-presubmit-master |
Unable to understand the lint error:
Is it a flake? I didn't even change the file. |
8c2554e
to
ea5d780
Compare
Ready for review @Liujingfang1 @pwittrock |
@yujunz Where did you see the lint error? Is it resolved? |
api/loader/fileloader.go
Outdated
} | ||
|
||
// newLoaderAtConfirmedDir returns a new fileLoader with given root. | ||
func newLoaderAtConfirmedDir( | ||
lr LoadRestrictorFunc, | ||
root filesys.ConfirmedDir, fSys filesys.FileSystem, | ||
referrer *fileLoader, cloner git.Cloner) *fileLoader { | ||
referrer *fileLoader, cloner git.Cloner, getter resourceGetter) *fileLoader { |
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 looks like getter
and cover the functionality of cloner
. Can you see if we can use getter only rather than both?
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 an intersection between getter and cloner. Some special URLs can only be handled by cloner at the moment.
One thing we can do is refactoring cloner to Detect and Get in getter and register them in getter. Then we shall have the unified interface while keeping backward compatibility.
What do you think?
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.
What are the special URLs that can't be handled by cloner? If they are not supported by getter, keeping the cloner for them should be fine.
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.
For example,
kustomize/api/internal/git/repospec.go
Line 51 in 064f064
if isAzureHost(x.Host) || isAWSHost(x.Host) { |
I don't see detectors in go-getter to handle them. It supports only plain git, GitHub and bitbucket url.
Yes, it has been resolved by #2280 |
api/loader/resource.go
Outdated
// Getter is a function that can gets resource | ||
type resourceGetter func(rs *resourceSpec) error | ||
|
||
func newResourceGetter(raw string, fSys filesys.FileSystem, referrer *fileLoader, cloner git.Cloner, getter resourceGetter) (ifc.Loader, error) { |
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.
Change the function name of newResourceGetter
. Maybe newLoaderAtGetter
to be consistent with other function names.
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
|
||
`github.com/kubernetes-sigs/kustomize/examples/multibases?ref=v1.0.6` | ||
- a subdirectory in a repo on branch repoUrl2 | ||
# a repo with a root level kustomization.yaml on branch test |
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.
How about github.com/kubernetes-sigs/kustomize/examples/multibases?ref=v1.0.6
?
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 already covered by L91
# a subdirectory in a repo on branch repoUrl2
- github.com/Liujingfang1/kustomize/examples/helloWorld?ref=repoUrl2
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.
Already covered in L91 that followed. kustomize
repository is too huge for testing. It takes a long time to clone when network is not so good.
api/loader/resource.go
Outdated
return nil, err | ||
} | ||
|
||
// TODO(yujunz): check file or directory |
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.
What do you mean by this todo?
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.
A resource can either be a plain yaml or an archive. The former should be loaded as it is and the latter needs to be extracted to directory. It turns out this is already handled in
kustomize/api/internal/target/kusttarget.go
Line 304 in 3a2635b
// try loading resource as file then as base (directory or git repository) |
Removed the TODO item
api/loader/resource.go
Outdated
// TODO(yujunz): check file or directory | ||
|
||
return &fileLoader{ | ||
loadRestrictor: RestrictionRootOnly, |
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.
The loadRestrictor should be inherited from the parent overlay.
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 top level similar tonewLoaderAtGiClone
kustomize/api/loader/fileloader.go
Line 226 in 3a2635b
// Clones never allowed to escape root. |
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.
Yes, you're correct. For the remote target, we should restrict the load restrictor to be within that remote target.
api/loader/resource.go
Outdated
} | ||
|
||
// Getter is a function that can gets resource | ||
type resourceGetter func(rs *resourceSpec) error |
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.
Suggest to change resourceGetter
to remoteTargetGetter
since resource
has a specific meaning in kustomize, which is different from the usage here.
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
api/loader/resource.go
Outdated
"sigs.k8s.io/kustomize/api/internal/git" | ||
) | ||
|
||
type resourceSpec struct { |
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.
resourceSpec
-> remoteTargetSpec
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
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.
Comments inline
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Liujingfang1, yujunz 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 |