Skip to content

Commit 37acf23

Browse files
committed
Gt-23 ArangoTask handler
1 parent db986e2 commit 37acf23

20 files changed

+432
-52
lines changed

pkg/apis/deployment/v1/arango_task_spec.go

+12-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ import "encoding/json"
2424

2525
type ArangoTaskType string
2626

27+
const (
28+
// ArangoTaskPingType send ping to the db server
29+
ArangoTaskPingType ArangoTaskType = "Ping"
30+
)
31+
2732
type ArangoTaskDetails []byte
2833

2934
func (a ArangoTaskDetails) MarshalJSON() ([]byte, error) {
@@ -68,7 +73,12 @@ var _ json.Unmarshaler = &ArangoTaskDetails{}
6873
var _ json.Marshaler = ArangoTaskDetails{}
6974

7075
type ArangoTaskSpec struct {
71-
Type ArangoTaskType `json:"type,omitempty"`
76+
Type ArangoTaskType `json:"type,required"`
77+
DeploymentName string `json:"deploymentName,required"`
78+
Details ArangoTaskDetails `json:"details,omitempty"`
79+
}
7280

73-
Details ArangoTaskDetails `json:"details,omitempty"`
81+
type ArangoTaskPing struct {
82+
DurationSeconds int `json:"durationSeconds"`
83+
Counts int `json:"counts"`
7484
}

pkg/apis/deployment/v1/arango_task_status.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,12 @@ const (
3131
)
3232

3333
type ArangoTaskStatus struct {
34-
AcceptedSpec *ArangoTaskSpec `json:"acceptedSpec,omitempty"`
34+
AcceptedSpec *ArangoTaskSpec `json:"acceptedSpec,omitempty"`
35+
State ArangoTaskState `json:"state,omitempty"`
36+
ActionsState []ArangoActionState `json:"actionsState,omitempty"`
37+
}
3538

36-
State ArangoTaskState `json:"state,omitempty"`
37-
Details ArangoTaskDetails `json:"details,omitempty"`
39+
type ArangoActionState struct {
40+
ActionId string `json:"actionId,omitempty"`
41+
State ArangoTaskState `json:"state,omitempty"`
3842
}

pkg/apis/deployment/v1/deployment_status.go

+3
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ type DeploymentStatus struct {
6767
// ResourcesPlan to update this deployment. Executed before plan, after highPlan
6868
ResourcesPlan Plan `json:"resourcesPlan,omitempty"`
6969

70+
// TaskPlan to update this deployment. Executed as the last one
71+
TaskPlan Plan `json:"taskPlan,omitempty"`
72+
7073
// AcceptedSpec contains the last specification that was accepted by the operator.
7174
AcceptedSpec *DeploymentSpec `json:"accepted-spec,omitempty"`
7275

pkg/apis/deployment/v1/plan.go

+11
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,11 @@ const (
195195

196196
// Resources
197197
ActionTypeResourceSync ActionType = "ResourceSync"
198+
199+
// ArangoTask actions
200+
201+
// ActionTypePing it a mock to check if the action flow is working
202+
ActionTypePing ActionType = "Ping"
198203
)
199204

200205
const (
@@ -327,6 +332,12 @@ func (a Action) SetImage(image string) Action {
327332
return a
328333
}
329334

335+
// SetTaskID sets the TaskID field to the given value and returns the modified action.
336+
func (a Action) SetTaskID(taskID types.UID) Action {
337+
a.TaskID = taskID
338+
return a
339+
}
340+
330341
// IsStarted returns true if the action has been started already.
331342
func (a Action) IsStarted() bool {
332343
return !a.StartTime.IsZero()

pkg/apis/deployment/v1/zz_generated.deepcopy.go

+42-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/deployment/v2alpha1/arango_task_spec.go

+12-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ import "encoding/json"
2424

2525
type ArangoTaskType string
2626

27+
const (
28+
// ArangoTaskPingType send ping to the db server
29+
ArangoTaskPingType ArangoTaskType = "Ping"
30+
)
31+
2732
type ArangoTaskDetails []byte
2833

2934
func (a ArangoTaskDetails) MarshalJSON() ([]byte, error) {
@@ -68,7 +73,12 @@ var _ json.Unmarshaler = &ArangoTaskDetails{}
6873
var _ json.Marshaler = ArangoTaskDetails{}
6974

7075
type ArangoTaskSpec struct {
71-
Type ArangoTaskType `json:"type,omitempty"`
76+
Type ArangoTaskType `json:"type,required"`
77+
DeploymentName string `json:"deploymentName,required"`
78+
Details ArangoTaskDetails `json:"details,omitempty"`
79+
}
7280

73-
Details ArangoTaskDetails `json:"details,omitempty"`
81+
type ArangoTaskPing struct {
82+
DurationSeconds int `json:"durationSeconds"`
83+
Counts int `json:"counts"`
7484
}

pkg/apis/deployment/v2alpha1/arango_task_status.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,12 @@ const (
3131
)
3232

3333
type ArangoTaskStatus struct {
34-
AcceptedSpec *ArangoTaskSpec `json:"acceptedSpec,omitempty"`
34+
AcceptedSpec *ArangoTaskSpec `json:"acceptedSpec,omitempty"`
35+
State ArangoTaskState `json:"state,omitempty"`
36+
ActionsState []ArangoActionState `json:"actionsState,omitempty"`
37+
}
3538

36-
State ArangoTaskState `json:"state,omitempty"`
37-
Details ArangoTaskDetails `json:"details,omitempty"`
39+
type ArangoActionState struct {
40+
ActionId string `json:"actionId,omitempty"`
41+
State ArangoTaskState `json:"state,omitempty"`
3842
}

pkg/apis/deployment/v2alpha1/deployment_status.go

+3
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ type DeploymentStatus struct {
6767
// ResourcesPlan to update this deployment. Executed before plan, after highPlan
6868
ResourcesPlan Plan `json:"resourcesPlan,omitempty"`
6969

70+
// TaskPlan to update this deployment. Executed as the last one
71+
TaskPlan Plan `json:"taskPlan,omitempty"`
72+
7073
// AcceptedSpec contains the last specification that was accepted by the operator.
7174
AcceptedSpec *DeploymentSpec `json:"accepted-spec,omitempty"`
7275

pkg/apis/deployment/v2alpha1/plan.go

+11
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,11 @@ const (
195195

196196
// Resources
197197
ActionTypeResourceSync ActionType = "ResourceSync"
198+
199+
// ArangoTask actions
200+
201+
// ActionTypePing it a mock to check if the action flow is working
202+
ActionTypePing ActionType = "Ping"
198203
)
199204

200205
const (
@@ -327,6 +332,12 @@ func (a Action) SetImage(image string) Action {
327332
return a
328333
}
329334

335+
// SetTaskID sets the TaskID field to the given value and returns the modified action.
336+
func (a Action) SetTaskID(taskID types.UID) Action {
337+
a.TaskID = taskID
338+
return a
339+
}
340+
330341
// IsStarted returns true if the action has been started already.
331342
func (a Action) IsStarted() bool {
332343
return !a.StartTime.IsZero()

pkg/apis/deployment/v2alpha1/zz_generated.deepcopy.go

+42-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)