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: manifest.go
    path of file: ./repos/sealer/pkg/imageengine/buildah
    
    the code of the file until where you have to start completion: // Copyright © 2022 Alibaba Group Holding Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package buildah

import (
	"context"
	"fmt"
	"os"
	"strings"

	"github.com/containers/storage"
	"github.com/pkg/errors"

	"github.com/containers/buildah/util"
	"github.com/containers/common/libimage"
	"github.com/containers/common/libimage/manifests"
	cp "github.com/containers/image/v5/copy"
	"github.com/containers/image/v5/manifest"
	"github.com/containers/image/v5/transports"
	"github.com/containers/image/v5/transports/alltransports"
	"github.com/containers/image/v5/types"
	"github.com/hashicorp/go-multierror"
	"github.com/opencontainers/go-digest"
	imgspecv1 "github.com/opencontainers/image-spec/specs-go/v1"
	"github.com/sealerio/sealer/pkg/define/options"
	"github.com/sirupsen/l
    
func (engine *Engine) addOneToManifestList(list manifests.List, imageSpec string, opts *options.ManifestAddOpts) error {
	store := engine.ImageStore()
	systemCxt := engine.SystemContext()

	ref, err := alltransports.ParseImageName(imageSpec)
	if err != nil {
		if ref, err = alltransports.ParseImageName(util.DefaultTransport + imageSpec); err != nil {
			// check if the local image exists
			if ref, _, err = util.FindImage(store, "", systemCxt, imageSpec); err != nil {
				return err
			}
		}
	}

	digestID, err := list.Add(getContext(), systemCxt, ref, opts.All)
	if err != nil {
		var storeErr error
		// Retry without a custom system context.  A user may want to add
		// a custom platform (see #3511).
		if ref, _, storeErr = util.FindImage(store, "", nil, imageSpec); storeErr != nil {
			logrus.Errorf("Error while trying to find image on local storage: %v", storeErr)
			return err
		}
		digestID, storeErr = list.Add(getContext(), systemCxt, ref, opts.All)
		if storeErr != nil {
			logrus.Errorf("Error while trying to add on manifest list: %v", storeErr)
			return err
		}
	}

	if opts.Os != "" {
		if err = list.SetOS(digestID, opts.Os); err != nil {
			return err
		}
	}
	if opts.OsVersion != "" {
		if err = list.SetOSVersion(digestID, opts.OsVersion); err != nil {
			return err
		}
	}
	if len(opts.OsFeatures) != 0 {
		if err = list.SetOSFeatures(digestID, opts.OsFeatures); err != nil {
			return err
		}
	}
	if opts.Arch != "" {
		if err = list.SetArchitecture(digestID, opts.Arch); err != nil {
			return err
		}
	}
	if opts.Variant != "" {
		if err = list.SetVariant(digestID, opts.Variant); err != nil {
			return err
		}
	}

	if len(opts.Annotations) != 0 {
		annotations := make(map[string]string)
		for _, annotationSpec := range opts.Annotations {
			spec := strings.SplitN(annotationSpec, "=", 2)
			if len(spec) != 2 {
				return fmt.Errorf("no value given for annotation %q", spec[0])
			}
			annotations[spec[0]] = spec[1]
		}
		if err = list.SetAnnotations(&digestID, annotations); err != nil {
			return err
		}
	}

	logrus.Infof("adding image %s successfully", imageSpec)

	return nil
}