install

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Copyright (C) 2025, Dione Limited. All rights reserved. See the file LICENSE for licensing terms.

Copyright (c) 2025 Dione Limited. See the file LICENSE for licensing terms.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractArchive

func ExtractArchive(kind ArchiveKind, archive []byte, outputDir string) error

ExtractArchive extracts the archive given as bytes slice [archive], into [outputDir]

func InstallBinary

func InstallBinary(
	url string,
	archiveKind ArchiveKind,
	outputDir string,
	relativeBinPath string,
) (string, error)

installs archive from given [url] into [outputDir], unless [relativeBinPath] exists in [outputDir] and is executable. verifies [relativeBinPath] exists in [outputDir] after installation, and returns full path

func InstallBinaryVersion

func InstallBinaryVersion(
	url string,
	archiveKind ArchiveKind,
	baseDir string,
	relativeBinPath string,
	version string,
) (string, error)

installs archive into a [version] subdir of [baseDir] see InstallBinary from installation checks

func InstallGithubRelease

func InstallGithubRelease(
	org string,
	repo string,
	authToken string,
	releaseKind ReleaseKind,
	customVersion string,
	getAssetName func(string) (string, error),
	archiveKind ArchiveKind,
	baseDir string,
	relativeBinPath string,
) (string, error)

Types

type ArchiveKind

type ArchiveKind int64
const (
	UndefinedArchive ArchiveKind = iota
	Zip
	TarGz
)

type MockHTTPClient

type MockHTTPClient struct {
	// contains filtered or unexported fields
}

MockHTTPClient provides a mock implementation for HTTP requests

func NewMockHTTPClient

func NewMockHTTPClient() *MockHTTPClient

NewMockHTTPClient creates a new mock HTTP client

func (*MockHTTPClient) Get

func (m *MockHTTPClient) Get(url string) ([]byte, error)

Get simulates an HTTP GET request

func (*MockHTTPClient) SetError

func (m *MockHTTPClient) SetError(url string, err error)

SetError sets a mock error for a URL

func (*MockHTTPClient) SetResponse

func (m *MockHTTPClient) SetResponse(url string, data []byte)

SetResponse sets a mock response for a URL

type MockHTTPError

type MockHTTPError struct {
	URL     string
	Message string
}

MockHTTPError represents an error from the mock HTTP client

func (*MockHTTPError) Error

func (e *MockHTTPError) Error() string

type ReleaseKind

type ReleaseKind int64
const (
	UndefinedRelease ReleaseKind = iota
	LatestRelease
	LatestPreRelease
	CustomRelease
)

type TestArchiveBuilder

type TestArchiveBuilder struct {
	// contains filtered or unexported fields
}

TestArchiveBuilder helps build test archives for testing

func NewTestArchiveBuilder

func NewTestArchiveBuilder(t *testing.T) *TestArchiveBuilder

NewTestArchiveBuilder creates a new test archive builder

func (*TestArchiveBuilder) CreateTarGzWithFiles

func (b *TestArchiveBuilder) CreateTarGzWithFiles(files map[string]string) []byte

CreateTarGzWithFiles creates a tar.gz archive with the specified files

func (*TestArchiveBuilder) CreateTarGzWithZipSlip

func (b *TestArchiveBuilder) CreateTarGzWithZipSlip() []byte

CreateTarGzWithZipSlip creates a tar.gz archive that attempts zip slip attacks

func (*TestArchiveBuilder) CreateZipWithFiles

func (b *TestArchiveBuilder) CreateZipWithFiles(files map[string]string) []byte

CreateZipWithFiles creates a zip archive with the specified files

func (*TestArchiveBuilder) CreateZipWithZipSlip

func (b *TestArchiveBuilder) CreateZipWithZipSlip() []byte

CreateZipWithZipSlip creates a zip archive that attempts zip slip attacks

type TestArchiveValidator

type TestArchiveValidator struct {
	// contains filtered or unexported fields
}

TestArchiveValidator helps validate archive extraction results

func NewTestArchiveValidator

func NewTestArchiveValidator(t *testing.T, baseDir string) *TestArchiveValidator

NewTestArchiveValidator creates a new archive validator

func (*TestArchiveValidator) AssertFileContent

func (v *TestArchiveValidator) AssertFileContent(relativePath, expectedContent string)

AssertFileContent checks that a file has the expected content

func (*TestArchiveValidator) AssertFilesExist

func (v *TestArchiveValidator) AssertFilesExist(files []string)

AssertFilesExist checks that the specified files exist after extraction

func (*TestArchiveValidator) AssertFilesNotExist

func (v *TestArchiveValidator) AssertFilesNotExist(files []string)

AssertFilesNotExist checks that the specified files do not exist after extraction

func (*TestArchiveValidator) AssertNoZipSlipFiles

func (v *TestArchiveValidator) AssertNoZipSlipFiles()

AssertNoZipSlipFiles checks that no zip slip attack files were created

type TestFileSystem

type TestFileSystem struct {
	// contains filtered or unexported fields
}

TestFileSystem provides utilities for testing file operations

func NewTestFileSystem

func NewTestFileSystem(t *testing.T) *TestFileSystem

NewTestFileSystem creates a new test file system

func (*TestFileSystem) AssertFileContent

func (fs *TestFileSystem) AssertFileContent(relativePath, expectedContent string)

AssertFileContent checks if a file has the expected content

func (*TestFileSystem) AssertFileExecutable

func (fs *TestFileSystem) AssertFileExecutable(relativePath string)

AssertFileExecutable checks if a file is executable

func (*TestFileSystem) AssertFileExists

func (fs *TestFileSystem) AssertFileExists(relativePath string)

AssertFileExists checks if a file exists

func (*TestFileSystem) AssertFileNotExists

func (fs *TestFileSystem) AssertFileNotExists(relativePath string)

AssertFileNotExists checks if a file does not exist

func (*TestFileSystem) Cleanup

func (fs *TestFileSystem) Cleanup()

Cleanup removes all created files (usually called automatically by t.TempDir())

func (*TestFileSystem) CreateDirectory

func (fs *TestFileSystem) CreateDirectory(relativePath string) string

CreateDirectory creates a directory

func (*TestFileSystem) CreateExecutableFile

func (fs *TestFileSystem) CreateExecutableFile(relativePath, content string) string

CreateExecutableFile creates an executable file

func (*TestFileSystem) CreateFile

func (fs *TestFileSystem) CreateFile(relativePath, content string) string

CreateFile creates a file with the given content

func (*TestFileSystem) GetPath

func (fs *TestFileSystem) GetPath(relativePath string) string

GetPath returns the full path for a relative path

Jump to

Keyboard shortcuts

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