diff --git a/cluster-registry-crd.yaml b/cluster-registry-crd.yaml index da87e36b..c060189d 100644 --- a/cluster-registry-crd.yaml +++ b/cluster-registry-crd.yaml @@ -4,7 +4,7 @@ metadata: creationTimestamp: null labels: api: "" - kubebuilder.k8s.io: 0.1.9 + kubebuilder.k8s.io: 0.1.10 name: clusters.clusterregistry.k8s.io spec: group: clusterregistry.k8s.io @@ -25,9 +25,23 @@ spec: properties: authInfo: properties: - controllerAuthInfo: + controller: + properties: + kind: + type: string + name: + type: string + namespace: + type: string type: object - userAuthInfo: + user: + properties: + kind: + type: string + name: + type: string + namespace: + type: string type: object type: object kubernetesApiEndpoints: diff --git a/docs/reference/build/documents/_generated_authinfo_v1alpha1_clusterregistry_definition.md b/docs/reference/build/documents/_generated_authinfo_v1alpha1_clusterregistry_definition.md index f6dd4f8c..f67a5117 100644 --- a/docs/reference/build/documents/_generated_authinfo_v1alpha1_clusterregistry_definition.md +++ b/docs/reference/build/documents/_generated_authinfo_v1alpha1_clusterregistry_definition.md @@ -17,6 +17,6 @@ Appears In: Field | Description ------------ | ----------- -`controllerAuthInfo`
*[ObjectReference](#objectreference-v1)* | ControllerAuthInfo references an object that contains implementation-specific details about how a controller should authenticate. A simple use case for this would be to reference a secret in another namespace that stores a bearer token that can be used to authenticate against this cluster's API server. -`userAuthInfo`
*[ObjectReference](#objectreference-v1)* | UserAuthInfo references an object that contains implementation-specific details about how a user should authenticate against this cluster. +`controller`
*[ObjectReference](#objectreference-v1alpha1)* | Controller references an object that contains implementation-specific details about how a controller should authenticate. A simple use case for this would be to reference a secret in another namespace that stores a bearer token that can be used to authenticate against this cluster's API server. +`user`
*[ObjectReference](#objectreference-v1alpha1)* | User references an object that contains implementation-specific details about how a user should authenticate against this cluster. diff --git a/docs/reference/build/documents/_generated_objectreference_v1_core_definition.md b/docs/reference/build/documents/_generated_objectreference_v1_core_definition.md deleted file mode 100644 index f077f2dc..00000000 --- a/docs/reference/build/documents/_generated_objectreference_v1_core_definition.md +++ /dev/null @@ -1,27 +0,0 @@ -## ObjectReference v1 - -Group | Version | Kind ------------- | ---------- | ----------- -`core` | `v1` | `ObjectReference` - - - -ObjectReference contains enough information to let you inspect or modify the referred object. - - - -Field | Description ------------- | ----------- -`apiVersion`
*string* | API version of the referent. -`fieldPath`
*string* | If referring to a piece of an object instead of an entire object, this string should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2]. For example, if the object reference is to a container within a pod, this would take on a value like: "spec.containers{name}" (where "name" refers to the name of the container that triggered the event) or if no container name is specified "spec.containers[2]" (container with index 2 in this pod). This syntax is chosen only to have some well-defined way of referencing a part of an object. -`kind`
*string* | Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds -`name`
*string* | Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names -`namespace`
*string* | Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/ -`resourceVersion`
*string* | Specific resourceVersion to which this reference is made, if any. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#concurrency-control-and-consistency -`uid`
*string* | UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids - diff --git a/docs/reference/build/documents/_generated_objectreference_v1alpha1_clusterregistry_definition.md b/docs/reference/build/documents/_generated_objectreference_v1alpha1_clusterregistry_definition.md new file mode 100644 index 00000000..428ff49f --- /dev/null +++ b/docs/reference/build/documents/_generated_objectreference_v1alpha1_clusterregistry_definition.md @@ -0,0 +1,23 @@ +## ObjectReference v1alpha1 + +Group | Version | Kind +------------ | ---------- | ----------- +`clusterregistry` | `v1alpha1` | `ObjectReference` + + + +ObjectReference contains enough information to let you inspect or modify the referred object. + + + +Field | Description +------------ | ----------- +`kind`
*string* | Kind contains the kind of the referent, e.g., Secret or ConfigMap More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds +`name`
*string* | Name contains the name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names +`namespace`
*string* | Namespace contains the namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/ + diff --git a/docs/reference/build/index.html b/docs/reference/build/index.html index 4d94a7fc..3ba80cfb 100644 --- a/docs/reference/build/index.html +++ b/docs/reference/build/index.html @@ -11,7 +11,7 @@ - +

Clusterregistry

@@ -151,12 +151,12 @@

AuthInfo v1alpha1

-controllerAuthInfo
ObjectReference -ControllerAuthInfo references an object that contains implementation-specific details about how a controller should authenticate. A simple use case for this would be to reference a secret in another namespace that stores a bearer token that can be used to authenticate against this cluster's API server. +controller
ObjectReference +Controller references an object that contains implementation-specific details about how a controller should authenticate. A simple use case for this would be to reference a secret in another namespace that stores a bearer token that can be used to authenticate against this cluster's API server. -userAuthInfo
ObjectReference -UserAuthInfo references an object that contains implementation-specific details about how a user should authenticate against this cluster. +user
ObjectReference +User references an object that contains implementation-specific details about how a user should authenticate against this cluster. @@ -490,7 +490,7 @@

ObjectMeta v1

-

ObjectReference v1

+

ObjectReference v1alpha1

@@ -501,8 +501,8 @@

ObjectReference v1

- - + + @@ -524,32 +524,16 @@

ObjectReference v1

- - - - - - - - - + - + - - - - - - - - - +
corev1clusterregistryv1alpha1 ObjectReference
apiVersion
string
API version of the referent.
fieldPath
string
If referring to a piece of an object instead of an entire object, this string should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2]. For example, if the object reference is to a container within a pod, this would take on a value like: "spec.containers{name}" (where "name" refers to the name of the container that triggered the event) or if no container name is specified "spec.containers[2]" (container with index 2 in this pod). This syntax is chosen only to have some well-defined way of referencing a part of an object.
kind
string
Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kindsKind contains the kind of the referent, e.g., Secret or ConfigMap More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds
name
string
Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#namesName contains the name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
namespace
string
Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/
resourceVersion
string
Specific resourceVersion to which this reference is made, if any. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#concurrency-control-and-consistency
uid
string
UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uidsNamespace contains the namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/
diff --git a/docs/reference/build/manifest.json b/docs/reference/build/manifest.json index 3fbf69c6..dce9e704 100644 --- a/docs/reference/build/manifest.json +++ b/docs/reference/build/manifest.json @@ -35,7 +35,7 @@ "filename": "_generated_objectmeta_v1_meta_definition.md" }, { - "filename": "_generated_objectreference_v1_core_definition.md" + "filename": "_generated_objectreference_v1alpha1_clusterregistry_definition.md" }, { "filename": "_generated_ownerreference_v1_meta_definition.md" diff --git a/docs/reference/build/navData.js b/docs/reference/build/navData.js index c2c725ef..1204b0ba 100644 --- a/docs/reference/build/navData.js +++ b/docs/reference/build/navData.js @@ -1 +1 @@ -(function(){navData = {"toc":[{"section":"-strong-field-definitions-strong-","subsections":[{"section":"time-v1"},{"section":"statusdetails-v1"},{"section":"statuscause-v1"},{"section":"status-v1"},{"section":"serveraddressbyclientcidr-v1alpha1"},{"section":"ownerreference-v1"},{"section":"objectreference-v1"},{"section":"objectmeta-v1"},{"section":"listmeta-v1"},{"section":"kubernetesapiendpoints-v1alpha1"},{"section":"initializers-v1"},{"section":"initializer-v1"},{"section":"clustercondition-v1alpha1"},{"section":"authinfo-v1alpha1"}]},{"section":"-strong-old-api-versions-strong-","subsections":[]},{"section":"cluster-v1alpha1","subsections":[]},{"section":"-strong-clusterregistry-strong-","subsections":[]}],"flatToc":["time-v1","statusdetails-v1","statuscause-v1","status-v1","serveraddressbyclientcidr-v1alpha1","ownerreference-v1","objectreference-v1","objectmeta-v1","listmeta-v1","kubernetesapiendpoints-v1alpha1","initializers-v1","initializer-v1","clustercondition-v1alpha1","authinfo-v1alpha1","-strong-field-definitions-strong-","-strong-old-api-versions-strong-","cluster-v1alpha1","-strong-clusterregistry-strong-"]};})(); \ No newline at end of file +(function(){navData = {"toc":[{"section":"-strong-field-definitions-strong-","subsections":[{"section":"time-v1"},{"section":"statusdetails-v1"},{"section":"statuscause-v1"},{"section":"status-v1"},{"section":"serveraddressbyclientcidr-v1alpha1"},{"section":"ownerreference-v1"},{"section":"objectreference-v1alpha1"},{"section":"objectmeta-v1"},{"section":"listmeta-v1"},{"section":"kubernetesapiendpoints-v1alpha1"},{"section":"initializers-v1"},{"section":"initializer-v1"},{"section":"clustercondition-v1alpha1"},{"section":"authinfo-v1alpha1"}]},{"section":"-strong-old-api-versions-strong-","subsections":[]},{"section":"cluster-v1alpha1","subsections":[]},{"section":"-strong-clusterregistry-strong-","subsections":[]}],"flatToc":["time-v1","statusdetails-v1","statuscause-v1","status-v1","serveraddressbyclientcidr-v1alpha1","ownerreference-v1","objectreference-v1alpha1","objectmeta-v1","listmeta-v1","kubernetesapiendpoints-v1alpha1","initializers-v1","initializer-v1","clustercondition-v1alpha1","authinfo-v1alpha1","-strong-field-definitions-strong-","-strong-old-api-versions-strong-","cluster-v1alpha1","-strong-clusterregistry-strong-"]};})(); \ No newline at end of file diff --git a/docs/reference/openapi-spec/swagger.json b/docs/reference/openapi-spec/swagger.json index f90f04a5..175897d6 100755 --- a/docs/reference/openapi-spec/swagger.json +++ b/docs/reference/openapi-spec/swagger.json @@ -17776,18 +17776,18 @@ "Schema": { "description": "AuthInfo holds information that describes how a client can get credentials to access the cluster. For example, OAuth2 client registration endpoints and supported flows, or Kerberos server locations.", "properties": { - "controllerAuthInfo": { - "description": "ControllerAuthInfo references an object that contains implementation-specific details about how a controller should authenticate. A simple use case for this would be to reference a secret in another namespace that stores a bearer token that can be used to authenticate against this cluster's API server.", - "$ref": "#/definitions/core.v1.ObjectReference" + "controller": { + "description": "Controller references an object that contains implementation-specific details about how a controller should authenticate. A simple use case for this would be to reference a secret in another namespace that stores a bearer token that can be used to authenticate against this cluster's API server.", + "$ref": "#/definitions/clusterregistry.v1alpha1.ObjectReference" }, - "userAuthInfo": { - "description": "UserAuthInfo references an object that contains implementation-specific details about how a user should authenticate against this cluster.", - "$ref": "#/definitions/core.v1.ObjectReference" + "user": { + "description": "User references an object that contains implementation-specific details about how a user should authenticate against this cluster.", + "$ref": "#/definitions/clusterregistry.v1alpha1.ObjectReference" } } }, "Dependencies": [ - "k8s.io/api/core/v1.ObjectReference" + "k8s.io/cluster-registry/pkg/apis/clusterregistry/v1alpha1.ObjectReference" ] }, "k8s.io/cluster-registry/pkg/apis/clusterregistry/v1alpha1.Cluster": { @@ -17949,6 +17949,26 @@ "k8s.io/cluster-registry/pkg/apis/clusterregistry/v1alpha1.ServerAddressByClientCIDR" ] }, + "k8s.io/cluster-registry/pkg/apis/clusterregistry/v1alpha1.ObjectReference": { + "Schema": { + "description": "ObjectReference contains enough information to let you inspect or modify the referred object.", + "properties": { + "kind": { + "description": "Kind contains the kind of the referent, e.g., Secret or ConfigMap More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "name": { + "description": "Name contains the name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", + "type": "string" + }, + "namespace": { + "description": "Namespace contains the namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/", + "type": "string" + } + } + }, + "Dependencies": [] + }, "k8s.io/cluster-registry/pkg/apis/clusterregistry/v1alpha1.ServerAddressByClientCIDR": { "Schema": { "description": "ServerAddressByClientCIDR helps clients determine the server address that they should use, depending on the ClientCIDR that they match.", diff --git a/pkg/apis/clusterregistry/v1alpha1/types.go b/pkg/apis/clusterregistry/v1alpha1/types.go index 08f7789e..664b49ac 100644 --- a/pkg/apis/clusterregistry/v1alpha1/types.go +++ b/pkg/apis/clusterregistry/v1alpha1/types.go @@ -98,17 +98,35 @@ type ServerAddressByClientCIDR struct { // credentials to access the cluster. For example, OAuth2 client registration // endpoints and supported flows, or Kerberos server locations. type AuthInfo struct { - // UserAuthInfo references an object that contains implementation-specific - // details about how a user should authenticate against this cluster. + // User references an object that contains implementation-specific details + // about how a user should authenticate against this cluster. // +optional - UserAuthInfo *v1.ObjectReference `json:"userAuthInfo,omitempty" protobuf:"bytes,1,opt,name=userAuthInfo"` + User *ObjectReference `json:"user,omitempty" protobuf:"bytes,1,opt,name=user"` + + // Controller references an object that contains implementation-specific + // details about how a controller should authenticate. A simple use case for + // this would be to reference a secret in another namespace that stores a + // bearer token that can be used to authenticate against this cluster's API + // server. + Controller *ObjectReference `json:"controller,omitempty" protobuf:"bytes,2,opt,name=controller"` +} + +// ObjectReference contains enough information to let you inspect or modify the referred object. +type ObjectReference struct { + // Kind contains the kind of the referent, e.g., Secret or ConfigMap + // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds + // +optional + Kind string `json:"kind,omitempty" protobuf:"bytes,1,opt,name=kind"` - // ControllerAuthInfo references an object that contains - // implementation-specific details about how a controller should authenticate. - // A simple use case for this would be to reference a secret in another - // namespace that stores a bearer token that can be used to authenticate - // against this cluster's API server. - ControllerAuthInfo *v1.ObjectReference `json:"controllerAuthInfo,omitempty" protobuf:"bytes,2,opt,name=controllerAuthInfo"` + // Name contains the name of the referent. + // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + // +optional + Name string `json:"name,omitempty" protobuf:"bytes,2,opt,name=name"` + + // Namespace contains the namespace of the referent. + // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/ + // +optional + Namespace string `json:"namespace,omitempty" protobuf:"bytes,3,opt,name=namespace"` } // ClusterConditionType marks the kind of cluster condition being reported. diff --git a/pkg/apis/clusterregistry/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/clusterregistry/v1alpha1/zz_generated.deepcopy.go index cdaf22b3..f3d93f03 100644 --- a/pkg/apis/clusterregistry/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/clusterregistry/v1alpha1/zz_generated.deepcopy.go @@ -21,28 +21,27 @@ limitations under the License. package v1alpha1 import ( - v1 "k8s.io/api/core/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *AuthInfo) DeepCopyInto(out *AuthInfo) { *out = *in - if in.UserAuthInfo != nil { - in, out := &in.UserAuthInfo, &out.UserAuthInfo + if in.User != nil { + in, out := &in.User, &out.User if *in == nil { *out = nil } else { - *out = new(v1.ObjectReference) + *out = new(ObjectReference) **out = **in } } - if in.ControllerAuthInfo != nil { - in, out := &in.ControllerAuthInfo, &out.ControllerAuthInfo + if in.Controller != nil { + in, out := &in.Controller, &out.Controller if *in == nil { *out = nil } else { - *out = new(v1.ObjectReference) + *out = new(ObjectReference) **out = **in } } @@ -205,6 +204,22 @@ func (in *KubernetesAPIEndpoints) DeepCopy() *KubernetesAPIEndpoints { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ObjectReference) DeepCopyInto(out *ObjectReference) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ObjectReference. +func (in *ObjectReference) DeepCopy() *ObjectReference { + if in == nil { + return nil + } + out := new(ObjectReference) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ServerAddressByClientCIDR) DeepCopyInto(out *ServerAddressByClientCIDR) { *out = *in diff --git a/pkg/apis/clusterregistry/v1alpha1/zz_generated.kubebuilder.go b/pkg/apis/clusterregistry/v1alpha1/zz_generated.kubebuilder.go index 834c0e61..9e242983 100644 --- a/pkg/apis/clusterregistry/v1alpha1/zz_generated.kubebuilder.go +++ b/pkg/apis/clusterregistry/v1alpha1/zz_generated.kubebuilder.go @@ -64,6 +64,10 @@ func getFloat(f float64) *float64 { return &f } +func getInt(i int64) *int64 { + return &i +} + var ( // Define CRDs for resources ClusterCRD = v1beta1.CustomResourceDefinition{ @@ -97,13 +101,33 @@ var ( "authInfo": { Type: "object", Properties: map[string]v1beta1.JSONSchemaProps{ - "controllerAuthInfo": { - Type: "object", - Properties: map[string]v1beta1.JSONSchemaProps{}, + "controller": { + Type: "object", + Properties: map[string]v1beta1.JSONSchemaProps{ + "kind": { + Type: "string", + }, + "name": { + Type: "string", + }, + "namespace": { + Type: "string", + }, + }, }, - "userAuthInfo": { - Type: "object", - Properties: map[string]v1beta1.JSONSchemaProps{}, + "user": { + Type: "object", + Properties: map[string]v1beta1.JSONSchemaProps{ + "kind": { + Type: "string", + }, + "name": { + Type: "string", + }, + "namespace": { + Type: "string", + }, + }, }, }, }, diff --git a/test/integration/server_test.go b/test/integration/server_test.go index fd47c5a6..b5a429c9 100644 --- a/test/integration/server_test.go +++ b/test/integration/server_test.go @@ -20,10 +20,8 @@ import ( "testing" "github.com/kubernetes-sigs/kubebuilder/pkg/test" - "k8s.io/api/core/v1" "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/types" "k8s.io/cluster-registry/pkg/apis/clusterregistry/v1alpha1" crclientset "k8s.io/cluster-registry/pkg/client/clientset/versioned" ) @@ -102,11 +100,10 @@ func testClusterUpdate(t *testing.T, clientset *crclientset.Clientset, clusterNa authSecretName := "authSecret" cluster.Spec.AuthInfo = v1alpha1.AuthInfo{ - ControllerAuthInfo: &v1.ObjectReference{ + Controller: &v1alpha1.ObjectReference{ Kind: "Secret", Name: authSecretName, Namespace: "default", - UID: types.UID("testUID"), }, } @@ -118,9 +115,9 @@ func testClusterUpdate(t *testing.T, clientset *crclientset.Clientset, clusterNa t.Fatalf("Expected a cluster, got nil") } else if cluster.Name != clusterName { t.Fatalf("Expected a cluster named 'cluster', got a cluster named '%v'.", cluster.Name) - } else if cluster.Spec.AuthInfo.ControllerAuthInfo == nil || cluster.Spec.AuthInfo.ControllerAuthInfo.Name != authSecretName { + } else if cluster.Spec.AuthInfo.Controller == nil || cluster.Spec.AuthInfo.Controller.Name != authSecretName { t.Fatalf("Expected a cluster controller auth info named '%v', got cluster auth provider '%v'", - authSecretName, cluster.Spec.AuthInfo.ControllerAuthInfo) + authSecretName, cluster.Spec.AuthInfo.Controller) } }