11//
22// DISCLAIMER
33//
4- // Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
4+ // Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
55//
66// Licensed under the Apache License, Version 2.0 (the "License");
77// you may not use this file except in compliance with the License.
@@ -26,18 +26,7 @@ import (
2626 core "k8s.io/api/core/v1"
2727
2828 api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
29- )
30-
31- const (
32- setConditionActionV2KeyTypeAdd string = "add"
33- setConditionActionV2KeyTypeRemove string = "remove"
34-
35- setConditionActionV2KeyType string = "type"
36- setConditionActionV2KeyAction string = "action"
37- setConditionActionV2KeyStatus string = "status"
38- setConditionActionV2KeyReason string = "reason"
39- setConditionActionV2KeyMessage string = "message"
40- setConditionActionV2KeyHash string = "hash"
29+ "github.com/arangodb/kube-arangodb/pkg/deployment/reconcile/shared"
4130)
4231
4332func newSetConditionV2Action (action api.Action , actionCtx ActionContext ) Action {
@@ -57,32 +46,32 @@ type actionSetConditionV2 struct {
5746
5847// Start starts the action for changing conditions on the provided member.
5948func (a actionSetConditionV2 ) Start (ctx context.Context ) (bool , error ) {
60- at , ok := a .action .Params [setConditionActionV2KeyType ]
49+ at , ok := a .action .Params [shared . SetConditionActionV2KeyType ]
6150 if ! ok {
62- a .log .Info ("key %s is missing in action definition" , setConditionActionV2KeyType )
51+ a .log .Info ("key %s is missing in action definition" , shared . SetConditionActionV2KeyType )
6352 return true , nil
6453 }
6554
66- aa , ok := a .action .Params [setConditionActionV2KeyAction ]
55+ aa , ok := a .action .Params [shared . SetConditionActionV2KeyAction ]
6756 if ! ok {
68- a .log .Info ("key %s is missing in action definition" , setConditionActionV2KeyAction )
57+ a .log .Info ("key %s is missing in action definition" , shared . SetConditionActionV2KeyAction )
6958 return true , nil
7059 }
7160
7261 switch at {
73- case setConditionActionV2KeyTypeAdd :
74- ah := a .action .Params [setConditionActionV2KeyHash ]
75- am := a .action .Params [setConditionActionV2KeyMessage ]
76- ar := a .action .Params [setConditionActionV2KeyReason ]
77- as := a .action .Params [setConditionActionV2KeyStatus ] == string (core .ConditionTrue )
62+ case shared . SetConditionActionV2KeyTypeAdd :
63+ ah := a .action .Params [shared . SetConditionActionV2KeyHash ]
64+ am := a .action .Params [shared . SetConditionActionV2KeyMessage ]
65+ ar := a .action .Params [shared . SetConditionActionV2KeyReason ]
66+ as := a .action .Params [shared . SetConditionActionV2KeyStatus ] == string (core .ConditionTrue )
7867
7968 if err := a .actionCtx .WithStatusUpdateErr (ctx , func (s * api.DeploymentStatus ) (bool , error ) {
8069 return s .Conditions .UpdateWithHash (api .ConditionType (aa ), as , ar , am , ah ), nil
8170 }); err != nil {
8271 a .log .Err (err ).Warn ("unable to update status" )
8372 return true , nil
8473 }
85- case setConditionActionV2KeyTypeRemove :
74+ case shared . SetConditionActionV2KeyTypeRemove :
8675 if err := a .actionCtx .WithStatusUpdateErr (ctx , func (s * api.DeploymentStatus ) (bool , error ) {
8776 return s .Conditions .Remove (api .ConditionType (aa )), nil
8877 }); err != nil {
0 commit comments