Each engineMethod call now owns the prev and dest variables instead of being shared in mo
(ctx context.Context, mo *SingleMethodObj, path string, change *object.Change)
| 680 | |
| 681 | // Each engineMethod call now owns the prev and dest variables instead of being shared in mo |
| 682 | func (hc *FetchitConfig) EngineMethod(ctx context.Context, mo *SingleMethodObj, path string, change *object.Change) error { |
| 683 | switch mo.Method { |
| 684 | case rawMethod: |
| 685 | prev, err := getChangeString(change) |
| 686 | if err != nil { |
| 687 | return err |
| 688 | } |
| 689 | return rawPodman(ctx, mo, path, prev) |
| 690 | case systemdMethod: |
| 691 | // TODO: add logic for non-root services |
| 692 | var prev *string = nil |
| 693 | if change != nil { |
| 694 | if change.To.Name != "" { |
| 695 | prev = &change.To.Name |
| 696 | } |
| 697 | } |
| 698 | nonRootHomeDir := os.Getenv("HOME") |
| 699 | if nonRootHomeDir == "" { |
| 700 | return fmt.Errorf("Could not determine $HOME for host, must set $HOME on host machine for non-root systemd method") |
| 701 | } |
| 702 | var dest string |
| 703 | if mo.Target.Methods.Systemd.Root { |
| 704 | dest = systemdPathRoot |
| 705 | } else { |
| 706 | dest = filepath.Join(nonRootHomeDir, ".config", "systemd", "user") |
| 707 | } |
| 708 | if change != nil { |
| 709 | mo.Target.Methods.Systemd.initialRun = true |
| 710 | } |
| 711 | return systemdPodman(ctx, mo, path, dest, prev) |
| 712 | case fileTransferMethod: |
| 713 | var prev *string = nil |
| 714 | if change != nil { |
| 715 | if change.To.Name != "" { |
| 716 | prev = &change.To.Name |
| 717 | } |
| 718 | } |
| 719 | dest := mo.Target.Methods.FileTransfer.DestinationDirectory |
| 720 | return fileTransferPodman(ctx, mo, path, dest, prev) |
| 721 | case kubeMethod: |
| 722 | prev, err := getChangeString(change) |
| 723 | if err != nil { |
| 724 | return err |
| 725 | } |
| 726 | return kubePodman(ctx, mo, path, prev) |
| 727 | case ansibleMethod: |
| 728 | return ansiblePodman(ctx, mo, path) |
| 729 | default: |
| 730 | return fmt.Errorf("unsupported method: %s", mo.Method) |
| 731 | } |
| 732 | } |
| 733 | |
| 734 | func (hc *FetchitConfig) getClone(target *Target) error { |
| 735 | directory := filepath.Base(target.Url) |
no test coverage detected