Remove gogoproto.customtype

gogoproto.customtype is used to have go-digest.Digest instead of string.
While it is convinient, protoc-gen-go doesn't support the extension
and that blocks #6564.

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
This commit is contained in:
Kazuyoshi Kato
2022-03-18 21:20:58 +00:00
parent 0c701654a1
commit 3eeeb9429a
22 changed files with 296 additions and 335 deletions

View File

@@ -36,7 +36,7 @@ func (ra *remoteReaderAt) Size() int64 {
func (ra *remoteReaderAt) ReadAt(p []byte, off int64) (n int, err error) {
rr := &contentapi.ReadContentRequest{
Digest: ra.digest,
Digest: ra.digest.String(),
Offset: off,
Size_: int64(len(p)),
}

View File

@@ -42,7 +42,7 @@ func NewContentStore(client contentapi.ContentClient) content.Store {
func (pcs *proxyContentStore) Info(ctx context.Context, dgst digest.Digest) (content.Info, error) {
resp, err := pcs.client.Info(ctx, &contentapi.InfoRequest{
Digest: dgst,
Digest: dgst.String(),
})
if err != nil {
return content.Info{}, errdefs.FromGRPC(err)
@@ -81,7 +81,7 @@ func (pcs *proxyContentStore) Walk(ctx context.Context, fn content.WalkFunc, fil
func (pcs *proxyContentStore) Delete(ctx context.Context, dgst digest.Digest) error {
if _, err := pcs.client.Delete(ctx, &contentapi.DeleteContentRequest{
Digest: dgst,
Digest: dgst.String(),
}); err != nil {
return errdefs.FromGRPC(err)
}
@@ -119,7 +119,7 @@ func (pcs *proxyContentStore) Status(ctx context.Context, ref string) (content.S
UpdatedAt: status.UpdatedAt,
Offset: status.Offset,
Total: status.Total,
Expected: status.Expected,
Expected: digest.Digest(status.Expected),
}, nil
}
@@ -152,7 +152,7 @@ func (pcs *proxyContentStore) ListStatuses(ctx context.Context, filters ...strin
UpdatedAt: status.UpdatedAt,
Offset: status.Offset,
Total: status.Total,
Expected: status.Expected,
Expected: digest.Digest(status.Expected),
})
}
@@ -200,7 +200,7 @@ func (pcs *proxyContentStore) negotiate(ctx context.Context, ref string, size in
Action: contentapi.WriteActionStat,
Ref: ref,
Total: size,
Expected: expected,
Expected: expected.String(),
}); err != nil {
return nil, 0, err
}
@@ -215,7 +215,7 @@ func (pcs *proxyContentStore) negotiate(ctx context.Context, ref string, size in
func infoToGRPC(info content.Info) contentapi.Info {
return contentapi.Info{
Digest: info.Digest,
Digest: info.Digest.String(),
Size_: info.Size,
CreatedAt: info.CreatedAt,
UpdatedAt: info.UpdatedAt,
@@ -225,7 +225,7 @@ func infoToGRPC(info content.Info) contentapi.Info {
func infoFromGRPC(info contentapi.Info) content.Info {
return content.Info{
Digest: info.Digest,
Digest: digest.Digest(info.Digest),
Size: info.Size_,
CreatedAt: info.CreatedAt,
UpdatedAt: info.UpdatedAt,

View File

@@ -45,7 +45,7 @@ func (rw *remoteWriter) send(req *contentapi.WriteContentRequest) (*contentapi.W
if err == nil {
// try to keep these in sync
if resp.Digest != "" {
rw.digest = resp.Digest
rw.digest = digest.Digest(resp.Digest)
}
}
@@ -92,7 +92,7 @@ func (rw *remoteWriter) Write(p []byte) (n int, err error) {
rw.offset += int64(n)
if resp.Digest != "" {
rw.digest = resp.Digest
rw.digest = digest.Digest(resp.Digest)
}
return
}
@@ -115,7 +115,7 @@ func (rw *remoteWriter) Commit(ctx context.Context, size int64, expected digest.
Action: contentapi.WriteActionCommit,
Total: size,
Offset: rw.offset,
Expected: expected,
Expected: expected.String(),
Labels: base.Labels,
})
if err != nil {
@@ -126,11 +126,12 @@ func (rw *remoteWriter) Commit(ctx context.Context, size int64, expected digest.
return fmt.Errorf("unexpected size: %v != %v", resp.Offset, size)
}
if expected != "" && resp.Digest != expected {
actual := digest.Digest(resp.Digest)
if expected != "" && actual != expected {
return fmt.Errorf("unexpected digest: %v != %v", resp.Digest, expected)
}
rw.digest = resp.Digest
rw.digest = actual
rw.offset = resp.Offset
return nil
}