utils

package
v4.5.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2023 License: Apache-2.0 Imports: 16 Imported by: 1

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 added in v4.2.0

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 added in v4.2.0

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 added in v4.2.0

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

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

func ExecuteTransfer added in v4.2.0

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

func ExtractImage added in v4.2.0

func ExtractImage(out []byte) string

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

func GetServiceInformation added in v4.2.0

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

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

func GetUserInfo added in v4.2.0

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

func IfPassesSecretsFilter

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

func LoadToRemote added in v4.2.0

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 added in v4.2.0

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 added in v4.2.0

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 added in v4.2.0

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 added in v4.2.0

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 added in v4.2.0

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 added in v4.2.0

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 added in v4.2.0

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

func ValidateSCPArgs added in v4.2.0

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