Merge pull request #462 from vincent-pli/extend-cluster-status

Extend cluster.status.APIEnablements.Resources to struct with Kind
This commit is contained in:
karmada-bot 2021-06-24 15:15:08 +08:00 committed by GitHub
commit c053b6c8b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 52 additions and 8 deletions

View File

@ -149,9 +149,22 @@ spec:
is for.
type: string
resources:
description: Resources contains the name of the resources.
description: Resources is a list of APIResource.
items:
type: string
description: APIResource specifies the name and kind names
for the resource.
properties:
kind:
description: Kind is the kind for the resource (e.g. 'Deployment'
is the kind for resource 'deployments')
type: string
name:
description: Name is the plural name of the resource.
type: string
required:
- kind
- name
type: object
type: array
required:
- groupVersion

View File

@ -138,9 +138,19 @@ type ClusterStatus struct {
type APIEnablement struct {
// GroupVersion is the group and version this APIEnablement is for.
GroupVersion string `json:"groupVersion"`
// Resources contains the name of the resources.
// Resources is a list of APIResource.
// +optional
Resources []string `json:"resources,omitempty"`
Resources []APIResource `json:"resources,omitempty"`
}
// APIResource specifies the name and kind names for the resource.
type APIResource struct {
// Name is the plural name of the resource.
// +required
Name string `json:"name"`
// Kind is the kind for the resource (e.g. 'Deployment' is the kind for resource 'deployments')
// +required
Kind string `json:"kind"`
}
// NodeSummary represents the summary of nodes status in a specific cluster.

View File

@ -15,7 +15,7 @@ func (in *APIEnablement) DeepCopyInto(out *APIEnablement) {
*out = *in
if in.Resources != nil {
in, out := &in.Resources, &out.Resources
*out = make([]string, len(*in))
*out = make([]APIResource, len(*in))
copy(*out, *in)
}
return
@ -31,6 +31,22 @@ func (in *APIEnablement) DeepCopy() *APIEnablement {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *APIResource) DeepCopyInto(out *APIResource) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIResource.
func (in *APIResource) DeepCopy() *APIResource {
if in == nil {
return nil
}
out := new(APIResource)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Cluster) DeepCopyInto(out *Cluster) {
*out = *in

View File

@ -369,11 +369,16 @@ func getAPIEnablements(clusterClient *util.ClusterClient) ([]v1alpha1.APIEnablem
var apiEnablements []v1alpha1.APIEnablement
for _, list := range apiResourceList {
var apiResource []string
var apiResources []v1alpha1.APIResource
for _, resource := range list.APIResources {
apiResource = append(apiResource, resource.Name)
apiResource := v1alpha1.APIResource{
Name: resource.Name,
Kind: resource.Kind,
}
apiResources = append(apiResources, apiResource)
}
apiEnablements = append(apiEnablements, v1alpha1.APIEnablement{GroupVersion: list.GroupVersion, Resources: apiResource})
apiEnablements = append(apiEnablements, v1alpha1.APIEnablement{GroupVersion: list.GroupVersion, Resources: apiResources})
}
return apiEnablements, nil