MCPcopy Create free account
hub / github.com/containers/fetchit / processFileTransfer

Method processFileTransfer

pkg/engine/fetchit.go:566–612  ·  view source on GitHub ↗
(ctx context.Context, target *Target, skew int)

Source from the content-addressed store, hash-verified

564}
565
566func (hc *FetchitConfig) processFileTransfer(ctx context.Context, target *Target, skew int) {
567 time.Sleep(time.Duration(skew) * time.Millisecond)
568 target.mu.Lock()
569 defer target.mu.Unlock()
570
571 ft := target.Methods.FileTransfer
572 initial := ft.initialRun
573 mo := &SingleMethodObj{
574 Conn: hc.conn,
575 Method: fileTransferMethod,
576 Target: target,
577 }
578 if initial {
579 err := hc.getClone(target)
580 if err != nil {
581 klog.Errorf("Failed to clone repo at %s for target %s: %v", target.Url, target.Name, err)
582 return
583 }
584 }
585
586 latest, err := hc.GetLatest(mo.Target)
587 if err != nil {
588 klog.Errorf("Failed to get latest commit: %v", err)
589 return
590 }
591
592 current, err := hc.GetCurrent(mo.Target, mo.Method)
593 if err != nil {
594 klog.Errorf("Failed to get current commit: %v", err)
595 return
596 }
597
598 if latest != current {
599 err = hc.Apply(ctx, mo, current, latest, mo.Target.Methods.FileTransfer.TargetPath, nil)
600 if err != nil {
601 klog.Errorf("Failed to apply changes: %v", err)
602 return
603 }
604
605 hc.UpdateCurrent(ctx, target, mo.Method, latest)
606 klog.Infof("Moved filetransfer from %s to %s for target %s", current, latest, target.Name)
607 } else {
608 klog.Infof("No changes applied to target %s this run, filetransfer currently at %s", target.Name, current)
609 }
610
611 ft.initialRun = false
612}
613
614func (hc *FetchitConfig) processKube(ctx context.Context, target *Target, skew int) {
615 time.Sleep(time.Duration(skew) * time.Millisecond)

Callers

nothing calls this directly

Calls 5

getCloneMethod · 0.95
GetLatestMethod · 0.95
GetCurrentMethod · 0.95
ApplyMethod · 0.95
UpdateCurrentMethod · 0.95

Tested by

no test coverage detected