improve multicluster resource controller
Signed-off-by: hongming <talonwan@yunify.com>
This commit is contained in:
161
pkg/apis/iam/v1alpha2/federated_types.go
Normal file
161
pkg/apis/iam/v1alpha2/federated_types.go
Normal file
@@ -0,0 +1,161 @@
|
||||
/*
|
||||
|
||||
Copyright 2020 The KubeSphere Authors.
|
||||
|
||||
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.
|
||||
|
||||
*/
|
||||
|
||||
package v1alpha2
|
||||
|
||||
import (
|
||||
rbacv1 "k8s.io/api/rbac/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
)
|
||||
|
||||
const (
|
||||
ResourcesSingularFedUser = "federateduser"
|
||||
ResourcesSingularFedGlobalRoleBinding = "federatedglobalrolebinding"
|
||||
ResourcesSingularFedWorkspaceRoleBinding = "federatedworkspacerolebinding"
|
||||
ResourcesSingularFedGlobalRole = "federatedglobalrole"
|
||||
ResourcesSingularFedWorkspaceRole = "federatedworkspacerole"
|
||||
ResourcesPluralFedUser = "federatedusers"
|
||||
ResourcesPluralFedGlobalRoleBinding = "federatedglobalrolebindings"
|
||||
ResourcesPluralFedWorkspaceRoleBinding = "federatedworkspacerolebindings"
|
||||
ResourcesPluralFedGlobalRole = "federatedglobalroles"
|
||||
ResourcesPluralFedWorkspaceRole = "federatedworkspaceroles"
|
||||
FedClusterRoleBindingKind = "FederatedClusterRoleBinding"
|
||||
FedClusterRoleKind = "FederatedClusterRole"
|
||||
FedGlobalRoleKind = "FederatedGlobalRole"
|
||||
FedWorkspaceRoleKind = "FederatedWorkspaceRole"
|
||||
FedGlobalRoleBindingKind = "FederatedGlobalRoleBinding"
|
||||
FedWorkspaceRoleBindingKind = "FederatedWorkspaceRoleBinding"
|
||||
fedResourceGroup = "types.kubefed.io"
|
||||
fedResourceVersion = "v1beta1"
|
||||
FedUserKind = "FederatedUser"
|
||||
)
|
||||
|
||||
var (
|
||||
FedUserResource = metav1.APIResource{
|
||||
Name: ResourcesPluralFedUser,
|
||||
SingularName: ResourcesSingularFedUser,
|
||||
Namespaced: false,
|
||||
Group: fedResourceGroup,
|
||||
Version: fedResourceVersion,
|
||||
Kind: FedUserKind,
|
||||
}
|
||||
FedGlobalRoleBindingResource = metav1.APIResource{
|
||||
Name: ResourcesPluralFedGlobalRoleBinding,
|
||||
SingularName: ResourcesSingularFedGlobalRoleBinding,
|
||||
Namespaced: false,
|
||||
Group: fedResourceGroup,
|
||||
Version: fedResourceVersion,
|
||||
Kind: FedGlobalRoleBindingKind,
|
||||
}
|
||||
FedWorkspaceRoleBindingResource = metav1.APIResource{
|
||||
Name: ResourcesPluralFedWorkspaceRoleBinding,
|
||||
SingularName: ResourcesSingularFedWorkspaceRoleBinding,
|
||||
Namespaced: false,
|
||||
Group: fedResourceGroup,
|
||||
Version: fedResourceVersion,
|
||||
Kind: FedWorkspaceRoleBindingKind,
|
||||
}
|
||||
FedGlobalRoleResource = metav1.APIResource{
|
||||
Name: ResourcesPluralFedGlobalRole,
|
||||
SingularName: ResourcesSingularFedGlobalRole,
|
||||
Namespaced: false,
|
||||
Group: fedResourceGroup,
|
||||
Version: fedResourceVersion,
|
||||
Kind: FedGlobalRoleKind,
|
||||
}
|
||||
|
||||
FedWorkspaceRoleResource = metav1.APIResource{
|
||||
Name: ResourcesPluralFedWorkspaceRole,
|
||||
SingularName: ResourcesSingularFedWorkspaceRole,
|
||||
Namespaced: false,
|
||||
Group: fedResourceGroup,
|
||||
Version: fedResourceVersion,
|
||||
Kind: FedWorkspaceRoleKind,
|
||||
}
|
||||
|
||||
FederatedClusterRoleBindingResource = schema.GroupVersionResource{
|
||||
Group: fedResourceGroup,
|
||||
Version: fedResourceVersion,
|
||||
Resource: "federatedclusterrolebindings",
|
||||
}
|
||||
)
|
||||
|
||||
type FederatedRoleBinding struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
Spec FederatedRoleBindingSpec `json:"spec"`
|
||||
}
|
||||
|
||||
type FederatedRoleBindingSpec struct {
|
||||
Template RoleBindingTemplate `json:"template"`
|
||||
Placement Placement `json:"placement"`
|
||||
}
|
||||
type RoleBindingTemplate struct {
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
Subjects []rbacv1.Subject `json:"subjects,omitempty"`
|
||||
RoleRef rbacv1.RoleRef `json:"roleRef"`
|
||||
}
|
||||
|
||||
type FederatedRole struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
Spec FederatedRoleSpec `json:"spec"`
|
||||
}
|
||||
|
||||
type FederatedRoleSpec struct {
|
||||
Template RoleTemplate `json:"template"`
|
||||
Placement Placement `json:"placement"`
|
||||
}
|
||||
|
||||
type RoleTemplate struct {
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
// +optional
|
||||
Rules []rbacv1.PolicyRule `json:"rules" protobuf:"bytes,2,rep,name=rules"`
|
||||
}
|
||||
|
||||
type FederatedUser struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
Spec FederatedUserSpec `json:"spec"`
|
||||
}
|
||||
|
||||
type FederatedUserSpec struct {
|
||||
Template UserTemplate `json:"template"`
|
||||
Placement Placement `json:"placement"`
|
||||
}
|
||||
|
||||
type UserTemplate struct {
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
Spec UserSpec `json:"spec"`
|
||||
// +optional
|
||||
Status UserStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
type Placement struct {
|
||||
Clusters []Cluster `json:"clusters,omitempty"`
|
||||
ClusterSelector ClusterSelector `json:"clusterSelector,omitempty"`
|
||||
}
|
||||
|
||||
type ClusterSelector struct {
|
||||
MatchLabels map[string]string `json:"matchLabels,omitempty"`
|
||||
}
|
||||
|
||||
type Cluster struct {
|
||||
Name string `json:"name"`
|
||||
}
|
||||
@@ -59,7 +59,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
|
||||
&WorkspaceRoleList{},
|
||||
&WorkspaceRoleBinding{},
|
||||
&WorkspaceRoleBindingList{},
|
||||
&FederatedClusterRoleBinding{},
|
||||
&RoleBase{},
|
||||
&RoleBaseList{},
|
||||
)
|
||||
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
|
||||
return nil
|
||||
|
||||
@@ -19,6 +19,7 @@ package v1alpha2
|
||||
import (
|
||||
rbacv1 "k8s.io/api/rbac/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -65,6 +66,7 @@ const (
|
||||
ScopeCluster = "cluster"
|
||||
ScopeNamespace = "namespace"
|
||||
PlatformAdmin = "platform-admin"
|
||||
NamespaceAdmin = "admin"
|
||||
ClusterAdmin = "cluster-admin"
|
||||
)
|
||||
|
||||
@@ -284,31 +286,22 @@ type WorkspaceRoleBindingList struct {
|
||||
Items []WorkspaceRoleBinding `json:"items"`
|
||||
}
|
||||
|
||||
// +genclient
|
||||
// +genclient:nonNamespaced
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
type FederatedClusterRoleBinding struct {
|
||||
// +kubebuilder:resource:categories="iam",scope="Cluster"
|
||||
type RoleBase struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
Spec FederatedClusterRoleBindingSpec `json:"spec"`
|
||||
|
||||
Role runtime.RawExtension `json:"role"`
|
||||
}
|
||||
|
||||
type FederatedClusterRoleBindingSpec struct {
|
||||
Template Template `json:"template"`
|
||||
Placement Placement `json:"placement"`
|
||||
}
|
||||
type Template struct {
|
||||
Subjects []rbacv1.Subject `json:"subjects,omitempty"`
|
||||
RoleRef rbacv1.RoleRef `json:"roleRef"`
|
||||
}
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
type Placement struct {
|
||||
Clusters []Cluster `json:"clusters,omitempty"`
|
||||
ClusterSelector ClusterSelector `json:"clusterSelector,omitempty"`
|
||||
}
|
||||
|
||||
type ClusterSelector struct {
|
||||
MatchLabels map[string]string `json:"matchLabels,omitempty"`
|
||||
}
|
||||
|
||||
type Cluster struct {
|
||||
Name string `json:"name"`
|
||||
// RoleBaseList contains a list of RoleBase
|
||||
type RoleBaseList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []RoleBase `json:"items"`
|
||||
}
|
||||
|
||||
196
pkg/apis/iam/v1alpha2/zz_generated.deepcopy.go
generated
196
pkg/apis/iam/v1alpha2/zz_generated.deepcopy.go
generated
@@ -63,44 +63,106 @@ func (in *ClusterSelector) DeepCopy() *ClusterSelector {
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *FederatedClusterRoleBinding) DeepCopyInto(out *FederatedClusterRoleBinding) {
|
||||
func (in *FederatedRole) DeepCopyInto(out *FederatedRole) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FederatedClusterRoleBinding.
|
||||
func (in *FederatedClusterRoleBinding) DeepCopy() *FederatedClusterRoleBinding {
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FederatedRole.
|
||||
func (in *FederatedRole) DeepCopy() *FederatedRole {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(FederatedClusterRoleBinding)
|
||||
out := new(FederatedRole)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *FederatedClusterRoleBinding) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *FederatedRoleBinding) DeepCopyInto(out *FederatedRoleBinding) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FederatedRoleBinding.
|
||||
func (in *FederatedRoleBinding) DeepCopy() *FederatedRoleBinding {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
out := new(FederatedRoleBinding)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *FederatedClusterRoleBindingSpec) DeepCopyInto(out *FederatedClusterRoleBindingSpec) {
|
||||
func (in *FederatedRoleBindingSpec) DeepCopyInto(out *FederatedRoleBindingSpec) {
|
||||
*out = *in
|
||||
in.Template.DeepCopyInto(&out.Template)
|
||||
in.Placement.DeepCopyInto(&out.Placement)
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FederatedClusterRoleBindingSpec.
|
||||
func (in *FederatedClusterRoleBindingSpec) DeepCopy() *FederatedClusterRoleBindingSpec {
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FederatedRoleBindingSpec.
|
||||
func (in *FederatedRoleBindingSpec) DeepCopy() *FederatedRoleBindingSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(FederatedClusterRoleBindingSpec)
|
||||
out := new(FederatedRoleBindingSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *FederatedRoleSpec) DeepCopyInto(out *FederatedRoleSpec) {
|
||||
*out = *in
|
||||
in.Template.DeepCopyInto(&out.Template)
|
||||
in.Placement.DeepCopyInto(&out.Placement)
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FederatedRoleSpec.
|
||||
func (in *FederatedRoleSpec) DeepCopy() *FederatedRoleSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(FederatedRoleSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *FederatedUser) DeepCopyInto(out *FederatedUser) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FederatedUser.
|
||||
func (in *FederatedUser) DeepCopy() *FederatedUser {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(FederatedUser)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *FederatedUserSpec) DeepCopyInto(out *FederatedUserSpec) {
|
||||
*out = *in
|
||||
in.Template.DeepCopyInto(&out.Template)
|
||||
in.Placement.DeepCopyInto(&out.Placement)
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FederatedUserSpec.
|
||||
func (in *FederatedUserSpec) DeepCopy() *FederatedUserSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(FederatedUserSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
@@ -254,8 +316,67 @@ func (in *Placement) DeepCopy() *Placement {
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *Template) DeepCopyInto(out *Template) {
|
||||
func (in *RoleBase) DeepCopyInto(out *RoleBase) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Role.DeepCopyInto(&out.Role)
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RoleBase.
|
||||
func (in *RoleBase) DeepCopy() *RoleBase {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(RoleBase)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *RoleBase) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *RoleBaseList) DeepCopyInto(out *RoleBaseList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]RoleBase, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RoleBaseList.
|
||||
func (in *RoleBaseList) DeepCopy() *RoleBaseList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(RoleBaseList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *RoleBaseList) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *RoleBindingTemplate) DeepCopyInto(out *RoleBindingTemplate) {
|
||||
*out = *in
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
if in.Subjects != nil {
|
||||
in, out := &in.Subjects, &out.Subjects
|
||||
*out = make([]v1.Subject, len(*in))
|
||||
@@ -264,12 +385,35 @@ func (in *Template) DeepCopyInto(out *Template) {
|
||||
out.RoleRef = in.RoleRef
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Template.
|
||||
func (in *Template) DeepCopy() *Template {
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RoleBindingTemplate.
|
||||
func (in *RoleBindingTemplate) DeepCopy() *RoleBindingTemplate {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(Template)
|
||||
out := new(RoleBindingTemplate)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *RoleTemplate) DeepCopyInto(out *RoleTemplate) {
|
||||
*out = *in
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
if in.Rules != nil {
|
||||
in, out := &in.Rules, &out.Rules
|
||||
*out = make([]v1.PolicyRule, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RoleTemplate.
|
||||
func (in *RoleTemplate) DeepCopy() *RoleTemplate {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(RoleTemplate)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
@@ -391,6 +535,24 @@ func (in *UserStatus) DeepCopy() *UserStatus {
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *UserTemplate) DeepCopyInto(out *UserTemplate) {
|
||||
*out = *in
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
in.Status.DeepCopyInto(&out.Status)
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new UserTemplate.
|
||||
func (in *UserTemplate) DeepCopy() *UserTemplate {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(UserTemplate)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *WorkspaceRole) DeepCopyInto(out *WorkspaceRole) {
|
||||
*out = *in
|
||||
|
||||
@@ -18,6 +18,7 @@ package v1alpha2
|
||||
|
||||
import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"kubesphere.io/kubesphere/pkg/apis/tenant/v1alpha1"
|
||||
)
|
||||
|
||||
@@ -25,6 +26,22 @@ const (
|
||||
ResourceKindWorkspaceTemplate = "WorkspaceTemplate"
|
||||
ResourceSingularWorkspaceTemplate = "workspacetemplate"
|
||||
ResourcePluralWorkspaceTemplate = "workspacetemplates"
|
||||
ResourcesPluralFedWorkspace = "federatedworkspaces"
|
||||
ResourcesSingularFedWorkspace = "federatedworkspace"
|
||||
FedWorkspaceKind = "FederatedWorkspace"
|
||||
fedResourceGroup = "types.kubefed.io"
|
||||
fedResourceVersion = "v1beta1"
|
||||
)
|
||||
|
||||
var (
|
||||
FedWorkspaceResource = metav1.APIResource{
|
||||
Name: ResourcesPluralFedWorkspace,
|
||||
SingularName: ResourcesSingularFedWorkspace,
|
||||
Namespaced: false,
|
||||
Group: fedResourceGroup,
|
||||
Version: fedResourceVersion,
|
||||
Kind: FedWorkspaceKind,
|
||||
}
|
||||
)
|
||||
|
||||
// +genclient
|
||||
@@ -44,7 +61,8 @@ type WorkspaceTemplateSpec struct {
|
||||
v1alpha1.WorkspaceSpec `json:",inline"`
|
||||
// authorized clusters
|
||||
// +optional
|
||||
Clusters []string `json:"clusters,omitempty"`
|
||||
Clusters []string `json:"clusters,omitempty"`
|
||||
Overrides []Override `json:"overrides,omitempty"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
@@ -60,3 +78,44 @@ type WorkspaceTemplateList struct {
|
||||
func init() {
|
||||
SchemeBuilder.Register(&WorkspaceTemplate{}, &WorkspaceTemplateList{})
|
||||
}
|
||||
|
||||
type FederatedWorkspace struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
Spec FederatedWorkspaceSpec `json:"spec"`
|
||||
}
|
||||
|
||||
type FederatedWorkspaceSpec struct {
|
||||
Template Template `json:"template"`
|
||||
Placement Placement `json:"placement"`
|
||||
Overrides []Override `json:"overrides,omitempty"`
|
||||
}
|
||||
|
||||
type Template struct {
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
Spec v1alpha1.WorkspaceSpec `json:"spec"`
|
||||
}
|
||||
|
||||
type Placement struct {
|
||||
Clusters []Cluster `json:"clusters,omitempty"`
|
||||
ClusterSelector ClusterSelector `json:"clusterSelector,omitempty"`
|
||||
}
|
||||
|
||||
type ClusterSelector struct {
|
||||
MatchLabels map[string]string `json:"matchLabels,omitempty"`
|
||||
}
|
||||
|
||||
type Cluster struct {
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type Override struct {
|
||||
ClusterName string `json:"clusterName"`
|
||||
ClusterOverrides []ClusterOverride `json:"clusterOverrides"`
|
||||
}
|
||||
|
||||
type ClusterOverride struct {
|
||||
Path string `json:"path"`
|
||||
Op string `json:"op,omitempty"`
|
||||
Value runtime.RawExtension `json:"value"`
|
||||
}
|
||||
|
||||
164
pkg/apis/tenant/v1alpha2/zz_generated.deepcopy.go
generated
164
pkg/apis/tenant/v1alpha2/zz_generated.deepcopy.go
generated
@@ -21,9 +21,164 @@ limitations under the License.
|
||||
package v1alpha2
|
||||
|
||||
import (
|
||||
runtime "k8s.io/apimachinery/pkg/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 *Cluster) DeepCopyInto(out *Cluster) {
|
||||
*out = *in
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Cluster.
|
||||
func (in *Cluster) DeepCopy() *Cluster {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(Cluster)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ClusterOverride) DeepCopyInto(out *ClusterOverride) {
|
||||
*out = *in
|
||||
in.Value.DeepCopyInto(&out.Value)
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterOverride.
|
||||
func (in *ClusterOverride) DeepCopy() *ClusterOverride {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ClusterOverride)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ClusterSelector) DeepCopyInto(out *ClusterSelector) {
|
||||
*out = *in
|
||||
if in.MatchLabels != nil {
|
||||
in, out := &in.MatchLabels, &out.MatchLabels
|
||||
*out = make(map[string]string, len(*in))
|
||||
for key, val := range *in {
|
||||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterSelector.
|
||||
func (in *ClusterSelector) DeepCopy() *ClusterSelector {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ClusterSelector)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *FederatedWorkspace) DeepCopyInto(out *FederatedWorkspace) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FederatedWorkspace.
|
||||
func (in *FederatedWorkspace) DeepCopy() *FederatedWorkspace {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(FederatedWorkspace)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *FederatedWorkspaceSpec) DeepCopyInto(out *FederatedWorkspaceSpec) {
|
||||
*out = *in
|
||||
in.Template.DeepCopyInto(&out.Template)
|
||||
in.Placement.DeepCopyInto(&out.Placement)
|
||||
if in.Overrides != nil {
|
||||
in, out := &in.Overrides, &out.Overrides
|
||||
*out = make([]Override, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FederatedWorkspaceSpec.
|
||||
func (in *FederatedWorkspaceSpec) DeepCopy() *FederatedWorkspaceSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(FederatedWorkspaceSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *Override) DeepCopyInto(out *Override) {
|
||||
*out = *in
|
||||
if in.ClusterOverrides != nil {
|
||||
in, out := &in.ClusterOverrides, &out.ClusterOverrides
|
||||
*out = make([]ClusterOverride, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Override.
|
||||
func (in *Override) DeepCopy() *Override {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(Override)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *Placement) DeepCopyInto(out *Placement) {
|
||||
*out = *in
|
||||
if in.Clusters != nil {
|
||||
in, out := &in.Clusters, &out.Clusters
|
||||
*out = make([]Cluster, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
in.ClusterSelector.DeepCopyInto(&out.ClusterSelector)
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Placement.
|
||||
func (in *Placement) DeepCopy() *Placement {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(Placement)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *Template) DeepCopyInto(out *Template) {
|
||||
*out = *in
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
out.Spec = in.Spec
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Template.
|
||||
func (in *Template) DeepCopy() *Template {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(Template)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *WorkspaceTemplate) DeepCopyInto(out *WorkspaceTemplate) {
|
||||
*out = *in
|
||||
@@ -91,6 +246,13 @@ func (in *WorkspaceTemplateSpec) DeepCopyInto(out *WorkspaceTemplateSpec) {
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.Overrides != nil {
|
||||
in, out := &in.Overrides, &out.Overrides
|
||||
*out = make([]Override, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkspaceTemplateSpec.
|
||||
|
||||
Reference in New Issue
Block a user