Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix resource editor api implementation #281

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ require (
kmodules.xyz/custom-resources v0.29.0
kmodules.xyz/go-containerregistry v0.0.12
kmodules.xyz/monitoring-agent-api v0.29.0
kmodules.xyz/resource-metadata v0.18.2-0.20240118143554-f415526b8139
kmodules.xyz/resource-metadata v0.18.2-0.20240118152448-267a08d36cf0
kmodules.xyz/resource-metrics v0.29.0
kmodules.xyz/sets v0.29.0
kubeops.dev/scanner v0.0.16
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -3456,8 +3456,8 @@ kmodules.xyz/monitoring-agent-api v0.29.0 h1:gpFl6OZrlMLb/ySMHdREI9EwGtnJ91oZBn9
kmodules.xyz/monitoring-agent-api v0.29.0/go.mod h1:iNbvaMTgVFOI5q2LJtGK91j4Dmjv4ZRiRdasGmWLKQI=
kmodules.xyz/offshoot-api v0.29.0 h1:GHLhxxT9jU1N8+FvOCCeJNyU5g0duYS46UGrs6AHNLY=
kmodules.xyz/offshoot-api v0.29.0/go.mod h1:5NxhBblXoDHWStx9HCDJR2KFTwYjEZ7i1Id3jelIunw=
kmodules.xyz/resource-metadata v0.18.2-0.20240118143554-f415526b8139 h1:5aMsW8E+Cgvp5jgec/a7j8pQ2zfD00TyiZTuLu+Vw+0=
kmodules.xyz/resource-metadata v0.18.2-0.20240118143554-f415526b8139/go.mod h1:I9HeSgkshwzwUy0IDhp4yIfRFbFQJ21syeSf4NsB04o=
kmodules.xyz/resource-metadata v0.18.2-0.20240118152448-267a08d36cf0 h1:AH4FZ4XybovFyuPi0GuOMibM/ID2DVumdmxqic3SpHs=
kmodules.xyz/resource-metadata v0.18.2-0.20240118152448-267a08d36cf0/go.mod h1:I9HeSgkshwzwUy0IDhp4yIfRFbFQJ21syeSf4NsB04o=
kmodules.xyz/resource-metrics v0.29.0 h1:YBSVCbGdAugUqZK4igHu3fPhxvpYar4xejE6njryNM4=
kmodules.xyz/resource-metrics v0.29.0/go.mod h1:OuG/QobZ7o8GFHl/u3lqaUR0fDZDegxtV8Vdh+MNBD4=
kmodules.xyz/sets v0.29.0 h1:ZX/qOECzUob95JhhRtngJElHSlJ1UNNdwK4hTEy+nl0=
Expand Down
10 changes: 8 additions & 2 deletions pkg/registry/meta/resourceeditor/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ func (r *Storage) Get(ctx context.Context, name string, options *metav1.GetOptio
if err != nil {
return nil, kerr.NewNotFound(schema.GroupResource{Group: meta.GroupName, Resource: uiapi.ResourceKindResourceEditor}, name)
}
return complete(obj.DeepCopy()), err
return complete(&rsapi.ResourceEditor{
ObjectMeta: obj.ObjectMeta,
Spec: *obj.Spec.DeepCopy(),
}), err
}

// Lister
Expand Down Expand Up @@ -116,7 +119,10 @@ func (r *Storage) List(ctx context.Context, options *metainternalversion.ListOpt
if options.LabelSelector != nil && !options.LabelSelector.Matches(labels.Set(obj.GetLabels())) {
continue
}
items = append(items, *complete(obj.DeepCopy()))
items = append(items, *complete(&rsapi.ResourceEditor{
ObjectMeta: obj.ObjectMeta,
Spec: *obj.Spec.DeepCopy(),
}))
}

return &rsapi.ResourceEditorList{Items: items}, nil
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,34 @@ limitations under the License.

package v1alpha1

import uiapi "kmodules.xyz/resource-metadata/apis/ui/v1alpha1"
import (
uiapi "kmodules.xyz/resource-metadata/apis/ui/v1alpha1"

type (
ResourceEditor = uiapi.ResourceEditor
ResourceEditorList = uiapi.ResourceEditorList
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// +genclient
// +genclient:nonNamespaced
// +k8s:openapi-gen=true
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// +kubebuilder:object:root=true
// +kubebuilder:resource:path=resourceeditors,singular=resourceeditor,scope=Cluster
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.phase"
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
type ResourceEditor struct {
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec uiapi.ResourceEditorSpec `json:"spec,omitempty"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:object:root=true

type ResourceEditorList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []ResourceEditor `json:"items,omitempty"`
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading