From b1ec616de54a07db161e4a05b72b0de4774a3e71 Mon Sep 17 00:00:00 2001 From: ajanikow <12255597+ajanikow@users.noreply.github.com> Date: Tue, 3 May 2022 11:10:45 +0000 Subject: [PATCH] [Feature] [ACS] Reorganize object --- pkg/deployment/acs/acs.community.go | 10 +++++++- pkg/deployment/acs/sutil/interfaces.go | 33 ++++++++++++++++++++++++++ pkg/deployment/deployment.go | 4 ++++ pkg/deployment/deployment_inspector.go | 3 +-- 4 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 pkg/deployment/acs/sutil/interfaces.go diff --git a/pkg/deployment/acs/acs.community.go b/pkg/deployment/acs/acs.community.go index a9f493927..10b83d385 100644 --- a/pkg/deployment/acs/acs.community.go +++ b/pkg/deployment/acs/acs.community.go @@ -25,10 +25,18 @@ import ( "context" api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" + "github.com/arangodb/kube-arangodb/pkg/deployment/acs/sutil" inspectorInterface "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector" "github.com/arangodb/kube-arangodb/pkg/util/kclient" ) -func Inspect(ctx context.Context, deployment *api.ArangoDeployment, client kclient.Client, cachedStatus inspectorInterface.Inspector) error { +func NewACS() sutil.ACS { + return acs{} +} + +type acs struct { +} + +func (a acs) Inspect(ctx context.Context, deployment *api.ArangoDeployment, client kclient.Client, cachedStatus inspectorInterface.Inspector) error { return nil } diff --git a/pkg/deployment/acs/sutil/interfaces.go b/pkg/deployment/acs/sutil/interfaces.go new file mode 100644 index 000000000..b6f2ebc98 --- /dev/null +++ b/pkg/deployment/acs/sutil/interfaces.go @@ -0,0 +1,33 @@ +// +// DISCLAIMER +// +// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany +// +// 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 holder is ArangoDB GmbH, Cologne, Germany +// + +package sutil + +import ( + "context" + + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" + inspectorInterface "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector" + "github.com/arangodb/kube-arangodb/pkg/util/kclient" +) + +type ACS interface { + Inspect(ctx context.Context, deployment *api.ArangoDeployment, client kclient.Client, cachedStatus inspectorInterface.Inspector) error +} diff --git a/pkg/deployment/deployment.go b/pkg/deployment/deployment.go index 3348709d5..0105a0b38 100644 --- a/pkg/deployment/deployment.go +++ b/pkg/deployment/deployment.go @@ -53,6 +53,8 @@ import ( "k8s.io/client-go/tools/record" api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" + "github.com/arangodb/kube-arangodb/pkg/deployment/acs" + "github.com/arangodb/kube-arangodb/pkg/deployment/acs/sutil" "github.com/arangodb/kube-arangodb/pkg/deployment/chaos" memberState "github.com/arangodb/kube-arangodb/pkg/deployment/member" "github.com/arangodb/kube-arangodb/pkg/deployment/reconcile" @@ -138,6 +140,7 @@ type Deployment struct { resilience *resilience.Resilience resources *resources.Resources chaosMonkey *chaos.Monkey + acs sutil.ACS syncClientCache client.ClientCache haveServiceMonitorCRD bool @@ -246,6 +249,7 @@ func New(config Config, deps Dependencies, apiObject *api.ArangoDeployment) (*De stopCh: make(chan struct{}), agencyCache: agency.NewCache(apiObject.Spec.Mode), currentState: inspector.NewInspector(newDeploymentThrottle(), deps.Client, apiObject.GetNamespace(), apiObject.GetName()), + acs: acs.NewACS(), } d.memberState = memberState.NewStateInspector(d) diff --git a/pkg/deployment/deployment_inspector.go b/pkg/deployment/deployment_inspector.go index 8ad5f0a93..7a827dd0c 100644 --- a/pkg/deployment/deployment_inspector.go +++ b/pkg/deployment/deployment_inspector.go @@ -39,7 +39,6 @@ import ( "github.com/arangodb/kube-arangodb/pkg/apis/deployment" api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" - "github.com/arangodb/kube-arangodb/pkg/deployment/acs" "github.com/arangodb/kube-arangodb/pkg/metrics" "github.com/arangodb/kube-arangodb/pkg/upgrade" "github.com/arangodb/kube-arangodb/pkg/util" @@ -178,7 +177,7 @@ func (d *Deployment) inspectDeploymentWithError(ctx context.Context, lastInterva } } - if err := acs.Inspect(ctx, d.apiObject, d.deps.Client, d.GetCachedStatus()); err != nil { + if err := d.acs.Inspect(ctx, d.apiObject, d.deps.Client, d.GetCachedStatus()); err != nil { d.deps.Log.Warn().Err(err).Msgf("Unable to handle ACS objects") }