You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: schema1.go
    path of file: ./repos/docker-ce/components/engine/vendor/github.com/moby/buildkit/util/imageutil
    
    the code of the file until where you have to start completion: package imageutil

import (
	"context"
	"encoding/json"
	"io/ioutil"
	"strings"
	"time"

	"github.com/containerd/containerd/remotes"
    
func convertSchema1ConfigMeta(in []byte) ([]byte, error) {
	type history struct {
		V1Compatibility string `json:"v1Compatibility"`
	}
	var m struct {
		History []history `json:"history"`
	}
	if err := json.Unmarshal(in, &m); err != nil {
		return nil, errors.Wrap(err, "failed to unmarshal schema1 manifest")
	}
	if len(m.History) == 0 {
		return nil, errors.Errorf("invalid schema1 manifest")
	}

	var img specs.Image
	if err := json.Unmarshal([]byte(m.History[0].V1Compatibility), &img); err != nil {
		return nil, errors.Wrap(err, "failed to unmarshal image from schema 1 history")
	}

	img.RootFS = specs.RootFS{
		Type: "layers", // filled in by exporter
	}
	img.History = make([]specs.History, len(m.History))

	for i := range m.History {
		var h v1History
		if err := json.Unmarshal([]byte(m.History[i].V1Compatibility), &h); err != nil {
			return nil, errors.Wrap(err, "failed to unmarshal history")
		}
		img.History[len(m.History)-i-1] = specs.History{
			Author:     h.Author,
			Comment:    h.Comment,
			Created:    &h.Created,
			CreatedBy:  strings.Join(h.ContainerConfig.Cmd, " "),
			EmptyLayer: (h.ThrowAway != nil && *h.ThrowAway) || (h.Size != nil && *h.Size == 0),
		}
	}

	dt, err := json.MarshalIndent(img, "", "   ")
	if err != nil {
		return nil, errors.Wrap(err, "failed to marshal schema1 config")
	}
	return dt, nil
}