Skip to content
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 the docs directory with design report for kpm sparse checkout #334

Closed
wants to merge 36 commits into from
Closed
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
55ede5c
added the docs directory with design report for kpm sparse checkout
d4v1d03 May 24, 2024
2aff90f
slight changes
d4v1d03 May 25, 2024
a99b9a6
slight changes
d4v1d03 May 25, 2024
cacaaea
feat: add StoreModLockFile and StoreModFile to store modfile and lock…
zong-zhe May 27, 2024
3c2bdb7
fix: rm log 'adding' during updating the dependencies
zong-zhe May 27, 2024
629b9e2
fix: fix test case
zong-zhe May 27, 2024
313d038
feat: supports add dependencies by git branch
zong-zhe May 27, 2024
f2a1608
fix: fix failed ci
zong-zhe May 27, 2024
e6734fd
chore: bump kcl-go version to v0.9.0-alpha.2
zong-zhe May 27, 2024
5673c8b
fix: fix test cases
zong-zhe May 27, 2024
df7c07f
final design doc
d4v1d03 May 28, 2024
385bec4
added dictionary
d4v1d03 May 28, 2024
4f4f8bf
fix: fix missing dependencies when add dependencies from local path
zong-zhe May 28, 2024
1189907
some fix
d4v1d03 May 28, 2024
031049b
chore: bump kcl-go to v0.9.0-beta.1 and fix the get schema type impl …
Peefy May 29, 2024
0b24e22
test: update new override spec in the v0.9.0-beta.1 version
Peefy May 29, 2024
7d2fbda
chore: add depend bot
Peefy May 29, 2024
6ee91c0
chore: update reference to latest
Peefy May 29, 2024
8eb5882
chore: (deps): bump contributor-assistant/github-action
dependabot[bot] May 29, 2024
5b68d0a
chore: (deps): bump goreleaser/goreleaser-action from 4 to 5
dependabot[bot] May 29, 2024
b7ee3c8
chore: (deps): bump actions/checkout from 2 to 4
dependabot[bot] May 29, 2024
1dc8c21
chore: (deps): bump actions/setup-go from 2 to 5
dependabot[bot] May 29, 2024
e6817a3
Chore: (deps): bump github.com/onsi/ginkgo/v2 from 2.11.0 to 2.19.0
dependabot[bot] May 29, 2024
c8229aa
Chore: (deps): bump github.com/go-git/go-git/v5 from 5.11.0 to 5.12.0
dependabot[bot] May 29, 2024
eaee134
Chore: (deps): bump github.com/hashicorp/go-version from 1.6.0 to 1.7.0
dependabot[bot] May 29, 2024
5441529
reverted the useless changes
d4v1d03 May 29, 2024
87b3299
fix in doc
d4v1d03 May 29, 2024
bcb0a8e
minor changes regarding the deprecated kpm
d4v1d03 May 29, 2024
eb5492a
downloader pattern implemented with test added
d4v1d03 May 30, 2024
ab10bdc
Revert "downloader pattern implemented with test added"
d4v1d03 May 30, 2024
208e9f5
fixed DCO and committed doc final
d4v1d03 May 30, 2024
8db93ed
fixed failing test pkg/version
d4v1d03 May 30, 2024
09f16da
Revert "fixed DCO and committed doc final"
d4v1d03 May 30, 2024
aadc97e
Merge branch 'kcl-lang:main' into main
d4v1d03 Jun 2, 2024
512037a
seperated tests
d4v1d03 Jun 3, 2024
003f931
Revert "seperated tests"
d4v1d03 Jun 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions docs/kpm_sparse_checkout.md
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
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

kcl mod add https://github.com/kcl-lang/modules/tree/main/nginx-ingress/restrict-ingress-anotations

I'm not sure what the problems will be behind such a merging, so you need to consider it or have a research.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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" }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem here is the same as above.

[dependencies]
my_dependency = { git = "https://github.com/example/repo/path/to/package" }

Any problem like this ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This chapter I think could need more details.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.
Loading