utils

package
v5.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 17, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DeepCopy = func(dst interface{}, src interface{}) error {
	payload, err := json.Marshal(src)
	if err != nil {
		return err
	}

	err = json.Unmarshal(payload, dst)
	if err != nil {
		return err
	}
	return nil
}

DeepCopy does a deep copy of a structure Error checking of parameters delegated to json engine

Functions

func CreateCommands

func CreateCommands(source entities.ImageScpOptions, dest entities.ImageScpOptions, parentFlags []string, podman string) ([]string, []string)

createCommands forms the podman save and load commands used by SCP

func CreateSCPCommand

func CreateSCPCommand(cmd *exec.Cmd, command []string) *exec.Cmd

CreateSCPCommand takes an existing command, appends the given arguments and returns a configured podman command for image scp

func ExecPodman

func ExecPodman(dest entities.ImageScpOptions, podman string, command []string) (string, error)

execPodman executes the podman save/load command given the podman binary

func ExecuteTransfer

func ExecuteTransfer(src, dst string, parentFlags []string, quiet bool, sshMode ssh.EngineMode) (*entities.ImageLoadReport, *entities.ImageScpOptions, *entities.ImageScpOptions, []string, error)

func ExtractImage

func ExtractImage(out []byte) string

ExtractImage pulls out the last line of output from save/load (image id)

func GetServiceInformation

func GetServiceInformation(sshInfo *entities.ImageScpConnections, cliConnections []string, cfg *config.Config) error

GetServiceInformation takes the parsed list of hosts to connect to and validates the information

func GetUserInfo

func GetUserInfo(uri *url.URL) (*url.Userinfo, error)

func IfPassesSecretsFilter

func IfPassesSecretsFilter(s secrets.Secret, filters map[string][]string) (bool, error)

func LoadToRemote

func LoadToRemote(dest entities.ImageScpOptions, localFile string, tag string, url *url.URL, iden string, sshEngine ssh.EngineMode) (string, string, error)

loadToRemote takes image and remote connection information. it connects to the specified client and copies the saved image dir over to the remote host and then loads it onto the machine returns a string containing output or an error

func LoginUser

func LoginUser(user string) (*exec.Cmd, error)

LoginUser starts the user process on the host so that image scp can use systemd-run

func ParseImageSCPArg

func ParseImageSCPArg(arg string) (*entities.ImageScpOptions, []string, error)

parseImageSCPArg returns the valid connection, and source/destination data based off of the information provided by the user arg is a string containing one of the cli arguments returned is a filled out source/destination options structs as well as a connections array and an error if applicable

func RemoteArgLength

func RemoteArgLength(input string, side int) int

remoteArgLength is a helper function to simplify the extracting of host argument data returns an int which contains the length of a specified index in a host::image string

func SaveToRemote

func SaveToRemote(image, localFile string, tag string, uri *url.URL, iden string, sshEngine ssh.EngineMode) error

saveToRemote takes image information and remote connection information. it connects to the specified client and saves the specified image on the remote machine and then copies it to the specified local location returns an error if one occurs.

func ScpTag

func ScpTag(cmd *exec.Cmd, podman string, dest entities.ImageScpOptions) error

ScpTag is a helper function for native podman to tag an image after a local load from image SCP

func ToLibpodFilters

func ToLibpodFilters(f url.Values) (filters []string)

func ToURLValues

func ToURLValues(f []string) (filters url.Values)

func ValidateImageName

func ValidateImageName(input string) string

validateImageName makes sure that the image given is valid and no injections are occurring we simply use this for error checking, bot setting the image

func ValidateImagePortion

func ValidateImagePortion(location entities.ImageScpOptions, arg string) (entities.ImageScpOptions, error)

func ValidateSCPArgs

func ValidateSCPArgs(locations []*entities.ImageScpOptions) error

validateSCPArgs takes the array of source and destination options and checks for common errors

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL