Documentation
¶
Index ¶
- Constants
- func CachePath(path ...string) string
- func CreateTarball(target string, contentPath string) error
- func DoBasicConnectivityCheck(endpoint string, trustedCertFingerprint string) (api.ExternalConnectivityStatus, *x509.Certificate)
- func FileCopy(source string, dest string) error
- func GetOwnerMode(fInfo os.FileInfo) (os.FileMode, int, int)
- func GetProjectRepo(ctx context.Context, latest bool) (*githubRepo, error)
- func GetTOFUServerConfig(serverCert *x509.Certificate) *tls.Config
- func InTestingMode() bool
- func IsDebianOrDerivative(osString string) bool
- func IsDir(name string) bool
- func IsRHELOrDerivative(osString string) bool
- func IsSUSEOrDerivative(osString string) bool
- func IsUnixSocket(path string) bool
- func LogPath(path ...string) string
- func RawWorkerImage() string
- func RenderTable(w io.Writer, format string, header []string, data [][]string, raw any) error
- func RunConcurrentList[T any](entities []T, f func(T) error) error
- func RunConcurrentMap[K comparable, V any](entities map[K]V, f func(K, V) error) error
- func RunPath(path ...string) string
- func UnixHTTPClient(socketPath string) *http.Client
- func VarPath(path ...string) string
- func WorkerVolume() string
- type Cache
- type Column
- type IDLock
- type SortColumnsNaturally
Constants ¶
const ( TableFormatCSV = "csv" TableFormatJSON = "json" TableFormatTable = "table" TableFormatYAML = "yaml" TableFormatCompact = "compact" )
Table list format.
const ( // TableOptionNoHeader hides the table header when possible. TableOptionNoHeader = "noheader" // TableOptionHeader adds header to csv. TableOptionHeader = "header" )
Variables ¶
This section is empty.
Functions ¶
func CachePath ¶
CachePath returns the directory that migration manager should use for caching assets. If MIGRATION_MANAGER_DIR is set, this path is $MIGRATION_MANAGER_DIR/cache, otherwise it is /var/cache/migration-manager.
func CreateTarball ¶
CreateTarball creates a tarball from a given path. If the path is a directory, the tarball will include the directory.
func DoBasicConnectivityCheck ¶
func DoBasicConnectivityCheck(endpoint string, trustedCertFingerprint string) (api.ExternalConnectivityStatus, *x509.Certificate)
func GetProjectRepo ¶
GetProjectRepo returns a GitHub repository client for the project at the current tag, and populates release assets. If latest is true, release assets will be populated from the latest release instead of the tag.
func GetTOFUServerConfig ¶
func GetTOFUServerConfig(serverCert *x509.Certificate) *tls.Config
func InTestingMode ¶
func InTestingMode() bool
InTestingMode returns whether migration manager is running in testing mode.
func IsDebianOrDerivative ¶
func IsRHELOrDerivative ¶
func IsSUSEOrDerivative ¶
func IsUnixSocket ¶
IsUnixSocket returns true if the given path is either a Unix socket or a symbolic link pointing at a Unix socket.
func LogPath ¶
LogPath returns the directory that migration manager should put logs under. If MIGRATION_MANAGER_DIR is set, this path is $MIGRATION_MANAGER_DIR/logs, otherwise it is /var/log.
func RawWorkerImage ¶
func RawWorkerImage() string
RawWorkerImage represents the raw worker image supplied to an Incus target.
func RenderTable ¶
RenderTable renders tabular data in various formats.
func RunConcurrentList ¶
RunConcurrentList runs the given function concurrently for each entity in the given list. Any encountered errors will be logged, and when the run finishes, the last encountered error is returned.
func RunConcurrentMap ¶
func RunConcurrentMap[K comparable, V any](entities map[K]V, f func(K, V) error) error
RunConcurrentMap runs the given function concurrently for each entity in the given map. Any encountered errors will be logged, and when the run finishes, the last encountered error is returned.
func RunPath ¶
RunPath returns the directory that migration manager should put runtime data under. If MIGRATION_MANAGER_DIR is set, this path is $MIGRATION_MANAGER_DIR/run, otherwise it is /run/migration-manager.
func UnixHTTPClient ¶
UnixHTTPClient returns an HTTP client suitable for a unix socket connection.
func VarPath ¶
VarPath returns the provided path elements joined by a slash and appended to the end of $MIGRATION_MANAGER_DIR, which defaults to /var/lib/migration-manager.
func WorkerVolume ¶
func WorkerVolume() string
WorkerVolume represents the name of the storage volume containing the migration worker.
Types ¶
type Cache ¶
type Cache[K comparable, V any] struct { // contains filtered or unexported fields }
func NewCache ¶
func NewCache[K comparable, V any]() *Cache[K, V]
type Column ¶
type Column struct { Header string // DataFunc is a method to retrieve data for this column. The argument to this function will be an element of the // "data" slice that is passed into RenderSlice. DataFunc func(any) (string, error) }
Column represents a single column in a table.
type IDLock ¶
type IDLock[T comparable] struct { // contains filtered or unexported fields }
func NewIDLock ¶
func NewIDLock[T comparable]() IDLock[T]
NewIDLock creates a thread-safe map of sync.Mutexes keyed by ID.
type SortColumnsNaturally ¶
type SortColumnsNaturally [][]string
SortColumnsNaturally represents the type for sorting columns in a natural order from left to right.
func (SortColumnsNaturally) Len ¶
func (a SortColumnsNaturally) Len() int
func (SortColumnsNaturally) Less ¶
func (a SortColumnsNaturally) Less(i, j int) bool
func (SortColumnsNaturally) Swap ¶
func (a SortColumnsNaturally) Swap(i, j int)