From d82e9cb4ad25495bade2a44d8322829aea1854bc Mon Sep 17 00:00:00 2001 From: Nikita Vanyasin Date: Fri, 3 Jun 2022 17:06:23 +0300 Subject: [PATCH] Add CRD generator for `ArangoBackupPolicy` --- CHANGELOG.md | 1 + .../templates/crd/cluster-role.yaml | 1 + pkg/crd/arangobackuppolicies.go | 119 ++++++++++++++++++ 3 files changed, 121 insertions(+) create mode 100644 pkg/crd/arangobackuppolicies.go diff --git a/CHANGELOG.md b/CHANGELOG.md index e89120376..1cb35ff8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - (Feature) Add `ArangoDeployment` CRD auto-installer - (Feature) Add `ArangoMember` CRD auto-installer - (Feature) Add `ArangoBackup` CRD auto-installer +- (Feature) Add `ArangoBackupPolicy` CRD auto-installer ## [1.2.13](https://github.com/arangodb/kube-arangodb/tree/1.2.13) (2022-06-07) - (Bugfix) Fix arangosync members state inspection diff --git a/chart/kube-arangodb/templates/crd/cluster-role.yaml b/chart/kube-arangodb/templates/crd/cluster-role.yaml index e297886d9..7b8590259 100644 --- a/chart/kube-arangodb/templates/crd/cluster-role.yaml +++ b/chart/kube-arangodb/templates/crd/cluster-role.yaml @@ -22,6 +22,7 @@ rules: - "arangomembers.database.arangodb.com" - "arangotasks.database.arangodb.com" - "arangobackups.backup.arangodb.com" + - "arangobackuppolicies.backup.arangodb.com" {{- end }} {{- end }} diff --git a/pkg/crd/arangobackuppolicies.go b/pkg/crd/arangobackuppolicies.go new file mode 100644 index 000000000..35e83e2c5 --- /dev/null +++ b/pkg/crd/arangobackuppolicies.go @@ -0,0 +1,119 @@ +// +// DISCLAIMER +// +// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package crd + +import ( + apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + + "github.com/arangodb/kube-arangodb/pkg/util" +) + +func init() { + registerCRDWithPanic("arangobackuppolicies.backup.arangodb.com", crd{ + version: "1.0.1", + spec: apiextensions.CustomResourceDefinitionSpec{ + Group: "backup.arangodb.com", + Names: apiextensions.CustomResourceDefinitionNames{ + Plural: "arangobackuppolicies", + Singular: "arangobackuppolicy", + Kind: "ArangoBackupPolicy", + ListKind: "ArangoBackupPolicyList", + ShortNames: []string{ + "arangobackuppolicy", + "arangobp", + }, + }, + Scope: apiextensions.NamespaceScoped, + Versions: []apiextensions.CustomResourceDefinitionVersion{ + { + Name: "v1", + Schema: &apiextensions.CustomResourceValidation{ + OpenAPIV3Schema: &apiextensions.JSONSchemaProps{ + Type: "object", + XPreserveUnknownFields: util.NewBool(true), + }, + }, + Served: true, + Storage: true, + AdditionalPrinterColumns: []apiextensions.CustomResourceColumnDefinition{ + { + JSONPath: ".spec.schedule", + Description: "Schedule", + Name: "Schedule", + Type: "string", + }, + { + JSONPath: ".status.scheduled", + Description: "Scheduled", + Name: "Scheduled", + Type: "string", + }, + { + JSONPath: ".status.message", + Priority: 1, + Description: "Message of the ArangoBackupPolicy object", + Name: "Message", + Type: "string", + }, + }, + Subresources: &apiextensions.CustomResourceSubresources{ + Status: &apiextensions.CustomResourceSubresourceStatus{}, + }, + }, + { + Name: "v1alpha", + Schema: &apiextensions.CustomResourceValidation{ + OpenAPIV3Schema: &apiextensions.JSONSchemaProps{ + Type: "object", + XPreserveUnknownFields: util.NewBool(true), + }, + }, + Served: true, + Storage: false, + AdditionalPrinterColumns: []apiextensions.CustomResourceColumnDefinition{ + { + JSONPath: ".spec.schedule", + Description: "Schedule", + Name: "Schedule", + Type: "string", + }, + { + JSONPath: ".status.scheduled", + Description: "Scheduled", + Name: "Scheduled", + Type: "string", + }, + { + JSONPath: ".status.message", + Priority: 1, + Description: "Message of the ArangoBackupPolicy object", + Name: "Message", + Type: "string", + }, + }, + Subresources: &apiextensions.CustomResourceSubresources{ + Status: &apiextensions.CustomResourceSubresourceStatus{}, + }, + }, + }, + }, + }) +}