Remove duplicated writeIndex func
Signed-off-by: Jin Dong <djdongjin95@gmail.com>
This commit is contained in:
16
task.go
16
task.go
@@ -17,9 +17,7 @@
|
||||
package containerd
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
@@ -511,7 +509,7 @@ func (t *task) Checkpoint(ctx context.Context, opts ...CheckpointTaskOpts) (Imag
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
desc, err := t.writeIndex(ctx, &index)
|
||||
desc, err := writeIndex(ctx, &index, t.client, t.id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -662,18 +660,6 @@ func (t *task) checkpointImage(ctx context.Context, index *v1.Index, image strin
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *task) writeIndex(ctx context.Context, index *v1.Index) (d v1.Descriptor, err error) {
|
||||
labels := map[string]string{}
|
||||
for i, m := range index.Manifests {
|
||||
labels[fmt.Sprintf("containerd.io/gc.ref.content.%d", i)] = m.Digest.String()
|
||||
}
|
||||
buf := bytes.NewBuffer(nil)
|
||||
if err := json.NewEncoder(buf).Encode(index); err != nil {
|
||||
return v1.Descriptor{}, err
|
||||
}
|
||||
return writeContent(ctx, t.client.ContentStore(), v1.MediaTypeImageIndex, t.id, buf, content.WithLabels(labels))
|
||||
}
|
||||
|
||||
func writeContent(ctx context.Context, store content.Ingester, mediaType, ref string, r io.Reader, opts ...content.Opt) (d v1.Descriptor, err error) {
|
||||
writer, err := store.Writer(ctx, content.WithRef(ref))
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user