-
Notifications
You must be signed in to change notification settings - Fork 49
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
feat: support adding third-party dependencies from git repo with the version
field
#405
Conversation
Sum string `json:"-" toml:"sum,omitempty"` | ||
// The actual local path of the package. | ||
// In vendor mode is "current_kcl_package/vendor" | ||
// In non-vendor mode is "$KCL_PKG_PATH" | ||
LocalFullPath string `json:"manifest_path" toml:"-"` | ||
downloader.Source `json:"-"` | ||
Version string `json:"version,omitempty" toml:"version,omitempty"` |
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 change here ?
@@ -85,7 +85,17 @@ func (dep *Dependency) MarshalTOML() string { | |||
source := dep.Source.MarshalTOML() | |||
var sb strings.Builder | |||
if len(source) != 0 { | |||
sb.WriteString(fmt.Sprintf(DEP_PATTERN, dep.Name, source)) | |||
sourceWithoutBrace := strings.TrimSuffix(source, "}") |
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 that the logic of serializing kcl.mod to toml is incorrect, maybe you should add some test cases to make sure this is correct. Because from a functional point of view, you are only adding a field, why are you adding "{}" again here ?
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.
if we directly pass it as a field it the kpm.mod
will look like,
[dependencies]
catalog = { git = "https://github.com/KusionStack/catalog.git", tag=“0.0.3”}, version = “0.1.1”
as the other fields are comin in from git source and if we try to append the version in the git source then the kpm.mod.lock
will have two version field, as done in this PR(#406 )
cc @zong-zhe
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 @Gmin2 😃
I see what you mean; what I mean is that if you want to change the process of generating "{}" to the upper level, you should remove the original code for generating "{}" instead of just trimming the string.
I suggest that you write some unit tests for your functional changes first so that I can intuitively judge whether your changes meet the expectations based on the unit tests and then review your specific implementation.
And, add more test cases. |
1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".):
Fixes #266
2. What is the scope of this PR (e.g. component or file name):
pkg/client/client.go
pkg/package/modfile.go
pkg/package/toml.go
3. Provide a description of the PR(e.g. more details, effects, motivations or doc link):
TODO:
![image](https://private-user-images.githubusercontent.com/127925465/352772311-d16065ad-5e58-42ae-bb8f-c35f2975c7ed.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0MTk0MzgsIm5iZiI6MTczOTQxOTEzOCwicGF0aCI6Ii8xMjc5MjU0NjUvMzUyNzcyMzExLWQxNjA2NWFkLTVlNTgtNDJhZS1iYjhmLWMzNWYyOTc1YzdlZC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjEzJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxM1QwMzU4NThaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1kMjM3NGY4NjI0NGI0ZjA1MzdlMzc0ODc2YWFkOTc1NzU2OWQyNWFkYzdlMWRkOTdiNTVmODA5ZTQ2MzRiYjUxJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.Or6hDBCU3DbLhr32t4CPQ9YZSCORRVTYPC3koRR34zU)
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:
TODO