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

Manage merge keys of top-level lists in a more consistent way #122

Merged
merged 33 commits into from
Sep 2, 2020

Conversation

kadel
Copy link
Member

@kadel kadel commented Aug 20, 2020

What does this PR do?

  • moves component and command merge keys (name and id) to top-level
  • This change requires updates to utility functions for handling unions (union.go). I was not able to found if this is being used somewhere. So I tried to write unit tests for it. I'm not sure if those functions actually ever worked correctly :-(

TODO:

  • update union.go and tests

What issues does this PR fix or reference?

fixes #102

Is your PR tested? Consider putting some instruction how to test your changes

Docs PR

@amisevsk
Copy link
Contributor

@kadel I believe the union/etc. functions will be updated in #98, if you feel like reviewing a 10k PR ;). That PR also adds a good amount of tests.

Copy link
Contributor

@amisevsk amisevsk left a comment

Choose a reason for hiding this comment

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

Generally LGTM, just a couple comments.

It looks like we'll need to figure out how to best merge this vs #98, as they'll likely conflict at least somewhat. Probably it makes sense to merge this one and figure out #98 afterwards, since David is on PTO anyways.

@kadel
Copy link
Member Author

kadel commented Aug 21, 2020

@amisevsk with regards to #111 Should I move all changes in this PR to v1alpha2?

@kadel kadel force-pushed the top-level-merge-key branch from 4db2ec5 to 8cc8418 Compare August 21, 2020 14:39
@amisevsk
Copy link
Contributor

@kadel Ah yeah I can't believe I forgot that, given that I opened the blocker issue. Yes, these changes should be applied to a v1alpha2 version -- sorry for the hassle.

@kadel
Copy link
Member Author

kadel commented Aug 24, 2020

@kadel Ah yeah I can't believe I forgot that, given that I opened the blocker issue. Yes, these changes should be applied to a v1alpha2 version -- sorry for the hassle.

No problem. I realized that after I opened this PR myself :-/ . Will update it today.

@davidfestal
Copy link
Collaborator

@kadel @amisevsk I merged #98 first, precisely because of the incompatibility this PR introduces in the v1alpha1 K8S API. So the merged overriding implementation supports v1alpha1, and could be then updated to also support v1alpha2 I assume.

@davidfestal
Copy link
Collaborator

davidfestal commented Aug 24, 2020

@kadel Ah yeah I can't believe I forgot that, given that I opened the blocker issue. Yes, these changes should be applied to a v1alpha2 version -- sorry for the hassle.

No problem. I realized that after I opened this PR myself :-/ . Will update it today.

So after discussing the situation again, the plan would be:

  1. Create a branch (or tag) on master with the existing v1alpha1 API, and let the workspace controller depend on this commit.
  2. Create and merge a distinct PR that would globally rename v1alpha1 folder and all v1alpha1mentions to v1alpha2 on the master branch
  3. Update this PR to merge it with the changes made in PR Implementation of parent and plugin overriding #98
  4. Merge this branch on master.
  5. On the workspace controller side, start working on the reintegration of the v1alpha1 + conversion webhooks, on a distinct PR branch
  6. When this last PR is merged, the workspace controller would be able to support both v1alpha1 and v1alpha2 with the conversion webhook.

So the main point here is that this PR should wait for the steps 1 and 2 to be finished.

@amisevsk please complete or correct this if necessary.

@amisevsk
Copy link
Contributor

@amisevsk please complete or correct this if necessary.

The above outline is basically it. There's some grey area about how integration will work down the line, but the main idea is to "fix" v1alpha1 in a tag/branch, and only support v1alpha2 in the repo for now, with the goal of implementing converstion webhooks, etc. before "releasing" v1alpha2. The reason I think we can do this is because the devworkspace controller depends on the api and crds, whereas odo only depends on the APIs.

visitorValue := reflect.ValueOf(visitor)
unionValue := reflect.ValueOf(union)
oneMemberPresent := false
typeOfVisitor := visitorValue.Type()
for i := 0; i < visitorValue.NumField(); i++ {
unionMemberToRead := typeOfVisitor.Field(i).Name
unionMember := unionValue.FieldByName(unionMemberToRead)
if !unionMember.IsNil() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

In fact the function that should be called instead of IsNil is IsZero. I already fixed that in PR #98.

@davidfestal davidfestal changed the title [WIP] Manage merge keys of top-level lists in a more consistent way Manage merge keys of top-level lists in a more consistent way Aug 26, 2020
@davidfestal
Copy link
Collaborator

@kadel I removed the WIP flag since I reworked this PR to:

  • integrate some required refactoring of the previously-merged PR Implementation of parent and plugin overriding #98
  • rebase on master (which includes being now based on the new v1alpha2 K8S API)
  • add (as the last commit of this PR) the ability to override the starterProjects list in a child devfile.

@amisevsk You might want to review the PR again.

kadel added a commit to kadel/registry-old that referenced this pull request Aug 28, 2020
... to avoid referencing the top-level lists that should be merged by name.

Signed-off-by: David Festal <[email protected]>
Signed-off-by: David Festal <[email protected]>
Signed-off-by: David Festal <[email protected]>
Copy link
Contributor

@amisevsk amisevsk left a comment

Choose a reason for hiding this comment

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

I have significant issues with the implementation of keys and unions as it's implemented currently. In addition, the messy commit history and big changes in this PR make reviewing that code very difficult (I can't even cleanly leave multi-line comments).

I think to unblock the core functionality of this PR, this PR should remove /pkg/utils and related api files from the repo, and a new PR should be created that re-adds those files to allow a full, straightforward review.

davidfestal and others added 14 commits September 1, 2020 10:51
cf [review comment](devfile#122 (comment))

Signed-off-by: David Festal <[email protected]>
cf [review comment](devfile#122 (comment))

Signed-off-by: David Festal <[email protected]>
... And use `Keyed` instead of `string` as the item type
in the `TopLevelLists` type

Signed-off-by: David Festal <[email protected]>
Signed-off-by: David Festal <[email protected]>
according to this [review comment](devfile#122 (comment))

Signed-off-by: David Festal <[email protected]>
Signed-off-by: David Festal <[email protected]>
... according to the following
[review coment](devfile#122 (comment))

Signed-off-by: David Festal <[email protected]>
Signed-off-by: David Festal <[email protected]>
Simplify checkKeys function in overriding util by separating out the
merging maps step

Signed-off-by: Angel Misevski <[email protected]>
@amisevsk
Copy link
Contributor

amisevsk commented Sep 1, 2020

@davidfestal I've added ef7ba59 to simplify checkKeys as we discussed (GitHub has once again chosen to break the readability of the diff by matching close parens 🙃). PTAL if you have a moment.

cc: @kadel

Copy link
Contributor

@amisevsk amisevsk left a comment

Choose a reason for hiding this comment

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

Bit strange to approve a PR after I've committed to it, but it LGTM at this point.

Fix tests that check error messages to ignore order, since Go iterates
through maps in a random order.

Signed-off-by: Angel Misevski <[email protected]>
Copy link
Member Author

@kadel kadel left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@davidfestal davidfestal merged commit 6cb3034 into devfile:master Sep 2, 2020
kadel added a commit to kadel/registry-old that referenced this pull request Sep 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Manage merge keys of top-level lists in a more consistent way
4 participants