MCPcopy
hub / github.com/containerd/containerd / Diff

Method Diff

contrib/diffservice/service.go:77–111  ·  view source on GitHub ↗
(ctx context.Context, dr *diffapi.DiffRequest)

Source from the content-addressed store, hash-verified

75}
76
77func (s *service) Diff(ctx context.Context, dr *diffapi.DiffRequest) (*diffapi.DiffResponse, error) {
78 if s.comparer == nil {
79 return nil, errgrpc.ToGRPC(errdefs.ErrNotImplemented)
80 }
81 var (
82 ocidesc ocispec.Descriptor
83 err error
84 aMounts = mount.FromProto(dr.Left)
85 bMounts = mount.FromProto(dr.Right)
86 )
87
88 var opts []diff.Opt
89 if dr.MediaType != "" {
90 opts = append(opts, diff.WithMediaType(dr.MediaType))
91 }
92 if dr.Ref != "" {
93 opts = append(opts, diff.WithReference(dr.Ref))
94 }
95 if dr.Labels != nil {
96 opts = append(opts, diff.WithLabels(dr.Labels))
97 }
98 if dr.SourceDateEpoch != nil {
99 tm := dr.SourceDateEpoch.AsTime()
100 opts = append(opts, diff.WithSourceDateEpoch(&tm))
101 }
102
103 ocidesc, err = s.comparer.Compare(ctx, aMounts, bMounts, opts...)
104 if err != nil {
105 return nil, errgrpc.ToGRPC(err)
106 }
107
108 return &diffapi.DiffResponse{
109 Diff: oci.DescriptorToProto(ocidesc),
110 }, nil
111}

Callers

nothing calls this directly

Calls 7

FromProtoFunction · 0.92
WithMediaTypeFunction · 0.92
WithReferenceFunction · 0.92
WithLabelsFunction · 0.92
WithSourceDateEpochFunction · 0.92
DescriptorToProtoFunction · 0.92
CompareMethod · 0.65

Tested by

no test coverage detected