distrofactory

package
v0.100.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: Apache-2.0 Imports: 9 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Factory

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

Factory is a list of distro.Distro factories.

func New

func New(factories ...FactoryFunc) *Factory

New returns a Factory of distro.Distro factories for the given distros.

func NewDefault

func NewDefault() *Factory

NewDefault returns a Factory of distro.Distro factories for all supported distros.

func NewTestDefault

func NewTestDefault() *Factory

NewTestDefault returns a Factory of distro.Distro factory for the test_distro.

func (*Factory) FromHost

func (f *Factory) FromHost() distro.Distro

FromHost returns a distro.Distro instance, that is specific to the host. If the host distro is not supported, nil is returned.

func (*Factory) GetDistro

func (f *Factory) GetDistro(name string) distro.Distro

GetDistro returns the distro.Distro that matches the given distro ID. If no distro.Distro matches the given distro ID, it tries to translate the given distro ID using the aliases map and tries again. If no distro.Distro matches the given distro ID, it returns nil. If multiple distro factories match the given distro ID, it panics.

func (*Factory) RegisterAliases

func (f *Factory) RegisterAliases(aliases map[string]string) error

RegisterAliases configures the factory with aliases for distro names. The provided aliases map has the following constraints: - An alias must not mask an existing distro. - An alias target must map to an existing distro.

type FactoryFunc

type FactoryFunc func(idStr string) distro.Distro

FactoryFunc is a function that returns a distro.Distro for a given distro represented as a string. If the string does not represent a distro, that can be detected by the factory, it should return nil.

Jump to

Keyboard shortcuts

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