util

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2019 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultDirectoryPermissions os.FileMode = 0755
	DefaultFilePermissions      os.FileMode = 0644
)
View Source
const (
	PresetPath               string      = "/etc/systemd/system-preset/20-ignition.preset"
	DefaultPresetPermissions os.FileMode = 0644
)

Variables

This section is empty.

Functions

func CBufToGoPtr

func CBufToGoPtr(s [C.PART_INFO_BUF_SIZE]C.char) *string

func CBufToGoStr

func CBufToGoStr(s [C.PART_INFO_BUF_SIZE]C.char) string

func CreateDeviceAlias

func CreateDeviceAlias(path string) (string, error)

CreateDeviceAlias creates a device alias for the supplied path. On success the canonicalized path used as the alias target is returned.

func Depth

func Depth(path string) uint

func DeviceAlias

func DeviceAlias(path string) string

DeviceAlias returns the aliased form of the supplied path. Note device paths in ignition are always absolute.

func FilesystemLabel

func FilesystemLabel(device string) (string, error)

func FilesystemType

func FilesystemType(device string) (string, error)

func FilesystemUUID

func FilesystemUUID(device string) (string, error)

func MkdirForFile

func MkdirForFile(path string) error

MkdirForFile helper creates the directory components of path.

func SplitPath

func SplitPath(p string) []string

func SystemdDropinsPath

func SystemdDropinsPath(unitName string) string

func SystemdRuntimeDropinsPath

func SystemdRuntimeDropinsPath(unitName string) string

func SystemdRuntimeUnitWantsPath

func SystemdRuntimeUnitWantsPath(unitName string) string

func SystemdRuntimeUnitsPath

func SystemdRuntimeUnitsPath() string

func SystemdUnitsPath

func SystemdUnitsPath() string

Types

type DiskInfo

type DiskInfo struct {
	LogicalSectorSize int // 4k or 512
	Partitions        []PartitionInfo
}

func DumpDisk

func DumpDisk(device string) (DiskInfo, error)

DumpPartitionTable returns a list of all partitions on device (e.g. /dev/vda). The list of partitions returned is unordered.

func (DiskInfo) GetPartition

func (d DiskInfo) GetPartition(n int) (PartitionInfo, bool)

type FetchOp

type FetchOp struct {
	Hash         hash.Hash
	Url          url.URL
	FetchOptions resource.FetchOptions
	Append       bool
	Node         types.Node
}

type PartitionInfo

type PartitionInfo struct {
	Label         string
	GUID          string
	TypeGUID      string
	StartSector   int
	SizeInSectors int
	Number        int
}

type Util

type Util struct {
	DestDir string // directory prefix to use in applying fs paths.
	Fetcher resource.Fetcher
	*log.Logger
}

Util encapsulates logging and destdir indirection for the util methods.

func (Util) AuthorizeSSHKeys

func (u Util) AuthorizeSSHKeys(c types.PasswdUser) error

AuthorizeSSHKeys adds the provided SSH public keys to the user's authorized keys.

func (Util) CheckIfUserExists

func (u Util) CheckIfUserExists(c types.PasswdUser) (bool, error)

CheckIfUserExists will return Info log when user is empty

func (Util) CreateGroup

func (u Util) CreateGroup(g types.PasswdGroup) error

CreateGroup creates the group as described.

func (Util) DisableUnit

func (ut Util) DisableUnit(unit types.Unit) error

func (Util) EnableRuntimeUnit

func (ut Util) EnableRuntimeUnit(unit types.Unit, target string) error

presets link in /etc, which doesn't make sense for runtime units Related: https://github.com/coreos/ignition/v2/issues/588

func (Util) EnableUnit

func (ut Util) EnableUnit(unit types.Unit) error

func (Util) EnsureUser

func (u Util) EnsureUser(c types.PasswdUser) error

EnsureUser ensures that the user exists as described. If the user does not yet exist, they will be created, otherwise the existing user will be modified.

func (Util) FileFromSystemdUnit

func (ut Util) FileFromSystemdUnit(unit types.Unit, runtime bool) (FetchOp, error)

func (Util) FileFromSystemdUnitDropin

func (ut Util) FileFromSystemdUnitDropin(unit types.Unit, dropin types.Dropin, runtime bool) (FetchOp, error)

func (Util) JoinPath

func (u Util) JoinPath(path ...string) (string, error)

JoinPath returns a path into the context ala filepath.Join(d, args) It resolves symlinks as if they were rooted at u.DestDir. This means that the resulting path will always be under u.DestDir. The last element of the path is never followed.

func (Util) MaskUnit

func (ut Util) MaskUnit(unit types.Unit) error

func (Util) PerformFetch

func (u Util) PerformFetch(f FetchOp) error

PerformFetch performs a fetch operation generated by PrepareFetch, retrieving the file and writing it to disk. Any encountered errors are returned.

func (Util) PrepareFetches

func (u Util) PrepareFetches(l *log.Logger, f types.File) ([]FetchOp, error)

PrepareFetches converts a given logger, http client, and types.File into a FetchOp. This includes operations such as parsing the source URL, generating a hasher, and performing user/group name lookups. If an error is encountered, the issue will be logged and nil will be returned.

func (Util) ResolveNodeUidAndGid

func (u Util) ResolveNodeUidAndGid(n types.Node, defaultUid, defaultGid int) (int, int, error)

ResolveNodeUidAndGid attempts to convert a types.Node into a concrete uid and gid. If the node has the User.ID field set, that's used for the uid. If the node has the User.Name field set, a username -> uid lookup is performed. If neither are set, it returns the passed in defaultUid. The logic is identical for gids with equivalent fields.

func (Util) SetPasswordHash

func (u Util) SetPasswordHash(c types.PasswdUser) error

SetPasswordHash sets the password hash of the specified user.

func (Util) SetPermissions

func (u Util) SetPermissions(mode *int, node types.Node) error
func (u Util) WriteLink(s types.Link) error

Jump to

Keyboard shortcuts

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