github.com/release-engineering/exodus-rsync@v1.11.2/internal/cmd/rsync.go (about)

     1  package cmd
     2  
     3  import (
     4  	"context"
     5  
     6  	"github.com/release-engineering/exodus-rsync/internal/args"
     7  	"github.com/release-engineering/exodus-rsync/internal/conf"
     8  	"github.com/release-engineering/exodus-rsync/internal/log"
     9  )
    10  
    11  func rsyncMain(ctx context.Context, cfg conf.Config, args args.Config) int {
    12  	logger := log.FromContext(ctx)
    13  	exitCode := 0
    14  
    15  	// Just run rsync. In the successful case, since we're doing execve system
    16  	// call, this will never return.
    17  	if err := ext.rsync.Exec(ctx, args); err != nil {
    18  		logger.WithField("error", err).Error("can't exec rsync")
    19  		exitCode = 94
    20  	}
    21  
    22  	return exitCode
    23  }
    24  
    25  func rsyncRaw(ctx context.Context, rawArgs []string) int {
    26  	logger := log.FromContext(ctx)
    27  	exitCode := 0
    28  
    29  	// Trim command name from raw argv.
    30  	args := rawArgs[1:]
    31  
    32  	// Just run rsync. In the successful case, since we're doing execve system
    33  	// call, this will never return.
    34  	if err := ext.rsync.RawExec(ctx, args); err != nil {
    35  		logger.WithField("error", err).Error("can't exec rsync")
    36  		exitCode = 94
    37  	}
    38  
    39  	return exitCode
    40  }