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: parse.go
    path of file: ./repos/moby/vendor/github.com/moby/buildkit/cache/remotecache/v1
    
    the code of the file until where you have to start completion: package cacheimport

import (
	"encoding/json"

	"github.com/moby/buildkit/solver"
	"github.com/moby/buildkit/util/contentutil"
	ocispecs "github.com/opencontainers/image-spec/specs-go/v1"
	"github.com/pkg/errors"
)

func Parse(configJSON []byte, provider DescriptorProvider, t solver.CacheExporterTarget) error {
	var config CacheConfig
	if err := json.Unmarshal(configJSON, &config); err != nil {
		return errors.WithStack(err)
	}

	return ParseConfig(config, provider, t)
}

func ParseConfig(config CacheConfig, provider DescriptorProvider, t solver.CacheExporterTarget) error {
	cache := map[int]solver.CacheExporterRecord{}

	for i := range config.Records {
		if _, err := parseRecord(config, i, provider, t, cache); err != nil {
			return err
		}
	}
	return nil
}

func parseRecord(cc CacheConf
    
func getRemoteChain(layers []CacheLayer, idx int, provider DescriptorProvider, visited map[int]struct{}) (*solver.Remote, error) {
	if _, ok := visited[idx]; ok {
		return nil, errors.Errorf("invalid looping layer")
	}
	visited[idx] = struct{}{}

	if idx < 0 || idx >= len(layers) {
		return nil, errors.Errorf("invalid layer index %d", idx)
	}

	l := layers[idx]

	descPair, ok := provider[l.Blob]
	if !ok {
		return nil, nil
	}

	var r *solver.Remote
	if l.ParentIndex != -1 {
		var err error
		r, err = getRemoteChain(layers, l.ParentIndex, provider, visited)
		if err != nil {
			return nil, err
		}
		if r == nil {
			return nil, nil
		}
		r.Descriptors = append(r.Descriptors, descPair.Descriptor)
		mp := contentutil.NewMultiProvider(r.Provider)
		mp.Add(descPair.Descriptor.Digest, descPair)
		r.Provider = mp
		return r, nil
	}
	return &solver.Remote{
		Descriptors: []ocispecs.Descriptor{descPair.Descriptor},
		Provider:    descPair,
	}, nil
}