Documentation
¶
Index ¶
- Constants
- func CreateFile(filePath string) (*os.File, error)
- func CreateFileWithContent(filePath string, content string) error
- func ExecScript(script ...string) error
- func ProcessFileWithChunks(filePath string, chunkSize int, processor ChunkProcessor, hash hash.Hash) error
- func WriteFileChunk(file *os.File, fileHash hash.Hash, chunk string) error
- type Agent
- type BootstrapSettings
- type ChunkProcessor
- type MessageError
- type MessageErrorCode
- type Request
- type RequestData
- type Response
- type ResponseData
- type ResponseResultFunc
Constants ¶
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 ¶
CreateFile creates a file with the provided name.
func CreateFileWithContent ¶
CreateFileWithContent creates a file with the provided name and content.
func ExecScript ¶
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.
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 ¶
CreateBootstrappingFeature publishes message to ensure the Bootstrapping feature.
func (*Agent) HandleResponse ¶
HandleResponse handles Bootstrapping response 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 ¶
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 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 ¶
ResponseResultFunc receives and handles the response result per bootstrapping request.