cloudconfig

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2023 License: Apache-2.0 Imports: 13 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CloudConfigTemplate = `` /* 6860-byte string literal not displayed */
View Source
var WindowsSetupScriptTemplate = `` /* 8401-byte string literal not displayed */

Functions

func GetCloudConfig

func GetCloudConfig(bootstrapParams params.BootstrapInstance, tools params.RunnerApplicationDownload, runnerName string) (string, error)

GetCloudConfig is a helper function that generates a cloud-init config for Linux and a powershell script for Windows. In most cases this function should do, but in situations where a more custom approach is needed, you may need to call GetCloudInitConfig() or GetRunnerInstallScript() directly and compose the final userdata in a different way. The extra specs PreInstallScripts is only supported on Linux via cloud-init by this function. On some providers, like Azure Windows initialization scripts are run by creating a separate CustomScriptExtension resource for each individual script. On other clouds it may be different. This function aims to be generic, which is why it only supports the PreInstallScripts via cloud-init.

func GetCloudInitConfig

func GetCloudInitConfig(bootstrapParams params.BootstrapInstance, installScript []byte) (string, error)

GetCloudInitConfig returns the cloud-init specific userdata config. This config can be used on most clouds for most Linux machines. The install runner script must be generated separately either by GetRunnerInstallScript() or some other means.

func GetRunnerInstallScript

func GetRunnerInstallScript(bootstrapParams params.BootstrapInstance, tools params.RunnerApplicationDownload, runnerName string) ([]byte, error)

GetRunnerInstallScript returns the runner install script for the given bootstrap params. This function will return either the default script for the given OS type or will use the supplied template if one is provided.

func InstallRunnerScript

func InstallRunnerScript(installParams InstallRunnerParams, osType params.OSType, tpl string) ([]byte, error)

Types

type CACerts

type CACerts struct {
	RemoveDefaults bool     `yaml:"remove-defaults"`
	Trusted        []string `yaml:"trusted"`
}

type CloudConfigSpec

type CloudConfigSpec struct {
	// RunnerInstallTemplate can be used to override the default runner install template.
	// If used, the caller is responsible for the correctness of the template as well as the
	// suitability of the template for the target OS.
	RunnerInstallTemplate []byte `json:"runner_install_template"`
	// PreInstallScripts is a map of pre-install scripts that will be run before the
	// runner install script. These will run as root and can be used to prep a generic image
	// before we attempt to install the runner. The key of the map is the name of the script
	// as it will be written to disk. The value is a byte array with the contents of the script.
	//
	// These scripts will be added and run in alphabetical order.
	//
	// On Linux, we will set the executable flag. On Windows, the name matters as Windows looks for an
	// extension to determine if the file is an executable or not. In theory this can hold binaries,
	// but in most cases this will most likely hold scripts. We do not currenly validate the payload,
	// so it's up to the user what they upload here.
	// Caution needs to be exercised when using this feature, as the total size of userdata is limited
	// on most providers.
	PreInstallScripts map[string][]byte `json:"pre_install_scripts"`
	// ExtraContext is a map of extra context that will be passed to the runner install template.
	ExtraContext map[string]string `json:"extra_context"`
}

CloudConfigSpec is a struct that holds extra specs that can be used to customize user data.

func GetSpecs

func GetSpecs(bootstrapParams params.BootstrapInstance) (CloudConfigSpec, error)

GetSpecs returns the cloud config specific extra specs from the bootstrap params.

type CloudInit

type CloudInit struct {
	PackageUpgrade    bool        `yaml:"package_upgrade"`
	Packages          []string    `yaml:"packages,omitempty"`
	SSHAuthorizedKeys []string    `yaml:"ssh_authorized_keys,omitempty"`
	SystemInfo        *SystemInfo `yaml:"system_info,omitempty"`
	RunCmd            []string    `yaml:"runcmd,omitempty"`
	WriteFiles        []File      `yaml:"write_files,omitempty"`
	CACerts           CACerts     `yaml:"ca-certs,omitempty"`
	// contains filtered or unexported fields
}

func NewDefaultCloudInitConfig

func NewDefaultCloudInitConfig() *CloudInit

func (*CloudInit) AddCACert

func (c *CloudInit) AddCACert(cert []byte) error

func (*CloudInit) AddFile

func (c *CloudInit) AddFile(contents []byte, path, owner, permissions string)

func (*CloudInit) AddPackage

func (c *CloudInit) AddPackage(pkgs ...string)

func (*CloudInit) AddRunCmd

func (c *CloudInit) AddRunCmd(cmd string)

func (*CloudInit) AddSSHKey

func (c *CloudInit) AddSSHKey(keys ...string)

func (*CloudInit) Serialize

func (c *CloudInit) Serialize() (string, error)

type DefaultUser

type DefaultUser struct {
	Name   string   `yaml:"name"`
	Home   string   `yaml:"home"`
	Shell  string   `yaml:"shell"`
	Groups []string `yaml:"groups,omitempty"`
	Sudo   string   `yaml:"sudo"`
}

type File

type File struct {
	Encoding    string `yaml:"encoding"`
	Content     string `yaml:"content"`
	Owner       string `yaml:"owner"`
	Path        string `yaml:"path"`
	Permissions string `yaml:"permissions"`
}

type InstallRunnerParams

type InstallRunnerParams struct {
	// FileName is the name of the file that will be downloaded from the download URL.
	// This will be the runner archive downloaded from GitHub.
	FileName string
	// DownloadURL is the URL from which the runner archive will be downloaded.
	DownloadURL string
	// RunnerUsername is the username of the user that will run the runner service.
	RunnerUsername string
	// RunnerGroup is the group of the user that will run the runner service.
	RunnerGroup string
	// RepoURL is the URL or the github repo the github runner agent needs to configure itself.
	RepoURL string
	// MetadataURL is the URL where instances can fetch information needed to set themselves up.
	// This URL is set in the GARM config file.
	MetadataURL string
	// RunnerName is the name of the runner. GARM will use this to register the runner with GitHub.
	RunnerName string
	// RunnerLabels is a comma separated list of labels that will be added to the runner.
	RunnerLabels string
	// CallbackURL is the URL where the instance can send a post, signaling progress or status.
	// This URL is set in the GARM config file.
	CallbackURL string
	// CallbackToken is the token that needs to be set by the instance in the headers in order to call
	// the CallbackURL.
	CallbackToken string
	// TempDownloadToken is the token that needs to be set by the instance in the headers in order to download
	// the githun runner. This is usually needed when using garm against a GHES instance.
	TempDownloadToken string
	// CABundle is a CA certificate bundle which will be sent to instances and which will tipically be installed
	// as a system wide trusted root CA by either cloud-init or whatever mechanism the provider will use to set
	// up the runner.
	CABundle string
	// GitHubRunnerGroup is the github runner group in which the newly installed runner should be added to.
	GitHubRunnerGroup string
	// EnableBootDebug will enable bash debug mode.
	EnableBootDebug bool
	// ExtraContext is a map of extra context that will be passed to the runner install template.
	// This option is useful for situations in which you're supplying your own template and you need
	// to pass in information that is not available in the default template.
	ExtraContext map[string]string
	// UseJITConfig indicates whether to attempt to configure the runner using JIT or a registration token.
	UseJITConfig bool
}

InstallRunnerParams holds the parameters needed to render the runner install script.

type SystemInfo

type SystemInfo struct {
	DefaultUser DefaultUser `yaml:"default_user"`
}

Jump to

Keyboard shortcuts

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