-
Notifications
You must be signed in to change notification settings - Fork 213
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
Add mixin version when building the bundle #1952
Add mixin version when building the bundle #1952
Conversation
dfce1ad
to
19d4924
Compare
1948-bundle-mixin-version.mp4There are still some failing tests, perhaps because the bit to the |
Oh I'm so glad that you picked this up, thanks! 👍 |
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.
This looks right, maybe for the tests try running mage UpdateTestFiles
and see if they start passing?
@joshuabezaleel Let me know if you'd like help getting the build passing. |
I ran I tried to print the The
So sorry that it took me a really long time to reply to this one, Carolyn. Looking forward to hearing from you. |
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.
Heads up that one of the tests you are working with has changed on the release/v1 branch. You'll need to merge with the most recent changes in release/v1. Let me know if you have trouble and I can help fix the merge conflicts.
pkg/cnab/config-adapter/stamp.go
Outdated
stamp.Mixins = make(map[string]MixinRecord, len(c.Manifest.Mixins)) | ||
for _, m := range c.Manifest.Mixins { | ||
stamp.Mixins[m.Name] = MixinRecord{} | ||
stamp.Mixins = make(map[string]MixinRecord, len(c.Mixins)) |
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.
Here you are looping over the list of installed mixins, not the list of mixins used in the bundle. You need to loop over c.Manifest.Mixins
which are the mixins used by the bundle. Then match the mixin name against the list of installed mixins c.Mixins
to lookup the version number.
Feel free to rename c.Mixins to c.InstalledMixins to help clear up confusion between those two variables.
The other problem is that the existing unit tests that test this functionality are not passing in a list of installed mixins. You'll need to change the tests like so:
installedMixins := []mixin.Metadata{
{Name: "exec", VersionInfo: pkgmgmt.VersionInfo{Version: "v1.2.3"}},
}
a := NewManifestConverter(c.Context, m, nil, installedMixins)
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.
Once you are done, you either need to update the test files with mage updateTestFiles
or edit pkg/cnab/config-adapter/testdata/mybuns.bundle.json by hand so that it includes the mixin version number.
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.
Ah got it, I was confused first what was the difference between c.Manifest.Mixins
and c.Mixins
as they contains the same list of mixins but the latter contains the version info while the former doesn't, so I just simply grab the latter one. Now it just makes sense to me that we need to iterate over the mixins defined in the manifest first.
I tried to resolve the conflict and fix the unit test, hopefully it already pass. Definitely couldn't do any contributions without your kind guidance and thoughtful review, Carolyn. Thank you lots! 🙂
95a01f5
to
1c1e553
Compare
pkg/cnab/config-adapter/stamp.go
Outdated
@@ -109,7 +118,7 @@ func (c *ManifestConverter) DigestManifest() (string, error) { | |||
v := pkg.Version | |||
data = append(data, v...) | |||
|
|||
for _, m := range c.Mixins { | |||
for _, m := range c.InstalledMixins { |
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 this may be a bug here (not caused by your change here).
The digest of the manifest is supposed to represent the mixins used by the bundle. But this loop is adding all installed mixins into the digest which is incorrect. Installed mixins has all mixins installed, including those not used by the current bundle.
Can you make a function out of that for loop above that finds the version of only mixins that are used by the bundle, and we can reuse that function here as well to fix the bug.
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.
Updated 😄
"mixins": { | ||
"exec": {} | ||
}, | ||
"mixins": {}, |
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.
This doesn't have any mixins listed, along with their version (which is the point of the PR). Can you identify which test goes with this file and modify it so that the list of installed mixins is populated. This file should look like this when you have it right:
"mixins": {"exec" {"version": "v1.2.3"}}
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 left some comments with a few more changes we need to make before this is ready
471754d
to
2efc00a
Compare
Signed-off-by: joshuabezaleel <[email protected]>
Signed-off-by: joshuabezaleel <[email protected]>
Signed-off-by: joshuabezaleel <[email protected]>
- Compare mixins installed with the ones defined in the manifest and then retrieved the version info - Update test to include mixin's version Signed-off-by: joshuabezaleel <[email protected]>
Signed-off-by: joshuabezaleel <[email protected]>
Signed-off-by: joshuabezaleel <[email protected]>
Signed-off-by: joshuabezaleel <[email protected]>
Signed-off-by: joshuabezaleel <[email protected]>
Signed-off-by: joshuabezaleel <[email protected]>
Signed-off-by: joshuabezaleel <[email protected]>
f31ef9b
to
0fc6f14
Compare
@joshuabezaleel Just a general request for pull requests going forward, when possible do not use rebase after someone has started reviewing it. When you add new commits that incorporate the requested feedback, then I can review just the new commit you pushed. When rebase is used, the reviewer has to review the entire PR from scratch since every commit has changed. Rereading every single file to make sure that they are correct, every time you make a change makes the review process a lot work more for the reviewers. Don't worry about lots of commits, you can either let me know that you want to clean up the commits once the review is complete, or what I usually do is squash the PR when I merge it so that it's a single commit. |
@carolynvs Ah, truly sorry for the inconvenience. I really thought at the beginning it was the other way around, that rebasing would make it more helpful for the reviewer, since it keeps the log straight.
But yeah, I haven't thought of this earlier. Makes perfect sense.
Now that I learned it gave the opposite effect, will definitely keep this in mind for future PRs. Thank you lots for the feedback, Carolyn! |
Yup, doing a merge and resolving the conflicts that way are totally fine. |
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.
Thanks for sticking with it and getting this fix in!
data = append(append(data, m.Name...), m.Version...) | ||
usedMixinsVersion := c.getUsedMixinsVersion() | ||
for usedMixinName, usedMixinVersion := range usedMixinsVersion { | ||
data = append(append(data, usedMixinName...), usedMixinVersion...) |
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 the way we are concatenating these bytes is already pretty odd but I don't want to have you try to fix that in this PR since it's unrelated. Once your PR is in, I'll submit a PR to clean that up.
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.
Is it because it was appended byte by byte? Should we transform everything to string first, append it one by one, then cast the finished version of it to []byte
at the end?
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.
It's just hard to read and when thinking about the digest as a whole, hard to follow what we are hashing here.
What does this change
Append the version of the mixin when building the bundle.
What issue does it fix
Closes #1948
Notes for the reviewer
Checklist
Reviewer Checklist