mirror of
https://github.com/arangodb/kube-arangodb.git
synced 2024-12-14 11:57:37 +00:00
[Bugfix] Fix Schema Apply Checksum (#1652)
This commit is contained in:
parent
bb45038808
commit
2397c7523a
25 changed files with 284 additions and 340 deletions
|
@ -4,6 +4,7 @@
|
||||||
- (Maintenance) Bump Prometheus API Version
|
- (Maintenance) Bump Prometheus API Version
|
||||||
- (Bugfix) Prevent unexpected rotation in case of SecurityContext change
|
- (Bugfix) Prevent unexpected rotation in case of SecurityContext change
|
||||||
- (Bugfix) Ensure PDB is created
|
- (Bugfix) Ensure PDB is created
|
||||||
|
- (Bugfix) Fix Schema Apply Checksum
|
||||||
|
|
||||||
## [1.2.40](https://github.com/arangodb/kube-arangodb/tree/1.2.40) (2024-04-10)
|
## [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
|
- (Feature) Add Core fields to the Scheduler Container Spec
|
||||||
|
|
|
@ -67,6 +67,7 @@ import (
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util/metrics"
|
"github.com/arangodb/kube-arangodb/pkg/util/metrics"
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util/probe"
|
"github.com/arangodb/kube-arangodb/pkg/util/probe"
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util/retry"
|
"github.com/arangodb/kube-arangodb/pkg/util/retry"
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/shutdown"
|
||||||
"github.com/arangodb/kube-arangodb/pkg/version"
|
"github.com/arangodb/kube-arangodb/pkg/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -378,7 +379,7 @@ func executeMain(cmd *cobra.Command, args []string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if crdOptions.install {
|
if crdOptions.install {
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
|
ctx, cancel := context.WithTimeout(shutdown.Context(), time.Minute)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
crdOpts, err := prepareCRDOptions(crdOptions.validationSchema)
|
crdOpts, err := prepareCRDOptions(crdOptions.validationSchema)
|
||||||
|
|
|
@ -34,6 +34,7 @@ import (
|
||||||
"github.com/arangodb/kube-arangodb/pkg/crd/crds"
|
"github.com/arangodb/kube-arangodb/pkg/crd/crds"
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util/errors"
|
"github.com/arangodb/kube-arangodb/pkg/util/errors"
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util/kclient"
|
"github.com/arangodb/kube-arangodb/pkg/util/kclient"
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/shutdown"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -108,7 +109,7 @@ func cmdCRDInstallRun(cmd *cobra.Command, args []string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
|
ctx, cancel := context.WithTimeout(shutdown.Context(), time.Minute)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
err = crd.EnsureCRDWithOptions(ctx, client, crd.EnsureCRDOptions{IgnoreErrors: false, CRDOptions: crdOpts, ForceUpdate: crdInstallOptions.force})
|
err = crd.EnsureCRDWithOptions(ctx, client, crd.EnsureCRDOptions{IgnoreErrors: false, CRDOptions: crdOpts, ForceUpdate: crdInstallOptions.force})
|
||||||
|
|
|
@ -28,8 +28,6 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/api/errors"
|
"k8s.io/apimachinery/pkg/api/errors"
|
||||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
||||||
"github.com/arangodb/go-driver"
|
|
||||||
|
|
||||||
"github.com/arangodb/kube-arangodb/pkg/crd/crds"
|
"github.com/arangodb/kube-arangodb/pkg/crd/crds"
|
||||||
"github.com/arangodb/kube-arangodb/pkg/logging"
|
"github.com/arangodb/kube-arangodb/pkg/logging"
|
||||||
kresources "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/resources"
|
kresources "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/resources"
|
||||||
|
@ -65,13 +63,13 @@ func EnsureCRDWithOptions(ctx context.Context, client kclient.Client, opts Ensur
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
var opt *crds.CRDOptions
|
var opt = &crdReg.defaultOpts
|
||||||
if o, ok := opts.CRDOptions[crdName]; ok {
|
if o, ok := opts.CRDOptions[crdName]; ok {
|
||||||
opt = &o
|
opt = &o
|
||||||
}
|
}
|
||||||
def := crdReg.getter(opt)
|
def := crdReg.getter(opt)
|
||||||
|
|
||||||
err := tryApplyCRD(ctx, client, def, opts.ForceUpdate)
|
err := tryApplyCRD(ctx, client, def, opt, opts.ForceUpdate)
|
||||||
if !opts.IgnoreErrors && err != nil {
|
if !opts.IgnoreErrors && err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -79,11 +77,19 @@ func EnsureCRDWithOptions(ctx context.Context, client kclient.Client, opts Ensur
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func tryApplyCRD(ctx context.Context, client kclient.Client, def crds.Definition, forceUpdate bool) error {
|
func tryApplyCRD(ctx context.Context, client kclient.Client, def crds.Definition, opts *crds.CRDOptions, forceUpdate bool) error {
|
||||||
crdDefinitions := client.KubernetesExtensions().ApiextensionsV1().CustomResourceDefinitions()
|
crdDefinitions := client.KubernetesExtensions().ApiextensionsV1().CustomResourceDefinitions()
|
||||||
|
|
||||||
crdName := def.CRD.Name
|
crdName := def.CRD.Name
|
||||||
|
|
||||||
|
definitionVersion, definitionSchemaVersion := def.DefinitionData.Checksum()
|
||||||
|
|
||||||
|
logger := logger.Str("version", definitionVersion)
|
||||||
|
|
||||||
|
if opts.GetWithSchema() {
|
||||||
|
logger = logger.Str("schema", definitionSchemaVersion)
|
||||||
|
}
|
||||||
|
|
||||||
c, err := crdDefinitions.Get(ctx, crdName, meta.GetOptions{})
|
c, err := crdDefinitions.Get(ctx, crdName, meta.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !errors.IsNotFound(err) {
|
if !errors.IsNotFound(err) {
|
||||||
|
@ -102,12 +108,16 @@ func tryApplyCRD(ctx context.Context, client kclient.Client, def crds.Definition
|
||||||
ObjectMeta: meta.ObjectMeta{
|
ObjectMeta: meta.ObjectMeta{
|
||||||
Name: crdName,
|
Name: crdName,
|
||||||
Labels: map[string]string{
|
Labels: map[string]string{
|
||||||
Version: string(def.Version),
|
Version: definitionVersion,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Spec: def.CRD.Spec,
|
Spec: def.CRD.Spec,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if opts.GetWithSchema() {
|
||||||
|
c.Labels[Schema] = definitionSchemaVersion
|
||||||
|
}
|
||||||
|
|
||||||
if _, err := crdDefinitions.Create(ctx, c, meta.CreateOptions{}); err != nil {
|
if _, err := crdDefinitions.Create(ctx, c, meta.CreateOptions{}); err != nil {
|
||||||
logger.Err(err).Str("crd", crdName).Warn("Create Operations is not allowed due to error")
|
logger.Err(err).Str("crd", crdName).Warn("Create Operations is not allowed due to error")
|
||||||
return err
|
return err
|
||||||
|
@ -127,14 +137,20 @@ func tryApplyCRD(ctx context.Context, client kclient.Client, def crds.Definition
|
||||||
c.ObjectMeta.Labels = map[string]string{}
|
c.ObjectMeta.Labels = map[string]string{}
|
||||||
}
|
}
|
||||||
|
|
||||||
if v, ok := c.ObjectMeta.Labels[Version]; ok && v != "" {
|
if !forceUpdate {
|
||||||
if !forceUpdate && !isUpdateRequired(def.Version, driver.Version(v)) {
|
if v, ok := c.ObjectMeta.Labels[Version]; ok && v == definitionVersion {
|
||||||
logger.Str("crd", crdName).Info("CRD Update not required")
|
if v, ok := c.ObjectMeta.Labels[Schema]; (opts.GetWithSchema() && (ok && v == definitionSchemaVersion)) || (!opts.GetWithSchema() && !ok) {
|
||||||
return nil
|
logger.Str("crd", crdName).Info("CRD Update not required")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
c.ObjectMeta.Labels[Version] = string(def.Version)
|
c.ObjectMeta.Labels[Version] = definitionVersion
|
||||||
|
delete(c.ObjectMeta.Labels, Schema)
|
||||||
|
if opts.GetWithSchema() {
|
||||||
|
c.ObjectMeta.Labels[Schema] = definitionSchemaVersion
|
||||||
|
}
|
||||||
c.Spec = def.CRD.Spec
|
c.Spec = def.CRD.Spec
|
||||||
|
|
||||||
if _, err := crdDefinitions.Update(ctx, c, meta.UpdateOptions{}); err != nil {
|
if _, err := crdDefinitions.Update(ctx, c, meta.UpdateOptions{}); err != nil {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// DISCLAIMER
|
// 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");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
|
@ -22,6 +22,7 @@ package crd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -51,6 +52,11 @@ func dropLogMessages(t *testing.T, s tests.LogScanner) map[string]string {
|
||||||
lines[p] = m
|
lines[p] = m
|
||||||
}
|
}
|
||||||
|
|
||||||
|
d, err := json.Marshal(lines)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
t.Logf("Lines: %s", string(d))
|
||||||
|
|
||||||
return lines
|
return lines
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,27 +139,88 @@ func runApply(t *testing.T, crdOpts map[string]crds.CRDOptions) {
|
||||||
|
|
||||||
t.Run("Create", func(t *testing.T) {
|
t.Run("Create", func(t *testing.T) {
|
||||||
d := crds.AllDefinitions()[0]
|
d := crds.AllDefinitions()[0]
|
||||||
|
|
||||||
q := d.CRD.DeepCopy()
|
q := d.CRD.DeepCopy()
|
||||||
q.Labels = map[string]string{
|
q.Labels = map[string]string{
|
||||||
Version: string(d.Version),
|
Version: "version",
|
||||||
}
|
}
|
||||||
_, err := c.KubernetesExtensions().ApiextensionsV1().CustomResourceDefinitions().Create(context.Background(), q, meta.CreateOptions{})
|
_, err := c.KubernetesExtensions().ApiextensionsV1().CustomResourceDefinitions().Create(context.Background(), q, meta.CreateOptions{})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("Ensure", func(t *testing.T) {
|
t.Run("Ensure without schema", func(t *testing.T) {
|
||||||
|
crdOpts = updateMap(t, crdOpts, func(t *testing.T, key string, el crds.CRDOptions) crds.CRDOptions {
|
||||||
|
el.WithSchema = false
|
||||||
|
return el
|
||||||
|
})
|
||||||
|
|
||||||
require.NoError(t, EnsureCRDWithOptions(context.Background(), c, EnsureCRDOptions{IgnoreErrors: false, CRDOptions: crdOpts}))
|
require.NoError(t, EnsureCRDWithOptions(context.Background(), c, EnsureCRDOptions{IgnoreErrors: false, CRDOptions: crdOpts}))
|
||||||
|
|
||||||
for k, v := range dropLogMessages(t, s) {
|
for k, v := range dropLogMessages(t, s) {
|
||||||
t.Run(k, func(t *testing.T) {
|
t.Run(k, func(t *testing.T) {
|
||||||
if k == crds.AllDefinitions()[0].CRD.GetName() {
|
if k == crds.AllDefinitions()[0].CRD.GetName() {
|
||||||
require.Equal(t, "CRD Update not required", v)
|
require.Equal(t, "CRD Updated", v)
|
||||||
} else {
|
} else {
|
||||||
require.Equal(t, "CRD Created", v)
|
require.Equal(t, "CRD Created", v)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("Rerun without schema", func(t *testing.T) {
|
||||||
|
crdOpts = updateMap(t, crdOpts, func(t *testing.T, key string, el crds.CRDOptions) crds.CRDOptions {
|
||||||
|
el.WithSchema = false
|
||||||
|
return el
|
||||||
|
})
|
||||||
|
|
||||||
|
require.NoError(t, EnsureCRDWithOptions(context.Background(), c, EnsureCRDOptions{IgnoreErrors: false, CRDOptions: crdOpts}))
|
||||||
|
|
||||||
|
for k, v := range dropLogMessages(t, s) {
|
||||||
|
t.Run(k, func(t *testing.T) {
|
||||||
|
require.Equal(t, "CRD Update not required", v)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("Ensure with schema", func(t *testing.T) {
|
||||||
|
crdOpts = updateMap(t, crdOpts, func(t *testing.T, key string, el crds.CRDOptions) crds.CRDOptions {
|
||||||
|
el.WithSchema = true
|
||||||
|
return el
|
||||||
|
})
|
||||||
|
|
||||||
|
require.NoError(t, EnsureCRDWithOptions(context.Background(), c, EnsureCRDOptions{IgnoreErrors: false, CRDOptions: crdOpts}))
|
||||||
|
|
||||||
|
for k, v := range dropLogMessages(t, s) {
|
||||||
|
t.Run(k, func(t *testing.T) {
|
||||||
|
require.Equal(t, "CRD Updated", v)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("Rerun with schema", func(t *testing.T) {
|
||||||
|
crdOpts = updateMap(t, crdOpts, func(t *testing.T, key string, el crds.CRDOptions) crds.CRDOptions {
|
||||||
|
el.WithSchema = true
|
||||||
|
return el
|
||||||
|
})
|
||||||
|
|
||||||
|
require.NoError(t, EnsureCRDWithOptions(context.Background(), c, EnsureCRDOptions{IgnoreErrors: false, CRDOptions: crdOpts}))
|
||||||
|
|
||||||
|
for k, v := range dropLogMessages(t, s) {
|
||||||
|
t.Run(k, func(t *testing.T) {
|
||||||
|
require.Equal(t, "CRD Update not required", v)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func updateMap[T comparable](t *testing.T, in map[string]T, f func(t *testing.T, key string, el T) T) map[string]T {
|
||||||
|
r := make(map[string]T, len(in))
|
||||||
|
|
||||||
|
for k, v := range in {
|
||||||
|
r[k] = f(t, k, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
|
@ -24,14 +24,6 @@ import (
|
||||||
_ "embed"
|
_ "embed"
|
||||||
|
|
||||||
apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
||||||
|
|
||||||
"github.com/arangodb/go-driver"
|
|
||||||
|
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
AppsJobVersion = driver.Version("1.0.1")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Deprecated: use AppsJobWithOptions instead
|
// Deprecated: use AppsJobWithOptions instead
|
||||||
|
@ -40,7 +32,7 @@ func AppsJob() *apiextensions.CustomResourceDefinition {
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppsJobWithOptions(opts ...func(*CRDOptions)) *apiextensions.CustomResourceDefinition {
|
func AppsJobWithOptions(opts ...func(*CRDOptions)) *apiextensions.CustomResourceDefinition {
|
||||||
return getCRD(appsJobsCRD, appsJobsCRDSchemas, opts...)
|
return getCRD(AppsJobDefinitionData(), opts...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: use AppsJobDefinitionWithOptions instead
|
// Deprecated: use AppsJobDefinitionWithOptions instead
|
||||||
|
@ -50,13 +42,17 @@ func AppsJobDefinition() Definition {
|
||||||
|
|
||||||
func AppsJobDefinitionWithOptions(opts ...func(*CRDOptions)) Definition {
|
func AppsJobDefinitionWithOptions(opts ...func(*CRDOptions)) Definition {
|
||||||
return Definition{
|
return Definition{
|
||||||
Version: AppsJobVersion,
|
DefinitionData: AppsJobDefinitionData(),
|
||||||
CRD: AppsJobWithOptions(opts...),
|
CRD: AppsJobWithOptions(opts...),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var appsJobsCRD = util.NewYamlLoader[apiextensions.CustomResourceDefinition](appsJobs)
|
func AppsJobDefinitionData() DefinitionData {
|
||||||
var appsJobsCRDSchemas = util.NewYamlLoader[crdSchemas](appsJobsSchemaRaw)
|
return DefinitionData{
|
||||||
|
definition: appsJobs,
|
||||||
|
schemaDefinition: appsJobsSchemaRaw,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//go:embed apps-job.yaml
|
//go:embed apps-job.yaml
|
||||||
var appsJobs []byte
|
var appsJobs []byte
|
||||||
|
|
|
@ -24,14 +24,6 @@ import (
|
||||||
_ "embed"
|
_ "embed"
|
||||||
|
|
||||||
apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
||||||
|
|
||||||
"github.com/arangodb/go-driver"
|
|
||||||
|
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
BackupsBackupVersion = driver.Version("1.0.1")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Deprecated: use BackupsBackupWithOptions instead
|
// Deprecated: use BackupsBackupWithOptions instead
|
||||||
|
@ -40,7 +32,7 @@ func BackupsBackup() *apiextensions.CustomResourceDefinition {
|
||||||
}
|
}
|
||||||
|
|
||||||
func BackupsBackupWithOptions(opts ...func(*CRDOptions)) *apiextensions.CustomResourceDefinition {
|
func BackupsBackupWithOptions(opts ...func(*CRDOptions)) *apiextensions.CustomResourceDefinition {
|
||||||
return getCRD(backupsBackupCRD, backupsBackupCRDSchemas, opts...)
|
return getCRD(BackupsBackupDefinitionData(), opts...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: use BackupsBackupDefinitionWithOptions instead
|
// Deprecated: use BackupsBackupDefinitionWithOptions instead
|
||||||
|
@ -50,13 +42,17 @@ func BackupsBackupDefinition() Definition {
|
||||||
|
|
||||||
func BackupsBackupDefinitionWithOptions(opts ...func(*CRDOptions)) Definition {
|
func BackupsBackupDefinitionWithOptions(opts ...func(*CRDOptions)) Definition {
|
||||||
return Definition{
|
return Definition{
|
||||||
Version: BackupsBackupVersion,
|
DefinitionData: BackupsBackupDefinitionData(),
|
||||||
CRD: BackupsBackupWithOptions(opts...),
|
CRD: BackupsBackupWithOptions(opts...),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var backupsBackupCRD = util.NewYamlLoader[apiextensions.CustomResourceDefinition](backupsBackup)
|
func BackupsBackupDefinitionData() DefinitionData {
|
||||||
var backupsBackupCRDSchemas = util.NewYamlLoader[crdSchemas](backupsBackupSchemaRaw)
|
return DefinitionData{
|
||||||
|
definition: backupsBackup,
|
||||||
|
schemaDefinition: backupsBackupSchemaRaw,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//go:embed backups-backup.yaml
|
//go:embed backups-backup.yaml
|
||||||
var backupsBackup []byte
|
var backupsBackup []byte
|
||||||
|
|
|
@ -24,14 +24,6 @@ import (
|
||||||
_ "embed"
|
_ "embed"
|
||||||
|
|
||||||
apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
||||||
|
|
||||||
"github.com/arangodb/go-driver"
|
|
||||||
|
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
BackupsBackupPolicyPolicyVersion = driver.Version("1.0.1")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Deprecated: use BackupsBackupPolicyPolicyWithOptions instead
|
// Deprecated: use BackupsBackupPolicyPolicyWithOptions instead
|
||||||
|
@ -40,7 +32,7 @@ func BackupsBackupPolicyPolicy() *apiextensions.CustomResourceDefinition {
|
||||||
}
|
}
|
||||||
|
|
||||||
func BackupsBackupPolicyPolicyWithOptions(opts ...func(*CRDOptions)) *apiextensions.CustomResourceDefinition {
|
func BackupsBackupPolicyPolicyWithOptions(opts ...func(*CRDOptions)) *apiextensions.CustomResourceDefinition {
|
||||||
return getCRD(backupsBackupPolicyCRD, backupsBackupPolicyCRDSchemas, opts...)
|
return getCRD(BackupsBackupPolicyDefinitionData(), opts...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: use func BackupsBackupPolicyDefinitionWithOptions instead
|
// Deprecated: use func BackupsBackupPolicyDefinitionWithOptions instead
|
||||||
|
@ -50,13 +42,17 @@ func BackupsBackupPolicyDefinition() Definition {
|
||||||
|
|
||||||
func BackupsBackupPolicyDefinitionWithOptions(opts ...func(*CRDOptions)) Definition {
|
func BackupsBackupPolicyDefinitionWithOptions(opts ...func(*CRDOptions)) Definition {
|
||||||
return Definition{
|
return Definition{
|
||||||
Version: BackupsBackupPolicyPolicyVersion,
|
DefinitionData: BackupsBackupPolicyDefinitionData(),
|
||||||
CRD: BackupsBackupPolicyPolicyWithOptions(opts...),
|
CRD: BackupsBackupPolicyPolicyWithOptions(opts...),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var backupsBackupPolicyCRD = util.NewYamlLoader[apiextensions.CustomResourceDefinition](backupsBackupPolicy)
|
func BackupsBackupPolicyDefinitionData() DefinitionData {
|
||||||
var backupsBackupPolicyCRDSchemas = util.NewYamlLoader[crdSchemas](backupsBackupPolicySchemaRaw)
|
return DefinitionData{
|
||||||
|
definition: backupsBackupPolicy,
|
||||||
|
schemaDefinition: backupsBackupPolicySchemaRaw,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//go:embed backups-backuppolicy.yaml
|
//go:embed backups-backuppolicy.yaml
|
||||||
var backupsBackupPolicy []byte
|
var backupsBackupPolicy []byte
|
||||||
|
|
|
@ -25,14 +25,35 @@ import (
|
||||||
|
|
||||||
apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
||||||
|
|
||||||
"github.com/arangodb/go-driver"
|
|
||||||
|
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util"
|
"github.com/arangodb/kube-arangodb/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Definition struct {
|
type Definition struct {
|
||||||
Version driver.Version
|
DefinitionData
|
||||||
CRD *apiextensions.CustomResourceDefinition
|
CRD *apiextensions.CustomResourceDefinition
|
||||||
|
}
|
||||||
|
|
||||||
|
type DefinitionData struct {
|
||||||
|
definition []byte
|
||||||
|
schemaDefinition []byte
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d DefinitionData) definitionLoader() util.Loader[apiextensions.CustomResourceDefinition] {
|
||||||
|
return util.NewYamlLoader[apiextensions.CustomResourceDefinition](d.definition)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d DefinitionData) schemaDefinitionLoader() util.Loader[crdSchemas] {
|
||||||
|
return util.NewYamlLoader[crdSchemas](d.schemaDefinition)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d DefinitionData) Checksum() (definition, schema string) {
|
||||||
|
if len(d.definition) > 0 {
|
||||||
|
definition = util.SHA256(d.definition)
|
||||||
|
}
|
||||||
|
if len(d.schemaDefinition) > 0 {
|
||||||
|
schema = util.SHA256(d.schemaDefinition)
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func AllDefinitions() []Definition {
|
func AllDefinitions() []Definition {
|
||||||
|
@ -75,6 +96,14 @@ type CRDOptions struct {
|
||||||
WithSchema bool
|
WithSchema bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *CRDOptions) GetWithSchema() bool {
|
||||||
|
if o == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return o.WithSchema
|
||||||
|
}
|
||||||
|
|
||||||
func (o *CRDOptions) AsFunc() func(*CRDOptions) {
|
func (o *CRDOptions) AsFunc() func(*CRDOptions) {
|
||||||
return func(opts *CRDOptions) {
|
return func(opts *CRDOptions) {
|
||||||
if o == nil || opts == nil {
|
if o == nil || opts == nil {
|
||||||
|
@ -91,18 +120,18 @@ func WithSchema() func(*CRDOptions) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getCRD(crdLoader util.Loader[apiextensions.CustomResourceDefinition], schemasLoader util.Loader[crdSchemas], opts ...func(*CRDOptions)) *apiextensions.CustomResourceDefinition {
|
func getCRD(data DefinitionData, opts ...func(*CRDOptions)) *apiextensions.CustomResourceDefinition {
|
||||||
o := &CRDOptions{}
|
o := &CRDOptions{}
|
||||||
for _, fn := range opts {
|
for _, fn := range opts {
|
||||||
fn(o)
|
fn(o)
|
||||||
}
|
}
|
||||||
|
|
||||||
crd := crdLoader.MustGet()
|
crd := data.definitionLoader().MustGet()
|
||||||
|
|
||||||
if o.WithSchema {
|
if o.WithSchema {
|
||||||
crdWithSchema := crd.DeepCopy()
|
crdWithSchema := crd.DeepCopy()
|
||||||
|
|
||||||
schemas := schemasLoader.MustGet()
|
schemas := data.schemaDefinitionLoader().MustGet()
|
||||||
|
|
||||||
for i, v := range crdWithSchema.Spec.Versions {
|
for i, v := range crdWithSchema.Spec.Versions {
|
||||||
schema, ok := schemas[v.Name]
|
schema, ok := schemas[v.Name]
|
||||||
|
|
|
@ -88,8 +88,20 @@ func Test_CRD(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_AllDefinitionsDefined(t *testing.T) {
|
func Test_AllDefinitionsDefined(t *testing.T) {
|
||||||
|
registered := map[string]bool{}
|
||||||
|
|
||||||
for _, def := range AllDefinitions() {
|
for _, def := range AllDefinitions() {
|
||||||
require.NotEmpty(t, def.Version)
|
a, b := def.Checksum()
|
||||||
|
|
||||||
|
require.NotEmpty(t, a)
|
||||||
|
require.NotEmpty(t, b)
|
||||||
|
|
||||||
|
require.NotContains(t, registered, a)
|
||||||
|
require.NotContains(t, registered, b)
|
||||||
|
|
||||||
|
registered[a] = true
|
||||||
|
registered[b] = true
|
||||||
|
|
||||||
require.NotNil(t, def.CRD)
|
require.NotNil(t, def.CRD)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,14 +24,6 @@ import (
|
||||||
_ "embed"
|
_ "embed"
|
||||||
|
|
||||||
apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
||||||
|
|
||||||
"github.com/arangodb/go-driver"
|
|
||||||
|
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
DatabaseClusterSynchronizationVersion = driver.Version("1.0.1")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Deprecated: use DatabaseClusterSynchronizationWithOptions instead
|
// Deprecated: use DatabaseClusterSynchronizationWithOptions instead
|
||||||
|
@ -40,7 +32,7 @@ func DatabaseClusterSynchronization() *apiextensions.CustomResourceDefinition {
|
||||||
}
|
}
|
||||||
|
|
||||||
func DatabaseClusterSynchronizationWithOptions(opts ...func(*CRDOptions)) *apiextensions.CustomResourceDefinition {
|
func DatabaseClusterSynchronizationWithOptions(opts ...func(*CRDOptions)) *apiextensions.CustomResourceDefinition {
|
||||||
return getCRD(databaseClusterSynchronizationCRD, databaseClusterSynchronizationCRDSchemas, opts...)
|
return getCRD(DatabaseClusterSynchronizationDefinitionData(), opts...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: use DatabaseClusterSynchronizationDefinitionWithOptions instead
|
// Deprecated: use DatabaseClusterSynchronizationDefinitionWithOptions instead
|
||||||
|
@ -50,13 +42,17 @@ func DatabaseClusterSynchronizationDefinition() Definition {
|
||||||
|
|
||||||
func DatabaseClusterSynchronizationDefinitionWithOptions(opts ...func(*CRDOptions)) Definition {
|
func DatabaseClusterSynchronizationDefinitionWithOptions(opts ...func(*CRDOptions)) Definition {
|
||||||
return Definition{
|
return Definition{
|
||||||
Version: DatabaseClusterSynchronizationVersion,
|
DefinitionData: DatabaseClusterSynchronizationDefinitionData(),
|
||||||
CRD: DatabaseClusterSynchronizationWithOptions(opts...),
|
CRD: DatabaseClusterSynchronizationWithOptions(opts...),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var databaseClusterSynchronizationCRD = util.NewYamlLoader[apiextensions.CustomResourceDefinition](databaseClusterSynchronization)
|
func DatabaseClusterSynchronizationDefinitionData() DefinitionData {
|
||||||
var databaseClusterSynchronizationCRDSchemas = util.NewYamlLoader[crdSchemas](databaseClusterSynchronizationSchemaRaw)
|
return DefinitionData{
|
||||||
|
definition: databaseClusterSynchronization,
|
||||||
|
schemaDefinition: databaseClusterSynchronizationSchemaRaw,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//go:embed database-clustersynchronization.yaml
|
//go:embed database-clustersynchronization.yaml
|
||||||
var databaseClusterSynchronization []byte
|
var databaseClusterSynchronization []byte
|
||||||
|
|
|
@ -24,14 +24,6 @@ import (
|
||||||
_ "embed"
|
_ "embed"
|
||||||
|
|
||||||
apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
||||||
|
|
||||||
"github.com/arangodb/go-driver"
|
|
||||||
|
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
DatabaseDeploymentVersion = driver.Version("1.0.1")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Deprecated: use DatabaseDeploymentWithOptions instead
|
// Deprecated: use DatabaseDeploymentWithOptions instead
|
||||||
|
@ -40,7 +32,7 @@ func DatabaseDeployment() *apiextensions.CustomResourceDefinition {
|
||||||
}
|
}
|
||||||
|
|
||||||
func DatabaseDeploymentWithOptions(opts ...func(*CRDOptions)) *apiextensions.CustomResourceDefinition {
|
func DatabaseDeploymentWithOptions(opts ...func(*CRDOptions)) *apiextensions.CustomResourceDefinition {
|
||||||
return getCRD(databaseDeploymentCRD, databaseDeploymentCRDSchemas, opts...)
|
return getCRD(DatabaseDeploymentDefinitionData(), opts...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: use DatabaseDeploymentDefinitionWithOptions instead
|
// Deprecated: use DatabaseDeploymentDefinitionWithOptions instead
|
||||||
|
@ -50,13 +42,17 @@ func DatabaseDeploymentDefinition() Definition {
|
||||||
|
|
||||||
func DatabaseDeploymentDefinitionWithOptions(opts ...func(*CRDOptions)) Definition {
|
func DatabaseDeploymentDefinitionWithOptions(opts ...func(*CRDOptions)) Definition {
|
||||||
return Definition{
|
return Definition{
|
||||||
Version: DatabaseDeploymentVersion,
|
DefinitionData: DatabaseDeploymentDefinitionData(),
|
||||||
CRD: DatabaseDeploymentWithOptions(opts...),
|
CRD: DatabaseDeploymentWithOptions(opts...),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var databaseDeploymentCRD = util.NewYamlLoader[apiextensions.CustomResourceDefinition](databaseDeployment)
|
func DatabaseDeploymentDefinitionData() DefinitionData {
|
||||||
var databaseDeploymentCRDSchemas = util.NewYamlLoader[crdSchemas](databaseDeploymentSchemaRaw)
|
return DefinitionData{
|
||||||
|
definition: databaseDeployment,
|
||||||
|
schemaDefinition: databaseDeploymentSchemaRaw,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//go:embed database-deployment.yaml
|
//go:embed database-deployment.yaml
|
||||||
var databaseDeployment []byte
|
var databaseDeployment []byte
|
||||||
|
|
|
@ -24,14 +24,6 @@ import (
|
||||||
_ "embed"
|
_ "embed"
|
||||||
|
|
||||||
apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
||||||
|
|
||||||
"github.com/arangodb/go-driver"
|
|
||||||
|
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
DatabaseMemberVersion = driver.Version("1.0.1")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Deprecated: use DatabaseMemberWithOptions instead
|
// Deprecated: use DatabaseMemberWithOptions instead
|
||||||
|
@ -40,7 +32,7 @@ func DatabaseMember() *apiextensions.CustomResourceDefinition {
|
||||||
}
|
}
|
||||||
|
|
||||||
func DatabaseMemberWithOptions(opts ...func(*CRDOptions)) *apiextensions.CustomResourceDefinition {
|
func DatabaseMemberWithOptions(opts ...func(*CRDOptions)) *apiextensions.CustomResourceDefinition {
|
||||||
return getCRD(databaseMemberCRD, databaseMemberCRDSchemas, opts...)
|
return getCRD(DatabaseMemberDefinitionData(), opts...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: use DatabaseMemberDefinitionWithOptions instead
|
// Deprecated: use DatabaseMemberDefinitionWithOptions instead
|
||||||
|
@ -50,13 +42,17 @@ func DatabaseMemberDefinition() Definition {
|
||||||
|
|
||||||
func DatabaseMemberDefinitionWithOptions(opts ...func(*CRDOptions)) Definition {
|
func DatabaseMemberDefinitionWithOptions(opts ...func(*CRDOptions)) Definition {
|
||||||
return Definition{
|
return Definition{
|
||||||
Version: DatabaseMemberVersion,
|
DefinitionData: DatabaseMemberDefinitionData(),
|
||||||
CRD: DatabaseMemberWithOptions(opts...),
|
CRD: DatabaseMemberWithOptions(opts...),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var databaseMemberCRD = util.NewYamlLoader[apiextensions.CustomResourceDefinition](databaseMember)
|
func DatabaseMemberDefinitionData() DefinitionData {
|
||||||
var databaseMemberCRDSchemas = util.NewYamlLoader[crdSchemas](databaseMemberSchemaRaw)
|
return DefinitionData{
|
||||||
|
definition: databaseMember,
|
||||||
|
schemaDefinition: databaseMemberSchemaRaw,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//go:embed database-member.yaml
|
//go:embed database-member.yaml
|
||||||
var databaseMember []byte
|
var databaseMember []byte
|
||||||
|
|
|
@ -24,14 +24,6 @@ import (
|
||||||
_ "embed"
|
_ "embed"
|
||||||
|
|
||||||
apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
||||||
|
|
||||||
"github.com/arangodb/go-driver"
|
|
||||||
|
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
DatabaseTaskVersion = driver.Version("1.0.1")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Deprecated: use DatabaseTaskWithOptions instead
|
// Deprecated: use DatabaseTaskWithOptions instead
|
||||||
|
@ -40,7 +32,7 @@ func DatabaseTask() *apiextensions.CustomResourceDefinition {
|
||||||
}
|
}
|
||||||
|
|
||||||
func DatabaseTaskWithOptions(opts ...func(*CRDOptions)) *apiextensions.CustomResourceDefinition {
|
func DatabaseTaskWithOptions(opts ...func(*CRDOptions)) *apiextensions.CustomResourceDefinition {
|
||||||
return getCRD(databaseTaskCRD, databaseTaskCRDSchemas, opts...)
|
return getCRD(DatabaseTaskDefinitionData(), opts...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: use DatabaseTaskDefinitionWithOptions instead
|
// Deprecated: use DatabaseTaskDefinitionWithOptions instead
|
||||||
|
@ -50,13 +42,17 @@ func DatabaseTaskDefinition() Definition {
|
||||||
|
|
||||||
func DatabaseTaskDefinitionWithOptions(opts ...func(*CRDOptions)) Definition {
|
func DatabaseTaskDefinitionWithOptions(opts ...func(*CRDOptions)) Definition {
|
||||||
return Definition{
|
return Definition{
|
||||||
Version: DatabaseTaskVersion,
|
DefinitionData: DatabaseTaskDefinitionData(),
|
||||||
CRD: DatabaseTaskWithOptions(opts...),
|
CRD: DatabaseTaskWithOptions(opts...),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var databaseTaskCRD = util.NewYamlLoader[apiextensions.CustomResourceDefinition](databaseTask)
|
func DatabaseTaskDefinitionData() DefinitionData {
|
||||||
var databaseTaskCRDSchemas = util.NewYamlLoader[crdSchemas](databaseTaskSchemaRaw)
|
return DefinitionData{
|
||||||
|
definition: databaseTask,
|
||||||
|
schemaDefinition: databaseTaskSchemaRaw,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//go:embed database-task.yaml
|
//go:embed database-task.yaml
|
||||||
var databaseTask []byte
|
var databaseTask []byte
|
||||||
|
|
|
@ -24,29 +24,25 @@ import (
|
||||||
_ "embed"
|
_ "embed"
|
||||||
|
|
||||||
apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
||||||
|
|
||||||
"github.com/arangodb/go-driver"
|
|
||||||
|
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
MLExtensionVersion = driver.Version("1.0.0")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func MLExtensionWithOptions(opts ...func(*CRDOptions)) *apiextensions.CustomResourceDefinition {
|
func MLExtensionWithOptions(opts ...func(*CRDOptions)) *apiextensions.CustomResourceDefinition {
|
||||||
return getCRD(mlExtensionCRD, mlExtensionCRDSchemas, opts...)
|
return getCRD(MLExtensionDefinitionData(), opts...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func MLExtensionDefinitionWithOptions(opts ...func(*CRDOptions)) Definition {
|
func MLExtensionDefinitionWithOptions(opts ...func(*CRDOptions)) Definition {
|
||||||
return Definition{
|
return Definition{
|
||||||
Version: MLExtensionVersion,
|
DefinitionData: MLExtensionDefinitionData(),
|
||||||
CRD: MLExtensionWithOptions(opts...),
|
CRD: MLExtensionWithOptions(opts...),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var mlExtensionCRD = util.NewYamlLoader[apiextensions.CustomResourceDefinition](mlExtension)
|
func MLExtensionDefinitionData() DefinitionData {
|
||||||
var mlExtensionCRDSchemas = util.NewYamlLoader[crdSchemas](mlExtensionSchemaRaw)
|
return DefinitionData{
|
||||||
|
definition: mlExtension,
|
||||||
|
schemaDefinition: mlExtensionSchemaRaw,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//go:embed ml-extension.yaml
|
//go:embed ml-extension.yaml
|
||||||
var mlExtension []byte
|
var mlExtension []byte
|
||||||
|
|
|
@ -24,29 +24,25 @@ import (
|
||||||
_ "embed"
|
_ "embed"
|
||||||
|
|
||||||
apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
||||||
|
|
||||||
"github.com/arangodb/go-driver"
|
|
||||||
|
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
MLBatchJobVersion = driver.Version("1.0.0")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func MLBatchJobWithOptions(opts ...func(*CRDOptions)) *apiextensions.CustomResourceDefinition {
|
func MLBatchJobWithOptions(opts ...func(*CRDOptions)) *apiextensions.CustomResourceDefinition {
|
||||||
return getCRD(mlBatchJobCRD, mlBatchJobCRDSchemas, opts...)
|
return getCRD(MLBatchJobDefinitionData(), opts...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func MLBatchJobDefinitionWithOptions(opts ...func(*CRDOptions)) Definition {
|
func MLBatchJobDefinitionWithOptions(opts ...func(*CRDOptions)) Definition {
|
||||||
return Definition{
|
return Definition{
|
||||||
Version: MLBatchJobVersion,
|
DefinitionData: MLBatchJobDefinitionData(),
|
||||||
CRD: MLBatchJobWithOptions(opts...),
|
CRD: MLBatchJobWithOptions(opts...),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var mlBatchJobCRD = util.NewYamlLoader[apiextensions.CustomResourceDefinition](mlBatchJob)
|
func MLBatchJobDefinitionData() DefinitionData {
|
||||||
var mlBatchJobCRDSchemas = util.NewYamlLoader[crdSchemas](mlBatchJobSchemaRaw)
|
return DefinitionData{
|
||||||
|
definition: mlBatchJob,
|
||||||
|
schemaDefinition: mlBatchJobSchemaRaw,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//go:embed ml-job-batch.yaml
|
//go:embed ml-job-batch.yaml
|
||||||
var mlBatchJob []byte
|
var mlBatchJob []byte
|
||||||
|
|
|
@ -24,29 +24,25 @@ import (
|
||||||
_ "embed"
|
_ "embed"
|
||||||
|
|
||||||
apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
||||||
|
|
||||||
"github.com/arangodb/go-driver"
|
|
||||||
|
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
MLCronJobVersion = driver.Version("1.0.0")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func MLCronJobWithOptions(opts ...func(*CRDOptions)) *apiextensions.CustomResourceDefinition {
|
func MLCronJobWithOptions(opts ...func(*CRDOptions)) *apiextensions.CustomResourceDefinition {
|
||||||
return getCRD(mlCronJobCRD, mlCronJobCRDSchemas, opts...)
|
return getCRD(MLCronJobDefinitionData(), opts...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func MLCronJobDefinitionWithOptions(opts ...func(*CRDOptions)) Definition {
|
func MLCronJobDefinitionWithOptions(opts ...func(*CRDOptions)) Definition {
|
||||||
return Definition{
|
return Definition{
|
||||||
Version: MLCronJobVersion,
|
DefinitionData: MLCronJobDefinitionData(),
|
||||||
CRD: MLCronJobWithOptions(opts...),
|
CRD: MLCronJobWithOptions(opts...),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var mlCronJobCRD = util.NewYamlLoader[apiextensions.CustomResourceDefinition](mlCronJob)
|
func MLCronJobDefinitionData() DefinitionData {
|
||||||
var mlCronJobCRDSchemas = util.NewYamlLoader[crdSchemas](mlCronJobSchemaRaw)
|
return DefinitionData{
|
||||||
|
definition: mlCronJob,
|
||||||
|
schemaDefinition: mlCronJobSchemaRaw,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//go:embed ml-job-cron.yaml
|
//go:embed ml-job-cron.yaml
|
||||||
var mlCronJob []byte
|
var mlCronJob []byte
|
||||||
|
|
|
@ -24,29 +24,25 @@ import (
|
||||||
_ "embed"
|
_ "embed"
|
||||||
|
|
||||||
apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
||||||
|
|
||||||
"github.com/arangodb/go-driver"
|
|
||||||
|
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
MLStorageVersion = driver.Version("1.0.0")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func MLStorageWithOptions(opts ...func(*CRDOptions)) *apiextensions.CustomResourceDefinition {
|
func MLStorageWithOptions(opts ...func(*CRDOptions)) *apiextensions.CustomResourceDefinition {
|
||||||
return getCRD(mlStorageCRD, mlStorageCRDSchemas, opts...)
|
return getCRD(MLStorageDefinitionData(), opts...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func MLStorageDefinitionWithOptions(opts ...func(*CRDOptions)) Definition {
|
func MLStorageDefinitionWithOptions(opts ...func(*CRDOptions)) Definition {
|
||||||
return Definition{
|
return Definition{
|
||||||
Version: MLStorageVersion,
|
DefinitionData: MLStorageDefinitionData(),
|
||||||
CRD: MLStorageWithOptions(opts...),
|
CRD: MLStorageWithOptions(opts...),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var mlStorageCRD = util.NewYamlLoader[apiextensions.CustomResourceDefinition](mlStorage)
|
func MLStorageDefinitionData() DefinitionData {
|
||||||
var mlStorageCRDSchemas = util.NewYamlLoader[crdSchemas](mlStorageSchemaRaw)
|
return DefinitionData{
|
||||||
|
definition: mlStorage,
|
||||||
|
schemaDefinition: mlStorageSchemaRaw,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//go:embed ml-storage.yaml
|
//go:embed ml-storage.yaml
|
||||||
var mlStorage []byte
|
var mlStorage []byte
|
||||||
|
|
|
@ -24,14 +24,6 @@ import (
|
||||||
_ "embed"
|
_ "embed"
|
||||||
|
|
||||||
apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
||||||
|
|
||||||
"github.com/arangodb/go-driver"
|
|
||||||
|
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
ReplicationDeploymentReplicationVersion = driver.Version("1.0.1")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Deprecated: use ReplicationDeploymentReplicationWithOptions instead
|
// Deprecated: use ReplicationDeploymentReplicationWithOptions instead
|
||||||
|
@ -40,7 +32,7 @@ func ReplicationDeploymentReplication() *apiextensions.CustomResourceDefinition
|
||||||
}
|
}
|
||||||
|
|
||||||
func ReplicationDeploymentReplicationWithOptions(opts ...func(*CRDOptions)) *apiextensions.CustomResourceDefinition {
|
func ReplicationDeploymentReplicationWithOptions(opts ...func(*CRDOptions)) *apiextensions.CustomResourceDefinition {
|
||||||
return getCRD(replicationDeploymentReplicationCRD, replicationDeploymentReplicationCRDSchemas, opts...)
|
return getCRD(ReplicationDeploymentReplicationDefinitionData(), opts...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: use ReplicationDeploymentReplicationDefinitionWithOptions instead
|
// Deprecated: use ReplicationDeploymentReplicationDefinitionWithOptions instead
|
||||||
|
@ -50,13 +42,17 @@ func ReplicationDeploymentReplicationDefinition() Definition {
|
||||||
|
|
||||||
func ReplicationDeploymentReplicationDefinitionWithOptions(opts ...func(*CRDOptions)) Definition {
|
func ReplicationDeploymentReplicationDefinitionWithOptions(opts ...func(*CRDOptions)) Definition {
|
||||||
return Definition{
|
return Definition{
|
||||||
Version: ReplicationDeploymentReplicationVersion,
|
DefinitionData: ReplicationDeploymentReplicationDefinitionData(),
|
||||||
CRD: ReplicationDeploymentReplicationWithOptions(opts...),
|
CRD: ReplicationDeploymentReplicationWithOptions(opts...),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var replicationDeploymentReplicationCRD = util.NewYamlLoader[apiextensions.CustomResourceDefinition](replicationDeploymentReplication)
|
func ReplicationDeploymentReplicationDefinitionData() DefinitionData {
|
||||||
var replicationDeploymentReplicationCRDSchemas = util.NewYamlLoader[crdSchemas](replicationDeploymentReplicationSchemaRaw)
|
return DefinitionData{
|
||||||
|
definition: replicationDeploymentReplication,
|
||||||
|
schemaDefinition: replicationDeploymentReplicationSchemaRaw,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//go:embed replication-deploymentreplication.yaml
|
//go:embed replication-deploymentreplication.yaml
|
||||||
var replicationDeploymentReplication []byte
|
var replicationDeploymentReplication []byte
|
||||||
|
|
|
@ -24,29 +24,25 @@ import (
|
||||||
_ "embed"
|
_ "embed"
|
||||||
|
|
||||||
apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
||||||
|
|
||||||
"github.com/arangodb/go-driver"
|
|
||||||
|
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
SchedulerProfileVersion = driver.Version("1.0.0")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func SchedulerProfileWithOptions(opts ...func(*CRDOptions)) *apiextensions.CustomResourceDefinition {
|
func SchedulerProfileWithOptions(opts ...func(*CRDOptions)) *apiextensions.CustomResourceDefinition {
|
||||||
return getCRD(schedulerProfileCRD, schedulerProfileCRDSchemas, opts...)
|
return getCRD(SchedulerProfileDefinitionData(), opts...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func SchedulerProfileDefinitionWithOptions(opts ...func(*CRDOptions)) Definition {
|
func SchedulerProfileDefinitionWithOptions(opts ...func(*CRDOptions)) Definition {
|
||||||
return Definition{
|
return Definition{
|
||||||
Version: SchedulerProfileVersion,
|
DefinitionData: SchedulerProfileDefinitionData(),
|
||||||
CRD: SchedulerProfileWithOptions(opts...),
|
CRD: SchedulerProfileWithOptions(opts...),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var schedulerProfileCRD = util.NewYamlLoader[apiextensions.CustomResourceDefinition](schedulerProfile)
|
func SchedulerProfileDefinitionData() DefinitionData {
|
||||||
var schedulerProfileCRDSchemas = util.NewYamlLoader[crdSchemas](schedulerProfileSchemaRaw)
|
return DefinitionData{
|
||||||
|
definition: schedulerProfile,
|
||||||
|
schemaDefinition: schedulerProfileSchemaRaw,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//go:embed scheduler-profile.yaml
|
//go:embed scheduler-profile.yaml
|
||||||
var schedulerProfile []byte
|
var schedulerProfile []byte
|
||||||
|
|
|
@ -24,14 +24,6 @@ import (
|
||||||
_ "embed"
|
_ "embed"
|
||||||
|
|
||||||
apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
||||||
|
|
||||||
"github.com/arangodb/go-driver"
|
|
||||||
|
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
StorageLocalStorageVersion = driver.Version("1.0.1")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Deprecated: use StorageLocalStorageWithOptions instead
|
// Deprecated: use StorageLocalStorageWithOptions instead
|
||||||
|
@ -40,7 +32,7 @@ func StorageLocalStorage() *apiextensions.CustomResourceDefinition {
|
||||||
}
|
}
|
||||||
|
|
||||||
func StorageLocalStorageWithOptions(opts ...func(*CRDOptions)) *apiextensions.CustomResourceDefinition {
|
func StorageLocalStorageWithOptions(opts ...func(*CRDOptions)) *apiextensions.CustomResourceDefinition {
|
||||||
return getCRD(storageLocalStorageCRD, storageLocalStorageCRDSchemas, opts...)
|
return getCRD(StorageLocalStorageDefinitionData(), opts...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: use StorageLocalStorageDefinitionWithOptions instead
|
// Deprecated: use StorageLocalStorageDefinitionWithOptions instead
|
||||||
|
@ -50,13 +42,17 @@ func StorageLocalStorageDefinition() Definition {
|
||||||
|
|
||||||
func StorageLocalStorageDefinitionWithOptions(opts ...func(*CRDOptions)) Definition {
|
func StorageLocalStorageDefinitionWithOptions(opts ...func(*CRDOptions)) Definition {
|
||||||
return Definition{
|
return Definition{
|
||||||
Version: StorageLocalStorageVersion,
|
DefinitionData: StorageLocalStorageDefinitionData(),
|
||||||
CRD: StorageLocalStorageWithOptions(opts...),
|
CRD: StorageLocalStorageWithOptions(opts...),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var storageLocalStorageCRD = util.NewYamlLoader[apiextensions.CustomResourceDefinition](storageLocalStorage)
|
func StorageLocalStorageDefinitionData() DefinitionData {
|
||||||
var storageLocalStorageCRDSchemas = util.NewYamlLoader[crdSchemas](storageLocalStorageSchemaRaw)
|
return DefinitionData{
|
||||||
|
definition: storageLocalStorage,
|
||||||
|
schemaDefinition: storageLocalStorageSchemaRaw,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//go:embed storage-localstorage.yaml
|
//go:embed storage-localstorage.yaml
|
||||||
var storageLocalStorage []byte
|
var storageLocalStorage []byte
|
||||||
|
|
|
@ -27,7 +27,10 @@ import (
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util/errors"
|
"github.com/arangodb/kube-arangodb/pkg/util/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
const Version = "arangodb.com/version"
|
const (
|
||||||
|
Version = "arangodb.com/version"
|
||||||
|
Schema = "arangodb.com/schema"
|
||||||
|
)
|
||||||
|
|
||||||
type crdDefinitionGetter func(opts *crds.CRDOptions) crds.Definition
|
type crdDefinitionGetter func(opts *crds.CRDOptions) crds.Definition
|
||||||
|
|
||||||
|
|
|
@ -1,57 +0,0 @@
|
||||||
//
|
|
||||||
// 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 (
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/arangodb/go-driver"
|
|
||||||
)
|
|
||||||
|
|
||||||
func isVersionValid(a driver.Version) bool {
|
|
||||||
q := strings.SplitN(string(a), ".", 3)
|
|
||||||
|
|
||||||
if len(q) < 2 {
|
|
||||||
// We do not have 2 parts
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err := strconv.Atoi(q[0])
|
|
||||||
if err != nil {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = strconv.Atoi(q[1])
|
|
||||||
return err == nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func isUpdateRequired(a, b driver.Version) bool {
|
|
||||||
if a == b {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
if !isVersionValid(b) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
return a.CompareTo(b) > 0
|
|
||||||
}
|
|
|
@ -1,73 +0,0 @@
|
||||||
//
|
|
||||||
// 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 (
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
|
|
||||||
"github.com/arangodb/go-driver"
|
|
||||||
)
|
|
||||||
|
|
||||||
func Test_Versions(t *testing.T) {
|
|
||||||
type c struct {
|
|
||||||
update bool
|
|
||||||
a, b driver.Version
|
|
||||||
}
|
|
||||||
|
|
||||||
cases := map[string]c{
|
|
||||||
"Empty": {
|
|
||||||
update: false,
|
|
||||||
},
|
|
||||||
"Local to empty": {
|
|
||||||
update: true,
|
|
||||||
a: "1.0.0",
|
|
||||||
b: "",
|
|
||||||
},
|
|
||||||
"Local to nonparsable": {
|
|
||||||
update: true,
|
|
||||||
a: "1.0.0",
|
|
||||||
b: "ffdfdasfdasdfsa",
|
|
||||||
},
|
|
||||||
"Same": {
|
|
||||||
update: false,
|
|
||||||
a: "1.0.0",
|
|
||||||
b: "1.0.0",
|
|
||||||
},
|
|
||||||
"Below": {
|
|
||||||
update: true,
|
|
||||||
a: "1.1.0",
|
|
||||||
b: "1.0.0",
|
|
||||||
},
|
|
||||||
"Above": {
|
|
||||||
update: false,
|
|
||||||
a: "1.0.0",
|
|
||||||
b: "1.1.0",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for name, c := range cases {
|
|
||||||
t.Run(name, func(t *testing.T) {
|
|
||||||
require.Equal(t, c.update, isUpdateRequired(c.a, c.b))
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// DISCLAIMER
|
// DISCLAIMER
|
||||||
//
|
//
|
||||||
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
|
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
|
@ -49,7 +49,7 @@ func (l *logScanner) GetData(t *testing.T, timeout time.Duration, obj interface{
|
||||||
if s, ok := l.Get(timeout); !ok {
|
if s, ok := l.Get(timeout); !ok {
|
||||||
return false
|
return false
|
||||||
} else {
|
} else {
|
||||||
require.NoError(t, json.Unmarshal([]byte(s), obj))
|
require.NoError(t, json.Unmarshal([]byte(s), obj), s)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue