diff --git a/.golangci.yaml b/.golangci.yaml index fcae6231e..65679941c 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -71,6 +71,8 @@ linters-settings: alias: mlShared - pkg: github.com/arangodb/kube-arangodb/pkg/handlers/enterprise/ml/shared/test alias: mlSharedTests + - pkg: github.com/arangodb/kube-arangodb/pkg/apis/analytics/v1alpha1 + alias: analyticsApi - pkg: github.com/arangodb/kube-arangodb/pkg/apis/ml/v1beta1 alias: mlApi - pkg: github.com/arangodb/kube-arangodb/pkg/apis/ml/v1alpha1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 0af49ff15..8dbb4e5dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ - (Feature) (ML) Enable TLS - (Feature) (ML) Release V1Beta1 API - (Maintenance) Update Go to 1.22.3 +- (Feature) (Analytics) GAE Integration ## [1.2.40](https://github.com/arangodb/kube-arangodb/tree/1.2.40) (2024-04-10) - (Feature) Add Core fields to the Scheduler Container Spec diff --git a/Makefile b/Makefile index 2102ae6c2..8cf6b7355 100644 --- a/Makefile +++ b/Makefile @@ -431,15 +431,23 @@ update-generated: "client lister informer deepcopy" \ "github.com/arangodb/kube-arangodb/pkg/generated" \ "github.com/arangodb/kube-arangodb/pkg/apis" \ - "deployment:v1 replication:v1 storage:v1alpha backup:v1 deployment:v2alpha1 replication:v2alpha1 apps:v1 ml:v1alpha1 ml:v1beta1 scheduler:v1alpha1 scheduler:v1beta1" \ + "deployment:v1 deployment:v2alpha1 \ + replication:v1 replication:v2alpha1 \ + storage:v1alpha \ + backup:v1 \ + apps:v1 \ + ml:v1alpha1 ml:v1beta1 \ + scheduler:v1alpha1 scheduler:v1beta1 \ + analytics:v1alpha1" \ --go-header-file "./tools/codegen/boilerplate.go.txt" \ $(VERIFYARGS) GOPATH=$(GOBUILDDIR) $(VENDORDIR)/k8s.io/code-generator/generate-groups.sh \ "deepcopy" \ "github.com/arangodb/kube-arangodb/pkg/generated" \ "github.com/arangodb/kube-arangodb/pkg/apis" \ - "shared:v1 scheduler:v1alpha1/container scheduler:v1alpha1/container/resources scheduler:v1alpha1/pod scheduler:v1alpha1/pod/resources\ - shared:v1 scheduler:v1beta1/container scheduler:v1beta1/container/resources scheduler:v1beta1/pod scheduler:v1beta1/pod/resources" \ + "shared:v1 \ + scheduler:v1alpha1/container scheduler:v1alpha1/container/resources scheduler:v1alpha1/pod scheduler:v1alpha1/pod/resources \ + scheduler:v1beta1/container scheduler:v1beta1/container/resources scheduler:v1beta1/pod scheduler:v1beta1/pod/resources" \ --go-header-file "./tools/codegen/boilerplate.go.txt" \ $(VERIFYARGS) @@ -858,7 +866,8 @@ CRDS:=apps-job \ database-clustersynchronization database-deployment database-member database-task \ replication-deploymentreplication \ ml-storage ml-extension ml-job-batch ml-job-cron \ - scheduler-profile + scheduler-profile \ + analytics-graphanalyticsengine .PHONY: sync-crds sync-crds: diff --git a/chart/kube-arangodb/crds/analytics-graphanalyticsengine.yaml b/chart/kube-arangodb/crds/analytics-graphanalyticsengine.yaml new file mode 100644 index 000000000..cac5e6f51 --- /dev/null +++ b/chart/kube-arangodb/crds/analytics-graphanalyticsengine.yaml @@ -0,0 +1,22 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + name: graphanalyticsengines.analytics.arangodb.com +spec: + group: analytics.arangodb.com + names: + kind: GraphAnalyticsEngine + listKind: GraphAnalyticsEngineList + plural: graphanalyticsengines + singular: graphanalyticsengine + scope: Namespaced + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + type: object + x-kubernetes-preserve-unknown-fields: true + served: true + storage: true + subresources: + status: {} diff --git a/chart/kube-arangodb/templates/analytics-operator/cluster-role-binding.yaml b/chart/kube-arangodb/templates/analytics-operator/cluster-role-binding.yaml new file mode 100644 index 000000000..201c4915b --- /dev/null +++ b/chart/kube-arangodb/templates/analytics-operator/cluster-role-binding.yaml @@ -0,0 +1,26 @@ +{{ if .Values.rbac.enabled -}} +{{ if not (eq .Values.operator.scope "namespaced") -}} +{{ if .Values.operator.features.analytics -}} + +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: {{ template "kube-arangodb.rbac-cluster" . }}-analytics + labels: + app.kubernetes.io/name: {{ template "kube-arangodb.name" . }} + helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + app.kubernetes.io/instance: {{ .Release.Name }} + release: {{ .Release.Name }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: {{ template "kube-arangodb.rbac-cluster" . }}-analytics +subjects: + - kind: ServiceAccount + name: {{ template "kube-arangodb.operatorName" . }} + namespace: {{ .Release.Namespace }} + +{{- end }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/chart/kube-arangodb/templates/analytics-operator/cluster-role.yaml b/chart/kube-arangodb/templates/analytics-operator/cluster-role.yaml new file mode 100644 index 000000000..76ac5ee99 --- /dev/null +++ b/chart/kube-arangodb/templates/analytics-operator/cluster-role.yaml @@ -0,0 +1,22 @@ +{{ if .Values.rbac.enabled -}} +{{ if not (eq .Values.operator.scope "namespaced") -}} +{{ if .Values.operator.features.analytics -}} + +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: {{ template "kube-arangodb.rbac-cluster" . }}-analytics + labels: + app.kubernetes.io/name: {{ template "kube-arangodb.name" . }} + helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + app.kubernetes.io/instance: {{ .Release.Name }} + release: {{ .Release.Name }} +rules: + - apiGroups: ["apiextensions.k8s.io"] + resources: ["customresourcedefinitions"] + verbs: ["get", "list", "watch"] + +{{- end }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/chart/kube-arangodb/templates/analytics-operator/role-binding.yaml b/chart/kube-arangodb/templates/analytics-operator/role-binding.yaml new file mode 100644 index 000000000..9fd0877f4 --- /dev/null +++ b/chart/kube-arangodb/templates/analytics-operator/role-binding.yaml @@ -0,0 +1,25 @@ +{{ if .Values.rbac.enabled -}} +{{ if .Values.operator.features.analytics -}} + +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: {{ template "kube-arangodb.rbac" . }}-analytics + namespace: {{ .Release.Namespace }} + labels: + app.kubernetes.io/name: {{ template "kube-arangodb.name" . }} + helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + app.kubernetes.io/instance: {{ .Release.Name }} + release: {{ .Release.Name }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: {{ template "kube-arangodb.rbac" . }}-analytics +subjects: + - kind: ServiceAccount + name: {{ template "kube-arangodb.operatorName" . }} + namespace: {{ .Release.Namespace }} + +{{- end }} +{{- end }} \ No newline at end of file diff --git a/chart/kube-arangodb/templates/analytics-operator/role.yaml b/chart/kube-arangodb/templates/analytics-operator/role.yaml new file mode 100644 index 000000000..2c7813f23 --- /dev/null +++ b/chart/kube-arangodb/templates/analytics-operator/role.yaml @@ -0,0 +1,36 @@ +{{ if .Values.rbac.enabled -}} +{{ if .Values.operator.features.analytics -}} + +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: {{ template "kube-arangodb.rbac" . }}-analytics + namespace: {{ .Release.Namespace }} + labels: + app.kubernetes.io/name: {{ template "kube-arangodb.name" . }} + helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + app.kubernetes.io/instance: {{ .Release.Name }} + release: {{ .Release.Name }} +rules: + - apiGroups: + - "analytics.arangodb.com" + resources: + - "graphanalyticsengines" + - "graphanalyticsengines/status" + verbs: + - "*" + - apiGroups: + - "database.arangodb.com" + resources: + - "arangodeployments" + verbs: + - "get" + - "list" + - "watch" + - apiGroups: [ "" ] + resources: + - "secrets" + verbs: [ "*" ] +{{- end }} +{{- end }} \ No newline at end of file diff --git a/chart/kube-arangodb/templates/deployment.yaml b/chart/kube-arangodb/templates/deployment.yaml index 1350ce98e..51b35d9a7 100644 --- a/chart/kube-arangodb/templates/deployment.yaml +++ b/chart/kube-arangodb/templates/deployment.yaml @@ -114,6 +114,9 @@ spec: {{ if .Values.operator.features.ml }} - --operator.ml {{- end }} +{{ if .Values.operator.features.analytics }} + - --operator.analytics +{{- end }} {{ if .Values.operator.features.k8sToK8sClusterSync }} - --operator.k2k-cluster-sync {{- end }} diff --git a/chart/kube-arangodb/values.yaml b/chart/kube-arangodb/values.yaml index f8870e155..3dbac69eb 100644 --- a/chart/kube-arangodb/values.yaml +++ b/chart/kube-arangodb/values.yaml @@ -33,6 +33,7 @@ operator: apps: false k8sToK8sClusterSync: false ml: false + analytics: false tolerations: [] rbac: enabled: true diff --git a/cmd/cmd.go b/cmd/cmd.go index f2a2bffce..f2c146966 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -118,6 +118,7 @@ var ( enableBackup bool // Run backup operator enableApps bool // Run apps operator enableML bool // Run ml operator + enableAnalytics bool // Run analytics operator versionOnly bool // Run only version endpoint, explicitly disabled with other enableK2KClusterSync bool // Run k2kClusterSync operator @@ -181,6 +182,7 @@ var ( backupProbe probe.ReadyProbe appsProbe probe.ReadyProbe mlProbe probe.ReadyProbe + analyticsProbe probe.ReadyProbe k2KClusterSyncProbe probe.ReadyProbe ) @@ -206,6 +208,7 @@ func init() { f.BoolVar(&operatorOptions.enableBackup, "operator.backup", false, "Enable to run the ArangoBackup operator") f.BoolVar(&operatorOptions.enableApps, "operator.apps", false, "Enable to run the ArangoApps operator") f.BoolVar(&operatorOptions.enableML, "operator.ml", false, "Enable to run the ArangoML operator") + f.BoolVar(&operatorOptions.enableAnalytics, "operator.analytics", false, "Enable to run the Analytics operator") f.BoolVar(&operatorOptions.enableK2KClusterSync, "operator.k2k-cluster-sync", false, "Enable to run the ListSimple operator") f.MarkDeprecated("operator.k2k-cluster-sync", "Enabled within deployment operator") f.BoolVar(&operatorOptions.versionOnly, "operator.version", false, "Enable only version endpoint in Operator") @@ -333,19 +336,19 @@ func executeMain(cmd *cobra.Command, args []string) { // Check operating mode if !operatorOptions.enableDeployment && !operatorOptions.enableDeploymentReplication && !operatorOptions.enableStorage && - !operatorOptions.enableBackup && !operatorOptions.enableApps && !operatorOptions.enableK2KClusterSync && !operatorOptions.enableML { + !operatorOptions.enableBackup && !operatorOptions.enableApps && !operatorOptions.enableK2KClusterSync && !operatorOptions.enableML && !operatorOptions.enableAnalytics { if !operatorOptions.versionOnly { if version.GetVersionV1().IsEnterprise() { - logger.Fatal("Turn on --operator.deployment, --operator.deployment-replication, --operator.storage, --operator.backup, --operator.apps, --operator.k2k-cluster-sync, --operator.ml or any combination of these") + logger.Fatal("Turn on --operator.deployment, --operator.deployment-replication, --operator.storage, --operator.backup, --operator.apps, --operator.k2k-cluster-sync, --operator.ml, --operator.analytics or any combination of these") } else { logger.Fatal("Turn on --operator.deployment, --operator.deployment-replication, --operator.storage, --operator.backup, --operator.apps, --operator.k2k-cluster-sync or any combination of these") } } } else if operatorOptions.versionOnly { - logger.Fatal("Options --operator.deployment, --operator.deployment-replication, --operator.storage, --operator.backup, --operator.apps, --operator.k2k-cluster-sync, --operator.ml cannot be enabled together with --operator.version") + logger.Fatal("Options --operator.deployment, --operator.deployment-replication, --operator.storage, --operator.backup, --operator.apps, --operator.k2k-cluster-sync, --operator.ml, --operator.analytics cannot be enabled together with --operator.version") } else if !version.GetVersionV1().IsEnterprise() { - if operatorOptions.enableML { - logger.Fatal("Options --operator.ml can be enabled only on the Enterprise Operator") + if operatorOptions.enableML || operatorOptions.enableAnalytics { + logger.Fatal("Options --operator.ml, --operator.analytics can be enabled only on the Enterprise Operator") } } @@ -476,6 +479,10 @@ func executeMain(cmd *cobra.Command, args []string) { Enabled: cfg.EnableML, Probe: &mlProbe, }, + Analytics: server.OperatorDependency{ + Enabled: cfg.EnableAnalytics, + Probe: &analyticsProbe, + }, ClusterSync: server.OperatorDependency{ Enabled: cfg.EnableK2KClusterSync, Probe: &k2KClusterSyncProbe, @@ -559,6 +566,7 @@ func newOperatorConfigAndDeps(id, namespace, name string) (operator.Config, oper EnableBackup: operatorOptions.enableBackup, EnableApps: operatorOptions.enableApps, EnableML: operatorOptions.enableML, + EnableAnalytics: operatorOptions.enableAnalytics, EnableK2KClusterSync: operatorOptions.enableK2KClusterSync, AllowChaos: chaosOptions.allowed, ScalingIntegrationEnabled: operatorOptions.scalingIntegrationEnabled, @@ -578,6 +586,7 @@ func newOperatorConfigAndDeps(id, namespace, name string) (operator.Config, oper BackupProbe: &backupProbe, AppsProbe: &appsProbe, MlProbe: &mlProbe, + AnalyticsProbe: &analyticsProbe, K2KClusterSyncProbe: &k2KClusterSyncProbe, } diff --git a/docs/api/GraphAnalyticsEngine.V1Alpha1.md b/docs/api/GraphAnalyticsEngine.V1Alpha1.md new file mode 100644 index 000000000..dd79dfcb5 --- /dev/null +++ b/docs/api/GraphAnalyticsEngine.V1Alpha1.md @@ -0,0 +1,56 @@ +--- +layout: page +parent: CRD reference +title: GraphAnalyticsEngine V1Alpha1 +--- + +# API Reference for GraphAnalyticsEngine V1Alpha1 + +## Spec + +### .spec.deploymentName + +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/analytics/v1alpha1/gae_spec.go#L30) + +DeploymentName define deployment name used in the object. Immutable + +## Status + +### .status.conditions + +Type: `api.Conditions` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/analytics/v1alpha1/gae_status.go#L31) + +Conditions specific to the entire extension + +*** + +### .status.deployment.checksum + +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/shared/v1/object.go#L61) + +UID keeps the information about object Checksum + +*** + +### .status.deployment.name + +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/shared/v1/object.go#L52) + +Name of the object + +*** + +### .status.deployment.namespace + +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/shared/v1/object.go#L55) + +Namespace of the object. Should default to the namespace of the parent object + +*** + +### .status.deployment.uid + +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/shared/v1/object.go#L58) + +UID keeps the information about object UID + diff --git a/internal/cr_validation_test.go b/internal/cr_validation_test.go index 1b17b6203..719088a5d 100644 --- a/internal/cr_validation_test.go +++ b/internal/cr_validation_test.go @@ -33,6 +33,7 @@ import ( apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" "sigs.k8s.io/yaml" + analyticsApi "github.com/arangodb/kube-arangodb/pkg/apis/analytics/v1alpha1" appsv1 "github.com/arangodb/kube-arangodb/pkg/apis/apps/v1" backupv1 "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" deploymentv1 "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" @@ -226,6 +227,13 @@ func Test_GenerateCRValidationSchemas(t *testing.T) { }, }, }, + "analytics-graphanalyticsengine": { + fmt.Sprintf("%s/pkg/apis/analytics/v1alpha1", root): { + "v1alpha1": { + analyticsApi.GraphAnalyticsEngine{}.Spec, + }, + }, + }, } for filePrefix, packagesToVersion := range input { diff --git a/internal/docs_test.go b/internal/docs_test.go index dc33a7cc5..bcb911be0 100644 --- a/internal/docs_test.go +++ b/internal/docs_test.go @@ -36,6 +36,7 @@ import ( "github.com/coreos/go-semver/semver" "github.com/stretchr/testify/require" + analyticsApi "github.com/arangodb/kube-arangodb/pkg/apis/analytics/v1alpha1" appsApi "github.com/arangodb/kube-arangodb/pkg/apis/apps/v1" backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" deploymentApi "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" @@ -248,6 +249,19 @@ func Test_GenerateAPIDocs(t *testing.T) { }, }, }, + "analytics": map[string]inputPackage{ + "v1alpha1": { + Types: inputPackageTypes{ + "GraphAnalyticsEngine.V1Alpha1": { + "Spec": analyticsApi.GraphAnalyticsEngine{}.Spec, + "Status": analyticsApi.GraphAnalyticsEngine{}.Status, + }, + }, + Shared: []string{ + "shared/v1", + }, + }, + }, "replication": map[string]inputPackage{ "v1": { Types: inputPackageTypes{ diff --git a/pkg/apis/analytics/definitions.go b/pkg/apis/analytics/definitions.go new file mode 100644 index 000000000..e63cde2ee --- /dev/null +++ b/pkg/apis/analytics/definitions.go @@ -0,0 +1,29 @@ +// +// DISCLAIMER +// +// Copyright 2024 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 analytics + +const ( + GraphAnalyticsEngineCRDName = GraphAnalyticsEngineResourcePlural + "." + ArangoAnalyticsGroupName + GraphAnalyticsEngineResourceKind = "GraphAnalyticsEngine" + GraphAnalyticsEngineResourcePlural = "graphanalyticsengines" + + ArangoAnalyticsGroupName = "analytics.arangodb.com" +) diff --git a/pkg/apis/analytics/v1alpha1/conditions.go b/pkg/apis/analytics/v1alpha1/conditions.go new file mode 100644 index 000000000..1e7909ab3 --- /dev/null +++ b/pkg/apis/analytics/v1alpha1/conditions.go @@ -0,0 +1,30 @@ +// +// DISCLAIMER +// +// Copyright 2024 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 v1alpha1 + +import api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" + +const ( + LicenseValidCondition api.ConditionType = "LicenseValid" + DeploymentFoundCondition api.ConditionType = "DeploymentFound" + ReadyCondition api.ConditionType = "Ready" + SpecValidCondition api.ConditionType = "SpecValid" +) diff --git a/pkg/apis/analytics/v1alpha1/doc.go b/pkg/apis/analytics/v1alpha1/doc.go new file mode 100644 index 000000000..4a2eb716f --- /dev/null +++ b/pkg/apis/analytics/v1alpha1/doc.go @@ -0,0 +1,23 @@ +// +// DISCLAIMER +// +// Copyright 2024 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 +// + +// +k8s:deepcopy-gen=package +// +groupName=analytics.arangodb.com +package v1alpha1 diff --git a/pkg/apis/analytics/v1alpha1/gae.go b/pkg/apis/analytics/v1alpha1/gae.go new file mode 100644 index 000000000..3d0a4b739 --- /dev/null +++ b/pkg/apis/analytics/v1alpha1/gae.go @@ -0,0 +1,69 @@ +// +// DISCLAIMER +// +// Copyright 2024 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 v1alpha1 + +import ( + meta "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/arangodb/kube-arangodb/pkg/apis/analytics" +) + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// GraphAnalyticsEngineList is a list of Arango Analytics GraphAnalyticsEngine. +type GraphAnalyticsEngineList struct { + meta.TypeMeta `json:",inline"` + meta.ListMeta `json:"metadata,omitempty"` + + Items []GraphAnalyticsEngine `json:"items"` +} + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// GraphAnalyticsEngine contains definition and status of the Arango Analytics GraphAnalyticsEngine. +type GraphAnalyticsEngine struct { + meta.TypeMeta `json:",inline"` + meta.ObjectMeta `json:"metadata,omitempty"` + + Spec GraphAnalyticsEngineSpec `json:"spec"` + Status GraphAnalyticsEngineStatus `json:"status"` +} + +// AsOwner creates an OwnerReference for the given Extension +func (g *GraphAnalyticsEngine) AsOwner() meta.OwnerReference { + trueVar := true + return meta.OwnerReference{ + APIVersion: SchemeGroupVersion.String(), + Kind: analytics.GraphAnalyticsEngineCRDName, + Name: g.Name, + UID: g.UID, + Controller: &trueVar, + } +} + +func (g *GraphAnalyticsEngine) GetStatus() GraphAnalyticsEngineStatus { + return g.Status +} + +func (g *GraphAnalyticsEngine) SetStatus(status GraphAnalyticsEngineStatus) { + g.Status = status +} diff --git a/pkg/apis/analytics/v1alpha1/gae_spec.go b/pkg/apis/analytics/v1alpha1/gae_spec.go new file mode 100644 index 000000000..d550ab5a6 --- /dev/null +++ b/pkg/apis/analytics/v1alpha1/gae_spec.go @@ -0,0 +1,47 @@ +// +// DISCLAIMER +// +// Copyright 2024 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 v1alpha1 + +import ( + shared "github.com/arangodb/kube-arangodb/pkg/apis/shared" + "github.com/arangodb/kube-arangodb/pkg/util/errors" +) + +type GraphAnalyticsEngineSpec struct { + // DeploymentName define deployment name used in the object. Immutable + DeploymentName *string `json:"deploymentName,omitempty"` +} + +func (g *GraphAnalyticsEngineSpec) Validate() error { + if g == nil { + g = &GraphAnalyticsEngineSpec{} + } + + return shared.WithErrors(shared.PrefixResourceErrors("spec", + shared.PrefixResourceErrors("deploymentName", shared.ValidateRequired(g.DeploymentName, func(s string) error { + if s == "" { + return errors.Errorf("DeploymentName should be not empty") + } + + return nil + })), + )) +} diff --git a/pkg/apis/analytics/v1alpha1/gae_status.go b/pkg/apis/analytics/v1alpha1/gae_status.go new file mode 100644 index 000000000..b4d7090c3 --- /dev/null +++ b/pkg/apis/analytics/v1alpha1/gae_status.go @@ -0,0 +1,35 @@ +// +// DISCLAIMER +// +// Copyright 2024 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 v1alpha1 + +import ( + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" + sharedApi "github.com/arangodb/kube-arangodb/pkg/apis/shared/v1" +) + +type GraphAnalyticsEngineStatus struct { + // Conditions specific to the entire extension + // +doc/type: api.Conditions + Conditions api.ConditionList `json:"conditions,omitempty"` + + // Deployment keeps the ArangoDeployment reference + Deployment *sharedApi.Object `json:"deployment,omitempty"` +} diff --git a/pkg/apis/analytics/v1alpha1/register.go b/pkg/apis/analytics/v1alpha1/register.go new file mode 100644 index 000000000..d71036b13 --- /dev/null +++ b/pkg/apis/analytics/v1alpha1/register.go @@ -0,0 +1,54 @@ +// +// DISCLAIMER +// +// Copyright 2024 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 v1alpha1 + +import ( + meta "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + + "github.com/arangodb/kube-arangodb/pkg/apis/analytics" +) + +const ( + ArangoAnalyticsVersion = "v1alpha1" +) + +var ( + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + AddToScheme = SchemeBuilder.AddToScheme + + SchemeGroupVersion = schema.GroupVersion{Group: analytics.ArangoAnalyticsGroupName, Version: ArangoAnalyticsVersion} +) + +// Resource gets an ArangoCluster GroupResource for a specified resource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +// addKnownTypes adds the set of types defined in this package to the supplied scheme. +func addKnownTypes(s *runtime.Scheme) error { + s.AddKnownTypes(SchemeGroupVersion, + &GraphAnalyticsEngine{}, + &GraphAnalyticsEngineList{}) + meta.AddToGroupVersion(s, SchemeGroupVersion) + return nil +} diff --git a/pkg/apis/analytics/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/analytics/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 000000000..4cb2181a9 --- /dev/null +++ b/pkg/apis/analytics/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,142 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +// +// DISCLAIMER +// +// Copyright 2024 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 +// + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1 "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" + sharedv1 "github.com/arangodb/kube-arangodb/pkg/apis/shared/v1" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GraphAnalyticsEngine) DeepCopyInto(out *GraphAnalyticsEngine) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GraphAnalyticsEngine. +func (in *GraphAnalyticsEngine) DeepCopy() *GraphAnalyticsEngine { + if in == nil { + return nil + } + out := new(GraphAnalyticsEngine) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *GraphAnalyticsEngine) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GraphAnalyticsEngineList) DeepCopyInto(out *GraphAnalyticsEngineList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]GraphAnalyticsEngine, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GraphAnalyticsEngineList. +func (in *GraphAnalyticsEngineList) DeepCopy() *GraphAnalyticsEngineList { + if in == nil { + return nil + } + out := new(GraphAnalyticsEngineList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *GraphAnalyticsEngineList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GraphAnalyticsEngineSpec) DeepCopyInto(out *GraphAnalyticsEngineSpec) { + *out = *in + if in.DeploymentName != nil { + in, out := &in.DeploymentName, &out.DeploymentName + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GraphAnalyticsEngineSpec. +func (in *GraphAnalyticsEngineSpec) DeepCopy() *GraphAnalyticsEngineSpec { + if in == nil { + return nil + } + out := new(GraphAnalyticsEngineSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GraphAnalyticsEngineStatus) DeepCopyInto(out *GraphAnalyticsEngineStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(v1.ConditionList, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Deployment != nil { + in, out := &in.Deployment, &out.Deployment + *out = new(sharedv1.Object) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GraphAnalyticsEngineStatus. +func (in *GraphAnalyticsEngineStatus) DeepCopy() *GraphAnalyticsEngineStatus { + if in == nil { + return nil + } + out := new(GraphAnalyticsEngineStatus) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/crd/analytics.go b/pkg/crd/analytics.go new file mode 100644 index 000000000..bfc2bca5f --- /dev/null +++ b/pkg/crd/analytics.go @@ -0,0 +1,39 @@ +// +// DISCLAIMER +// +// Copyright 2024 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 crd + +import ( + "github.com/arangodb/kube-arangodb/pkg/crd/crds" +) + +func init() { + defs := []func(...func(options *crds.CRDOptions)) crds.Definition{ + crds.AnalyticsGAEDefinitionWithOptions, + } + for _, getDef := range defs { + defFn := getDef // bring into scope + registerCRDWithPanic(func(opts *crds.CRDOptions) crds.Definition { + return defFn(opts.AsFunc()) + }, &crds.CRDOptions{ + WithSchema: true, + }) + } +} diff --git a/pkg/crd/crds/analytics-graphanalyticsengine.go b/pkg/crd/crds/analytics-graphanalyticsengine.go new file mode 100644 index 000000000..8ad590ede --- /dev/null +++ b/pkg/crd/crds/analytics-graphanalyticsengine.go @@ -0,0 +1,61 @@ +// +// DISCLAIMER +// +// Copyright 2024 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 crds + +import ( + _ "embed" + + apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" +) + +// Deprecated: use AnalyticsGAEWithOptions instead +func AnalyticsGAE() *apiextensions.CustomResourceDefinition { + return AnalyticsGAEWithOptions() +} + +func AnalyticsGAEWithOptions(opts ...func(*CRDOptions)) *apiextensions.CustomResourceDefinition { + return getCRD(AnalyticsGAEDefinitionData(), opts...) +} + +// Deprecated: use AnalyticsGAEDefinitionWithOptions instead +func AnalyticsGAEDefinition() Definition { + return AnalyticsGAEDefinitionWithOptions() +} + +func AnalyticsGAEDefinitionWithOptions(opts ...func(*CRDOptions)) Definition { + return Definition{ + DefinitionData: AnalyticsGAEDefinitionData(), + CRD: AnalyticsGAEWithOptions(opts...), + } +} + +func AnalyticsGAEDefinitionData() DefinitionData { + return DefinitionData{ + definition: analyticsGAEs, + schemaDefinition: analyticsGAEsSchemaRaw, + } +} + +//go:embed analytics-graphanalyticsengine.yaml +var analyticsGAEs []byte + +//go:embed analytics-graphanalyticsengine.schema.generated.yaml +var analyticsGAEsSchemaRaw []byte diff --git a/pkg/crd/crds/analytics-graphanalyticsengine.schema.generated.yaml b/pkg/crd/crds/analytics-graphanalyticsengine.schema.generated.yaml new file mode 100644 index 000000000..b2777f63d --- /dev/null +++ b/pkg/crd/crds/analytics-graphanalyticsengine.schema.generated.yaml @@ -0,0 +1,11 @@ +v1alpha1: + openAPIV3Schema: + properties: + spec: + properties: + deploymentName: + description: DeploymentName define deployment name used in the object. Immutable + type: string + type: object + type: object + x-kubernetes-preserve-unknown-fields: true diff --git a/pkg/crd/crds/analytics-graphanalyticsengine.yaml b/pkg/crd/crds/analytics-graphanalyticsengine.yaml new file mode 100644 index 000000000..cac5e6f51 --- /dev/null +++ b/pkg/crd/crds/analytics-graphanalyticsengine.yaml @@ -0,0 +1,22 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + name: graphanalyticsengines.analytics.arangodb.com +spec: + group: analytics.arangodb.com + names: + kind: GraphAnalyticsEngine + listKind: GraphAnalyticsEngineList + plural: graphanalyticsengines + singular: graphanalyticsengine + scope: Namespaced + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + type: object + x-kubernetes-preserve-unknown-fields: true + served: true + storage: true + subresources: + status: {} diff --git a/pkg/crd/crds/crds.go b/pkg/crd/crds/crds.go index ea7519ced..573186e20 100644 --- a/pkg/crd/crds/crds.go +++ b/pkg/crd/crds/crds.go @@ -87,6 +87,9 @@ func AllDefinitions() []Definition { // Scheduler SchedulerProfileDefinitionWithOptions(), + + // Analytics + AnalyticsGAEDefinitionWithOptions(), } } diff --git a/pkg/crd/crds/crds_test.go b/pkg/crd/crds/crds_test.go index 2eba7131c..c1ed38baa 100644 --- a/pkg/crd/crds/crds_test.go +++ b/pkg/crd/crds/crds_test.go @@ -123,6 +123,7 @@ func Test_CRDGetters(t *testing.T) { ReplicationDeploymentReplicationWithOptions, StorageLocalStorageWithOptions, SchedulerProfileWithOptions, + AnalyticsGAEWithOptions, } require.Equal(t, len(AllDefinitions()), len(getters)) diff --git a/pkg/debug_package/generator.go b/pkg/debug_package/generator.go index bb0105be6..d8c24a0eb 100644 --- a/pkg/debug_package/generator.go +++ b/pkg/debug_package/generator.go @@ -43,6 +43,7 @@ var rootFactories = []shared.Factory{ kubernetes.Deployments(), kubernetes.AgencyDump(), kubernetes.ML(), + kubernetes.Analytics(), kubernetes.Backup(), kubernetes.Scheduler(), } diff --git a/pkg/debug_package/generators/kubernetes/analytics.go b/pkg/debug_package/generators/kubernetes/analytics.go new file mode 100644 index 000000000..2b0317721 --- /dev/null +++ b/pkg/debug_package/generators/kubernetes/analytics.go @@ -0,0 +1,47 @@ +// +// DISCLAIMER +// +// Copyright 2023-2024 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 kubernetes + +import ( + "github.com/rs/zerolog" + + "github.com/arangodb/kube-arangodb/pkg/debug_package/shared" + "github.com/arangodb/kube-arangodb/pkg/util/errors" + "github.com/arangodb/kube-arangodb/pkg/util/kclient" +) + +func Analytics() shared.Factory { + return shared.NewFactory("analytics", true, analytics) +} + +func analytics(logger zerolog.Logger, files chan<- shared.File) error { + k, ok := kclient.GetDefaultFactory().Client() + if !ok { + return errors.Errorf("Client is not initialised") + } + + if err := analyticsGAEs(logger, files, k); err != nil { + logger.Err(err).Msgf("Error while collecting arango analytics engines") + return err + } + + return nil +} diff --git a/pkg/debug_package/generators/kubernetes/analytics_gae.go b/pkg/debug_package/generators/kubernetes/analytics_gae.go new file mode 100644 index 000000000..6937d332b --- /dev/null +++ b/pkg/debug_package/generators/kubernetes/analytics_gae.go @@ -0,0 +1,73 @@ +// +// DISCLAIMER +// +// Copyright 2023-2024 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 kubernetes + +import ( + "context" + "fmt" + + "github.com/rs/zerolog" + + analyticsApi "github.com/arangodb/kube-arangodb/pkg/apis/analytics/v1alpha1" + "github.com/arangodb/kube-arangodb/pkg/debug_package/cli" + "github.com/arangodb/kube-arangodb/pkg/debug_package/shared" + "github.com/arangodb/kube-arangodb/pkg/util/errors" + "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/kerrors" + "github.com/arangodb/kube-arangodb/pkg/util/kclient" +) + +func analyticsGAEs(logger zerolog.Logger, files chan<- shared.File, client kclient.Client) error { + extensions, err := listAnalyticsGAEs(client) + if err != nil { + if kerrors.IsForbiddenOrNotFound(err) { + return nil + } + + return err + } + + if err := errors.ExecuteWithErrorArrayP2(analyticsGAE, client, files, extensions...); err != nil { + logger.Err(err).Msgf("Error while collecting arango ml extensions") + return err + } + + return nil +} + +func analyticsGAE(client kclient.Client, files chan<- shared.File, ext *analyticsApi.GraphAnalyticsEngine) error { + files <- shared.NewYAMLFile(fmt.Sprintf("kubernetes/arango/analytics/gaes/%s.yaml", ext.GetName()), func() ([]interface{}, error) { + return []interface{}{ext}, nil + }) + + return nil +} + +func listAnalyticsGAEs(client kclient.Client) ([]*analyticsApi.GraphAnalyticsEngine, error) { + return ListObjects[*analyticsApi.GraphAnalyticsEngineList, *analyticsApi.GraphAnalyticsEngine](context.Background(), client.Arango().AnalyticsV1alpha1().GraphAnalyticsEngines(cli.GetInput().Namespace), func(result *analyticsApi.GraphAnalyticsEngineList) []*analyticsApi.GraphAnalyticsEngine { + q := make([]*analyticsApi.GraphAnalyticsEngine, len(result.Items)) + + for id, e := range result.Items { + q[id] = e.DeepCopy() + } + + return q + }) +} diff --git a/pkg/generated/clientset/versioned/clientset.go b/pkg/generated/clientset/versioned/clientset.go index 84b582636..d2f139f70 100644 --- a/pkg/generated/clientset/versioned/clientset.go +++ b/pkg/generated/clientset/versioned/clientset.go @@ -26,6 +26,7 @@ import ( "fmt" "net/http" + analyticsv1alpha1 "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/analytics/v1alpha1" appsv1 "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/apps/v1" backupv1 "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/backup/v1" databasev1 "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/deployment/v1" @@ -44,6 +45,7 @@ import ( type Interface interface { Discovery() discovery.DiscoveryInterface + AnalyticsV1alpha1() analyticsv1alpha1.AnalyticsV1alpha1Interface AppsV1() appsv1.AppsV1Interface BackupV1() backupv1.BackupV1Interface DatabaseV1() databasev1.DatabaseV1Interface @@ -60,6 +62,7 @@ type Interface interface { // Clientset contains the clients for groups. type Clientset struct { *discovery.DiscoveryClient + analyticsV1alpha1 *analyticsv1alpha1.AnalyticsV1alpha1Client appsV1 *appsv1.AppsV1Client backupV1 *backupv1.BackupV1Client databaseV1 *databasev1.DatabaseV1Client @@ -73,6 +76,11 @@ type Clientset struct { storageV1alpha *storagev1alpha.StorageV1alphaClient } +// AnalyticsV1alpha1 retrieves the AnalyticsV1alpha1Client +func (c *Clientset) AnalyticsV1alpha1() analyticsv1alpha1.AnalyticsV1alpha1Interface { + return c.analyticsV1alpha1 +} + // AppsV1 retrieves the AppsV1Client func (c *Clientset) AppsV1() appsv1.AppsV1Interface { return c.appsV1 @@ -172,6 +180,10 @@ func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, var cs Clientset var err error + cs.analyticsV1alpha1, err = analyticsv1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient) + if err != nil { + return nil, err + } cs.appsV1, err = appsv1.NewForConfigAndClient(&configShallowCopy, httpClient) if err != nil { return nil, err @@ -237,6 +249,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset { // New creates a new Clientset for the given RESTClient. func New(c rest.Interface) *Clientset { var cs Clientset + cs.analyticsV1alpha1 = analyticsv1alpha1.New(c) cs.appsV1 = appsv1.New(c) cs.backupV1 = backupv1.New(c) cs.databaseV1 = databasev1.New(c) diff --git a/pkg/generated/clientset/versioned/fake/clientset_generated.go b/pkg/generated/clientset/versioned/fake/clientset_generated.go index 1ad16d4fa..499793aa7 100644 --- a/pkg/generated/clientset/versioned/fake/clientset_generated.go +++ b/pkg/generated/clientset/versioned/fake/clientset_generated.go @@ -24,6 +24,8 @@ package fake import ( clientset "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned" + analyticsv1alpha1 "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/analytics/v1alpha1" + fakeanalyticsv1alpha1 "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/analytics/v1alpha1/fake" appsv1 "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/apps/v1" fakeappsv1 "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/apps/v1/fake" backupv1 "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/backup/v1" @@ -103,6 +105,11 @@ var ( _ testing.FakeClient = &Clientset{} ) +// AnalyticsV1alpha1 retrieves the AnalyticsV1alpha1Client +func (c *Clientset) AnalyticsV1alpha1() analyticsv1alpha1.AnalyticsV1alpha1Interface { + return &fakeanalyticsv1alpha1.FakeAnalyticsV1alpha1{Fake: &c.Fake} +} + // AppsV1 retrieves the AppsV1Client func (c *Clientset) AppsV1() appsv1.AppsV1Interface { return &fakeappsv1.FakeAppsV1{Fake: &c.Fake} diff --git a/pkg/generated/clientset/versioned/fake/register.go b/pkg/generated/clientset/versioned/fake/register.go index a95fee35e..2f65785ee 100644 --- a/pkg/generated/clientset/versioned/fake/register.go +++ b/pkg/generated/clientset/versioned/fake/register.go @@ -23,6 +23,7 @@ package fake import ( + analyticsv1alpha1 "github.com/arangodb/kube-arangodb/pkg/apis/analytics/v1alpha1" appsv1 "github.com/arangodb/kube-arangodb/pkg/apis/apps/v1" backupv1 "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" databasev1 "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" @@ -45,6 +46,7 @@ var scheme = runtime.NewScheme() var codecs = serializer.NewCodecFactory(scheme) var localSchemeBuilder = runtime.SchemeBuilder{ + analyticsv1alpha1.AddToScheme, appsv1.AddToScheme, backupv1.AddToScheme, databasev1.AddToScheme, diff --git a/pkg/generated/clientset/versioned/scheme/register.go b/pkg/generated/clientset/versioned/scheme/register.go index 0f069075e..cdaeb9465 100644 --- a/pkg/generated/clientset/versioned/scheme/register.go +++ b/pkg/generated/clientset/versioned/scheme/register.go @@ -23,6 +23,7 @@ package scheme import ( + analyticsv1alpha1 "github.com/arangodb/kube-arangodb/pkg/apis/analytics/v1alpha1" appsv1 "github.com/arangodb/kube-arangodb/pkg/apis/apps/v1" backupv1 "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" databasev1 "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" @@ -45,6 +46,7 @@ var Scheme = runtime.NewScheme() var Codecs = serializer.NewCodecFactory(Scheme) var ParameterCodec = runtime.NewParameterCodec(Scheme) var localSchemeBuilder = runtime.SchemeBuilder{ + analyticsv1alpha1.AddToScheme, appsv1.AddToScheme, backupv1.AddToScheme, databasev1.AddToScheme, diff --git a/pkg/generated/clientset/versioned/typed/analytics/v1alpha1/analytics_client.go b/pkg/generated/clientset/versioned/typed/analytics/v1alpha1/analytics_client.go new file mode 100644 index 000000000..e6143718f --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/analytics/v1alpha1/analytics_client.go @@ -0,0 +1,111 @@ +// +// DISCLAIMER +// +// Copyright 2024 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 +// + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "net/http" + + v1alpha1 "github.com/arangodb/kube-arangodb/pkg/apis/analytics/v1alpha1" + "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/scheme" + rest "k8s.io/client-go/rest" +) + +type AnalyticsV1alpha1Interface interface { + RESTClient() rest.Interface + GraphAnalyticsEnginesGetter +} + +// AnalyticsV1alpha1Client is used to interact with features provided by the analytics.arangodb.com group. +type AnalyticsV1alpha1Client struct { + restClient rest.Interface +} + +func (c *AnalyticsV1alpha1Client) GraphAnalyticsEngines(namespace string) GraphAnalyticsEngineInterface { + return newGraphAnalyticsEngines(c, namespace) +} + +// NewForConfig creates a new AnalyticsV1alpha1Client for the given config. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). +func NewForConfig(c *rest.Config) (*AnalyticsV1alpha1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + httpClient, err := rest.HTTPClientFor(&config) + if err != nil { + return nil, err + } + return NewForConfigAndClient(&config, httpClient) +} + +// NewForConfigAndClient creates a new AnalyticsV1alpha1Client for the given config and http client. +// Note the http client provided takes precedence over the configured transport values. +func NewForConfigAndClient(c *rest.Config, h *http.Client) (*AnalyticsV1alpha1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientForConfigAndClient(&config, h) + if err != nil { + return nil, err + } + return &AnalyticsV1alpha1Client{client}, nil +} + +// NewForConfigOrDie creates a new AnalyticsV1alpha1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *AnalyticsV1alpha1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new AnalyticsV1alpha1Client for the given RESTClient. +func New(c rest.Interface) *AnalyticsV1alpha1Client { + return &AnalyticsV1alpha1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1alpha1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + + return nil +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *AnalyticsV1alpha1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/pkg/generated/clientset/versioned/typed/analytics/v1alpha1/doc.go b/pkg/generated/clientset/versioned/typed/analytics/v1alpha1/doc.go new file mode 100644 index 000000000..f45dab6c5 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/analytics/v1alpha1/doc.go @@ -0,0 +1,24 @@ +// +// DISCLAIMER +// +// Copyright 2024 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 +// + +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1alpha1 diff --git a/pkg/generated/clientset/versioned/typed/analytics/v1alpha1/fake/doc.go b/pkg/generated/clientset/versioned/typed/analytics/v1alpha1/fake/doc.go new file mode 100644 index 000000000..cc487d814 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/analytics/v1alpha1/fake/doc.go @@ -0,0 +1,24 @@ +// +// DISCLAIMER +// +// Copyright 2024 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 +// + +// Code generated by client-gen. DO NOT EDIT. + +// Package fake has the automatically generated clients. +package fake diff --git a/pkg/generated/clientset/versioned/typed/analytics/v1alpha1/fake/fake_analytics_client.go b/pkg/generated/clientset/versioned/typed/analytics/v1alpha1/fake/fake_analytics_client.go new file mode 100644 index 000000000..44ddf3e43 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/analytics/v1alpha1/fake/fake_analytics_client.go @@ -0,0 +1,44 @@ +// +// DISCLAIMER +// +// Copyright 2024 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 +// + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1alpha1 "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/analytics/v1alpha1" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeAnalyticsV1alpha1 struct { + *testing.Fake +} + +func (c *FakeAnalyticsV1alpha1) GraphAnalyticsEngines(namespace string) v1alpha1.GraphAnalyticsEngineInterface { + return &FakeGraphAnalyticsEngines{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeAnalyticsV1alpha1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/pkg/generated/clientset/versioned/typed/analytics/v1alpha1/fake/fake_graphanalyticsengine.go b/pkg/generated/clientset/versioned/typed/analytics/v1alpha1/fake/fake_graphanalyticsengine.go new file mode 100644 index 000000000..b10ff47e3 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/analytics/v1alpha1/fake/fake_graphanalyticsengine.go @@ -0,0 +1,145 @@ +// +// DISCLAIMER +// +// Copyright 2024 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 +// + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1alpha1 "github.com/arangodb/kube-arangodb/pkg/apis/analytics/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeGraphAnalyticsEngines implements GraphAnalyticsEngineInterface +type FakeGraphAnalyticsEngines struct { + Fake *FakeAnalyticsV1alpha1 + ns string +} + +var graphanalyticsenginesResource = v1alpha1.SchemeGroupVersion.WithResource("graphanalyticsengines") + +var graphanalyticsenginesKind = v1alpha1.SchemeGroupVersion.WithKind("GraphAnalyticsEngine") + +// Get takes name of the graphAnalyticsEngine, and returns the corresponding graphAnalyticsEngine object, and an error if there is any. +func (c *FakeGraphAnalyticsEngines) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.GraphAnalyticsEngine, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(graphanalyticsenginesResource, c.ns, name), &v1alpha1.GraphAnalyticsEngine{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.GraphAnalyticsEngine), err +} + +// List takes label and field selectors, and returns the list of GraphAnalyticsEngines that match those selectors. +func (c *FakeGraphAnalyticsEngines) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.GraphAnalyticsEngineList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(graphanalyticsenginesResource, graphanalyticsenginesKind, c.ns, opts), &v1alpha1.GraphAnalyticsEngineList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.GraphAnalyticsEngineList{ListMeta: obj.(*v1alpha1.GraphAnalyticsEngineList).ListMeta} + for _, item := range obj.(*v1alpha1.GraphAnalyticsEngineList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested graphAnalyticsEngines. +func (c *FakeGraphAnalyticsEngines) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(graphanalyticsenginesResource, c.ns, opts)) + +} + +// Create takes the representation of a graphAnalyticsEngine and creates it. Returns the server's representation of the graphAnalyticsEngine, and an error, if there is any. +func (c *FakeGraphAnalyticsEngines) Create(ctx context.Context, graphAnalyticsEngine *v1alpha1.GraphAnalyticsEngine, opts v1.CreateOptions) (result *v1alpha1.GraphAnalyticsEngine, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(graphanalyticsenginesResource, c.ns, graphAnalyticsEngine), &v1alpha1.GraphAnalyticsEngine{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.GraphAnalyticsEngine), err +} + +// Update takes the representation of a graphAnalyticsEngine and updates it. Returns the server's representation of the graphAnalyticsEngine, and an error, if there is any. +func (c *FakeGraphAnalyticsEngines) Update(ctx context.Context, graphAnalyticsEngine *v1alpha1.GraphAnalyticsEngine, opts v1.UpdateOptions) (result *v1alpha1.GraphAnalyticsEngine, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(graphanalyticsenginesResource, c.ns, graphAnalyticsEngine), &v1alpha1.GraphAnalyticsEngine{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.GraphAnalyticsEngine), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeGraphAnalyticsEngines) UpdateStatus(ctx context.Context, graphAnalyticsEngine *v1alpha1.GraphAnalyticsEngine, opts v1.UpdateOptions) (*v1alpha1.GraphAnalyticsEngine, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(graphanalyticsenginesResource, "status", c.ns, graphAnalyticsEngine), &v1alpha1.GraphAnalyticsEngine{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.GraphAnalyticsEngine), err +} + +// Delete takes name of the graphAnalyticsEngine and deletes it. Returns an error if one occurs. +func (c *FakeGraphAnalyticsEngines) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(graphanalyticsenginesResource, c.ns, name, opts), &v1alpha1.GraphAnalyticsEngine{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeGraphAnalyticsEngines) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(graphanalyticsenginesResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.GraphAnalyticsEngineList{}) + return err +} + +// Patch applies the patch and returns the patched graphAnalyticsEngine. +func (c *FakeGraphAnalyticsEngines) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.GraphAnalyticsEngine, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(graphanalyticsenginesResource, c.ns, name, pt, data, subresources...), &v1alpha1.GraphAnalyticsEngine{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.GraphAnalyticsEngine), err +} diff --git a/pkg/generated/clientset/versioned/typed/analytics/v1alpha1/generated_expansion.go b/pkg/generated/clientset/versioned/typed/analytics/v1alpha1/generated_expansion.go new file mode 100644 index 000000000..7cdfc22bf --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/analytics/v1alpha1/generated_expansion.go @@ -0,0 +1,25 @@ +// +// DISCLAIMER +// +// Copyright 2024 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 +// + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +type GraphAnalyticsEngineExpansion interface{} diff --git a/pkg/generated/clientset/versioned/typed/analytics/v1alpha1/graphanalyticsengine.go b/pkg/generated/clientset/versioned/typed/analytics/v1alpha1/graphanalyticsengine.go new file mode 100644 index 000000000..2ca7273b5 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/analytics/v1alpha1/graphanalyticsengine.go @@ -0,0 +1,199 @@ +// +// DISCLAIMER +// +// Copyright 2024 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 +// + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + "time" + + v1alpha1 "github.com/arangodb/kube-arangodb/pkg/apis/analytics/v1alpha1" + scheme "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// GraphAnalyticsEnginesGetter has a method to return a GraphAnalyticsEngineInterface. +// A group's client should implement this interface. +type GraphAnalyticsEnginesGetter interface { + GraphAnalyticsEngines(namespace string) GraphAnalyticsEngineInterface +} + +// GraphAnalyticsEngineInterface has methods to work with GraphAnalyticsEngine resources. +type GraphAnalyticsEngineInterface interface { + Create(ctx context.Context, graphAnalyticsEngine *v1alpha1.GraphAnalyticsEngine, opts v1.CreateOptions) (*v1alpha1.GraphAnalyticsEngine, error) + Update(ctx context.Context, graphAnalyticsEngine *v1alpha1.GraphAnalyticsEngine, opts v1.UpdateOptions) (*v1alpha1.GraphAnalyticsEngine, error) + UpdateStatus(ctx context.Context, graphAnalyticsEngine *v1alpha1.GraphAnalyticsEngine, opts v1.UpdateOptions) (*v1alpha1.GraphAnalyticsEngine, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.GraphAnalyticsEngine, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.GraphAnalyticsEngineList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.GraphAnalyticsEngine, err error) + GraphAnalyticsEngineExpansion +} + +// graphAnalyticsEngines implements GraphAnalyticsEngineInterface +type graphAnalyticsEngines struct { + client rest.Interface + ns string +} + +// newGraphAnalyticsEngines returns a GraphAnalyticsEngines +func newGraphAnalyticsEngines(c *AnalyticsV1alpha1Client, namespace string) *graphAnalyticsEngines { + return &graphAnalyticsEngines{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the graphAnalyticsEngine, and returns the corresponding graphAnalyticsEngine object, and an error if there is any. +func (c *graphAnalyticsEngines) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.GraphAnalyticsEngine, err error) { + result = &v1alpha1.GraphAnalyticsEngine{} + err = c.client.Get(). + Namespace(c.ns). + Resource("graphanalyticsengines"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of GraphAnalyticsEngines that match those selectors. +func (c *graphAnalyticsEngines) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.GraphAnalyticsEngineList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.GraphAnalyticsEngineList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("graphanalyticsengines"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested graphAnalyticsEngines. +func (c *graphAnalyticsEngines) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("graphanalyticsengines"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a graphAnalyticsEngine and creates it. Returns the server's representation of the graphAnalyticsEngine, and an error, if there is any. +func (c *graphAnalyticsEngines) Create(ctx context.Context, graphAnalyticsEngine *v1alpha1.GraphAnalyticsEngine, opts v1.CreateOptions) (result *v1alpha1.GraphAnalyticsEngine, err error) { + result = &v1alpha1.GraphAnalyticsEngine{} + err = c.client.Post(). + Namespace(c.ns). + Resource("graphanalyticsengines"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(graphAnalyticsEngine). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a graphAnalyticsEngine and updates it. Returns the server's representation of the graphAnalyticsEngine, and an error, if there is any. +func (c *graphAnalyticsEngines) Update(ctx context.Context, graphAnalyticsEngine *v1alpha1.GraphAnalyticsEngine, opts v1.UpdateOptions) (result *v1alpha1.GraphAnalyticsEngine, err error) { + result = &v1alpha1.GraphAnalyticsEngine{} + err = c.client.Put(). + Namespace(c.ns). + Resource("graphanalyticsengines"). + Name(graphAnalyticsEngine.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(graphAnalyticsEngine). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *graphAnalyticsEngines) UpdateStatus(ctx context.Context, graphAnalyticsEngine *v1alpha1.GraphAnalyticsEngine, opts v1.UpdateOptions) (result *v1alpha1.GraphAnalyticsEngine, err error) { + result = &v1alpha1.GraphAnalyticsEngine{} + err = c.client.Put(). + Namespace(c.ns). + Resource("graphanalyticsengines"). + Name(graphAnalyticsEngine.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(graphAnalyticsEngine). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the graphAnalyticsEngine and deletes it. Returns an error if one occurs. +func (c *graphAnalyticsEngines) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("graphanalyticsengines"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *graphAnalyticsEngines) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("graphanalyticsengines"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched graphAnalyticsEngine. +func (c *graphAnalyticsEngines) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.GraphAnalyticsEngine, err error) { + result = &v1alpha1.GraphAnalyticsEngine{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("graphanalyticsengines"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/generated/informers/externalversions/analytics/interface.go b/pkg/generated/informers/externalversions/analytics/interface.go new file mode 100644 index 000000000..6f7d6b64c --- /dev/null +++ b/pkg/generated/informers/externalversions/analytics/interface.go @@ -0,0 +1,50 @@ +// +// DISCLAIMER +// +// Copyright 2024 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 +// + +// Code generated by informer-gen. DO NOT EDIT. + +package analytics + +import ( + v1alpha1 "github.com/arangodb/kube-arangodb/pkg/generated/informers/externalversions/analytics/v1alpha1" + internalinterfaces "github.com/arangodb/kube-arangodb/pkg/generated/informers/externalversions/internalinterfaces" +) + +// Interface provides access to each of this group's versions. +type Interface interface { + // V1alpha1 provides access to shared informers for resources in V1alpha1. + V1alpha1() v1alpha1.Interface +} + +type group struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// V1alpha1 returns a new v1alpha1.Interface. +func (g *group) V1alpha1() v1alpha1.Interface { + return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/pkg/generated/informers/externalversions/analytics/v1alpha1/graphanalyticsengine.go b/pkg/generated/informers/externalversions/analytics/v1alpha1/graphanalyticsengine.go new file mode 100644 index 000000000..0f1762e69 --- /dev/null +++ b/pkg/generated/informers/externalversions/analytics/v1alpha1/graphanalyticsengine.go @@ -0,0 +1,94 @@ +// +// DISCLAIMER +// +// Copyright 2024 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 +// + +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + time "time" + + analyticsv1alpha1 "github.com/arangodb/kube-arangodb/pkg/apis/analytics/v1alpha1" + versioned "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned" + internalinterfaces "github.com/arangodb/kube-arangodb/pkg/generated/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/arangodb/kube-arangodb/pkg/generated/listers/analytics/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// GraphAnalyticsEngineInformer provides access to a shared informer and lister for +// GraphAnalyticsEngines. +type GraphAnalyticsEngineInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.GraphAnalyticsEngineLister +} + +type graphAnalyticsEngineInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewGraphAnalyticsEngineInformer constructs a new informer for GraphAnalyticsEngine type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewGraphAnalyticsEngineInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredGraphAnalyticsEngineInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredGraphAnalyticsEngineInformer constructs a new informer for GraphAnalyticsEngine type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredGraphAnalyticsEngineInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.AnalyticsV1alpha1().GraphAnalyticsEngines(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.AnalyticsV1alpha1().GraphAnalyticsEngines(namespace).Watch(context.TODO(), options) + }, + }, + &analyticsv1alpha1.GraphAnalyticsEngine{}, + resyncPeriod, + indexers, + ) +} + +func (f *graphAnalyticsEngineInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredGraphAnalyticsEngineInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *graphAnalyticsEngineInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&analyticsv1alpha1.GraphAnalyticsEngine{}, f.defaultInformer) +} + +func (f *graphAnalyticsEngineInformer) Lister() v1alpha1.GraphAnalyticsEngineLister { + return v1alpha1.NewGraphAnalyticsEngineLister(f.Informer().GetIndexer()) +} diff --git a/pkg/generated/informers/externalversions/analytics/v1alpha1/interface.go b/pkg/generated/informers/externalversions/analytics/v1alpha1/interface.go new file mode 100644 index 000000000..85661b57c --- /dev/null +++ b/pkg/generated/informers/externalversions/analytics/v1alpha1/interface.go @@ -0,0 +1,49 @@ +// +// DISCLAIMER +// +// Copyright 2024 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 +// + +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + internalinterfaces "github.com/arangodb/kube-arangodb/pkg/generated/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // GraphAnalyticsEngines returns a GraphAnalyticsEngineInformer. + GraphAnalyticsEngines() GraphAnalyticsEngineInformer +} + +type version struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// GraphAnalyticsEngines returns a GraphAnalyticsEngineInformer. +func (v *version) GraphAnalyticsEngines() GraphAnalyticsEngineInformer { + return &graphAnalyticsEngineInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/pkg/generated/informers/externalversions/factory.go b/pkg/generated/informers/externalversions/factory.go index 3c63d2075..484ba4ea1 100644 --- a/pkg/generated/informers/externalversions/factory.go +++ b/pkg/generated/informers/externalversions/factory.go @@ -28,6 +28,7 @@ import ( time "time" versioned "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned" + analytics "github.com/arangodb/kube-arangodb/pkg/generated/informers/externalversions/analytics" apps "github.com/arangodb/kube-arangodb/pkg/generated/informers/externalversions/apps" backup "github.com/arangodb/kube-arangodb/pkg/generated/informers/externalversions/backup" deployment "github.com/arangodb/kube-arangodb/pkg/generated/informers/externalversions/deployment" @@ -263,6 +264,7 @@ type SharedInformerFactory interface { // client. InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer + Analytics() analytics.Interface Apps() apps.Interface Backup() backup.Interface Database() deployment.Interface @@ -272,6 +274,10 @@ type SharedInformerFactory interface { Storage() storage.Interface } +func (f *sharedInformerFactory) Analytics() analytics.Interface { + return analytics.New(f, f.namespace, f.tweakListOptions) +} + func (f *sharedInformerFactory) Apps() apps.Interface { return apps.New(f, f.namespace, f.tweakListOptions) } diff --git a/pkg/generated/informers/externalversions/generic.go b/pkg/generated/informers/externalversions/generic.go index 59c6826ac..108f70a45 100644 --- a/pkg/generated/informers/externalversions/generic.go +++ b/pkg/generated/informers/externalversions/generic.go @@ -25,11 +25,12 @@ package externalversions import ( "fmt" + v1alpha1 "github.com/arangodb/kube-arangodb/pkg/apis/analytics/v1alpha1" v1 "github.com/arangodb/kube-arangodb/pkg/apis/apps/v1" backupv1 "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" deploymentv1 "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" v2alpha1 "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v2alpha1" - v1alpha1 "github.com/arangodb/kube-arangodb/pkg/apis/ml/v1alpha1" + mlv1alpha1 "github.com/arangodb/kube-arangodb/pkg/apis/ml/v1alpha1" v1beta1 "github.com/arangodb/kube-arangodb/pkg/apis/ml/v1beta1" replicationv1 "github.com/arangodb/kube-arangodb/pkg/apis/replication/v1" replicationv2alpha1 "github.com/arangodb/kube-arangodb/pkg/apis/replication/v2alpha1" @@ -66,7 +67,11 @@ func (f *genericInformer) Lister() cache.GenericLister { // TODO extend this to unknown resources with a client pool func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { switch resource { - // Group=apps.arangodb.com, Version=v1 + // Group=analytics.arangodb.com, Version=v1alpha1 + case v1alpha1.SchemeGroupVersion.WithResource("graphanalyticsengines"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Analytics().V1alpha1().GraphAnalyticsEngines().Informer()}, nil + + // Group=apps.arangodb.com, Version=v1 case v1.SchemeGroupVersion.WithResource("arangojobs"): return &genericInformer{resource: resource.GroupResource(), informer: f.Apps().V1().ArangoJobs().Informer()}, nil @@ -97,13 +102,13 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource return &genericInformer{resource: resource.GroupResource(), informer: f.Database().V2alpha1().ArangoTasks().Informer()}, nil // Group=ml.arangodb.com, Version=v1alpha1 - case v1alpha1.SchemeGroupVersion.WithResource("arangomlbatchjobs"): + case mlv1alpha1.SchemeGroupVersion.WithResource("arangomlbatchjobs"): return &genericInformer{resource: resource.GroupResource(), informer: f.Ml().V1alpha1().ArangoMLBatchJobs().Informer()}, nil - case v1alpha1.SchemeGroupVersion.WithResource("arangomlcronjobs"): + case mlv1alpha1.SchemeGroupVersion.WithResource("arangomlcronjobs"): return &genericInformer{resource: resource.GroupResource(), informer: f.Ml().V1alpha1().ArangoMLCronJobs().Informer()}, nil - case v1alpha1.SchemeGroupVersion.WithResource("arangomlextensions"): + case mlv1alpha1.SchemeGroupVersion.WithResource("arangomlextensions"): return &genericInformer{resource: resource.GroupResource(), informer: f.Ml().V1alpha1().ArangoMLExtensions().Informer()}, nil - case v1alpha1.SchemeGroupVersion.WithResource("arangomlstorages"): + case mlv1alpha1.SchemeGroupVersion.WithResource("arangomlstorages"): return &genericInformer{resource: resource.GroupResource(), informer: f.Ml().V1alpha1().ArangoMLStorages().Informer()}, nil // Group=ml.arangodb.com, Version=v1beta1 diff --git a/pkg/generated/listers/analytics/v1alpha1/expansion_generated.go b/pkg/generated/listers/analytics/v1alpha1/expansion_generated.go new file mode 100644 index 000000000..eb4ab75b3 --- /dev/null +++ b/pkg/generated/listers/analytics/v1alpha1/expansion_generated.go @@ -0,0 +1,31 @@ +// +// DISCLAIMER +// +// Copyright 2024 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 +// + +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +// GraphAnalyticsEngineListerExpansion allows custom methods to be added to +// GraphAnalyticsEngineLister. +type GraphAnalyticsEngineListerExpansion interface{} + +// GraphAnalyticsEngineNamespaceListerExpansion allows custom methods to be added to +// GraphAnalyticsEngineNamespaceLister. +type GraphAnalyticsEngineNamespaceListerExpansion interface{} diff --git a/pkg/generated/listers/analytics/v1alpha1/graphanalyticsengine.go b/pkg/generated/listers/analytics/v1alpha1/graphanalyticsengine.go new file mode 100644 index 000000000..5c6596981 --- /dev/null +++ b/pkg/generated/listers/analytics/v1alpha1/graphanalyticsengine.go @@ -0,0 +1,103 @@ +// +// DISCLAIMER +// +// Copyright 2024 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 +// + +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/arangodb/kube-arangodb/pkg/apis/analytics/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// GraphAnalyticsEngineLister helps list GraphAnalyticsEngines. +// All objects returned here must be treated as read-only. +type GraphAnalyticsEngineLister interface { + // List lists all GraphAnalyticsEngines in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.GraphAnalyticsEngine, err error) + // GraphAnalyticsEngines returns an object that can list and get GraphAnalyticsEngines. + GraphAnalyticsEngines(namespace string) GraphAnalyticsEngineNamespaceLister + GraphAnalyticsEngineListerExpansion +} + +// graphAnalyticsEngineLister implements the GraphAnalyticsEngineLister interface. +type graphAnalyticsEngineLister struct { + indexer cache.Indexer +} + +// NewGraphAnalyticsEngineLister returns a new GraphAnalyticsEngineLister. +func NewGraphAnalyticsEngineLister(indexer cache.Indexer) GraphAnalyticsEngineLister { + return &graphAnalyticsEngineLister{indexer: indexer} +} + +// List lists all GraphAnalyticsEngines in the indexer. +func (s *graphAnalyticsEngineLister) List(selector labels.Selector) (ret []*v1alpha1.GraphAnalyticsEngine, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.GraphAnalyticsEngine)) + }) + return ret, err +} + +// GraphAnalyticsEngines returns an object that can list and get GraphAnalyticsEngines. +func (s *graphAnalyticsEngineLister) GraphAnalyticsEngines(namespace string) GraphAnalyticsEngineNamespaceLister { + return graphAnalyticsEngineNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// GraphAnalyticsEngineNamespaceLister helps list and get GraphAnalyticsEngines. +// All objects returned here must be treated as read-only. +type GraphAnalyticsEngineNamespaceLister interface { + // List lists all GraphAnalyticsEngines in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.GraphAnalyticsEngine, err error) + // Get retrieves the GraphAnalyticsEngine from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.GraphAnalyticsEngine, error) + GraphAnalyticsEngineNamespaceListerExpansion +} + +// graphAnalyticsEngineNamespaceLister implements the GraphAnalyticsEngineNamespaceLister +// interface. +type graphAnalyticsEngineNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all GraphAnalyticsEngines in the indexer for a given namespace. +func (s graphAnalyticsEngineNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.GraphAnalyticsEngine, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.GraphAnalyticsEngine)) + }) + return ret, err +} + +// Get retrieves the GraphAnalyticsEngine from the indexer for a given namespace and name. +func (s graphAnalyticsEngineNamespaceLister) Get(name string) (*v1alpha1.GraphAnalyticsEngine, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("graphanalyticsengine"), name) + } + return obj.(*v1alpha1.GraphAnalyticsEngine), nil +} diff --git a/pkg/operator/operator.community.go b/pkg/operator/operator.community.go index b8b6b9870..cead56db4 100644 --- a/pkg/operator/operator.community.go +++ b/pkg/operator/operator.community.go @@ -1,7 +1,7 @@ // // DISCLAIMER // -// Copyright 2023 ArangoDB GmbH, Cologne, Germany +// Copyright 2023-2024 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. @@ -40,3 +40,12 @@ func (o *Operator) onStartML(stop <-chan struct{}) { func (o *Operator) onStartOperatorV2ML(operator operatorV2.Operator, recorder event.Recorder, client arangoClientSet.Interface, kubeClient kubernetes.Interface, informer arangoInformer.SharedInformerFactory, kubeInformer informers.SharedInformerFactory) { panic("Unable to start ML Operator in Community") } + +// onStartAnalytics starts the operator and run till given channel is closed. +func (o *Operator) onStartAnalytics(stop <-chan struct{}) { + panic("Unable to start Analytics Operator in Community") +} + +func (o *Operator) onStartOperatorV2Analytics(operator operatorV2.Operator, recorder event.Recorder, client arangoClientSet.Interface, kubeClient kubernetes.Interface, informer arangoInformer.SharedInformerFactory, kubeInformer informers.SharedInformerFactory) { + panic("Unable to start Analytics Operator in Community") +} diff --git a/pkg/operator/operator.go b/pkg/operator/operator.go index a050423cc..c83515751 100644 --- a/pkg/operator/operator.go +++ b/pkg/operator/operator.go @@ -1,7 +1,7 @@ // // DISCLAIMER // -// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany +// Copyright 2016-2024 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. @@ -68,9 +68,10 @@ var logger = logging.Global().RegisterAndGetLogger("operator", logging.Info) type operatorV2type string const ( - backupOperator operatorV2type = "backup" - mlOperator operatorV2type = "ml" - appsOperator operatorV2type = "apps" + backupOperator operatorV2type = "backup" + mlOperator operatorV2type = "ml" + analyticsOperator operatorV2type = "analytics" + appsOperator operatorV2type = "apps" ) type Event struct { @@ -100,6 +101,7 @@ type Config struct { EnableDeploymentReplication bool EnableStorage bool EnableML bool + EnableAnalytics bool EnableBackup bool EnableApps bool EnableK2KClusterSync bool @@ -121,6 +123,7 @@ type Dependencies struct { StorageProbe *probe.ReadyProbe BackupProbe *probe.ReadyProbe MlProbe *probe.ReadyProbe + AnalyticsProbe *probe.ReadyProbe AppsProbe *probe.ReadyProbe K2KClusterSyncProbe *probe.ReadyProbe } @@ -182,6 +185,13 @@ func (o *Operator) Run() { go o.runWithoutLeaderElection("arango-ml-operator", constants.MLLabelRole, o.onStartML, o.Dependencies.MlProbe) } } + if o.Config.EnableAnalytics { + if !o.Config.SingleMode { + go o.runLeaderElection("arango-analytics-operator", constants.AnalyticsLabelRole, o.onStartAnalytics, o.Dependencies.AnalyticsProbe) + } else { + go o.runWithoutLeaderElection("arango-analytics-operator", constants.AnalyticsLabelRole, o.onStartAnalytics, o.Dependencies.AnalyticsProbe) + } + } if o.Config.EnableK2KClusterSync { // Nothing to do o.log.Warn("K2K Cluster sync is permanently disabled") @@ -277,6 +287,9 @@ func (o *Operator) onStartOperatorV2(operatorType operatorV2type, stop <-chan st case mlOperator: o.onStartOperatorV2ML(operator, eventRecorder, o.Client.Arango(), o.Client.Kubernetes(), arangoInformer, kubeInformer) o.Dependencies.MlProbe.SetReady() + case analyticsOperator: + o.onStartOperatorV2Analytics(operator, eventRecorder, o.Client.Arango(), o.Client.Kubernetes(), arangoInformer, kubeInformer) + o.Dependencies.AnalyticsProbe.SetReady() } if err := operator.RegisterStarter(arangoInformer); err != nil { @@ -291,6 +304,7 @@ func (o *Operator) onStartOperatorV2(operatorType operatorV2type, stop <-chan st operator.Start(8, stop) o.Dependencies.MlProbe.SetReady() + o.Dependencies.AnalyticsProbe.SetReady() <-stop } diff --git a/pkg/operatorV2/update_wraps.go b/pkg/operatorV2/update_wraps.go index a7bc813a8..a936e1e41 100644 --- a/pkg/operatorV2/update_wraps.go +++ b/pkg/operatorV2/update_wraps.go @@ -25,6 +25,7 @@ import ( meta "k8s.io/apimachinery/pkg/apis/meta/v1" + analyticsApi "github.com/arangodb/kube-arangodb/pkg/apis/analytics/v1alpha1" backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" mlApiv1alpha1 "github.com/arangodb/kube-arangodb/pkg/apis/ml/v1alpha1" mlApi "github.com/arangodb/kube-arangodb/pkg/apis/ml/v1beta1" @@ -46,6 +47,10 @@ func WithArangoBatchJobUpdateStatusInterfaceRetry(ctx context.Context, client Up return WithUpdateStatusInterfaceRetry[mlApiv1alpha1.ArangoMLBatchJobStatus, *mlApiv1alpha1.ArangoMLBatchJob](ctx, client, obj, status, opts) } +func WithAnalyticsGAEUpdateStatusInterfaceRetry(ctx context.Context, client UpdateStatusInterface[analyticsApi.GraphAnalyticsEngineStatus, *analyticsApi.GraphAnalyticsEngine], obj *analyticsApi.GraphAnalyticsEngine, status analyticsApi.GraphAnalyticsEngineStatus, opts meta.UpdateOptions) (*analyticsApi.GraphAnalyticsEngine, error) { + return WithUpdateStatusInterfaceRetry[analyticsApi.GraphAnalyticsEngineStatus, *analyticsApi.GraphAnalyticsEngine](ctx, client, obj, status, opts) +} + func WithArangoStorageUpdateStatusInterfaceRetry(ctx context.Context, client UpdateStatusInterface[mlApi.ArangoMLStorageStatus, *mlApi.ArangoMLStorage], obj *mlApi.ArangoMLStorage, status mlApi.ArangoMLStorageStatus, opts meta.UpdateOptions) (*mlApi.ArangoMLStorage, error) { return WithUpdateStatusInterfaceRetry[mlApi.ArangoMLStorageStatus, *mlApi.ArangoMLStorage](ctx, client, obj, status, opts) } diff --git a/pkg/server/server.go b/pkg/server/server.go index faa396897..0bf9ccac1 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -69,6 +69,7 @@ type Dependencies struct { Backup OperatorDependency Apps OperatorDependency ML OperatorDependency + Analytics OperatorDependency ClusterSync OperatorDependency Operators Operators Secrets typedCore.SecretInterface @@ -189,6 +190,10 @@ func NewServer(cli typedCore.CoreV1Interface, cfg Config, deps Dependencies) (*S r.GET("/ready/ml", gin.WrapF(deps.ML.Probe.ReadyHandler)) readyProbes = append(readyProbes, deps.ML.Probe) } + if deps.Analytics.Enabled { + r.GET("/ready/analytics", gin.WrapF(deps.Analytics.Probe.ReadyHandler)) + readyProbes = append(readyProbes, deps.Analytics.Probe) + } r.GET("/ready", gin.WrapF(ready(readyProbes...))) r.GET("/metrics", gin.WrapF(metrics.Handler())) r.POST("/login", s.auth.handleLogin) diff --git a/pkg/util/constants/constants.go b/pkg/util/constants/constants.go index 5824722e0..245d3ec05 100644 --- a/pkg/util/constants/constants.go +++ b/pkg/util/constants/constants.go @@ -72,6 +72,7 @@ const ( BackupLabelRole = "backup/role" MLLabelRole = "ml/role" + AnalyticsLabelRole = "analytics/role" AppsLabelRole = "apps/role" ClusterSyncLabelRole = "clustersync/role" LabelRole = "role" diff --git a/pkg/util/tests/kubernetes.go b/pkg/util/tests/kubernetes.go index 8c7ff8ba1..fe5e30498 100644 --- a/pkg/util/tests/kubernetes.go +++ b/pkg/util/tests/kubernetes.go @@ -36,6 +36,8 @@ import ( "k8s.io/apimachinery/pkg/util/uuid" "k8s.io/client-go/kubernetes" + "github.com/arangodb/kube-arangodb/pkg/apis/analytics" + analyticsApi "github.com/arangodb/kube-arangodb/pkg/apis/analytics/v1alpha1" "github.com/arangodb/kube-arangodb/pkg/apis/backup" backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" "github.com/arangodb/kube-arangodb/pkg/apis/deployment" @@ -235,6 +237,12 @@ func CreateObjects(t *testing.T, k8s kubernetes.Interface, arango arangoClientSe vl := *v _, err := arango.SchedulerV1beta1().ArangoProfiles(vl.GetNamespace()).Create(context.Background(), vl, meta.CreateOptions{}) require.NoError(t, err) + case **analyticsApi.GraphAnalyticsEngine: + require.NotNil(t, v) + + vl := *v + _, err := arango.AnalyticsV1alpha1().GraphAnalyticsEngines(vl.GetNamespace()).Create(context.Background(), vl, meta.CreateOptions{}) + require.NoError(t, err) default: require.Fail(t, fmt.Sprintf("Unable to create object: %s", reflect.TypeOf(v).String())) } @@ -383,6 +391,12 @@ func UpdateObjects(t *testing.T, k8s kubernetes.Interface, arango arangoClientSe vl := *v _, err := arango.SchedulerV1beta1().ArangoProfiles(vl.GetNamespace()).Update(context.Background(), vl, meta.UpdateOptions{}) require.NoError(t, err) + case **analyticsApi.GraphAnalyticsEngine: + require.NotNil(t, v) + + vl := *v + _, err := arango.AnalyticsV1alpha1().GraphAnalyticsEngines(vl.GetNamespace()).Update(context.Background(), vl, meta.UpdateOptions{}) + require.NoError(t, err) default: require.Fail(t, fmt.Sprintf("Unable to create object: %s", reflect.TypeOf(v).String())) } @@ -506,6 +520,11 @@ func DeleteObjects(t *testing.T, k8s kubernetes.Interface, arango arangoClientSe vl := *v require.NoError(t, arango.SchedulerV1beta1().ArangoProfiles(vl.GetNamespace()).Delete(context.Background(), vl.GetName(), meta.DeleteOptions{})) + case **analyticsApi.GraphAnalyticsEngine: + require.NotNil(t, v) + + vl := *v + require.NoError(t, arango.AnalyticsV1alpha1().GraphAnalyticsEngines(vl.GetNamespace()).Delete(context.Background(), vl.GetName(), meta.DeleteOptions{})) default: require.Fail(t, fmt.Sprintf("Unable to delete object: %s", reflect.TypeOf(v).String())) } @@ -848,6 +867,21 @@ func RefreshObjects(t *testing.T, k8s kubernetes.Interface, arango arangoClientS } else { *v = vn } + case **analyticsApi.GraphAnalyticsEngine: + require.NotNil(t, v) + + vl := *v + + vn, err := arango.AnalyticsV1alpha1().GraphAnalyticsEngines(vl.GetNamespace()).Get(context.Background(), vl.GetName(), meta.GetOptions{}) + if err != nil { + if kerrors.IsNotFound(err) { + *v = nil + } else { + require.NoError(t, err) + } + } else { + *v = vn + } default: require.Fail(t, fmt.Sprintf("Unable to get object: %s", reflect.TypeOf(v).String())) } @@ -1012,6 +1046,14 @@ func SetMetaBasedOnType(t *testing.T, object meta.Object) { scheduler.ArangoProfileResourcePlural, object.GetNamespace(), object.GetName())) + case *analyticsApi.GraphAnalyticsEngine: + v.Kind = analytics.GraphAnalyticsEngineResourceKind + v.APIVersion = analyticsApi.SchemeGroupVersion.String() + v.SetSelfLink(fmt.Sprintf("/api/%s/%s/%s/%s", + analyticsApi.SchemeGroupVersion.String(), + analytics.GraphAnalyticsEngineResourcePlural, + object.GetNamespace(), + object.GetName())) default: require.Fail(t, fmt.Sprintf("Unable to create object: %s", reflect.TypeOf(v).String())) } @@ -1182,6 +1224,12 @@ func GVK(t *testing.T, object meta.Object) schema.GroupVersionKind { Version: schedulerApi.ArangoSchedulerVersion, Kind: scheduler.ArangoProfileResourceKind, } + case *analyticsApi.GraphAnalyticsEngine: + return schema.GroupVersionKind{ + Group: analytics.ArangoAnalyticsGroupName, + Version: analyticsApi.ArangoAnalyticsVersion, + Kind: analytics.GraphAnalyticsEngineResourceKind, + } default: require.Fail(t, fmt.Sprintf("Unable to create object: %s", reflect.TypeOf(v).String())) return schema.GroupVersionKind{} diff --git a/pkg/util/tests/kubernetes_test.go b/pkg/util/tests/kubernetes_test.go index 84477e301..d5e2716ce 100644 --- a/pkg/util/tests/kubernetes_test.go +++ b/pkg/util/tests/kubernetes_test.go @@ -31,6 +31,7 @@ import ( rbac "k8s.io/api/rbac/v1" meta "k8s.io/apimachinery/pkg/apis/meta/v1" + analyticsApi "github.com/arangodb/kube-arangodb/pkg/apis/analytics/v1alpha1" backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" mlApiv1alpha1 "github.com/arangodb/kube-arangodb/pkg/apis/ml/v1alpha1" @@ -85,4 +86,5 @@ func Test_NewMetaObject(t *testing.T) { NewMetaObjectRun[*mlApiv1alpha1.ArangoMLBatchJob](t) NewMetaObjectRun[*mlApiv1alpha1.ArangoMLCronJob](t) NewMetaObjectRun[*schedulerApi.ArangoProfile](t) + NewMetaObjectRun[*analyticsApi.GraphAnalyticsEngine](t) }