Documentation ¶
Index ¶
- Constants
- func CBufToGoPtr(s [C.PART_INFO_BUF_SIZE]C.char) *string
- func CBufToGoStr(s [C.PART_INFO_BUF_SIZE]C.char) string
- func CreateDeviceAlias(path string) (string, error)
- func Depth(path string) uint
- func DeviceAlias(path string) string
- func FilesystemIsEmpty(dirpath string) (bool, error)
- func FindFirstMissingPathComponent(path string) (string, error)
- func GetBlockDevices(fstype string) ([]string, error)
- func MkdirForFile(path string) error
- func PathExists(path string) (bool, error)
- func SplitPath(p string) []string
- func SystemdDropinsPath(unitName string) string
- func SystemdUnitsPath() string
- func ZkeySecureKeyRepoFiles(l string) map[string]string
- type DiskInfo
- type FetchOp
- type FilesystemInfo
- type PartitionInfo
- type Util
- func (u Util) AuthorizeSSHKeys(c types.PasswdUser) error
- func (u Util) CheckIfGroupExists(g types.PasswdGroup) (bool, error)
- func (u Util) CheckIfUserExists(c types.PasswdUser) (bool, error)
- func (ut Util) DisableUnit(disabledUnit string) error
- func (ut Util) EnableUnit(enabledUnit string) error
- func (u Util) EnsureGroup(g types.PasswdGroup) error
- func (u Util) EnsureUser(c types.PasswdUser) error
- func (ut Util) FileFromSystemdUnit(unit types.Unit) (FetchOp, error)
- func (ut Util) FileFromSystemdUnitDropin(unit types.Unit, dropin types.Dropin) (FetchOp, error)
- func (u Util) GetUserHomeDir(c types.PasswdUser) (string, error)
- func (ut Util) IsUnitMasked(unit types.Unit) (bool, error)
- func (u Util) JoinPath(path ...string) (string, error)
- func (ut Util) MaskUnit(unit types.Unit) (string, error)
- func (u Util) ModifyHomeDirPermissions(c types.PasswdUser) error
- func (u Util) NotateMkdirAll(path string, perm os.FileMode) error
- func (u Util) PerformFetch(f FetchOp) error
- func (u Util) PrepareFetches(l *log.Logger, f types.File) ([]FetchOp, error)
- func (ut Util) RelabelFiles(patterns []string) error
- func (u Util) ResolveNodeUidAndGid(n types.Node, defaultUid, defaultGid int) (int, int, error)
- func (u Util) ResolveSymlink(path string) (string, error)
- func (u Util) SetPasswordHash(c types.PasswdUser) error
- func (u Util) SetPermissions(mode *int, node types.Node) error
- func (ut Util) UnmaskUnit(unit types.Unit) error
- func (u Util) WriteLink(s types.Link) error
Constants ¶
const ( DefaultDirectoryPermissions os.FileMode = 0755 DefaultFilePermissions os.FileMode = 0644 )
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 ¶
CreateDeviceAlias creates a device alias for the supplied path. On success the canonicalized path used as the alias target is returned.
func DeviceAlias ¶
DeviceAlias returns the aliased form of the supplied path. Note device paths in ignition are always absolute.
func FilesystemIsEmpty ¶ added in v2.12.0
FilesystemIsEmpty checks the mountpoint of a filesystem to see whether the filesystem is empty. Adapted from https://stackoverflow.com/a/30708914
func FindFirstMissingPathComponent ¶ added in v2.13.0
FindFirstMissingPathComponent returns the path up to the first component which was found to be missing, or the whole path if it already exists.
func GetBlockDevices ¶ added in v2.12.0
GetBlockDevices returns a slice of block devices with the given filesystem
func MkdirForFile ¶
MkdirForFile helper creates the directory components of path.
func PathExists ¶ added in v2.3.0
PathExists checks if the path exists for a given config.
func SystemdDropinsPath ¶
func SystemdUnitsPath ¶
func SystemdUnitsPath() string
func ZkeySecureKeyRepoFiles ¶ added in v2.19.0
Helper function to concatenate the key files.
Types ¶
type DiskInfo ¶
type DiskInfo struct { LogicalSectorSize int // 4k or 512 Partitions []PartitionInfo }
func DumpDisk ¶
DumpDisk 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 FilesystemInfo ¶ added in v2.4.0
func GetFilesystemInfo ¶ added in v2.4.0
func GetFilesystemInfo(device string, allowAmbivalent bool) (FilesystemInfo, error)
If allowAmbivalent is false, fail if we find traces of more than one filesystem on the device.
type PartitionInfo ¶
type Util ¶
type Util struct { DestDir string // directory prefix to use in applying fs paths. Fetcher resource.Fetcher *log.Logger State *state.State }
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) CheckIfGroupExists ¶ added in v2.6.0
func (u Util) CheckIfGroupExists(g types.PasswdGroup) (bool, error)
CheckIfGroupExists will return Info log when group is empty
func (Util) CheckIfUserExists ¶
func (u Util) CheckIfUserExists(c types.PasswdUser) (bool, error)
CheckIfUserExists will return Info log when user is empty
func (Util) DisableUnit ¶
func (Util) EnableUnit ¶
func (Util) EnsureGroup ¶ added in v2.6.0
func (u Util) EnsureGroup(g types.PasswdGroup) error
EnsureGroup ensures that the group exists as described. If the `shouldExist` field is set to false and the group already exists, then it will be deleted.
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. If the `shouldExist` field is set to false and the user already exists, then they will be deleted.
func (Util) FileFromSystemdUnit ¶
func (Util) FileFromSystemdUnitDropin ¶
func (Util) GetUserHomeDir ¶ added in v2.4.0
func (u Util) GetUserHomeDir(c types.PasswdUser) (string, error)
GetUserHomeDir returns the user home directory. Note that DestDir is not prefixed.
func (Util) IsUnitMasked ¶ added in v2.8.0
IsUnitMasked returns true/false if a systemd unit is masked
func (Util) JoinPath ¶
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 ¶
MaskUnit writes a symlink to /dev/null to mask the specified unit and returns the path of that unit without the sysroot prefix
func (Util) ModifyHomeDirPermissions ¶ added in v2.12.0
func (u Util) ModifyHomeDirPermissions(c types.PasswdUser) error
ModifyHomeDirPermissions changes the permissions for the user's home directory if it was created during the Ignition mount stage as a result of a mountpoint.
func (Util) NotateMkdirAll ¶ added in v2.12.0
NotateMkdirAll creates directories relative to the u.DestDir root, including any missing parents, and records the paths to any created directories in the State for future use.
func (Util) PerformFetch ¶
PerformFetch performs a fetch operation generated by PrepareFetch, retrieving the file and writing it to disk. Any encountered errors are returned.
func (Util) PrepareFetches ¶
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) RelabelFiles ¶ added in v2.1.0
RelabelFiles relabels all the files matching the globby patterns given.
func (Util) ResolveNodeUidAndGid ¶
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) ResolveSymlink ¶ added in v2.4.0
ResolveSymlink resolves the symlink path, respecting the u.DestDir root. If the path is not a symlink, returns "". Otherwise, returns an unprefixed path to the target.
func (Util) SetPasswordHash ¶
func (u Util) SetPasswordHash(c types.PasswdUser) error
SetPasswordHash sets the password hash of the specified user.
func (Util) UnmaskUnit ¶ added in v2.8.0
UnmaskUnit deletes the symlink to /dev/null for a masked unit