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

Proposed solution for #508 #562

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
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
32 changes: 32 additions & 0 deletions research/design-doc/push_cmd_enhancement.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Enhancement Proposal: Validation of Required Fields (`name` and `version`) in `kcl.mod` During Push Operations

### Author:- Ravjot Singh

## Overview

The enhancement focuses on ensuring that the `kcl.mod` file contains the essential fields `name` and `version` before a KCL package is pushed to an OCI registry. This validation aims to improve package integrity, prevent errors during the push process, and maintain consistency within the OCI repository.


## Background

The `kpm push` command is utilized to upload KCL packages to an OCI (Open Container Initiative) registry. Currently, the command may proceed without verifying the presence of critical metadata fields (`name` and `version`) in the `kcl.mod` file. This omission can lead to incomplete or inconsistent packages being pushed, which may cause issues in package management and dependency resolution.

## Proposed Solution

### Design

To address the issue, the enhancement involves adding validation checks for the `name` and `version` fields within the `kcl.mod` file. These checks will be integrated into the functions responsible for loading and pushing the package, ensuring that validation occurs at the appropriate stage of the push process.

**Key Components:**

1. **Validation Logic**: Verify the presence of `name` and `version` in `kcl.mod` immediately after loading the package.
2. **Error Handling**: Provide clear and descriptive error messages if validation fails, guiding users to rectify the issues.
3. **Code Integration**: Embed the validation within the `pushCurrentPackage` and `pushTarPackage` functions to maintain separation of concerns and avoid redundant package loading.





## Conclusion

Implementing validation for the `name` and `version` fields in the `kcl.mod` file during push operations is a critical enhancement that ensures package integrity, consistency, and reliability within the OCI registry. By integrating validation directly into the package loading functions (`pushCurrentPackage` and `pushTarPackage`), the solution maintains a clean separation of concerns, avoids redundant operations, and provides clear feedback to users.