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

Add From/ToProto helpers #8757

Merged
merged 4 commits into from Jul 3, 2023
Merged

Conversation

dcantah
Copy link
Member

@dcantah dcantah commented Jun 28, 2023

In many of the core packages we have local types, and then their corresponding over the wire structures used for folks interacting via GRPC. In all these cases we have duplicated code that handles the conversions from our internal types to the generated structures. Ideally these conversions could just live next to the definitions for the internal types, and that's what this change sets out to do. I split this into four commits to make it easier if some of these aren't wanted, but the commits contain helpers to do conversions for:

  1. mount (Mount)
  2. oci (Descriptor)
  3. snapshots (Kind, Usage, Info)
  4. platforms ([]Platform)

Helpers to convert from containerd's [Mount] to its protobuf structure for
[Mount] and vice-versa appear three times. It seems sane to just expose
this facility in /mount.

Signed-off-by: Danny Canter <danny@dcantah.dev>
oci/spec.go Outdated Show resolved Hide resolved
Helpers to convert from the OCI image specs [Descriptor] to its protobuf
structure for Descriptor and vice-versa appear three times. It seems sane
to just expose this facility in /oci.

Signed-off-by: Danny Canter <danny@dcantah.dev>
Helpers to convert from snapshot types to their protobuf structures and
vice-versa appear three times. It seems sane to just expose this facility
in the snapshots pkg. From/ToKind weren't used anywhere but doesn't hurt to
round out the types by exposing them.

Signed-off-by: Danny Canter <danny@dcantah.dev>
Copy link
Member

@djdongjin djdongjin left a comment

Choose a reason for hiding this comment

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

LGTM (just left a typo and a nit), thanks!

platforms/platforms.go Outdated Show resolved Hide resolved
services/introspection/local.go Outdated Show resolved Hide resolved
Helpers to convert from a slice of platforms to our protobuf representation
and vice-versa appear a couple times. It seems sane to just expose this facility
in the platforms pkg.

Signed-off-by: Danny Canter <danny@dcantah.dev>
Copy link
Member

@djdongjin djdongjin left a comment

Choose a reason for hiding this comment

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

LGTM

@dcantah
Copy link
Member Author

dcantah commented Jun 29, 2023

Oof: E: Failed to fetch http://azure.archive.ubuntu.com/ubuntu/pool/main/g/gcc-9-cross/gcc-9-arm-linux-gnueabihf-base_9.4.0-1ubuntu1~20.04.1cross2_amd64.deb Connection failed [IP: 52.154.174.208 80]

@kzys kzys merged commit 099d2e7 into containerd:main Jul 3, 2023
45 checks passed
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.

None yet

5 participants