Documentation ¶
Overview ¶
Copyright 2017 Northern.tech AS
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2019 Northern.tech AS
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2019 Northern.tech AS
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2019 Northern.tech AS
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2018 Northern.tech AS
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2019 Northern.tech AS
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2019 Northern.tech AS
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2017 Northern.tech AS
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- func GetExponentialBackoffTime(tried int, maxInterval time.Duration) (time.Duration, error)
- type APIError
- type ApiClient
- type ApiRequest
- type ApiRequester
- type AuthClient
- type AuthDataMessenger
- type AuthReqData
- type AuthRequest
- type AuthRequester
- type AuthToken
- type ClientReauthorizeFunc
- type ClientServerCertificateError
- type Config
- type CurrentUpdate
- type InventoryAttribute
- type InventoryClient
- type InventoryData
- type InventorySubmitter
- type LogData
- type LogUploadClient
- type LogUploader
- type MenderServer
- type RequestProcessingFunc
- type ServerManagementFunc
- type StatusClient
- type StatusReport
- type StatusReportWrapper
- type StatusReporter
- type UpdateClient
- type UpdateResumer
- type Updater
Constants ¶
const ( StatusInstalling = "installing" StatusDownloading = "downloading" StatusRebooting = "rebooting" StatusSuccess = "success" StatusFailure = "failure" StatusAlreadyInstalled = "already-installed" )
const (
EmptyAuthToken = AuthToken("")
)
Variables ¶
var (
ErrDeploymentAborted = errors.New("deployment was aborted")
)
var (
ErrNotAuthorized = errors.New("client not authorized")
)
var ExponentialBackoffSmallestUnit time.Duration = time.Minute
Normally one minute, but used in tests to lower the interval to avoid waiting.
Functions ¶
Types ¶
type APIError ¶
type APIError struct {
// contains filtered or unexported fields
}
APIError is an error type returned after receiving an error message from the server. It wraps a regular error with the request_id - and if the server returns an error message, this is also returned.
type ApiClient ¶
wrapper for http.Client with additional methods
func NewApiClient ¶
func (*ApiClient) Request ¶
func (a *ApiClient) Request(code AuthToken, nextServerIterator ServerManagementFunc, reauth ClientReauthorizeFunc) *ApiRequest
Return a new ApiRequest
type ApiRequest ¶
type ApiRequest struct {
// contains filtered or unexported fields
}
ApiRequester compatible helper. The helper can be used for executing API requests that require authorization as provided Do() method will automatically setup authorization information in the request.
type ApiRequester ¶
Mender API Client wrapper. A standard http.Client is compatible with this interface and can be used without further configuration where ApiRequester is expected. Instead of instantiating the client by yourself, one can also use a wrapper call NewApiClient() that sets up TLS handling according to passed configuration.
type AuthClient ¶
type AuthClient struct { }
Auth client wrapper. Instantiate by yourself or use `NewAuthClient()` helper
func NewAuth ¶
func NewAuth() *AuthClient
func (*AuthClient) Request ¶
func (u *AuthClient) Request(api ApiRequester, server string, dataSrc AuthDataMessenger) ([]byte, error)
type AuthDataMessenger ¶
type AuthDataMessenger interface { // Build authorization request data, returns auth request or an error MakeAuthRequest() (*AuthRequest, error) // Receive authorization token. Normally, the recipient should store the token // in a safe place, so that the token can be used in subsequent API requests. RecvAuthResponse([]byte) error }
Interface capturing a functionality of generating and parsing on authorization messages
type AuthReqData ¶
type AuthReqData struct { // identity data IdData string `json:"id_data"` // tenant token TenantToken string `json:"tenant_token"` // client's public key Pubkey string `json:"pubkey"` }
Structure representing authorization request data. The caller must fill each field.
func (*AuthReqData) ToBytes ¶
func (ard *AuthReqData) ToBytes() ([]byte, error)
Produce a raw byte sequence with authorization data encoded in a format expected by the backend
type AuthRequest ¶
type AuthRequest struct { // raw request message data Data []byte // tenant's authorization token Token AuthToken // request signature Signature []byte }
A wrapper for authorization request
type AuthRequester ¶
type AuthRequester interface {
Request(api ApiRequester, server string, dataSrc AuthDataMessenger) ([]byte, error)
}
type ClientReauthorizeFunc ¶
function type for reauthorization closure (see func reauthorize@mender.go)
type ClientServerCertificateError ¶
type ClientServerCertificateError struct {
// contains filtered or unexported fields
}
func (*ClientServerCertificateError) Error ¶
func (s *ClientServerCertificateError) Error() string
type CurrentUpdate ¶
CurrentUpdate describes currently installed update. Non empty fields will be used when querying for the next update.
type InventoryAttribute ¶
type InventoryAttribute struct { Name string `json:"name"` Value interface{} `json:"value"` }
type InventoryClient ¶
type InventoryClient struct { }
func (*InventoryClient) Submit ¶
func (i *InventoryClient) Submit(api ApiRequester, url string, data interface{}) error
Submit reports status information to the backend
type InventoryData ¶
type InventoryData []InventoryAttribute
func (*InventoryData) ReplaceAttributes ¶
func (id *InventoryData) ReplaceAttributes(attr []InventoryAttribute) error
type InventorySubmitter ¶
type InventorySubmitter interface {
Submit(api ApiRequester, server string, data interface{}) error
}
func NewInventory ¶
func NewInventory() InventorySubmitter
type LogUploadClient ¶
type LogUploadClient struct { }
func (*LogUploadClient) Upload ¶
func (u *LogUploadClient) Upload(api ApiRequester, url string, logs LogData) error
Report status information to the backend
type LogUploader ¶
type LogUploader interface {
Upload(api ApiRequester, server string, logs LogData) error
}
func NewLog ¶
func NewLog() LogUploader
type MenderServer ¶
type MenderServer struct {
ServerURL string
}
MenderServer is a placeholder for a full server definition used when multiple servers are given. The fields corresponds to the definitions given in menderConfig.
type RequestProcessingFunc ¶
type ServerManagementFunc ¶
type ServerManagementFunc func() *MenderServer
function type for setting server (in case of multiple fallover servers)
type StatusClient ¶
type StatusClient struct { }
func (*StatusClient) Report ¶
func (u *StatusClient) Report(api ApiRequester, url string, report StatusReport) error
Report status information to the backend
type StatusReport ¶
type StatusReportWrapper ¶
type StatusReportWrapper struct { Report StatusReport API ApiRequester URL string }
StatusReportWrapper holds the data that is passed to the statescript functions upon reporting script exectution-status to the backend.
type StatusReporter ¶
type StatusReporter interface {
Report(api ApiRequester, server string, report StatusReport) error
}
func NewStatus ¶
func NewStatus() StatusReporter
type UpdateClient ¶
type UpdateClient struct {
// contains filtered or unexported fields
}
func NewUpdate ¶
func NewUpdate() *UpdateClient
func (*UpdateClient) FetchUpdate ¶
func (u *UpdateClient) FetchUpdate(api ApiRequester, url string, maxWait time.Duration) (io.ReadCloser, int64, error)
FetchUpdate returns a byte stream which is a download of the given link.
func (*UpdateClient) GetScheduledUpdate ¶
func (u *UpdateClient) GetScheduledUpdate(api ApiRequester, server string, current CurrentUpdate) (interface{}, error)
type UpdateResumer ¶
type UpdateResumer struct {
// contains filtered or unexported fields
}
func NewUpdateResumer ¶
func NewUpdateResumer(stream io.ReadCloser, contentLength int64, maxWait time.Duration, apiReq ApiRequester, req *http.Request) *UpdateResumer
Note: It is important that nothing has been read from the stream yet.
func (*UpdateResumer) Close ¶
func (h *UpdateResumer) Close() error
type Updater ¶
type Updater interface { GetScheduledUpdate(api ApiRequester, server string, current CurrentUpdate) (interface{}, error) FetchUpdate(api ApiRequester, url string, maxWait time.Duration) (io.ReadCloser, int64, error) }