Skip to content

Commit b6468b6

Browse files
committed
[Feature] [Platform] Storage V1Alpha1
1 parent d69678b commit b6468b6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+2382
-13
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- (Bugfix) Fix Gateway Options
1313
- (Feature) StorageV2 Integration Service Definition
1414
- (Feature) AWS Client
15+
- (Feature) (Platform) Storage V1Alpha1
1516

1617
## [1.2.43](https://github.com/arangodb/kube-arangodb/tree/1.2.43) (2024-10-14)
1718
- (Feature) ArangoRoute CRD

chart/kube-arangodb/templates/deployment-operator/role.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ rules:
3838
- apiGroups: ["coordination.k8s.io"]
3939
resources: ["leases"]
4040
verbs: ["*"]
41+
- apiGroups: ["platform.arangodb.com"]
42+
resources: ["arangoplatformstorages", "arangoplatformstorages/status"]
43+
verbs: ["get", "list", "watch"]
4144
- apiGroups: ["backup.arangodb.com"]
4245
resources: ["arangobackuppolicies", "arangobackups"]
4346
verbs: ["get", "list", "watch"]

internal/cr_validation_test.go

+10
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import (
4141
mlApiv1alpha1 "github.com/arangodb/kube-arangodb/pkg/apis/ml/v1alpha1"
4242
mlApi "github.com/arangodb/kube-arangodb/pkg/apis/ml/v1beta1"
4343
networkingApi "github.com/arangodb/kube-arangodb/pkg/apis/networking/v1alpha1"
44+
platformApi "github.com/arangodb/kube-arangodb/pkg/apis/platform/v1alpha1"
4445
replicationv1 "github.com/arangodb/kube-arangodb/pkg/apis/replication/v1"
4546
replicationv2alpha1 "github.com/arangodb/kube-arangodb/pkg/apis/replication/v2alpha1"
4647
schedulerApiv1alpha1 "github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1alpha1"
@@ -329,6 +330,15 @@ func Test_GenerateCRValidationSchemas(t *testing.T) {
329330
},
330331
},
331332
},
333+
"platform-storage": {
334+
fmt.Sprintf("%s/pkg/apis/platform/v1alpha1", root): {
335+
"v1alpha1": {
336+
objects: map[string]interface{}{
337+
"spec": platformApi.ArangoPlatformStorage{}.Spec,
338+
},
339+
},
340+
},
341+
},
332342
}
333343

334344
for filePrefix, packagesToVersion := range input {

internal/docs_test.go

+13
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import (
4545
mlApiv1alpha1 "github.com/arangodb/kube-arangodb/pkg/apis/ml/v1alpha1"
4646
mlApi "github.com/arangodb/kube-arangodb/pkg/apis/ml/v1beta1"
4747
networkingApi "github.com/arangodb/kube-arangodb/pkg/apis/networking/v1alpha1"
48+
platformApi "github.com/arangodb/kube-arangodb/pkg/apis/platform/v1alpha1"
4849
replicationApi "github.com/arangodb/kube-arangodb/pkg/apis/replication/v1"
4950
schedulerApiv1alpha1 "github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1alpha1"
5051
schedulerApi "github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1beta1"
@@ -347,6 +348,18 @@ func Test_GenerateAPIDocs(t *testing.T) {
347348
},
348349
},
349350
},
351+
"platform": map[string]inputPackage{
352+
"v1alpha1": {
353+
Types: inputPackageTypes{
354+
"ArangoPlatformStorage.V1Alpha1": {
355+
"Spec": platformApi.ArangoPlatformStorage{}.Spec,
356+
},
357+
},
358+
Shared: []string{
359+
"shared/v1",
360+
},
361+
},
362+
},
350363
}
351364

352365
for name, versions := range input {

pkg/apis/platform/definitions.go

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2024 ArangoDB GmbH, Cologne, Germany
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
//
20+
21+
package platform
22+
23+
const (
24+
ArangoPlatformStorageCRDName = ArangoPlatformStorageResourcePlural + "." + ArangoPlatformGroupName
25+
ArangoPlatformStorageResourceKind = "ArangoPlatformStorage"
26+
ArangoPlatformStorageResourcePlural = "arangoplatformstorages"
27+
28+
ArangoPlatformGroupName = "platform.arangodb.com"
29+
)
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2024 ArangoDB GmbH, Cologne, Germany
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
//
20+
21+
package v1alpha1
22+
23+
import api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
24+
25+
const (
26+
SpecValidCondition api.ConditionType = "SpecValid"
27+
ReadyCondition api.ConditionType = "Ready"
28+
)

pkg/apis/platform/v1alpha1/doc.go

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2024 ArangoDB GmbH, Cologne, Germany
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
//
20+
21+
// +k8s:deepcopy-gen=package
22+
// +groupName=platform.arangodb.com
23+
package v1alpha1
+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2023-2024 ArangoDB GmbH, Cologne, Germany
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
//
20+
21+
package v1alpha1
22+
23+
import (
24+
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
25+
"k8s.io/apimachinery/pkg/runtime"
26+
"k8s.io/apimachinery/pkg/runtime/schema"
27+
28+
"github.com/arangodb/kube-arangodb/pkg/apis/networking"
29+
)
30+
31+
const (
32+
ArangoPlatformVersion = "v1alpha1"
33+
)
34+
35+
var (
36+
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
37+
AddToScheme = SchemeBuilder.AddToScheme
38+
39+
SchemeGroupVersion = schema.GroupVersion{Group: networking.ArangoNetworkingGroupName, Version: ArangoPlatformVersion}
40+
)
41+
42+
// Resource gets an ArangoCluster GroupResource for a specified resource
43+
func Resource(resource string) schema.GroupResource {
44+
return SchemeGroupVersion.WithResource(resource).GroupResource()
45+
}
46+
47+
// addKnownTypes adds the set of types defined in this package to the supplied scheme.
48+
func addKnownTypes(s *runtime.Scheme) error {
49+
s.AddKnownTypes(SchemeGroupVersion,
50+
&ArangoPlatformStorage{},
51+
&ArangoPlatformStorageList{},
52+
)
53+
meta.AddToGroupVersion(s, SchemeGroupVersion)
54+
return nil
55+
}

pkg/apis/platform/v1alpha1/storage.go

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2024 ArangoDB GmbH, Cologne, Germany
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
//
20+
21+
package v1alpha1
22+
23+
import (
24+
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
25+
26+
"github.com/arangodb/kube-arangodb/pkg/apis/networking"
27+
)
28+
29+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
30+
31+
// ArangoPlatformStorageList is a list of ArangoPlatform Storage.
32+
type ArangoPlatformStorageList struct {
33+
meta.TypeMeta `json:",inline"`
34+
meta.ListMeta `json:"metadata,omitempty"`
35+
36+
Items []ArangoPlatformStorage `json:"items"`
37+
}
38+
39+
// +genclient
40+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
41+
42+
// ArangoPlatformStorage contains definition and status of the ArangoPlatform Storage.
43+
type ArangoPlatformStorage struct {
44+
meta.TypeMeta `json:",inline"`
45+
meta.ObjectMeta `json:"metadata,omitempty"`
46+
47+
Spec ArangoPlatformStorageSpec `json:"spec"`
48+
Status ArangoPlatformStorageStatus `json:"status"`
49+
}
50+
51+
// AsOwner creates an OwnerReference for the given Extension
52+
func (a *ArangoPlatformStorage) AsOwner() meta.OwnerReference {
53+
trueVar := true
54+
return meta.OwnerReference{
55+
APIVersion: SchemeGroupVersion.String(),
56+
Kind: networking.ArangoRouteResourceKind,
57+
Name: a.Name,
58+
UID: a.UID,
59+
Controller: &trueVar,
60+
}
61+
}
62+
63+
func (a *ArangoPlatformStorage) GetStatus() ArangoPlatformStorageStatus {
64+
return a.Status
65+
}
66+
67+
func (a *ArangoPlatformStorage) SetStatus(status ArangoPlatformStorageStatus) {
68+
a.Status = status
69+
}
+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2024 ArangoDB GmbH, Cologne, Germany
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
//
20+
21+
package v1alpha1
22+
23+
import (
24+
shared "github.com/arangodb/kube-arangodb/pkg/apis/shared"
25+
)
26+
27+
type ArangoPlatformStorageSpec struct {
28+
// Deployment specifies the ArangoDeployment object name
29+
Deployment *string `json:"deployment,omitempty"`
30+
31+
// Backend defines how storage is implemented
32+
Backend *ArangoPlatformStorageSpecBackend `json:"backend,omitempty"`
33+
}
34+
35+
func (s *ArangoPlatformStorageSpec) GetDeployment() string {
36+
if s == nil || s.Deployment == nil {
37+
return ""
38+
}
39+
40+
return *s.Deployment
41+
}
42+
43+
func (s *ArangoPlatformStorageSpec) GetBackend() *ArangoPlatformStorageSpecBackend {
44+
if s == nil || s.Backend == nil {
45+
return nil
46+
}
47+
return s.Backend
48+
}
49+
50+
func (s *ArangoPlatformStorageSpec) Validate() error {
51+
if s == nil {
52+
s = &ArangoPlatformStorageSpec{}
53+
}
54+
55+
if err := shared.WithErrors(shared.PrefixResourceErrors("spec",
56+
shared.PrefixResourceError("backend", s.Backend.Validate()),
57+
)); err != nil {
58+
return err
59+
}
60+
61+
return nil
62+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2024 ArangoDB GmbH, Cologne, Germany
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
//
20+
21+
package v1alpha1
22+
23+
import (
24+
shared "github.com/arangodb/kube-arangodb/pkg/apis/shared"
25+
"github.com/arangodb/kube-arangodb/pkg/util/errors"
26+
)
27+
28+
type ArangoPlatformStorageSpecBackend struct {
29+
// S3 backend implements storage as a proxy to the provided S3 API endpoint
30+
S3 *ArangoPlatformStorageSpecBackendS3 `json:"s3,omitempty"`
31+
}
32+
33+
func (s *ArangoPlatformStorageSpecBackend) GetS3() *ArangoPlatformStorageSpecBackendS3 {
34+
if s == nil || s.S3 == nil {
35+
return nil
36+
}
37+
return s.S3
38+
}
39+
40+
func (s *ArangoPlatformStorageSpecBackend) Validate() error {
41+
if s == nil {
42+
return errors.Errorf("Backend is not specified")
43+
}
44+
45+
if s.S3 == nil {
46+
return errors.Errorf("At least one backend needs to be defined")
47+
}
48+
49+
return shared.WithErrors(shared.PrefixResourceError("s3", s.S3.Validate()))
50+
}

0 commit comments

Comments
 (0)