Skip to content

Support for conversions between models of different versions #420

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

Merged

Conversation

macsux
Copy link
Contributor

@macsux macsux commented Apr 16, 2020

  • Allows conversions between models of different versions (v1 <--> v1beta1)
  • Explicit type conversion via type operators

The use of automapper allows ensuring that all field mappings are accounted for. This work is a precursor to introducing API methods that automatically select the endpoint and model based on the server k8s version.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Apr 16, 2020
@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Apr 16, 2020
@macsux macsux force-pushed the feature/version-converters branch from 414523c to 5b8c018 Compare April 16, 2020 18:38
@macsux
Copy link
Contributor Author

macsux commented Apr 16, 2020

/assign brendandburns

Copy link
Member

@tg123 tg123 left a comment

Choose a reason for hiding this comment

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

is this to support api call to lower version k8s server?


namespace k8s.Versioning
{
public class KubernetesVersionComparer : IComparer<string>
Copy link
Member

Choose a reason for hiding this comment

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

System.Version?
you may want to reuse it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

is this to support api call to lower version k8s server?

Yes, there's an open PR for creating and installed CRDs from me. I've ran into this problem when installing into my test cluster which is actually using an older version of CRDs. I'm refactoring that code to be based on this one, and automatically do conversion based on server version. I'm partly blocked on that one until we figure out what to do with #417


internal static void GetKubernetesMaps(IMapperConfigurationExpression cfg)
{
cfg.DisableConstructorMapping();
Copy link
Member

Choose a reason for hiding this comment

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

generated?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I generated it in LinqPad, but few of these maps had to be manually realigned. I guess I can put the autogeneration logic where there are no conflicts into the gen project and augment it with manual maps for where there are conflicts.

@macsux macsux force-pushed the feature/version-converters branch 6 times, most recently from 1d2d1b8 to 9de5644 Compare April 20, 2020 06:22
@macsux macsux force-pushed the feature/version-converters branch 3 times, most recently from 1004259 to 5e98f5a Compare April 23, 2020 21:17
@brendandburns
Copy link
Contributor

@macsux this seems like a reasonable start. Is this in a state where you'd like to merge it?

@tg123 any further comments on this PR?

@macsux
Copy link
Contributor Author

macsux commented May 18, 2020

Yes, it's good to go as far as I'm concerned

@brendandburns
Copy link
Contributor

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 20, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: brendandburns, macsux

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 20, 2020
@k8s-ci-robot k8s-ci-robot merged commit f1a3586 into kubernetes-client:master May 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants