@@ -29,13 +29,13 @@ import (
2929 meta "k8s.io/apimachinery/pkg/apis/meta/v1"
3030
3131 "github.com/arangodb/arangosync-client/client"
32- "github.com/arangodb/go-driver"
3332 "github.com/arangodb/go-driver/agency"
3433
34+ "github.com/arangodb/go-driver"
3535 backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1"
3636 api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
3737 agencyCache "github.com/arangodb/kube-arangodb/pkg/deployment/agency"
38- "github.com/arangodb/kube-arangodb/pkg/deployment/resources "
38+ "github.com/arangodb/kube-arangodb/pkg/deployment/reconciler "
3939 "github.com/arangodb/kube-arangodb/pkg/util/errors"
4040 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
4141 inspectorInterface "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector"
@@ -52,31 +52,17 @@ import (
5252// ActionContext provides methods to the Action implementations
5353// to control their context.
5454type ActionContext interface {
55- resources.DeploymentStatusUpdate
56- resources.DeploymentAgencyMaintenance
57- resources.ArangoMemberContext
58- resources.DeploymentPodRenderer
59- resources.DeploymentModInterfaces
60- resources.DeploymentCachedStatus
61- resources.ArangoAgencyGet
62- resources.DeploymentInfoGetter
63-
64- // Gets the specified mode of deployment
65- GetMode () api.DeploymentMode
66- // GetDatabaseClient returns a cached client for the entire database (cluster coordinators or single server),
67- // creating one if needed.
68- GetDatabaseClient (ctx context.Context ) (driver.Client , error )
69- // GetServerClient returns a cached client for a specific server.
70- GetServerClient (ctx context.Context , group api.ServerGroup , id string ) (driver.Client , error )
71- // GetAgencyClients returns a client connection for every agency member.
72- GetAgencyClients (ctx context.Context ) ([]driver.Connection , error )
73- // GetAgency returns a connection to the entire agency.
74- GetAgency (ctx context.Context ) (agency.Agency , error )
75- // GetSyncServerClient returns a cached client for a specific arangosync server.
76- GetSyncServerClient (ctx context.Context , group api.ServerGroup , id string ) (client.API , error )
77- // CreateEvent creates a given event.
78- // On error, the error is logged.
79- CreateEvent (evt * k8sutil.Event )
55+ reconciler.DeploymentStatusUpdate
56+ reconciler.DeploymentAgencyMaintenance
57+ reconciler.ArangoMemberContext
58+ reconciler.DeploymentPodRenderer
59+ reconciler.DeploymentModInterfaces
60+ reconciler.DeploymentCachedStatus
61+ reconciler.ArangoAgencyGet
62+ reconciler.DeploymentInfoGetter
63+ reconciler.DeploymentClient
64+ reconciler.DeploymentSyncClient
65+
8066 // GetMemberStatusByID returns the current member status
8167 // for the member with given id.
8268 // Returns member status, true when found, or false
@@ -119,7 +105,7 @@ type ActionContext interface {
119105 // GetImageInfo returns the image info for an image with given name.
120106 // Returns: (info, infoFound)
121107 GetImageInfo (imageName string ) (api.ImageInfo , bool )
122- // GetImageInfo returns the image info for an current image.
108+ // GetCurrentImageInfo returns the image info for an current image.
123109 // Returns: (info, infoFound)
124110 GetCurrentImageInfo () (api.ImageInfo , bool )
125111 // SetCurrentImage changes the CurrentImage field in the deployment
@@ -135,7 +121,7 @@ type ActionContext interface {
135121 DisableScalingCluster (ctx context.Context ) error
136122 // EnableScalingCluster enables scaling DBservers and coordinators
137123 EnableScalingCluster (ctx context.Context ) error
138- // WithStatusUpdate update status of ArangoDeployment with defined modifier. If action returns True action is taken
124+ // UpdateClusterCondition update status of ArangoDeployment with defined modifier. If action returns True action is taken
139125 UpdateClusterCondition (ctx context.Context , conditionType api.ConditionType , status bool , reason , message string ) error
140126 // GetBackup receives information about a backup resource
141127 GetBackup (ctx context.Context , backup string ) (* backupApi.ArangoBackup , error )
@@ -161,6 +147,18 @@ type actionContext struct {
161147 cachedStatus inspectorInterface.Inspector
162148}
163149
150+ func (ac * actionContext ) UpdateStatus (ctx context.Context , status api.DeploymentStatus , lastVersion int32 , force ... bool ) error {
151+ return ac .context .UpdateStatus (ctx , status , lastVersion , force ... )
152+ }
153+
154+ func (ac * actionContext ) GetNamespace () string {
155+ return ac .context .GetNamespace ()
156+ }
157+
158+ func (ac * actionContext ) GetAgencyClientsWithPredicate (ctx context.Context , predicate func (id string ) bool ) ([]driver.Connection , error ) {
159+ return ac .context .GetAgencyClientsWithPredicate (ctx , predicate )
160+ }
161+
164162func (ac * actionContext ) GetStatus () (api.DeploymentStatus , int32 ) {
165163 return ac .context .GetStatus ()
166164}
@@ -189,11 +187,11 @@ func (ac *actionContext) SetAgencyMaintenanceMode(ctx context.Context, enabled b
189187 return ac .context .SetAgencyMaintenanceMode (ctx , enabled )
190188}
191189
192- func (ac * actionContext ) WithArangoMemberUpdate (ctx context.Context , namespace , name string , action resources .ArangoMemberUpdateFunc ) error {
190+ func (ac * actionContext ) WithArangoMemberUpdate (ctx context.Context , namespace , name string , action reconciler .ArangoMemberUpdateFunc ) error {
193191 return ac .context .WithArangoMemberUpdate (ctx , namespace , name , action )
194192}
195193
196- func (ac * actionContext ) WithArangoMemberStatusUpdate (ctx context.Context , namespace , name string , action resources .ArangoMemberStatusUpdateFunc ) error {
194+ func (ac * actionContext ) WithArangoMemberStatusUpdate (ctx context.Context , namespace , name string , action reconciler .ArangoMemberStatusUpdateFunc ) error {
197195 return ac .context .WithArangoMemberStatusUpdate (ctx , namespace , name , action )
198196}
199197
@@ -221,11 +219,11 @@ func (ac *actionContext) GetBackup(ctx context.Context, backup string) (*backupA
221219 return ac .context .GetBackup (ctx , backup )
222220}
223221
224- func (ac * actionContext ) WithStatusUpdateErr (ctx context.Context , action resources .DeploymentStatusUpdateErrFunc , force ... bool ) error {
222+ func (ac * actionContext ) WithStatusUpdateErr (ctx context.Context , action reconciler .DeploymentStatusUpdateErrFunc , force ... bool ) error {
225223 return ac .context .WithStatusUpdateErr (ctx , action , force ... )
226224}
227225
228- func (ac * actionContext ) WithStatusUpdate (ctx context.Context , action resources .DeploymentStatusUpdateFunc , force ... bool ) error {
226+ func (ac * actionContext ) WithStatusUpdate (ctx context.Context , action reconciler .DeploymentStatusUpdateFunc , force ... bool ) error {
229227 return ac .context .WithStatusUpdate (ctx , action , force ... )
230228}
231229
@@ -322,7 +320,7 @@ func (ac *actionContext) GetServerClient(ctx context.Context, group api.ServerGr
322320
323321// GetAgencyClients returns a client connection for every agency member.
324322func (ac * actionContext ) GetAgencyClients (ctx context.Context ) ([]driver.Connection , error ) {
325- c , err := ac .context .GetAgencyClients (ctx , nil )
323+ c , err := ac .context .GetAgencyClients (ctx )
326324 if err != nil {
327325 return nil , errors .WithStack (err )
328326 }
0 commit comments