(ctx context.Context, dr *diffapi.DiffRequest)
| 75 | } |
| 76 | |
| 77 | func (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 | } |
nothing calls this directly
no test coverage detected