package coreos

import "github.com/purpleidea/mgmt/lang/core/os"

Index

Constants

const (
	// ModuleName is the prefix given to all the functions in this module.
	ModuleName = "os"
)
const (
	// ReadFileFuncName is the name this function is registered as.
	ReadFileFuncName = "readfile"
)
const (
	// SystemFuncName is the name this function is registered as.
	SystemFuncName = "system"
)

Functions

func Args

Args returns the `argv` of the current process. Keep in mind that this will return different values depending on how this is deployed, so don't expect a result on your deploy client to behave the same as a server receiving code. FIXME: Sanitize any command-line secrets we might pass in by cli.

func ExpandHome

func ExpandHome(ctx context.Context, input []types.Value) (types.Value, error)

ExpandHome expands any tilde patterns in the input path according to the currently running user. While most of the time its likely this is `root`, there is no reason the program is necessarily running as root!

func Family

func Family(ctx context.Context, input []types.Value) (types.Value, error)

Family returns the distro family. TODO: Detect OS changes.

func IsFamilyArchLinux

func IsFamilyArchLinux(ctx context.Context, input []types.Value) (types.Value, error)

IsFamilyArchLinux detects if the os family is archlinux. TODO: Detect OS changes.

func IsFamilyDebian

func IsFamilyDebian(ctx context.Context, input []types.Value) (types.Value, error)

IsFamilyDebian detects if the os family is debian. TODO: Detect OS changes.

func IsFamilyRedHat

func IsFamilyRedHat(ctx context.Context, input []types.Value) (types.Value, error)

IsFamilyRedHat detects if the os family is redhat. TODO: Detect OS changes.

func IsVirtual

func IsVirtual(ctx context.Context, input []types.Value) (types.Value, error)

IsVirtual is a function that executes two types of checks: first, it checks whether we're running on Linux. If that's the case, we run checks related with the presence of virtualization platforms. If any of those checks returns true, then so does this function. Otherwise, it's assumed that it's not a virtualized environment.

func ParseDistroUID

func ParseDistroUID(ctx context.Context, input []types.Value) (types.Value, error)

ParseDistroUID parses a distro UID into its component values. If it cannot parse correctly, all the struct fields have the zero values. NOTE: The UID pattern is subject to change.

Types

type ReadFileFunc

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

ReadFileFunc is a function that reads the full contents from a local file. If the file contents change or the file path changes, a new string will be sent. Please note that this is different from the readfile function in the deploy package.

func (*ReadFileFunc) ArgGen

func (obj *ReadFileFunc) ArgGen(index int) (string, error)

ArgGen returns the Nth arg name for this function.

func (*ReadFileFunc) Call

func (obj *ReadFileFunc) Call(ctx context.Context, args []types.Value) (types.Value, error)

Call this function with the input args and return the value if it is possible to do so at this time.

func (*ReadFileFunc) Info

func (obj *ReadFileFunc) Info() *interfaces.Info

Info returns some static info about itself.

func (*ReadFileFunc) Init

func (obj *ReadFileFunc) Init(init *interfaces.Init) error

Init runs some startup code for this function.

func (*ReadFileFunc) Stream

func (obj *ReadFileFunc) Stream(ctx context.Context) error

Stream returns the changing values that this func has over time.

func (*ReadFileFunc) String

func (obj *ReadFileFunc) String() string

String returns a simple name for this function. This is needed so this struct can satisfy the pgraph.Vertex interface.

func (*ReadFileFunc) Validate

func (obj *ReadFileFunc) Validate() error

Validate makes sure we've built our struct properly. It is usually unused for normal functions that users can use directly.

type SystemFunc

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

SystemFunc runs a string as a shell command, then produces each line from stdout. If the input string changes, then the commands are executed one after the other and the concatenation of their outputs is produced line by line.

Note that in the likely case in which the process emits several lines one after the other, the downstream resources might not run for every line unless the "Meta:realize" metaparam is set to true.

func (*SystemFunc) ArgGen

func (obj *SystemFunc) ArgGen(index int) (string, error)

ArgGen returns the Nth arg name for this function.

func (*SystemFunc) Info

func (obj *SystemFunc) Info() *interfaces.Info

Info returns some static info about itself.

func (*SystemFunc) Init

func (obj *SystemFunc) Init(init *interfaces.Init) error

Init runs some startup code for this function.

func (*SystemFunc) Stream

func (obj *SystemFunc) Stream(ctx context.Context) error

Stream returns the changing values that this func has over time.

func (*SystemFunc) String

func (obj *SystemFunc) String() string

String returns a simple name for this function. This is needed so this struct can satisfy the pgraph.Vertex interface.

func (*SystemFunc) Validate

func (obj *SystemFunc) Validate() error

Validate makes sure we've built our struct properly. It is usually unused for normal functions that users can use directly.

Source Files

args.go distro.go expand_home.go family.go is_virtual.go os.go readfile.go system.go

Version
v0.0.0-20250322185616-c50a578426f1 (latest)
Published
Mar 22, 2025
Platform
linux/amd64
Imports
18 packages
Last checked
4 days ago

Tools for package owners.