-
Notifications
You must be signed in to change notification settings - Fork 56
added the docs directory with design report for kpm sparse checkout #334
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
Changes from 33 commits
55ede5c
2aff90f
a99b9a6
cacaaea
3c2bdb7
629b9e2
313d038
f2a1608
e6734fd
5673c8b
df7c07f
385bec4
4f4f8bf
1189907
031049b
0b24e22
7d2fbda
6ee91c0
8eb5882
5b68d0a
b7ee3c8
1dc8c21
e6817a3
c8229aa
eaee134
5441529
87b3299
bcb0a8e
eb5492a
ab10bdc
208e9f5
8db93ed
09f16da
aadc97e
512037a
003f931
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# To get started with Dependabot version updates, you'll need to specify which | ||
# package ecosystems to update and where the package manifests are located. | ||
# Please see the documentation for all configuration options: | ||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
|
||
version: 2 | ||
updates: | ||
- package-ecosystem: "gomod" # See documentation for possible values | ||
directory: "/" # Location of package manifests | ||
schedule: | ||
interval: "weekly" | ||
commit-message: | ||
prefix: "Chore: " | ||
include: "scope" | ||
ignore: | ||
- dependency-name: k8s.io/* | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
commit-message: | ||
prefix: "chore: " | ||
include: "scope" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
## KPM Sparse-Checkout feature | ||
Peefy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## 1. Introduction | ||
kpm which is the package management tool for KCL, does not support sparse-checkout, which means an issue arises when dealing with monorepos, which may contain many KCL packages. We need to get a solution to download specific packages instead of all in a monorepo. | ||
|
||
## 2. User Worklow | ||
- Adding a Subdirectory Dependency via Command Line | ||
- Specifying a Subdirectory in `kcl.mod` | ||
- Adding a Subdirectory Dependency via Configuration File | ||
|
||
## 3. Command Line Inteface | ||
We will try to keep the command line interface as simple and straightforward as possible for adding a Git repository subdirectory as a dependency. The below steps show how a user can use the feature: | ||
|
||
- Adding a Dependency : | ||
The following command will lead to the addition of a dependency: | ||
`kcl mod add <repository_url> <subdirectory_path>` | ||
|
||
This command will add the specified subdirectory as a dependency in the current KCL project. | ||
|
||
- Non-interactive Method : | ||
In addition to the command line interface, users can specify subdirectory dependencies directly in the `kcl.mod` file, which can be particularly useful for automated environments. | ||
|
||
## 4. Example Use-case | ||
Considering the nginx-ingres module, on typing the command | ||
|
||
``` | ||
kcl mod add https://github.com/kcl-lang/modules/tree/main/nginx-ingress /restrict-ingress-anotations | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just have a question, why don't you just merge these two parameters, something like this?
I'm not sure what the problems will be behind such a merging, so you need to consider it or have a research. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done the changes, i did some research and gave thought to it but i don't think there won't be much of any problem. If any problems arise during implementation, i'll adjust accordingly. |
||
``` | ||
|
||
The following command will lead to the addition of restrict-ingress-anotations package to the current KCL project and will update the kcl.mod accordingly. | ||
|
||
Alternatively, for non-interactive environments, users can directly edit the `kcl.mod` file: | ||
``` | ||
[package] | ||
name = "test" | ||
edition = "v0.9.0" | ||
version = "0.0.1" | ||
|
||
[dependencies] | ||
my_dependency = { git = "https://github.com/example/repo", subdirectory = "path/to/package" } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The problem here is the same as above.
Any problem like this ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. made the changes |
||
|
||
``` | ||
|
||
## 5. Specifying how kcl.mod will specify the added subdirectories | ||
To support the specification of a subdirectory for dependencies that are sourced from Git repositories, we need to extend the kcl.mod file structure. This involves adding an optional `subdirectory` field under each dependency. This can be manually edited or automatically updated by the kcl mod add command. | ||
|
||
A sample kcl mod for the same would look like this. | ||
|
||
``` | ||
[package] | ||
name = "test" | ||
edition = "v0.9.0" | ||
version = "0.0.1" | ||
|
||
[dependencies] | ||
my_dependency = { git = "https://github.com/example/repo", subdirectory = "path/to/package" } | ||
``` | ||
|
||
## 6. Integration and the use of go-getter to download the specific subdirectories | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This chapter I think could need more details. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I'll add some on my own, though can you still point out some specific details (if any) you're looking for. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
The repoUrl field in the struct `CloneOptions` in kpm/pkg/git/git.go will be given the subdir url accordingly, which then downloads each selected subdirectory one by one. KCL currently uses go-getter to download using URL's with ease. | ||
|
||
We can also provide a fallback mechanism to download the entire repo if the subdirectory download fails repeatedly by something like - | ||
|
||
```Go | ||
err := downloadSubdir(repoUrl, subdir) | ||
if err != nil { | ||
log.Printf("Failed to download subdirectory, falling back to full repository: %v", err) | ||
return downloadRepo(repoUrl) | ||
} | ||
|
||
``` | ||
|
||
## 7. Conclusion | ||
By extending the kcl.mod file to include a subdirectory field for Git-based dependencies, users can now specify and manage dependencies that reside in specific subdirectories of a Git repository. This enhancement will enable kpm to download only the necessary parts of large repositories, significantly improving performance when dealing with monorepos. The user interface remains intuitive, and the implementation leverages Git's sparse-checkout feature to achieve the desired functionality even when used in automated CI/CD pipelines. |
Uh oh!
There was an error while loading. Please reload this page.