-
Notifications
You must be signed in to change notification settings - Fork 19
/
rebooting_state.go
54 lines (43 loc) · 1.3 KB
/
rebooting_state.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
* UpdateHub
* Copyright (C) 2017
* O.S. Systems Sofware LTDA: contato@ossystems.com.br
*
* SPDX-License-Identifier: Apache-2.0
*/
package updatehub
import (
"github.com/UpdateHub/updatehub/client"
"github.com/UpdateHub/updatehub/metadata"
)
// RebootingState is the State interface implementation for the UpdateHubStateRebooting
type RebootingState struct {
BaseState
ReportableState
updateMetadata *metadata.UpdateMetadata
}
// ID returns the state id
func (state *RebootingState) ID() UpdateHubState {
return state.id
}
// UpdateMetadata is the ReportableState interface implementation
func (state *RebootingState) UpdateMetadata() *metadata.UpdateMetadata {
return state.updateMetadata
}
// Handle for RebootingState implements the installation process itself
func (state *RebootingState) Handle(uh *UpdateHub) (State, bool) {
err := uh.Reboot()
if err != nil {
return NewErrorState(state.apiClient, nil, NewTransientError(err)), false
}
return NewIdleState(), false
}
// NewRebootingState creates a new RebootingState
func NewRebootingState(apiClient *client.ApiClient, updateMetadata *metadata.UpdateMetadata) *RebootingState {
state := &RebootingState{
BaseState: BaseState{id: UpdateHubStateRebooting},
updateMetadata: updateMetadata,
}
state.apiClient = apiClient
return state
}