-
Notifications
You must be signed in to change notification settings - Fork 47
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
added design doc for sparse checkout #335
added design doc for sparse checkout #335
Conversation
Signed-off-by: Asish Kumar <[email protected]>
Pull Request Test Coverage Report for Build 10505658929Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
Signed-off-by: Asish Kumar <[email protected]>
Hello @officialasishkumar I think we only need to set a subdirectory for the Git repository, as it may contain multiple kcl modules, while OCI, Local source is not required. |
Signed-off-by: Asish Kumar <[email protected]>
e467457
to
a52c590
Compare
The current design doc addresses this. |
I noticed that the design document has not changed, it still supports setting sub folders for local source and oci source, which is not necessary. |
Signed-off-by: Asish Kumar <[email protected]>
@Peefy Apologies for not being specific. I have updated the PR. Please let me know if any more changes are needed. |
kpm add --subdir <subdir> <git-repo-url> | ||
``` | ||
|
||
The `--subdir` flag will be optional. If the flag is not provided, `kpm` will download the entire repository as it does now. If the flag is provided, `kpm` will download only the specified subdirectory. The `kcl.mod` file will be generated with the path to the subdirectory. |
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
kcl.mod
file will be generated with the path to the subdirectory.
Here, I personally think that if there is no kcl.mod
file in the subdirectory downloaded by the user, we should output diagnostic information and notify the user, rather than generate the file for him, because the kcl.mod
file will affect the compilation result in some cases, if the user does not know that kpm have generated the file for him, it may cause trouble to his use.
Example usage: | ||
|
||
``` | ||
kpm add --subdir 1.21/* k8s |
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 now, I recommend that this function should be operated on a valid KCL package and not extended to various files and file directories, so I do not recommend adding support such as *
or a *.k file
.
--subdir xxx/xxx # only a subdir here, and the subdir must contains `kcl.mod` file, if not, raise an error.
In the future, if there is a demand for *
, we can consider the research again to decide whether to support it. It is too early to introduce this feature in the path details.
|
||
``` | ||
[dependencies] | ||
bbb = { path = "../bbb", subdir = ["test-*", "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.
I don't understand the workflow for kpm when it get the kcl.mod
like this, could you please add more details ?
The main point that confuse me is:
The main purpose of this work was to support the addition of dependencies from subdirectories of git repo.
bbb = { path = "../bbb", subdir = ["test-", "test-"]}
It doesn't seem to have anything to do with git
|
||
As mentioned in the [go-getter](https://pkg.go.dev/github.com/hashicorp/go-getter#readme-subdirectories) docs, we can append our subDir from `CloneOptions` (only if subDir is not empty) in `WithRepoURL` function. | ||
|
||
### using go-git |
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.
kpm
used to use go-git
to interact with git repo, but one issue that forced me to switch to go-getters
. Let me give you a few more details that may be helpful.
When supporting taking git repo as dependencies, there is one tricky issue to consider: authentication. go-git
and the native git client do not share the same authentication, which means that if you use go-git
, you need to consider the authentication in kpm
and implement it. It's a lot of work.
And the authentication part of go-git
itself is not yet complete: go-git/go-git#490
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.
Got it. So I will be using go-getter methods.
@officialasishkumar Sorry for the late review 😳, which is my mistake. I finished the review yesterday, but I forgot to click submit review... |
Signed-off-by: Asish Kumar <[email protected]>
Signed-off-by: Asish Kumar <[email protected]>
|
||
``` | ||
[dependencies] | ||
bbb = { git = "https://github.com/kcl-lang/flask-demo-kcl-manifests.git", commit = "ade147b", subdir = ["something"]} |
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 subdir
is a list ?
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 defined this because in the future if we want to add other subdir from a git repo say kcl-lang/modules then we would be able to achieve that without overwritting the previous subdir
Signed-off-by: Asish Kumar <[email protected]>
Signed-off-by: Asish Kumar <[email protected]>
bbb = { git = "https://github.com/kcl-lang/modules", commit = "ade147b", subdir = ["add-ndots"]} | ||
``` | ||
|
||
The subdir is a list because in the future if user wants to add another subdir from the same git repo then it can be added without overwritting the current subdir. |
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 are still some things I don't understand here.
then it can be added without overwritting the current subdir
If we refer to different directories in the same repository, I think the kcl.mod
will looks like:
[dependencies]
bbb = { git = "https://github.com/kcl-lang/modules/add-ndots", commit = "ade147b"}
another_bbb = { git = "https://github.com/kcl-lang/modules/another-add-ndots", commit = "ade147b"}
And, the two packages are stored in two different directories.
So can you show an example to describe the problem you mentioned above?
The subdir is a list because in the future if user wants to add another subdir from the same git repo then it can be added without overwritting the current subdir.
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.
In my proposal, I am trying to achieve this directory structure :
├── .kcl
│ ├── kpm
│ │ ├── modules
│ │ │ ├── k8s
│ │ │ ├── agent
And, the two packages are stored in two different directories.
Do you mean this directory structure?
├── .kcl
│ ├── kpm
│ │ ├──modules
│ │ │ └── k8s
│ │ ├── modules
│ │ │ ├── agent
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 two file trees you gave above, are they different on the file system 😳 ? They seem to be just different drawings of the same file tree.
In my proposal, I am trying to achieve this directory structure :
The directory structure is correct and I have no problem. My question is, why is there a subdir
field in kcl.mod
, and why is it a list
. Is there a problem with some mechanism of go-getter
?
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 two file trees you gave above, are they different on the file system?
Sorry, I misunderstood something.
why is there a subdir field in kcl.mod, and why is it a list. Is there a problem with some mechanism of go-getter ?
No, there is no problem with go-getter. I have removed subdir flag. Thanks for the suggestion!
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.
Should I revert back my subdir/package change in kcl.mod?
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 think you can follow the cargo
design for this feature. I have one question about your design: why do you want to use a list as the subdir
? You should also add some details about how users can import dependencies in KCL code.
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 removed subdir. I think i will be able to parse and download the dependencies by just keeping the whole 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.
Hi @officialasishkumar 😄, I think there may be some misunderstandings between us. What needs to be determined in this document is how users can use this function properly. I don't worry about whether this function can be implemented. This feature does not involve some complex and hard parts, and there should be no obstacles to implementation. Maybe you could consider the option I mentioned earlier #335 (comment)
Hi @officialasishkumar 😄 I've been looking at the cargo's design for this feature. I have some new findings to share with you. Hope this helpful. I find this design comfortable to use. ❤️ The
It will clone the git repo -> recursively look for all I tried to use this feature on a project and found several advantages of this design.
|
Signed-off-by: Asish Kumar <[email protected]>
e66801e
to
cb6d79d
Compare
Signed-off-by: Asish Kumar <[email protected]>
Signed-off-by: Asish Kumar <[email protected]>
@zong-zhe I have a question. Which option is better with the user perspective? |
From my point of view, I think using a flag option (only the package name) is better. |
Hi @officialasishkumar 😄 Hi, please update this doc and synchronize the results of our discussion with the final design decision. In this PR, we need to keep the design document consistent with the implementation, as both the document and the final code implementation are required. |
Signed-off-by: Asish Kumar <[email protected]>
@Peefy Thanks for the comment. I have updated accordingly. Please have a look! |
Where updated? ... |
I can't see it in the design doc... |
What I mean is that you need to complete the design doc and clearly display the unfinished tasks in the doc. |
|
According to discussion with zong-zhe, I don't think there is any unfinished tasks. |
However, I use the kpm v0.10.0-beta.1 to test the feature, it does not work for me kcl mod init me && cd me
kcl mod add --git https://github.com/kcl-lang/modules --tag v0.1.0 --package helloworld
kcl mod metadata
|
|
Oh my bad, i will do the changes on those subcommand and update it by tonight. |
Just for confirmation, are only graph, metadata, update are needed to be synched right? |
|
|
Signed-off-by: Asish Kumar <[email protected]>
Hey @Peefy, Can you please check and let me know what all things are remaining? I will start working on them at the earliest. |
Hello @officialasishkumar Just merge all design PRs and feature development PR, and test them to pass including unit tests and e2e tests including |
Signed-off-by: Asish Kumar <[email protected]>
|
||
The user can then run `kcl mod run` to run the code: | ||
|
||
`kcl mod run` |
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.
s/kcl mod run
/kcl run
Signed-off-by: Asish Kumar <[email protected]>
The metadata of
|
If i am right I have to change the fullname to the repo name? Are there any things that needs to be updated with repo name? |
Yes, using the repo name as the full path looks more logical, see this issue #384 for more information. |
should the key name will also changed to repo name?
or
|
The kcl.mod.lock looks like this rn after my changes. Lmk if everything looks good i will open a PR.
|
and the metadata
|
The form is right. The key should be always the package name.
|
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
1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".):
2. What is the scope of this PR (e.g. component or file name):
3. Provide a description of the PR(e.g. more details, effects, motivations or doc link):
4. Are there any breaking changes?(Y/N) and describe the breaking changes(e.g. more details, motivations or doc link):
5. Are there test cases for these changes?(Y/N) select and add more details, references or doc links: