execwrap

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package execwrap wraps external command execution and runtime dependency checks.

Index

Constants

This section is empty.

Variables

View Source
var Dependencies = map[string]Dependency{
	"kubectl": {
		Binary:      "kubectl",
		VersionArgs: []string{"version", "--client", "true"},
		VersionParse: func(output string) (string, error) {
			lines := strings.Split(output, "\n")
			for _, line := range lines {
				if strings.Contains(line, "Client Version: v") {
					return strings.TrimSpace(strings.Replace(line, "Client Version: v", "", 1)), nil
				}
			}
			return "", nil
		},
		MinVersion: 1,
	},
	"rsync": {
		Binary:      "rsync",
		VersionArgs: []string{"--version"},
		VersionParse: func(output string) (string, error) {

			lines := strings.Split(output, "\n")
			for _, line := range lines {
				parts := rsyncVersionRegex.FindStringSubmatch(line)
				if len(parts) >= 2 {
					return parts[1], nil
				}
			}
			return "", fmt.Errorf("Unable to determine rsync version")
		},
		MinVersion: 3,
	},
	"mkcert": {
		Binary:      "mkcert",
		VersionArgs: []string{"-version"},
		VersionParse: func(output string) (string, error) {
			version := strings.TrimSpace(output)
			version = strings.TrimPrefix(version, "v")
			if version == "" {
				return "", fmt.Errorf("unable to determine mkcert version")
			}
			return version, nil
		},
		MinVersion: 1,
	},
	"qemu-system-aarch64": qemuDependency("qemu-system-aarch64"),
	"qemu-system-x86_64":  qemuDependency("qemu-system-x86_64"),
	"qemu-img":            qemuDependency("qemu-img"),
}

Functions

func Command

func Command(name string, arg ...string) *exec.Cmd

Command creates an exec.Command and logs the invocation at debug level.

func Installed

func Installed(dependencies []string) error

Installed checks if a dependency is installed

func VersionCheck

func VersionCheck(versionStr string, requireMajor int) (bool, error)

VersionCheck verifies if the provided version string is at least requireMajor

Types

type Dependency

type Dependency struct {
	Binary       string
	VersionArgs  []string
	VersionParse func(output string) (string, error)
	MinVersion   int
}

Jump to

Keyboard shortcuts

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