vmextension

package
v0.0.0-...-73b5b3b Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: MIT Imports: 16 Imported by: 2

Documentation

Overview

Copyright (c) Microsoft Corporation. Licensed under the MIT License.

Copyright (c) Microsoft Corporation. Licensed under the MIT License.

Copyright (c) Microsoft Corporation. Licensed under the MIT License.

Copyright (c) Microsoft Corporation. Licensed under the MIT License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CallbackFunc

type CallbackFunc func(ext *VMExtension) error

CallbackFunc is used for a non-Enable operation callback

type EnableCallbackFunc

type EnableCallbackFunc func(ext *VMExtension) (string, error)

EnableCallbackFunc is used for Enable operation callbacks

type InitializationInfo

type InitializationInfo struct {
	Name                  string                        // The name of the extension, without the Linux or Windows suffix
	Version               string                        // The version of the extension
	SupportsDisable       bool                          // True if we should automatically disable the extension if Disable is called
	SupportsResetState    bool                          // True if we should remove all contents of all folder when ResetState is called
	RequiresSeqNoChange   bool                          // True if Enable will only execute if the sequence number changes
	InstallExitCode       int                           // Exit code to use for the install case
	OtherExitCode         int                           // Exit code to use for all other cases
	EnableCallback        EnableCallbackFunc            // Called for the enable operation
	DisableCallback       CallbackFunc                  // Called for the Disable operation. Only set this if the extension wants a callback.
	UpdateCallback        CallbackFunc                  // Called for the Update operation. If nil, then update is not supported.
	ResetStateCallback    CallbackFunc                  // Called for the ResetState operation. Only set this if the extension wants a callback.
	InstallCallback       CallbackFunc                  // Called for the Install operation. Only set this if the extension wants a callback.
	UninstallCallback     CallbackFunc                  // Called for the Uninstall operation. Only set this if the extension wants a callback.
	CustomStatusFormatter status.StatusMessageFormatter // Provide a function to format the status message. If nil default formatting behavior will be preserved.
	LogFileNamePattern    string                        // Default format to use for log files. Expected to be format string with one parameter; Eg: "<name_pattern>%v"
}

InitializationInfo is passed by the extension to specify how the framework should run

func GetInitializationInfo

func GetInitializationInfo(name string, version string, requiresSeqNoChange bool, enableCallback EnableCallbackFunc) (*InitializationInfo, error)

GetInitializationInfo returns a new InitializationInfo object

type OperationName

type OperationName string
const (
	InstallOperation    OperationName = "install"
	UninstallOperation  OperationName = "uninstall"
	EnableOperation     OperationName = "enable"
	UpdateOperation     OperationName = "update"
	DisableOperation    OperationName = "disable"
	ResetStateOperation OperationName = "resetstate"
)

func OperationNameFromString

func OperationNameFromString(operation string) (OperationName, error)

func (OperationName) ToStatusName

func (operationName OperationName) ToStatusName() string

func (OperationName) ToString

func (operationName OperationName) ToString() string

type VMExtension

type VMExtension struct {
	Name                       string                                    // The name of the extension. This will contain 'Windows' or 'Linux'
	Version                    string                                    // The version of the extension
	GetRequestedSequenceNumber func() (uint, error)                      // Function to get the requested sequence number to run
	CurrentSequenceNumber      *uint                                     // The last run sequence number, null means no existing sequence number was found
	HandlerEnv                 *handlerenv.HandlerEnvironment            // Contains information about the folders necessary for the extension
	GetSettings                func() (*settings.HandlerSettings, error) // Function to get settings passed to the extension
	ExtensionEvents            *extensionevents.ExtensionEventManager    // Allows extensions to raise events
	ExtensionLogger            *logging.ExtensionLogger                  // Automatically logs to the log directory
	// contains filtered or unexported fields
}

VMExtension is an abstraction for standard extension operations in an OS agnostic manner

func GetVMExtension

func GetVMExtension(initInfo *InitializationInfo) (ext *VMExtension, _ error)

GetVMExtension returns a new VMExtension object

func GetVMExtensionForTesting

func GetVMExtensionForTesting(initInfo *InitializationInfo, manager environmentmanager.IGetVMExtensionEnvironmentManager) (ext *VMExtension, _ error)

GetVMExtensionForTesting mocks out the environment part of the VM extension for use with your extension

func (*VMExtension) Do

func (ve *VMExtension) Do()

Do is the main worker method of the extension and determines which operation to run, if necessary

Jump to

Keyboard shortcuts

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