handlersettings

package
v1.3.12 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const HandlerEnvFileName = "HandlerEnvironment.json"

HandlerEnvFileName is the file name of the Handler Environment as placed by the Azure Linux Guest Agent.

Variables

This section is empty.

Functions

func DoesFileExist

func DoesFileExist(path string) bool

func GetConfigFilePath

func GetConfigFilePath(configFolder string, sequenceNumber int, extensionName string) string

Gets the config file path for the current extension name and sequence number. Example config file path: RC0001_02.0.settings

func GetHandlerEnv

func GetHandlerEnv() (he types.HandlerEnvironment, _ error)

GetHandlerEnv locates the HandlerEnvironment.json file by assuming it lives next to or one level above the extension handler (read: this) executable, reads, parses and returns it.

func GetUriForLogging

func GetUriForLogging(uriString string) string

Scrub query. Used to remove the query parts like SAS token.

func ParseHandlerEnv

func ParseHandlerEnv(b []byte) (he types.HandlerEnvironment, _ error)

ParseHandlerEnv parses the /var/lib/waagent/[extension]/HandlerEnvironment.json format.

func ReadSettings

func ReadSettings(configFilePath string) (public, protected map[string]interface{}, _ error)

ReadSettings locates the .settings file and returns public settings JSON, and protected settings JSON (by decrypting it with the keys in configFolder).

func UnmarshalHandlerSettings

func UnmarshalHandlerSettings(publicSettings, protectedSettings map[string]interface{}, publicV, protectedV interface{}) error

UnmarshalHandlerSettings unmarshals given publicSettings/protectedSettings types assumed underlying values are JSON into references publicV/protectedV respectively (of struct types that contain structured fields for settings).

Types

type HandlerSettings

type HandlerSettings struct {
	PublicSettings
	ProtectedSettings
}

handlerSettings holds the configuration of the extension handler.

func GetHandlerSettings

func GetHandlerSettings(configFolder string, extensionName string, sequenceNumber int, logContext *log.Context) (HandlerSettings, error)

Get handler settings from config folder. Example path: /var/lib/waagent/Microsoft.CPlat.Core.RunCommandHandlerLinux-1.3.2/config

func ParseAndValidateSettings

func ParseAndValidateSettings(ctx *log.Context, configFilePath string) (h HandlerSettings, _ error)

parseAndValidateSettings reads configuration from configFolder, decrypts it, runs JSON-schema and logical validation on it and returns it back.

func (HandlerSettings) InstallAsService

func (s HandlerSettings) InstallAsService() bool

Gets the InstallAsService field from the RunCommand's properties

func (HandlerSettings) ReadArtifacts

func (s HandlerSettings) ReadArtifacts() ([]UnifiedArtifact, error)

func (HandlerSettings) Script

func (s HandlerSettings) Script() string

func (HandlerSettings) ScriptSAS

func (s HandlerSettings) ScriptSAS() string

func (HandlerSettings) ScriptURI

func (s HandlerSettings) ScriptURI() string

type HandlerSettingsFile

type HandlerSettingsFile struct {
	RuntimeSettings []RunTimeSettingsFile `json:"runtimeSettings"`
}

type ParameterDefinition

type ParameterDefinition struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type ProtectedArtifactSource

type ProtectedArtifactSource struct {
	ArtifactId              int                        `json:"id"`
	ArtifactSasToken        string                     `json:"sasToken"`
	ArtifactManagedIdentity *RunCommandManagedIdentity `json:"artifactManagedIdentity"`
}

Contains secret information about an artifact to download to the VM. This includes the sas token for the uri (located in public settings) and the managed identity. The public and protected artifact sources are keyed by the artifactId.

type ProtectedSettings

type ProtectedSettings struct {
	RunAsPassword       string                `json:"runAsPassword"`
	SourceSASToken      string                `json:"sourceSASToken"`
	OutputBlobSASToken  string                `json:"outputBlobSASToken"`
	ErrorBlobSASToken   string                `json:"errorBlobSASToken"`
	ProtectedParameters []ParameterDefinition `json:"protectedParameters"`

	// List of artifacts to download before running the script
	Artifacts []ProtectedArtifactSource `json:"artifacts"`

	// Managed identity to use for reading the script if its not a SAS and if the VM doesn't have a system managed identity
	SourceManagedIdentity *RunCommandManagedIdentity `json:"sourceManagedIdentity"`

	// Managed identity to use for writing the output blob if the VM doesn't have a system managed identity
	OutputBlobManagedIdentity *RunCommandManagedIdentity `json:"outputBlobManagedIdentity"`

	// Managed identity to use for writing the error blob if the VM doesn't have a system managed identity
	ErrorBlobManagedIdentity *RunCommandManagedIdentity `json:"errorBlobManagedIdentity"`
}

ProtectedSettings is the type decoded and deserialized from protected configuration section. This should be in sync with protectedSettingsSchema.

type PublicArtifactSource

type PublicArtifactSource struct {
	ArtifactId  int    `json:"id"`
	ArtifactUri string `json:"uri"`
	FileName    string `json:"fileName"`
}

Contains all public information for the artifact. Any sas token will be removed from the uri and added to the ArtifactSource in the protected settings. The public and protected artifact settings are keyed by the artifactId.

type PublicSettings

type PublicSettings struct {
	Source                          *ScriptSource         `json:"source"`
	Parameters                      []ParameterDefinition `json:"parameters"`
	RunAsUser                       string                `json:"runAsUser"`
	OutputBlobURI                   string                `json:"outputBlobUri"`
	ErrorBlobURI                    string                `json:"errorBlobUri"`
	TimeoutInSeconds                int                   `json:"timeoutInSeconds,int"`
	AsyncExecution                  bool                  `json:"asyncExecution,bool"`
	TreatFailureAsDeploymentFailure bool                  `json:"treatFailureAsDeploymentFailure,bool"`

	// List of artifacts to download before running the script
	Artifacts []PublicArtifactSource `json:"artifacts"`
}

PublicSettings is the type deserialized from public configuration section of the extension handler. This should be in sync with publicSettingsSchema.

type RunCommandManagedIdentity

type RunCommandManagedIdentity struct {
	ObjectId string `json:"objectId"`
	ClientId string `json:"clientId"`
}

type RunTimeSettingsFile

type RunTimeSettingsFile struct {
	HandlerSettings settings.SettingsCommon `json:"handlerSettings"`
}

type ScriptSource

type ScriptSource struct {
	Script    string `json:"script"`
	ScriptURI string `json:"scriptUri"`
	// When the RunCommand extension sees the installAsService == true, it will apply the operations on the service as well.
	// This service will continuously poll HGAP for any new goal state.
	InstallAsService bool `json:"installAsService,bool"`
}

type UnifiedArtifact

type UnifiedArtifact struct {
	ArtifactId              int
	ArtifactUri             string
	FileName                string
	ArtifactSasToken        string
	ArtifactManagedIdentity *RunCommandManagedIdentity
}

Contains the public and protected information for the artifact to download This structure is only kept in memory. It is neither read nor persisted

Jump to

Keyboard shortcuts

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