blueprint

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2023 License: Apache-2.0 Imports: 14 Imported by: 5

Documentation

Overview

Package blueprint contains primitives for representing weldr blueprints

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckDirectoryCustomizationsPolicy

func CheckDirectoryCustomizationsPolicy(dirs []DirectoryCustomization, pathPolicy *pathpolicy.PathPolicies) error

CheckDirectoryCustomizationsPolicy checks if the given Directory customizations are allowed by the path policy. If any of the customizations are not allowed by the path policy, an error is returned. Otherwise, nil is returned.

func CheckFileCustomizationsPolicy

func CheckFileCustomizationsPolicy(files []FileCustomization, pathPolicy *pathpolicy.PathPolicies) error

CheckFileCustomizationsPolicy checks if the given File customizations are allowed by the path policy. If any of the customizations are not allowed by the path policy, an error is returned. Otherwise, nil is returned.

func CheckMountpointsPolicy

func CheckMountpointsPolicy(mountpoints []FilesystemCustomization, mountpointAllowList *pathpolicy.PathPolicies) error

CheckMountpointsPolicy checks if the mountpoints are allowed by the policy

func DirectoryCustomizationsToFsNodeDirectories

func DirectoryCustomizationsToFsNodeDirectories(dirs []DirectoryCustomization) ([]*fsnode.Directory, error)

DirectoryCustomizationsToFsNodeDirectories converts a slice of DirectoryCustomizations to a slice of fsnode.Directories

func FileCustomizationsToFsNodeFiles

func FileCustomizationsToFsNodeFiles(files []FileCustomization) ([]*fsnode.File, error)

FileCustomizationsToFsNodeFiles converts a slice of FileCustomization to a slice of *fsnode.File

func RepoCustomizationsToRepoConfigAndGPGKeyFiles

func RepoCustomizationsToRepoConfigAndGPGKeyFiles(repos []RepositoryCustomization) (map[string][]rpmmd.RepoConfig, []*fsnode.File, error)

func ValidateDirFileCustomizations

func ValidateDirFileCustomizations(dirs []DirectoryCustomization, files []FileCustomization) error

ValidateDirFileCustomizations validates the given Directory and File customizations. If the customizations are invalid, an error is returned. Otherwise, nil is returned.

It currently ensures that: - No file path is a prefix of another file or directory path - There are no duplicate file or directory paths in the customizations

Types

type Blueprint

type Blueprint struct {
	Name           string          `json:"name" toml:"name"`
	Description    string          `json:"description" toml:"description"`
	Version        string          `json:"version,omitempty" toml:"version,omitempty"`
	Packages       []Package       `json:"packages" toml:"packages"`
	Modules        []Package       `json:"modules" toml:"modules"`
	Groups         []Group         `json:"groups" toml:"groups"`
	Containers     []Container     `json:"containers,omitempty" toml:"containers,omitempty"`
	Customizations *Customizations `json:"customizations,omitempty" toml:"customizations"`
	Distro         string          `json:"distro" toml:"distro"`

	// EXPERIMENTAL
	Minimal bool `json:"minimal" toml:"minimal"`
}

A Blueprint is a high-level description of an image.

func (*Blueprint) GetPackages

func (b *Blueprint) GetPackages() []string

packages, modules, and groups all resolve to rpm packages right now. This function returns a combined list of "name-version" strings.

func (*Blueprint) GetPackagesEx

func (b *Blueprint) GetPackagesEx(bootable bool) []string

type Container

type Container struct {
	Source string `json:"source" toml:"source"`
	Name   string `json:"name,omitempty" toml:"name,omitempty"`

	TLSVerify *bool `json:"tls-verify,omitempty" toml:"tls-verify,omitempty"`
}

type CustomizationError

type CustomizationError struct {
	Message string
}

func (*CustomizationError) Error

func (e *CustomizationError) Error() string

type Customizations

type Customizations struct {
	Hostname           *string                   `json:"hostname,omitempty" toml:"hostname,omitempty"`
	Kernel             *KernelCustomization      `json:"kernel,omitempty" toml:"kernel,omitempty"`
	SSHKey             []SSHKeyCustomization     `json:"sshkey,omitempty" toml:"sshkey,omitempty"`
	User               []UserCustomization       `json:"user,omitempty" toml:"user,omitempty"`
	Group              []GroupCustomization      `json:"group,omitempty" toml:"group,omitempty"`
	Timezone           *TimezoneCustomization    `json:"timezone,omitempty" toml:"timezone,omitempty"`
	Locale             *LocaleCustomization      `json:"locale,omitempty" toml:"locale,omitempty"`
	Firewall           *FirewallCustomization    `json:"firewall,omitempty" toml:"firewall,omitempty"`
	Services           *ServicesCustomization    `json:"services,omitempty" toml:"services,omitempty"`
	Filesystem         []FilesystemCustomization `json:"filesystem,omitempty" toml:"filesystem,omitempty"`
	InstallationDevice string                    `json:"installation_device,omitempty" toml:"installation_device,omitempty"`
	FDO                *FDOCustomization         `json:"fdo,omitempty" toml:"fdo,omitempty"`
	OpenSCAP           *OpenSCAPCustomization    `json:"openscap,omitempty" toml:"openscap,omitempty"`
	Ignition           *IgnitionCustomization    `json:"ignition,omitempty" toml:"ignition,omitempty"`
	Directories        []DirectoryCustomization  `json:"directories,omitempty" toml:"directories,omitempty"`
	Files              []FileCustomization       `json:"files,omitempty" toml:"files,omitempty"`
	Repositories       []RepositoryCustomization `json:"repositories,omitempty" toml:"repositories,omitempty"`
}

func (*Customizations) CheckAllowed

func (c *Customizations) CheckAllowed(allowed ...string) error

CheckCustomizations returns an error of type `CustomizationError` if `c` has any customizations not specified in `allowed`

func (*Customizations) GetDirectories

func (c *Customizations) GetDirectories() []DirectoryCustomization

func (*Customizations) GetFDO

func (c *Customizations) GetFDO() *FDOCustomization

func (*Customizations) GetFiles

func (c *Customizations) GetFiles() []FileCustomization

func (*Customizations) GetFilesystems

func (c *Customizations) GetFilesystems() []FilesystemCustomization

func (*Customizations) GetFilesystemsMinSize

func (c *Customizations) GetFilesystemsMinSize() uint64

func (*Customizations) GetFirewall

func (c *Customizations) GetFirewall() *FirewallCustomization

func (*Customizations) GetGroups

func (c *Customizations) GetGroups() []GroupCustomization

func (*Customizations) GetHostname

func (c *Customizations) GetHostname() *string

func (*Customizations) GetIgnition

func (c *Customizations) GetIgnition() *IgnitionCustomization

func (*Customizations) GetInstallationDevice

func (c *Customizations) GetInstallationDevice() string

func (*Customizations) GetKernel

func (c *Customizations) GetKernel() *KernelCustomization

func (*Customizations) GetOpenSCAP

func (c *Customizations) GetOpenSCAP() *OpenSCAPCustomization

func (*Customizations) GetPrimaryLocale

func (c *Customizations) GetPrimaryLocale() (*string, *string)

func (*Customizations) GetRepositories

func (c *Customizations) GetRepositories() ([]RepositoryCustomization, error)

func (*Customizations) GetServices

func (c *Customizations) GetServices() *ServicesCustomization

func (*Customizations) GetTimezoneSettings

func (c *Customizations) GetTimezoneSettings() (*string, []string)

func (*Customizations) GetUsers

func (c *Customizations) GetUsers() []UserCustomization

type DirectoryCustomization

type DirectoryCustomization struct {
	// Absolute path to the directory
	Path string `json:"path" toml:"path"`
	// Owner of the directory specified as a string (user name), int64 (UID) or nil
	User interface{} `json:"user,omitempty" toml:"user,omitempty"`
	// Owner of the directory specified as a string (group name), int64 (UID) or nil
	Group interface{} `json:"group,omitempty" toml:"group,omitempty"`
	// Permissions of the directory specified as an octal number
	Mode string `json:"mode,omitempty" toml:"mode,omitempty"`
	// EnsureParents ensures that all parent directories of the directory exist
	EnsureParents bool `json:"ensure_parents,omitempty" toml:"ensure_parents,omitempty"`
}

DirectoryCustomization represents a directory to be created in the image

func (DirectoryCustomization) ToFsNodeDirectory

func (d DirectoryCustomization) ToFsNodeDirectory() (*fsnode.Directory, error)

ToFsNodeDirectory converts the DirectoryCustomization to an fsnode.Directory

func (*DirectoryCustomization) UnmarshalJSON

func (d *DirectoryCustomization) UnmarshalJSON(data []byte) error

Custom JSON unmarshalling for DirectoryCustomization with validation

func (*DirectoryCustomization) UnmarshalTOML

func (d *DirectoryCustomization) UnmarshalTOML(data interface{}) error

Custom TOML unmarshalling for DirectoryCustomization with validation

type EmbeddedIgnitionCustomization

type EmbeddedIgnitionCustomization struct {
	Config string `json:"config,omitempty" toml:"config,omitempty"`
}

type FDOCustomization

type FDOCustomization struct {
	ManufacturingServerURL string `json:"manufacturing_server_url,omitempty" toml:"manufacturing_server_url,omitempty"`
	DiunPubKeyInsecure     string `json:"diun_pub_key_insecure,omitempty" toml:"diun_pub_key_insecure,omitempty"`
	// This is the output of:
	// echo "sha256:$(openssl x509 -fingerprint -sha256 -noout -in diun_cert.pem | cut -d"=" -f2 | sed 's/://g')"
	DiunPubKeyHash      string `json:"diun_pub_key_hash,omitempty" toml:"diun_pub_key_hash,omitempty"`
	DiunPubKeyRootCerts string `json:"diun_pub_key_root_certs,omitempty" toml:"diun_pub_key_root_certs,omitempty"`
}

type FileCustomization

type FileCustomization struct {
	// Absolute path to the file
	Path string `json:"path" toml:"path"`
	// Owner of the directory specified as a string (user name), int64 (UID) or nil
	User interface{} `json:"user,omitempty" toml:"user,omitempty"`
	// Owner of the directory specified as a string (group name), int64 (UID) or nil
	Group interface{} `json:"group,omitempty" toml:"group,omitempty"`
	// Permissions of the file specified as an octal number
	Mode string `json:"mode,omitempty" toml:"mode,omitempty"`
	// Data is the file content in plain text
	Data string `json:"data,omitempty" toml:"data,omitempty"`
}

FileCustomization represents a file to be created in the image

func (FileCustomization) ToFsNodeFile

func (f FileCustomization) ToFsNodeFile() (*fsnode.File, error)

ToFsNodeFile converts the FileCustomization to an fsnode.File

func (*FileCustomization) UnmarshalJSON

func (f *FileCustomization) UnmarshalJSON(data []byte) error

Custom JSON unmarshalling for FileCustomization with validation

func (*FileCustomization) UnmarshalTOML

func (f *FileCustomization) UnmarshalTOML(data interface{}) error

Custom TOML unmarshalling for FileCustomization with validation

type FilesystemCustomization

type FilesystemCustomization struct {
	Mountpoint string `json:"mountpoint,omitempty" toml:"mountpoint,omitempty"`
	MinSize    uint64 `json:"minsize,omitempty" toml:"size,omitempty"`
}

func (*FilesystemCustomization) UnmarshalJSON

func (fsc *FilesystemCustomization) UnmarshalJSON(data []byte) error

func (*FilesystemCustomization) UnmarshalTOML

func (fsc *FilesystemCustomization) UnmarshalTOML(data interface{}) error

type FirewallCustomization

type FirewallCustomization struct {
	Ports    []string                       `json:"ports,omitempty" toml:"ports,omitempty"`
	Services *FirewallServicesCustomization `json:"services,omitempty" toml:"services,omitempty"`
	Zones    []FirewallZoneCustomization    `json:"zones,omitempty" toml:"zones,omitempty"`
}

type FirewallServicesCustomization

type FirewallServicesCustomization struct {
	Enabled  []string `json:"enabled,omitempty" toml:"enabled,omitempty"`
	Disabled []string `json:"disabled,omitempty" toml:"disabled,omitempty"`
}

type FirewallZoneCustomization

type FirewallZoneCustomization struct {
	Name    *string  `json:"name,omitempty" toml:"name,omitempty"`
	Sources []string `json:"sources,omitempty" toml:"sources,omitempty"`
}

type FirstBootIgnitionCustomization

type FirstBootIgnitionCustomization struct {
	ProvisioningURL string `json:"url,omitempty" toml:"url,omitempty"`
}

type Group

type Group struct {
	Name string `json:"name" toml:"name"`
}

A group specifies an package group.

type GroupCustomization

type GroupCustomization struct {
	Name string `json:"name" toml:"name"`
	GID  *int   `json:"gid,omitempty" toml:"gid,omitempty"`
}

type IgnitionCustomization

type IgnitionCustomization struct {
	Embedded  *EmbeddedIgnitionCustomization  `json:"embedded,omitempty" toml:"embedded,omitempty"`
	FirstBoot *FirstBootIgnitionCustomization `json:"firstboot,omitempty" toml:"firstboot,omitempty"`
}

type KernelCustomization

type KernelCustomization struct {
	Name   string `json:"name,omitempty" toml:"name,omitempty"`
	Append string `json:"append" toml:"append"`
}

type LocaleCustomization

type LocaleCustomization struct {
	Languages []string `json:"languages,omitempty" toml:"languages,omitempty"`
	Keyboard  *string  `json:"keyboard,omitempty" toml:"keyboard,omitempty"`
}

type OpenSCAPCustomization

type OpenSCAPCustomization struct {
	DataStream string                           `json:"datastream,omitempty" toml:"datastream,omitempty"`
	ProfileID  string                           `json:"profile_id,omitempty" toml:"profile_id,omitempty"`
	Tailoring  *OpenSCAPTailoringCustomizations `json:"tailoring,omitempty" toml:"tailoring,omitempty"`
}

type OpenSCAPTailoringCustomizations

type OpenSCAPTailoringCustomizations struct {
	Selected   []string `json:"selected,omitempty" toml:"selected,omitempty"`
	Unselected []string `json:"unselected,omitempty" toml:"unselected,omitempty"`
}

type Package

type Package struct {
	Name    string `json:"name" toml:"name"`
	Version string `json:"version,omitempty" toml:"version,omitempty"`
}

A Package specifies an RPM package.

func (Package) ToNameVersion

func (p Package) ToNameVersion() string

type RepositoryCustomization

type RepositoryCustomization struct {
	Id           string   `json:"id" toml:"id"`
	BaseURLs     []string `json:"baseurls,omitempty" toml:"baseurls,omitempty"`
	GPGKeys      []string `json:"gpgkeys,omitempty" toml:"gpgkeys,omitempty"`
	Metalink     string   `json:"metalink,omitempty" toml:"metalink,omitempty"`
	Mirrorlist   string   `json:"mirrorlist,omitempty" toml:"mirrorlist,omitempty"`
	Name         string   `json:"name,omitempty" toml:"name,omitempty"`
	Priority     *int     `json:"priority,omitempty" toml:"priority,omitempty"`
	Enabled      *bool    `json:"enabled,omitempty" toml:"enabled,omitempty"`
	GPGCheck     *bool    `json:"gpgcheck,omitempty" toml:"gpgcheck,omitempty"`
	RepoGPGCheck *bool    `json:"repo_gpgcheck,omitempty" toml:"repo_gpgcheck,omitempty"`
	SSLVerify    *bool    `json:"sslverify,omitempty" toml:"sslverify,omitempty"`
	Filename     string   `json:"filename,omitempty" toml:"filename,omitempty"`
}

type SSHKeyCustomization

type SSHKeyCustomization struct {
	User string `json:"user" toml:"user"`
	Key  string `json:"key" toml:"key"`
}

type ServicesCustomization

type ServicesCustomization struct {
	Enabled  []string `json:"enabled,omitempty" toml:"enabled,omitempty"`
	Disabled []string `json:"disabled,omitempty" toml:"disabled,omitempty"`
}

type TimezoneCustomization

type TimezoneCustomization struct {
	Timezone   *string  `json:"timezone,omitempty" toml:"timezone,omitempty"`
	NTPServers []string `json:"ntpservers,omitempty" toml:"ntpservers,omitempty"`
}

type UserCustomization

type UserCustomization struct {
	Name        string   `json:"name" toml:"name"`
	Description *string  `json:"description,omitempty" toml:"description,omitempty"`
	Password    *string  `json:"password,omitempty" toml:"password,omitempty"`
	Key         *string  `json:"key,omitempty" toml:"key,omitempty"`
	Home        *string  `json:"home,omitempty" toml:"home,omitempty"`
	Shell       *string  `json:"shell,omitempty" toml:"shell,omitempty"`
	Groups      []string `json:"groups,omitempty" toml:"groups,omitempty"`
	UID         *int     `json:"uid,omitempty" toml:"uid,omitempty"`
	GID         *int     `json:"gid,omitempty" toml:"gid,omitempty"`
}

Jump to

Keyboard shortcuts

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