Skip to content

Commit cd3124d

Browse files
committed
Add catalog api
Signed-off-by: Mangirdas Judeikis <mangirdas@judeikis.lt> On-behalf-of: @SAP mangirdas.judeikis@sap.com
1 parent 10c28b8 commit cd3124d

5 files changed

Lines changed: 523 additions & 0 deletions

File tree

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/*
2+
Copyright 2025 The Kube Bind Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
22+
conditionsapi "github.com/kube-bind/kube-bind/sdk/apis/third_party/conditions/apis/conditions/v1alpha1"
23+
)
24+
25+
// Collection groups multiple Modules into a logical group. This functions as a folder in the UI.
26+
//
27+
// +crd
28+
// +genclient
29+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
30+
// +kubebuilder:resource:scope=Namespaced,categories=kube-bindings
31+
// +kubebuilder:subresource:status
32+
// +kubebuilder:printcolumn:name="Description",type="string",JSONPath=`.spec.description`
33+
// +kubebuilder:printcolumn:name="Modules",type="integer",JSONPath=`.spec.modules[*]`
34+
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=`.metadata.creationTimestamp`,priority=0
35+
type Collection struct {
36+
metav1.TypeMeta `json:",inline"`
37+
metav1.ObjectMeta `json:"metadata,omitempty"`
38+
39+
// spec specifies the collection.
40+
// +required
41+
// +kubebuilder:validation:Required
42+
Spec CollectionSpec `json:"spec"`
43+
44+
// status contains reconciliation information for the collection.
45+
Status CollectionStatus `json:"status,omitempty"`
46+
}
47+
48+
func (in *Collection) GetConditions() conditionsapi.Conditions {
49+
return in.Status.Conditions
50+
}
51+
52+
func (in *Collection) SetConditions(conditions conditionsapi.Conditions) {
53+
in.Status.Conditions = conditions
54+
}
55+
56+
// CollectionSpec defines the desired state of Collection.
57+
type CollectionSpec struct {
58+
// description is a human readable description of this collection.
59+
//
60+
// +optional
61+
Description string `json:"description,omitempty"`
62+
63+
// modules is a list of module references that are part of this collection.
64+
//
65+
// +required
66+
// +kubebuilder:validation:Required
67+
// +kubebuilder:validation:MinItems=1
68+
Modules []ModuleReference `json:"modules"`
69+
}
70+
71+
// ModuleReference references a Module by name.
72+
type ModuleReference struct {
73+
// name is the name of the module.
74+
//
75+
// +required
76+
// +kubebuilder:validation:Required
77+
Name string `json:"name"`
78+
}
79+
80+
// CollectionStatus stores status information about a Collection.
81+
type CollectionStatus struct {
82+
// conditions is a list of conditions that apply to the Collection.
83+
Conditions conditionsapi.Conditions `json:"conditions,omitempty"`
84+
}
85+
86+
// CollectionList is the list of Collection.
87+
//
88+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
89+
type CollectionList struct {
90+
metav1.TypeMeta `json:",inline"`
91+
metav1.ListMeta `json:"metadata"`
92+
93+
Items []Collection `json:"items"`
94+
}

sdk/apis/catalog/v1alpha1/doc.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
Copyright 2025 The Kube Bind Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// +k8s:deepcopy-gen=package
18+
// +k8s:protobuf-gen=package
19+
// +k8s:openapi-gen=true
20+
// +groupName=catalog.kube-bind.io
21+
22+
// Package v1alpha1 contains API Schema definitions for the catalog v1alpha1 API group
23+
package v1alpha1
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*
2+
Copyright 2025 The Kube Bind Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
22+
kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2"
23+
conditionsapi "github.com/kube-bind/kube-bind/sdk/apis/third_party/conditions/apis/conditions/v1alpha1"
24+
)
25+
26+
// Module groups multiple CRDs with related resources (permissionClaims) as a Service definition.
27+
//
28+
// +crd
29+
// +genclient
30+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
31+
// +kubebuilder:resource:scope=Namespaced,categories=kube-bindings
32+
// +kubebuilder:subresource:status
33+
// +kubebuilder:printcolumn:name="Resources",type="integer",JSONPath=`.spec.resources[*]`
34+
// +kubebuilder:printcolumn:name="Permission Claims",type="integer",JSONPath=`.spec.permissionClaims[*]`
35+
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=`.metadata.creationTimestamp`,priority=0
36+
type Module struct {
37+
metav1.TypeMeta `json:",inline"`
38+
metav1.ObjectMeta `json:"metadata,omitempty"`
39+
40+
// spec specifies the module.
41+
// +required
42+
// +kubebuilder:validation:Required
43+
Spec ModuleSpec `json:"spec"`
44+
45+
// status contains reconciliation information for the module.
46+
Status ModuleStatus `json:"status,omitempty"`
47+
}
48+
49+
func (in *Module) GetConditions() conditionsapi.Conditions {
50+
return in.Status.Conditions
51+
}
52+
53+
func (in *Module) SetConditions(conditions conditionsapi.Conditions) {
54+
in.Status.Conditions = conditions
55+
}
56+
57+
// ModuleSpec defines the desired state of Module.
58+
type ModuleSpec struct {
59+
// resources defines the CRDs that are part of this module.
60+
//
61+
// +required
62+
// +kubebuilder:validation:Required
63+
// +kubebuilder:validation:MinItems=1
64+
Resources []kubebindv1alpha2.APIServiceExportResource `json:"resources"`
65+
66+
// permissionClaims defines the permission claims required by this module.
67+
//
68+
// +optional
69+
PermissionClaims []kubebindv1alpha2.PermissionClaim `json:"permissionClaims,omitempty"`
70+
}
71+
72+
// ModuleStatus stores status information about a Module.
73+
type ModuleStatus struct {
74+
// conditions is a list of conditions that apply to the Module.
75+
Conditions conditionsapi.Conditions `json:"conditions,omitempty"`
76+
}
77+
78+
// ModuleList is the list of Module.
79+
//
80+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
81+
type ModuleList struct {
82+
metav1.TypeMeta `json:",inline"`
83+
metav1.ListMeta `json:"metadata"`
84+
85+
Items []Module `json:"items"`
86+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
Copyright 2025 The Kube Bind Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
"k8s.io/apimachinery/pkg/runtime"
22+
"k8s.io/apimachinery/pkg/runtime/schema"
23+
)
24+
25+
var (
26+
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
27+
AddToScheme = SchemeBuilder.AddToScheme
28+
)
29+
30+
const (
31+
// GroupName is the group name used in this package.
32+
GroupName = "catalog.kube-bind.io"
33+
34+
// GroupVersion is the group version used in this package.
35+
GroupVersion = "v1alpha1"
36+
)
37+
38+
// SchemeGroupVersion is group version used to register these objects.
39+
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: GroupVersion}
40+
41+
// Resource takes an unqualified resource and returns a Group qualified GroupResource.
42+
func Resource(resource string) schema.GroupResource {
43+
return SchemeGroupVersion.WithResource(resource).GroupResource()
44+
}
45+
46+
// Adds the list of known types to api.Scheme.
47+
func addKnownTypes(scheme *runtime.Scheme) error {
48+
scheme.AddKnownTypes(SchemeGroupVersion,
49+
&Module{},
50+
&ModuleList{},
51+
&Collection{},
52+
&CollectionList{},
53+
)
54+
55+
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
56+
return nil
57+
}

0 commit comments

Comments
 (0)