From ac68abcecde291645d5c034b581474f0eade9dc7 Mon Sep 17 00:00:00 2001 From: Tamal Saha Date: Thu, 21 Sep 2023 16:05:42 -0700 Subject: [PATCH] Fix api (#365) Signed-off-by: Tamal Saha --- apis/core/fuzzer/fuzzer.go | 4 - apis/meta/fuzzer/fuzzer.go | 3 + apis/meta/v1alpha1/project_types.go | 8 +- apis/meta/v1alpha1/register.go | 2 + .../typed/core/v1alpha1/fake/fake_project.go | 69 ------------ crds/core.k8s.appscode.com_projects.yaml | 102 ------------------ .../v1alpha1/projects.yaml | 75 ++++++++++++- .../v1alpha1/projects.yaml | 6 +- .../v1alpha1/projects.yaml | 6 +- 9 files changed, 85 insertions(+), 190 deletions(-) delete mode 100644 client/clientset/versioned/typed/core/v1alpha1/fake/fake_project.go delete mode 100644 crds/core.k8s.appscode.com_projects.yaml rename hub/resourcedescriptors/{core.k8s.appscode.com => meta.k8s.appscode.com}/v1alpha1/projects.yaml (57%) rename hub/resourceeditors/{core.k8s.appscode.com => meta.k8s.appscode.com}/v1alpha1/projects.yaml (70%) rename hub/resourcetabledefinitions/{core.k8s.appscode.com => meta.k8s.appscode.com}/v1alpha1/projects.yaml (72%) diff --git a/apis/core/fuzzer/fuzzer.go b/apis/core/fuzzer/fuzzer.go index a31585be0..97e6b5b07 100644 --- a/apis/core/fuzzer/fuzzer.go +++ b/apis/core/fuzzer/fuzzer.go @@ -18,7 +18,6 @@ package fuzzer import ( "kmodules.xyz/resource-metadata/apis/core/v1alpha1" - v1alpha12 "kmodules.xyz/resource-metadata/apis/meta/v1alpha1" fuzz "github.com/google/gofuzz" runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" @@ -31,9 +30,6 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { func(s *v1alpha1.PodView, c fuzz.Continue) { c.FuzzNoCustom(s) // fuzz self without calling this function again }, - func(s *v1alpha12.Project, c fuzz.Continue) { - c.FuzzNoCustom(s) // fuzz self without calling this function again - }, func(s *v1alpha1.ResourceSummary, c fuzz.Continue) { c.FuzzNoCustom(s) // fuzz self without calling this function again }, diff --git a/apis/meta/fuzzer/fuzzer.go b/apis/meta/fuzzer/fuzzer.go index 1155d4f21..3c630bfbc 100644 --- a/apis/meta/fuzzer/fuzzer.go +++ b/apis/meta/fuzzer/fuzzer.go @@ -29,5 +29,8 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { func(s *v1alpha1.ResourceDescriptor, c fuzz.Continue) { c.FuzzNoCustom(s) // fuzz self without calling this function again }, + func(s *v1alpha1.Project, c fuzz.Continue) { + c.FuzzNoCustom(s) // fuzz self without calling this function again + }, } } diff --git a/apis/meta/v1alpha1/project_types.go b/apis/meta/v1alpha1/project_types.go index 54a1e730f..16d01f347 100644 --- a/apis/meta/v1alpha1/project_types.go +++ b/apis/meta/v1alpha1/project_types.go @@ -17,9 +17,9 @@ limitations under the License. package v1alpha1 import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" kmapi "kmodules.xyz/client-go/api/v1" - "kmodules.xyz/resource-metadata/apis/core/v1alpha1" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) const ( @@ -83,7 +83,3 @@ type ProjectList struct { metav1.ListMeta `json:"metadata,omitempty"` Items []Project `json:"items"` } - -func init() { - v1alpha1.SchemeBuilder.Register(&Project{}, &ProjectList{}) -} diff --git a/apis/meta/v1alpha1/register.go b/apis/meta/v1alpha1/register.go index cb15684f4..5fc2279b3 100644 --- a/apis/meta/v1alpha1/register.go +++ b/apis/meta/v1alpha1/register.go @@ -50,6 +50,8 @@ func Resource(resource string) schema.GroupResource { func addKnownTypes(scheme *runtime.Scheme) error { scheme.AddKnownTypes(SchemeGroupVersion, &ChartPresetQuery{}, + &Project{}, + &ProjectList{}, &ResourceDescriptor{}, &ResourceDescriptorList{}, &ResourceTableDefinition{}, diff --git a/client/clientset/versioned/typed/core/v1alpha1/fake/fake_project.go b/client/clientset/versioned/typed/core/v1alpha1/fake/fake_project.go deleted file mode 100644 index f4c36ef67..000000000 --- a/client/clientset/versioned/typed/core/v1alpha1/fake/fake_project.go +++ /dev/null @@ -1,69 +0,0 @@ -/* -Copyright AppsCode Inc. and Contributors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package fake - -import ( - "context" - "kmodules.xyz/resource-metadata/apis/meta/v1alpha1" - - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" - testing "k8s.io/client-go/testing" -) - -// FakeProjects implements ProjectInterface -type FakeProjects struct { - Fake *FakeCoreV1alpha1 -} - -var projectsResource = schema.GroupVersionResource{Group: "core.k8s.appscode.com", Version: "v1alpha1", Resource: "projects"} - -var projectsKind = schema.GroupVersionKind{Group: "core.k8s.appscode.com", Version: "v1alpha1", Kind: "Project"} - -// Get takes name of the project, and returns the corresponding project object, and an error if there is any. -func (c *FakeProjects) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Project, err error) { - obj, err := c.Fake. - Invokes(testing.NewRootGetAction(projectsResource, name), &v1alpha1.Project{}) - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.Project), err -} - -// List takes label and field selectors, and returns the list of Projects that match those selectors. -func (c *FakeProjects) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ProjectList, err error) { - obj, err := c.Fake. - Invokes(testing.NewRootListAction(projectsResource, projectsKind, opts), &v1alpha1.ProjectList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &v1alpha1.ProjectList{ListMeta: obj.(*v1alpha1.ProjectList).ListMeta} - for _, item := range obj.(*v1alpha1.ProjectList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} diff --git a/crds/core.k8s.appscode.com_projects.yaml b/crds/core.k8s.appscode.com_projects.yaml deleted file mode 100644 index a1ac9a0d2..000000000 --- a/crds/core.k8s.appscode.com_projects.yaml +++ /dev/null @@ -1,102 +0,0 @@ - ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - creationTimestamp: null - name: projects.core.k8s.appscode.com -spec: - group: core.k8s.appscode.com - names: - kind: Project - listKind: ProjectList - plural: projects - singular: project - scope: Cluster - versions: - - name: v1alpha1 - schema: - openAPIV3Schema: - description: Project is the Schema for the projects API - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' - type: string - kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' - type: string - metadata: - type: object - spec: - description: ProjectSpec defines the desired state of Project - properties: - namespaceSelector: - description: A label selector is a label query over a set of resources. - The result of matchLabels and matchExpressions are ANDed. An empty - label selector matches all objects. A null label selector matches - no objects. - properties: - matchExpressions: - description: matchExpressions is a list of label selector requirements. - The requirements are ANDed. - items: - description: A label selector requirement is a selector that - contains values, a key, and an operator that relates the key - and values. - properties: - key: - description: key is the label key that the selector applies - to. - type: string - operator: - description: operator represents a key's relationship to - a set of values. Valid operators are In, NotIn, Exists - and DoesNotExist. - type: string - values: - description: values is an array of string values. If the - operator is In or NotIn, the values array must be non-empty. - If the operator is Exists or DoesNotExist, the values - array must be empty. This array is replaced during a strategic - merge patch. - items: - type: string - type: array - required: - - key - - operator - type: object - type: array - matchLabels: - additionalProperties: - type: string - description: matchLabels is a map of {key,value} pairs. A single - {key,value} in the matchLabels map is equivalent to an element - of matchExpressions, whose key field is "key", the operator - is "In", and the values array contains only "value". The requirements - are ANDed. - type: object - type: object - x-kubernetes-map-type: atomic - namespaces: - items: - type: string - type: array - type: - default: User - enum: - - Default - - System - - User - type: string - type: object - status: - description: ProjectStatus defines the observed state of Project - type: object - type: object - served: true - storage: true diff --git a/hub/resourcedescriptors/core.k8s.appscode.com/v1alpha1/projects.yaml b/hub/resourcedescriptors/meta.k8s.appscode.com/v1alpha1/projects.yaml similarity index 57% rename from hub/resourcedescriptors/core.k8s.appscode.com/v1alpha1/projects.yaml rename to hub/resourcedescriptors/meta.k8s.appscode.com/v1alpha1/projects.yaml index fb9f370ba..e852a32f9 100644 --- a/hub/resourcedescriptors/core.k8s.appscode.com/v1alpha1/projects.yaml +++ b/hub/resourcedescriptors/meta.k8s.appscode.com/v1alpha1/projects.yaml @@ -3,14 +3,14 @@ kind: ResourceDescriptor metadata: creationTimestamp: null labels: - k8s.io/group: core.k8s.appscode.com + k8s.io/group: meta.k8s.appscode.com k8s.io/kind: Project k8s.io/resource: projects k8s.io/version: v1alpha1 - name: core.k8s.appscode.com-v1alpha1-projects + name: meta.k8s.appscode.com-v1alpha1-projects spec: resource: - group: core.k8s.appscode.com + group: meta.k8s.appscode.com kind: Project name: projects scope: Cluster @@ -44,6 +44,39 @@ spec: spec: description: ProjectSpec defines the desired state of Project properties: + monitoring: + properties: + alertmanagerRef: + description: ObjectReference contains enough information to let you inspect or modify the referred object. + properties: + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names' + type: string + namespace: + description: 'Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/' + type: string + required: + - name + type: object + alertmanagerURL: + type: string + grafanaURL: + type: string + prometheusRef: + description: ObjectReference contains enough information to let you inspect or modify the referred object. + properties: + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names' + type: string + namespace: + description: 'Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/' + type: string + required: + - name + type: object + prometheusURL: + type: string + type: object namespaceSelector: description: A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all objects. A null label selector matches no objects. properties: @@ -79,6 +112,42 @@ spec: items: type: string type: array + presets: + items: + properties: + ref: + description: ObjectReference contains enough information to let you inspect or modify the referred object. + properties: + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names' + type: string + namespace: + description: 'Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/' + type: string + required: + - name + type: object + resource: + description: ResourceID identifies a resource + properties: + group: + type: string + kind: + description: Kind is the serialized kind of the resource. It is normally CamelCase and singular. + type: string + name: + description: 'Name is the plural name of the resource to serve. It must match the name of the CustomResourceDefinition-registration too: plural.group and it must be all lowercase.' + type: string + scope: + description: ResourceScope is an enum defining the different scopes available to a custom resource + type: string + version: + type: string + required: + - group + type: object + type: object + type: array type: default: User enum: diff --git a/hub/resourceeditors/core.k8s.appscode.com/v1alpha1/projects.yaml b/hub/resourceeditors/meta.k8s.appscode.com/v1alpha1/projects.yaml similarity index 70% rename from hub/resourceeditors/core.k8s.appscode.com/v1alpha1/projects.yaml rename to hub/resourceeditors/meta.k8s.appscode.com/v1alpha1/projects.yaml index 67f31b30d..7d7048202 100644 --- a/hub/resourceeditors/core.k8s.appscode.com/v1alpha1/projects.yaml +++ b/hub/resourceeditors/meta.k8s.appscode.com/v1alpha1/projects.yaml @@ -3,14 +3,14 @@ kind: ResourceEditor metadata: creationTimestamp: null labels: - k8s.io/group: core.k8s.appscode.com + k8s.io/group: meta.k8s.appscode.com k8s.io/kind: Project k8s.io/resource: projects k8s.io/version: v1alpha1 - name: core.k8s.appscode.com-v1alpha1-projects + name: meta.k8s.appscode.com-v1alpha1-projects spec: resource: - group: core.k8s.appscode.com + group: meta.k8s.appscode.com kind: Project name: projects scope: Cluster diff --git a/hub/resourcetabledefinitions/core.k8s.appscode.com/v1alpha1/projects.yaml b/hub/resourcetabledefinitions/meta.k8s.appscode.com/v1alpha1/projects.yaml similarity index 72% rename from hub/resourcetabledefinitions/core.k8s.appscode.com/v1alpha1/projects.yaml rename to hub/resourcetabledefinitions/meta.k8s.appscode.com/v1alpha1/projects.yaml index 5676b6d5b..209fb8648 100644 --- a/hub/resourcetabledefinitions/core.k8s.appscode.com/v1alpha1/projects.yaml +++ b/hub/resourcetabledefinitions/meta.k8s.appscode.com/v1alpha1/projects.yaml @@ -3,15 +3,15 @@ kind: ResourceTableDefinition metadata: creationTimestamp: null labels: - k8s.io/group: core.k8s.appscode.com + k8s.io/group: meta.k8s.appscode.com k8s.io/kind: Project k8s.io/resource: projects k8s.io/version: v1alpha1 - name: core.k8s.appscode.com-v1alpha1-projects + name: meta.k8s.appscode.com-v1alpha1-projects spec: defaultView: true resource: - group: core.k8s.appscode.com + group: meta.k8s.appscode.com kind: Project name: projects scope: Cluster