Documentation ¶
Index ¶
- Variables
- func GetCloudConfig(bootstrapParams params.BootstrapInstance, ...) (string, error)
- func GetCloudInitConfig(bootstrapParams params.BootstrapInstance, installScript []byte) (string, error)
- func GetRunnerInstallScript(bootstrapParams params.BootstrapInstance, ...) ([]byte, error)
- func InstallRunnerScript(installParams InstallRunnerParams, osType params.OSType, tpl string) ([]byte, error)
- type CACerts
- type CloudConfigSpec
- type CloudInit
- func (c *CloudInit) AddCACert(cert []byte) error
- func (c *CloudInit) AddFile(contents []byte, path, owner, permissions string)
- func (c *CloudInit) AddPackage(pkgs ...string)
- func (c *CloudInit) AddRunCmd(cmd string)
- func (c *CloudInit) AddSSHKey(keys ...string)
- func (c *CloudInit) ReplaceDefaultUser(user params.UserDescription)
- func (c *CloudInit) Serialize() (string, error)
- type DefaultUser
- type File
- type InstallRunnerParams
- type SystemInfo
Constants ¶
This section is empty.
Variables ¶
var CloudConfigTemplate = `` /* 6371-byte string literal not displayed */
var WindowsSetupScriptTemplate = `` /* 12344-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 ¶
Types ¶
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 `` /* 405-byte string literal not displayed */ // 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 `` /* 405-byte string literal not displayed */ // ExtraContext is a map of extra context that will be passed to the runner install template. ExtraContext map[string]string `` /* 148-byte string literal not displayed */ }
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 { Users []string `yaml:"users"` 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) AddPackage ¶
func (*CloudInit) ReplaceDefaultUser ¶
func (c *CloudInit) ReplaceDefaultUser(user params.UserDescription)
type DefaultUser ¶
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"`
}