bootstrapping

package
v0.1.0-M4 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2023 License: Apache-2.0, EPL-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MessagesParameterInvalid defines the invalid parameter code.
	MessagesParameterInvalid MessageErrorCode = "messages:parameter.invalid"
	// MessagesExecutionFailed defines the execution failed code.
	MessagesExecutionFailed MessageErrorCode = "messages:execution.failed"

	// StatusBadRequest defines the bad request status code.
	StatusBadRequest = http.StatusBadRequest
	// StatusInternalError defines the internal server error status code.
	StatusInternalError = http.StatusInternalServerError
)

Variables

This section is empty.

Functions

func CreateFile

func CreateFile(filePath string) (*os.File, error)

CreateFile creates a file with the provided name.

func CreateFileWithContent

func CreateFileWithContent(filePath string, content string) error

CreateFileWithContent creates a file with the provided name and content.

func ExecScript

func ExecScript(script ...string) error

ExecScript executes a script file or command.

func ProcessFileWithChunks

func ProcessFileWithChunks(filePath string, chunkSize int, processor ChunkProcessor, hash hash.Hash) error

ProcessFileWithChunks reads file in chunks and calls ChunkProcessor for each one. Breaks proccessing on chunk proccesssing error.

func WriteFileChunk

func WriteFileChunk(file *os.File, fileHash hash.Hash, chunk string) error

WriteFileChunk decodes and appends the chunk to the provided file. Updates the provided file hash.

Types

type Agent

type Agent struct {
	ResultFunc ResponseResultFunc

	Logger logger.Logger
	// contains filtered or unexported fields
}

Agent contains the Bootstrapping Agent system data.

func NewAgent

func NewAgent(bs *BootstrapSettings, logger logger.Logger, resultfunc ResponseResultFunc) (*Agent, error)

NewAgent creates Bootstrapping Agent with provided settings.

func (*Agent) CreateBootstrappingFeature

func (a *Agent) CreateBootstrappingFeature(publisher message.Publisher) error

CreateBootstrappingFeature publishes message to ensure the Bootstrapping feature.

func (*Agent) HandleResponse

func (a *Agent) HandleResponse(inboxMsg *message.Message) ([]*message.Message, error)

HandleResponse handles Bootstrapping response messages.

func (*Agent) PublishRequest

func (a *Agent) PublishRequest(requestID string, publisher message.Publisher) error

PublishRequest publishes Bootstrapping request messages.

type BootstrapSettings

type BootstrapSettings struct {
	logger.LogSettings

	config.HubConnectionSettings

	PreBootstrapFile   string   `json:"preBootstrapFile"`
	PreBootstrapScript []string `json:"preBootstrapScript"`

	PostBootstrapFile   string   `json:"postBootstrapFile"`
	PostBootstrapScript []string `json:"postBootstrapScript"`

	ProvisioningFile          string `json:"provisioningFile"`
	BootstrapProvisioningFile string `json:"bootstrapProvisioningFile"`

	ChunkSize int `json:"chunkSize"`
}

BootstrapSettings contains all Bootstrapping Agent configuration data.

func DefaultSettings

func DefaultSettings() *BootstrapSettings

DefaultSettings returns the default settings.

func (*BootstrapSettings) Validate

func (c *BootstrapSettings) Validate() error

Validate validates the bootstrapping settings.

type ChunkProcessor

type ChunkProcessor func(chunk string, hasNext bool) error

ChunkProcessor is called to process each chunk on ProcessFileWithChunks invocation. The chunk is base64 encoded while the hasNext argument is true if there are more file chunks.

type MessageError

type MessageError struct {
	ErrorCode MessageErrorCode `json:"error"`
	Status    int              `json:"status"`
}

MessageError contains a message error data.

func NewMessageInternalError

func NewMessageInternalError() *MessageError

NewMessageInternalError creates internal server message error.

func NewMessageParameterInvalidError

func NewMessageParameterInvalidError() *MessageError

NewMessageParameterInvalidError creates invalid parameter message error.

type MessageErrorCode

type MessageErrorCode string

MessageErrorCode defines the error code.

type Request

type Request struct {
	// contains filtered or unexported fields
}

Request contains the system data related per bootstrapping request.

type RequestData

type RequestData struct {
	ID    string `json:"requestId"`
	Chunk string `json:"chunk,omitempty"`
	Hash  string `json:"hash,omitempty"`
}

RequestData defines the request fields.

type Response

type Response struct {
	// contains filtered or unexported fields
}

Response contains the system data related per bootstrapping request response.

type ResponseData

type ResponseData struct {
	ID           string `json:"requestId"`
	Chunk        string `json:"chunk,omitempty"`
	Hash         string `json:"hash,omitempty"`
	Provisioning string `json:"provisioning,omitempty"`
	Err          int    `json:"error,omitempty"`
}

ResponseData defines the response fields.

type ResponseResultFunc

type ResponseResultFunc func(requestID string, succeeded bool)

ResponseResultFunc receives and handles the response result per bootstrapping request.

Jump to

Keyboard shortcuts

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