func RunPromoteFiles(ctx context.Context, options PromoteFilesOptions) error {
	manifests, err := ReadManifests(options)
	if err != nil {
		return err
	}
	if options.Confirm {
		fmt.Fprintf(
			options.Out,
			"********** START **********\n",
		)
	} else {
		fmt.Fprintf(
			options.Out,
			"********** START (DRY RUN) **********\n",
		)
	}
	var ops []filepromoter.SyncFileOp
	for _, manifest := range manifests {
		promoter := &filepromoter.ManifestPromoter{
			Manifest:          manifest,
			Confirm:           options.Confirm,
			UseServiceAccount: options.UseServiceAccount,
		}
		o, err := promoter.BuildOperations(ctx)
		if err != nil {
			return fmt.Errorf("error building operations: %v", err)
		}
		ops = append(ops, o...)
	}
	var errors []error
	for _, op := range ops {
		if _, err := fmt.Fprintf(options.Out, "%v\n", op); err != nil {
			errors = append(
				errors,
				fmt.Errorf("error writing to output: %v", err),
			)
		}
		if options.Confirm {
			if err := op.Run(ctx); err != nil {
				logrus.Warnf("error copying file: %v", err)
				errors = append(errors, err)
			}
		}
	}
	if len(errors) != 0 {
		fmt.Fprintf(
			options.Out,
			"********** FINISHED WITH ERRORS **********\n")
		for _, err := range errors {
			fmt.Fprintf(options.Out, "%v\n", err)
		}
		return errors[0]
	}
	if options.Confirm {
		fmt.Fprintf(
			options.Out,
			"********** FINISHED **********\n",
		)
	} else {
		fmt.Fprintf(
			options.Out,
			"********** FINISHED (DRY RUN) **********\n",
		)
	}
	return nil
}
RunPromoteFiles executes a file promotion command
package promobot
import (
	"context"
	"fmt"
	"io"
	"os"
	"path/filepath"
	"sort"
	"github.com/sirupsen/logrus"
	"golang.org/x/xerrors"
	api "sigs.k8s.io/promo-tools/v3/api/files"
	"sigs.k8s.io/promo-tools/v3/filepromoter"
)
type PromoteFilesOptions struct {
	FilestoresPath string
	FilesPath string
	ManifestsPath string
	Confirm bool
	UseServiceAccount bool
	Out io.Writer
}
func (o *PromoteFilesOptions) PopulateDefaults() {
	o.Confirm = false
	o.UseServiceAccount = false
	o.Out = os.Stdout
}