Skip to content

Commit

Permalink
slight changes
Browse files Browse the repository at this point in the history
Signed-off-by: d4v1d03 <a_pandey1@ce.iitr.ac.in>
  • Loading branch information
d4v1d03 committed May 25, 2024
1 parent 55ede5c commit 23d4e41
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions docs/kpm_sparse_checkout.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,35 @@
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. Design research
A solution to this problem lies onto using GithubAPIs for kpm. The API can be used to fetch repository contents and then processing the response data to list the sub-directories of a specific monorepo. On listing the subdirectories, we can make the user toggle between different packages and press *space* to select the packages they want according to their project.
A solution to this problem lies onto using GithubAPIs for kpm. The API can be used to fetch repository contents and then processing the response data to list the sub-directories of a specific monorepo.

## 3. Implementation steps
## 3. User Interface
The user will have to enter the command
```
kpm add <github_repo_url>
```
to get the list of all the subdirectories(recursively all the directories which had a kcl.mod file in it). The user now has to toggle between the output subdirectories and press 'space' to select the ones which they want to keep.

Considering the nginx-ingres module, on typing the command

```
kpm add <url of nginx-ingres>
```
kpm will list the two subdirectories as
- restrict-ingress-annotations
- restrict-ingress-paths

The user now has to select which package they want according to their project.

The experience for the user will be completely different than any other package manager installing packages or package subdirectories.

## 4. Implementation steps for the functionality
- setting up the Github API Access
- make a request to the endpoint `GET /repos/{owner}/{repo}/contents/{path}`
- parsing the JSON response to identify directories and subdirectories
- recursively fetch and process the contents of each directory to get a full list of subdirectories
- integrate it with the kpm code
- integrate it with the kpm code and update the kcl.mod accordingly

## 5. Integration and the use of go-getter to download the specific subdirectories

we will use Go's standard libraries for HTTP requests and JSON decoding, might need to handle additional error and edge cases.
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.

0 comments on commit 23d4e41

Please sign in to comment.