Skip to content

Commit 44112f0

Browse files
committed
Fix cluster profile api
Signed-off-by: Tamal Saha <tamal@appscode.com>
1 parent 77c0815 commit 44112f0

File tree

12 files changed

+392
-12
lines changed

12 files changed

+392
-12
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ require (
5050
kmodules.xyz/go-containerregistry v0.0.12
5151
kmodules.xyz/monitoring-agent-api v0.30.2-0.20241001043315-b98120efea48
5252
kmodules.xyz/offshoot-api v0.30.1
53-
kmodules.xyz/resource-metadata v0.19.1-0.20241016073336-1307639922b4
53+
kmodules.xyz/resource-metadata v0.19.1-0.20241016154015-205ef283ba59
5454
kmodules.xyz/resource-metrics v0.30.4
5555
kmodules.xyz/resource-metrics/utils v0.30.4
5656
kmodules.xyz/sets v0.29.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -934,8 +934,8 @@ kmodules.xyz/monitoring-agent-api v0.30.2-0.20241001043315-b98120efea48 h1:kJdO7
934934
kmodules.xyz/monitoring-agent-api v0.30.2-0.20241001043315-b98120efea48/go.mod h1:oR3tk5O4koYar4cD9N3AjbBFr9XTwBU3sw9qD2NdNQc=
935935
kmodules.xyz/offshoot-api v0.30.1 h1:TrulAYO+oBsXe9sZZGTmNWIuI8qD2izMpgcTSPvgAmI=
936936
kmodules.xyz/offshoot-api v0.30.1/go.mod h1:T3mpjR6fui0QzOcmQvIuANytW48fe9ytmy/1cgx6D4g=
937-
kmodules.xyz/resource-metadata v0.19.1-0.20241016073336-1307639922b4 h1:k8JQX4XDUU/ULvscjx5ENBb4qNJdWFMcf2V79c+LIcI=
938-
kmodules.xyz/resource-metadata v0.19.1-0.20241016073336-1307639922b4/go.mod h1:ZVjgAj622Fp+8bdmAgHv6PNQHkXXqhR6aQpJg3lO8Bo=
937+
kmodules.xyz/resource-metadata v0.19.1-0.20241016154015-205ef283ba59 h1:0gErwOLp26ErRgl1K91e0MD+k+NRfp4gCTEDArQyTEM=
938+
kmodules.xyz/resource-metadata v0.19.1-0.20241016154015-205ef283ba59/go.mod h1:ZVjgAj622Fp+8bdmAgHv6PNQHkXXqhR6aQpJg3lO8Bo=
939939
kmodules.xyz/resource-metrics v0.30.4 h1:8HBPtYmo9ETY91gsc55JE8Z986+3ZuRq57M0wZ9npqI=
940940
kmodules.xyz/resource-metrics v0.30.4/go.mod h1:w9+rz7/s/kGP1GWzYSuRdCn+l7EwpesmESSEHkLBnIQ=
941941
kmodules.xyz/resource-metrics/utils v0.30.4 h1:bJS/x0Qr7N1FFdxugFbzZ/Es6HVs4ptsFlhkmgj3jac=

pkg/registry/meta/clusterprofile/storage.go

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
"k8s.io/apimachinery/pkg/runtime/schema"
3131
"k8s.io/apiserver/pkg/registry/rest"
3232
"kmodules.xyz/resource-metadata/apis/meta"
33+
rsapi "kmodules.xyz/resource-metadata/apis/meta/v1alpha1"
3334
uiapi "kmodules.xyz/resource-metadata/apis/ui/v1alpha1"
3435
"kmodules.xyz/resource-metadata/hub/clusterprofiles"
3536
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -53,14 +54,14 @@ func NewStorage(kc client.Reader) *Storage {
5354
return &Storage{
5455
kc: kc,
5556
convertor: rest.NewDefaultTableConvertor(schema.GroupResource{
56-
Group: uiapi.SchemeGroupVersion.Group,
57+
Group: rsapi.SchemeGroupVersion.Group,
5758
Resource: uiapi.ResourceClusterProfiles,
5859
}),
5960
}
6061
}
6162

6263
func (r *Storage) GroupVersionKind(_ schema.GroupVersion) schema.GroupVersionKind {
63-
return uiapi.SchemeGroupVersion.WithKind(uiapi.ResourceKindClusterProfile)
64+
return rsapi.SchemeGroupVersion.WithKind(uiapi.ResourceKindClusterProfile)
6465
}
6566

6667
func (r *Storage) NamespaceScoped() bool {
@@ -73,7 +74,7 @@ func (r *Storage) GetSingularName() string {
7374

7475
// Getter
7576
func (r *Storage) New() runtime.Object {
76-
return &uiapi.ClusterProfile{}
77+
return &rsapi.ClusterProfile{}
7778
}
7879

7980
func (r *Storage) Destroy() {}
@@ -83,12 +84,15 @@ func (r *Storage) Get(ctx context.Context, name string, options *metav1.GetOptio
8384
if err != nil {
8485
return nil, kerr.NewNotFound(schema.GroupResource{Group: meta.GroupName, Resource: uiapi.ResourceKindClusterProfile}, name)
8586
}
86-
return obj, err
87+
return &rsapi.ClusterProfile{
88+
ObjectMeta: obj.ObjectMeta,
89+
Spec: obj.Spec,
90+
}, err
8791
}
8892

8993
// Lister
9094
func (r *Storage) NewList() runtime.Object {
91-
return &uiapi.ClusterProfileList{}
95+
return &rsapi.ClusterProfileList{}
9296
}
9397

9498
func (r *Storage) List(ctx context.Context, options *metainternalversion.ListOptions) (runtime.Object, error) {
@@ -114,15 +118,18 @@ func (r *Storage) List(ctx context.Context, options *metainternalversion.ListOpt
114118
objs = objs[:options.Limit]
115119
}
116120

117-
items := make([]uiapi.ClusterProfile, 0, len(objs))
121+
items := make([]rsapi.ClusterProfile, 0, len(objs))
118122
for _, obj := range objs {
119123
if options.LabelSelector != nil && !options.LabelSelector.Matches(labels.Set(obj.GetLabels())) {
120124
continue
121125
}
122-
items = append(items, obj)
126+
items = append(items, rsapi.ClusterProfile{
127+
ObjectMeta: obj.ObjectMeta,
128+
Spec: obj.Spec,
129+
})
123130
}
124131

125-
return &uiapi.ClusterProfileList{Items: items}, nil
132+
return &rsapi.ClusterProfileList{Items: items}, nil
126133
}
127134

128135
func (r *Storage) ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) {
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
Copyright AppsCode Inc. and Contributors
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+
uiapi "kmodules.xyz/resource-metadata/apis/ui/v1alpha1"
21+
22+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
23+
)
24+
25+
// +genclient
26+
// +genclient:nonNamespaced
27+
// +genclient:skipVerbs=updateStatus
28+
// +k8s:openapi-gen=true
29+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
30+
// +kubebuilder:object:root=true
31+
// +kubebuilder:subresource:status
32+
// +kubebuilder:resource:scope=Cluster
33+
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.phase"
34+
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
35+
type ClusterProfile struct {
36+
metav1.TypeMeta `json:",inline"`
37+
// +optional
38+
metav1.ObjectMeta `json:"metadata,omitempty"`
39+
Spec uiapi.ClusterProfileSpec `json:"spec,omitempty"`
40+
}
41+
42+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
43+
// +kubebuilder:object:root=true
44+
45+
type ClusterProfileList struct {
46+
metav1.TypeMeta `json:",inline"`
47+
metav1.ListMeta `json:"metadata,omitempty"`
48+
Items []ClusterProfile `json:"items,omitempty"`
49+
}

vendor/kmodules.xyz/resource-metadata/apis/meta/v1alpha1/openapi_generated.go

Lines changed: 89 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/kmodules.xyz/resource-metadata/apis/meta/v1alpha1/register.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ func Resource(resource string) schema.GroupResource {
5050
func addKnownTypes(scheme *runtime.Scheme) error {
5151
scheme.AddKnownTypes(SchemeGroupVersion,
5252
&ChartPresetQuery{},
53+
&ClusterProfile{},
54+
&ClusterProfileList{},
5355
&ClusterStatus{},
5456
&ResourceCalculator{},
5557
&ResourceDescriptor{},

vendor/kmodules.xyz/resource-metadata/apis/meta/v1alpha1/zz_generated.deepcopy.go

Lines changed: 60 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
2+
---
3+
apiVersion: apiextensions.k8s.io/v1
4+
kind: CustomResourceDefinition
5+
metadata:
6+
creationTimestamp: null
7+
name: clusterprofiles.meta.k8s.appscode.com
8+
spec:
9+
group: meta.k8s.appscode.com
10+
names:
11+
kind: ClusterProfile
12+
listKind: ClusterProfileList
13+
plural: clusterprofiles
14+
singular: clusterprofile
15+
scope: Cluster
16+
versions:
17+
- additionalPrinterColumns:
18+
- jsonPath: .status.phase
19+
name: Status
20+
type: string
21+
- jsonPath: .metadata.creationTimestamp
22+
name: Age
23+
type: date
24+
name: v1alpha1
25+
schema:
26+
openAPIV3Schema:
27+
properties:
28+
apiVersion:
29+
description: 'APIVersion defines the versioned schema of this representation
30+
of an object. Servers should convert recognized schemas to the latest
31+
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
32+
type: string
33+
kind:
34+
description: 'Kind is a string value representing the REST resource this
35+
object represents. Servers may infer this from the endpoint the client
36+
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
37+
type: string
38+
metadata:
39+
type: object
40+
spec:
41+
description: ClusterProfileSpec defines the desired state of ClusterProfile
42+
properties:
43+
description:
44+
type: string
45+
provider:
46+
type: string
47+
requiredFeatureSets:
48+
additionalProperties:
49+
items:
50+
type: string
51+
type: array
52+
type: object
53+
title:
54+
type: string
55+
required:
56+
- description
57+
- title
58+
type: object
59+
type: object
60+
served: true
61+
storage: true
62+
subresources:
63+
status: {}

0 commit comments

Comments
 (0)