Add controller for ManagedClusterSet

This commit is contained in:
Yang Le
2020-08-26 15:03:38 +08:00
parent 6de37157d9
commit 74f73db584
57 changed files with 3410 additions and 57 deletions
@@ -43,3 +43,10 @@ rules:
resources: ["signers"]
resourceNames: ["kubernetes.io/kube-apiserver-client"]
verbs: ["approve"]
# Allow hub to manage managedclustersets
- apiGroups: ["cluster.open-cluster-management.io"]
resources: ["managedclustersets"]
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
- apiGroups: ["cluster.open-cluster-management.io"]
resources: ["managedclustersets/status"]
verbs: ["update", "patch"]
+1
View File
@@ -27,6 +27,7 @@ namespace: open-cluster-management
resources:
- ./managedcluster.crd.yaml
- ./manifestwork.crd.yaml
- ./managedclusterset.crd.yaml
- ./namespace.yaml
- ./service_account.yaml
- ./hub_controller_clusterrole_binding.yaml
+149
View File
@@ -0,0 +1,149 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
creationTimestamp: null
name: managedclustersets.cluster.open-cluster-management.io
spec:
group: cluster.open-cluster-management.io
names:
kind: ManagedClusterSet
listKind: ManagedClusterSetList
plural: managedclustersets
singular: managedclusterset
scope: Cluster
subresources:
status: {}
preserveUnknownFields: false
validation:
openAPIV3Schema:
description: "ManagedClusterSet defines a group of ManagedClusters that user's
workload can run on. A workload can be defined to deployed on a ManagedClusterSet,
which mean: \n 1. The workload can run on any ManagedCluster in the ManagedClusterSet
2. The workload cannot run on any ManagedCluster outside the ManagedClusterSet
3. The service exposed by the workload can be shared in any ManagedCluster
in the ManagedClusterSet"
type: object
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: Spec defines the attributes of the desired ManagedClusters
type: object
properties:
clusterSelectors:
description: ClusterSelectors represents a slice of selectors to select
ManagedClusters If empty, the ManagedClusterSet will include all ManagedClusters
If more than one ClusterSelector are specified in the slice, OR operation
will be used between them.
type: array
items:
description: ClusterSelector represents a selector of ManagedClusters
ClusterNames and LabelSelector are mutually exclusive. They cannot
be set at the same time. If none of them is set, all ManagedClusters
will be selected
type: object
properties:
clusterNames:
description: ClusterNames represents a list of cluster name
type: array
items:
type: string
labelSelector:
description: LabelSelector represents a label selector to select
cluster by label
type: object
properties:
matchExpressions:
description: matchExpressions is a list of label selector
requirements. The requirements are ANDed.
type: array
items:
description: A label selector requirement is a selector
that contains values, a key, and an operator that relates
the key and values.
type: object
required:
- key
- operator
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.
type: array
items:
type: string
matchLabels:
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
additionalProperties:
type: string
status:
description: Status represents the current status of the ManagedClusterSet
type: object
properties:
conditions:
description: Conditions contains the different condition statuses for
this ManagedClusterSet.
type: array
items:
description: StatusCondition contains condition information for a
ManagedClusterSet.
type: object
properties:
lastTransitionTime:
description: LastTransitionTime is the last time the condition
changed from one status to another.
type: string
format: date-time
message:
description: Message is a human-readable message indicating details
about the last status change.
type: string
reason:
description: Reason is a (brief) reason for the condition's last
status change.
type: string
status:
description: Status is the status of the condition. One of True,
False, Unknown.
type: string
type:
description: Type is the type of the ManagedClusterSet condition.
type: string
version: v1alpha1
versions:
- name: v1alpha1
served: true
storage: true
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
+1 -1
View File
@@ -6,7 +6,7 @@ require (
github.com/go-bindata/go-bindata v3.1.2+incompatible
github.com/onsi/ginkgo v1.11.0
github.com/onsi/gomega v1.8.1
github.com/open-cluster-management/api v0.0.0-20200610161514-939cead3902c
github.com/open-cluster-management/api v0.0.0-20200824150602-69fc6a00e4f8
github.com/openshift/api v0.0.0-20200521101457-60c476765272
github.com/openshift/build-machinery-go v0.0.0-20200424080330-082bf86082cc
github.com/openshift/generic-admission-server v1.14.1-0.20200514123932-ccc9079d8bdb
+4 -2
View File
@@ -302,8 +302,8 @@ github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGV
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/onsi/gomega v1.8.1 h1:C5Dqfs/LeauYDX0jJXIe2SWmwCbGzx9yF8C8xy3Lh34=
github.com/onsi/gomega v1.8.1/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA=
github.com/open-cluster-management/api v0.0.0-20200610161514-939cead3902c h1:UY7VEmlpib52/tI6lP60c21cGGSNJbX1terjoWOhJ0M=
github.com/open-cluster-management/api v0.0.0-20200610161514-939cead3902c/go.mod h1:+vUECYB7WkfCb52r0J7rxgD1mseSGAqGi8rTLLRcbgw=
github.com/open-cluster-management/api v0.0.0-20200824150602-69fc6a00e4f8 h1:pzQmanam3DNm/GlDNf4yJzdLOFPd7SgxQqipXz/P0nk=
github.com/open-cluster-management/api v0.0.0-20200824150602-69fc6a00e4f8/go.mod h1:+vUECYB7WkfCb52r0J7rxgD1mseSGAqGi8rTLLRcbgw=
github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
github.com/opencontainers/runc v0.0.0-20191031171055-b133feaeeb2e/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U=
@@ -455,6 +455,7 @@ golang.org/x/net v0.0.0-20200421231249-e086a090c8fd h1:QPwSajcTUrFriMF1nJ3Xzgoqa
golang.org/x/net v0.0.0-20200421231249-e086a090c8fd/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d h1:TzXSXBo42m9gQenoE3b9BGiEpg5IG2JkU5FkPIawgtw=
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -491,6 +492,7 @@ golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 h1:SvFZT6jyqRaOeXpc5h/JSfZenJ2O330aBsf7JfSUXmQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0 h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
+247
View File
@@ -0,0 +1,247 @@
package managedclusterset
import (
"context"
"fmt"
"reflect"
clientset "github.com/open-cluster-management/api/client/cluster/clientset/versioned"
clusterinformerv1 "github.com/open-cluster-management/api/client/cluster/informers/externalversions/cluster/v1"
clusterinformerv1alpha1 "github.com/open-cluster-management/api/client/cluster/informers/externalversions/cluster/v1alpha1"
clusterlisterv1 "github.com/open-cluster-management/api/client/cluster/listers/cluster/v1"
clusterlisterv1alpha1 "github.com/open-cluster-management/api/client/cluster/listers/cluster/v1alpha1"
clusterv1alpha1 "github.com/open-cluster-management/api/cluster/v1alpha1"
"github.com/openshift/library-go/pkg/controller/factory"
"github.com/openshift/library-go/pkg/operator/events"
operatorhelpers "github.com/openshift/library-go/pkg/operator/v1helpers"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/klog"
)
// managedClusterSetController reconciles instances of ManagedClusterSet on the hub.
type managedClusterSetController struct {
clusterClient clientset.Interface
clusterLister clusterlisterv1.ManagedClusterLister
clusterSetLister clusterlisterv1alpha1.ManagedClusterSetLister
eventRecorder events.Recorder
}
// NewManagedClusterSetController creates a new managed cluster set controller
func NewManagedClusterSetController(
clusterClient clientset.Interface,
clusterInformer clusterinformerv1.ManagedClusterInformer,
clusterSetInformer clusterinformerv1alpha1.ManagedClusterSetInformer,
recorder events.Recorder) factory.Controller {
c := &managedClusterSetController{
clusterClient: clusterClient,
clusterLister: clusterInformer.Lister(),
clusterSetLister: clusterSetInformer.Lister(),
eventRecorder: recorder.WithComponentSuffix("managed-cluster-set-controller"),
}
return factory.New().
WithInformersQueueKeyFunc(func(obj runtime.Object) string {
accessor, _ := meta.Accessor(obj)
return accessor.GetName()
}, clusterSetInformer.Informer()).
// TODO, create a PR for library-go to accept a queue key function, which
// is able to produce a []string instead of string based on one object, when
// registering event handler. And then refactor the logic here.
WithInformers(clusterInformer.Informer()).
WithSync(c.sync).
ToController("ManagedClusterSetController", recorder)
}
func (c *managedClusterSetController) sync(ctx context.Context, syncCtx factory.SyncContext) error {
key := syncCtx.QueueKey()
// if the sync is triggered by change of ManagedCluster, reconcile all cluster sets
if key == "key" {
// TODO: instead of resync all clustersets, sync those which might be impacted by
// the ManagedCluster change only
if err := c.syncAllClusterSets(ctx); err != nil {
return fmt.Errorf("failed to sync all ManagedClusterSets: %w", err)
}
return nil
}
clusterSet, err := c.clusterSetLister.Get(key)
if errors.IsNotFound(err) {
// cluster set not found, could have been deleted, do nothing.
return nil
}
if err != nil {
return err
}
if err = c.syncClusterSet(ctx, clusterSet); err != nil {
return fmt.Errorf("failed to sync ManagedClusterSet %q: %w", key, err)
}
return nil
}
// syncAllClusterSets syncs all cluster sets
func (c *managedClusterSetController) syncAllClusterSets(ctx context.Context) error {
clusterSets, err := c.clusterSetLister.List(labels.Everything())
if err != nil {
return err
}
errs := []error{}
for _, clusterSet := range clusterSets {
if err = c.syncClusterSet(ctx, clusterSet); err != nil {
errs = append(errs, err)
}
}
return operatorhelpers.NewMultiLineAggregate(errs)
}
// syncClusterSet syncs a particular cluster set
func (c *managedClusterSetController) syncClusterSet(ctx context.Context, clusterSet *clusterv1alpha1.ManagedClusterSet) error {
klog.V(4).Infof("Reconciling ManagedClusterSet %s", clusterSet.Name)
// no work to do if the cluster set is deleted
if !clusterSet.DeletionTimestamp.IsZero() {
return nil
}
selectedClusters := sets.NewString()
selectedCondition := clusterv1alpha1.StatusCondition{
Type: clusterv1alpha1.ManagedClusterSetConditionEmpty,
}
errs := []error{}
for _, selector := range clusterSet.Spec.ClusterSelectors {
clusters, err := c.selectClusters(selector)
if err != nil {
errs = append(errs, err)
}
selectedClusters.Insert(clusters...)
}
if count := selectedClusters.Len(); count == 0 {
selectedCondition.Status = metav1.ConditionTrue
selectedCondition.Reason = "NoClusterMatched"
selectedCondition.Message = "No ManagedCluster selected"
} else {
selectedCondition.Status = metav1.ConditionFalse
selectedCondition.Reason = "ClustersSelected"
selectedCondition.Message = fmt.Sprintf("%d ManagedClusters selected", count)
}
if err := c.updateClusterSetStatus(ctx, clusterSet, selectedCondition); err != nil {
errs = append(errs, err)
}
return operatorhelpers.NewMultiLineAggregate(errs)
}
// selectClusters returns names of managed clusters which match the cluster selector
func (c *managedClusterSetController) selectClusters(selector clusterv1alpha1.ClusterSelector) (clusterNames []string, err error) {
switch {
case len(selector.ClusterNames) > 0 && selector.LabelSelector != nil:
// return error if both ClusterNames and LabelSelector is specified for they are mutually exclusive
// This case should be handled by validating webhook
return nil, fmt.Errorf("both ClusterNames and LabelSelector is specified in ClusterSelector: %v", selector.LabelSelector)
case len(selector.ClusterNames) > 0:
// select clusters with cluster names
for _, clusterName := range selector.ClusterNames {
_, err = c.clusterLister.Get(clusterName)
switch {
case errors.IsNotFound(err):
continue
case err != nil:
return nil, fmt.Errorf("unable to fetch ManagedCluster %q: %w", clusterName, err)
default:
clusterNames = append(clusterNames, clusterName)
}
}
return clusterNames, nil
case selector.LabelSelector != nil:
// select clusters with label selector
labelSelector, err := convertLabels(selector.LabelSelector)
if err != nil {
// This case should be handled by validating webhook
return nil, fmt.Errorf("invalid label selector: %v, %w", selector.LabelSelector, err)
}
clusters, err := c.clusterLister.List(labelSelector)
if err != nil {
return nil, fmt.Errorf("unable to list ManagedClusters with label selector: %v, %w", selector.LabelSelector, err)
}
for _, cluster := range clusters {
clusterNames = append(clusterNames, cluster.Name)
}
return clusterNames, nil
default:
// no cluster selected if neither ClusterNames nor LabelSelector is specified
return clusterNames, nil
}
}
// updateClusterSetStatus updates the status of cluster set with a new status condition
// No work if the status of the cluster set does not change
func (c *managedClusterSetController) updateClusterSetStatus(ctx context.Context, clusterSet *clusterv1alpha1.ManagedClusterSet, newCondition clusterv1alpha1.StatusCondition) error {
newConditions := []clusterv1alpha1.StatusCondition{}
merged := false
for _, condition := range clusterSet.Status.Conditions {
if condition.Type == newCondition.Type {
newConditions = append(newConditions, mergeStatusCondition(condition, newCondition))
merged = true
continue
}
newConditions = append(newConditions, condition)
}
if !merged {
newCondition.LastTransitionTime = metav1.Now()
newConditions = append(newConditions, newCondition)
}
// skip update if cluster set status does not change
if reflect.DeepEqual(clusterSet.Status.Conditions, newConditions) {
return nil
}
clusterSet = clusterSet.DeepCopy()
clusterSet.Status.Conditions = newConditions
_, err := c.clusterClient.ClusterV1alpha1().ManagedClusterSets().UpdateStatus(ctx, clusterSet, metav1.UpdateOptions{})
return err
}
// convertLabels returns label
func convertLabels(labelSelector *metav1.LabelSelector) (labels.Selector, error) {
if labelSelector != nil {
selector, err := metav1.LabelSelectorAsSelector(labelSelector)
if err != nil {
return labels.Nothing(), err
}
return selector, nil
}
return labels.Everything(), nil
}
// mergeStatusCondition merges two given status conditions
func mergeStatusCondition(condition, newCondition clusterv1alpha1.StatusCondition) clusterv1alpha1.StatusCondition {
merged := clusterv1alpha1.StatusCondition{
Type: newCondition.Type,
Status: newCondition.Status,
Reason: newCondition.Reason,
Message: newCondition.Message,
}
if condition.Status == newCondition.Status {
merged.LastTransitionTime = condition.LastTransitionTime
} else {
merged.LastTransitionTime = metav1.Now()
}
return merged
}
@@ -0,0 +1,333 @@
package managedclusterset
import (
"context"
"testing"
"time"
clusterfake "github.com/open-cluster-management/api/client/cluster/clientset/versioned/fake"
clusterinformers "github.com/open-cluster-management/api/client/cluster/informers/externalversions"
clusterv1 "github.com/open-cluster-management/api/cluster/v1"
clusterv1alpha1 "github.com/open-cluster-management/api/cluster/v1alpha1"
testinghelpers "github.com/open-cluster-management/registration/pkg/helpers/testing"
"github.com/openshift/library-go/pkg/operator/events/eventstesting"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/sets"
clienttesting "k8s.io/client-go/testing"
"k8s.io/utils/diff"
)
func TestSelectClusters(t *testing.T) {
cases := []struct {
name string
existingClusters []*clusterv1.ManagedCluster
selector clusterv1alpha1.ClusterSelector
expectedSelectedClusters []string
}{
{
name: "select cluster with cluster names",
existingClusters: []*clusterv1.ManagedCluster{
newManagedCluster("cluster1", nil),
newManagedCluster("cluster2", nil),
newManagedCluster("cluster3", nil),
},
selector: clusterv1alpha1.ClusterSelector{
ClusterNames: []string{"cluster1", "cluster2"},
},
expectedSelectedClusters: []string{"cluster1", "cluster2"},
},
{
name: "select cluster with label selector",
existingClusters: []*clusterv1.ManagedCluster{
newManagedCluster("cluster1", map[string]string{"env": "dev"}),
newManagedCluster("cluster2", map[string]string{"env": "prod"}),
newManagedCluster("cluster3", map[string]string{"env": "prod"}),
},
selector: clusterv1alpha1.ClusterSelector{
LabelSelector: &metav1.LabelSelector{
MatchLabels: map[string]string{
"env": "prod",
},
},
},
expectedSelectedClusters: []string{"cluster2", "cluster3"},
},
{
name: "select no cluster",
existingClusters: []*clusterv1.ManagedCluster{
newManagedCluster("cluster1", nil),
newManagedCluster("cluster2", nil),
newManagedCluster("cluster3", nil),
},
selector: clusterv1alpha1.ClusterSelector{},
expectedSelectedClusters: nil,
},
}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
objects := []runtime.Object{}
for _, cluster := range c.existingClusters {
objects = append(objects, cluster)
}
clusterClient := clusterfake.NewSimpleClientset(objects...)
informerFactory := clusterinformers.NewSharedInformerFactory(clusterClient, 5*time.Minute)
for _, cluster := range c.existingClusters {
informerFactory.Cluster().V1().ManagedClusters().Informer().GetStore().Add(cluster)
}
ctrl := managedClusterSetController{
clusterLister: informerFactory.Cluster().V1().ManagedClusters().Lister(),
}
selectedClusters, err := ctrl.selectClusters(c.selector)
if err != nil {
t.Errorf("unexpected err: %v", err)
}
actual := sets.NewString(selectedClusters...)
expected := sets.NewString(c.expectedSelectedClusters...)
if !actual.Equal(expected) {
t.Errorf(diff.ObjectDiff(selectedClusters, c.expectedSelectedClusters))
}
})
}
}
func TestSyncManagedClusterSet(t *testing.T) {
cases := []struct {
name string
queueKey string
existingClusters []*clusterv1.ManagedCluster
existingClusterSets []*clusterv1alpha1.ManagedClusterSet
validateActions func(t *testing.T, actions []clienttesting.Action)
}{
{
name: "sync a deleted cluster set",
queueKey: "mcs1",
validateActions: func(t *testing.T, actions []clienttesting.Action) {
testinghelpers.AssertNoActions(t, actions)
},
},
{
name: "sync a deleting cluster set",
queueKey: "mcs1",
existingClusterSets: []*clusterv1alpha1.ManagedClusterSet{
newManagedClusterSet("mcs1", nil, true),
},
validateActions: func(t *testing.T, actions []clienttesting.Action) {
testinghelpers.AssertNoActions(t, actions)
},
},
{
name: "sync a cluster set with single selector",
queueKey: "mcs1",
existingClusters: []*clusterv1.ManagedCluster{
newManagedCluster("cluster1", nil),
},
existingClusterSets: []*clusterv1alpha1.ManagedClusterSet{
newManagedClusterSet("mcs1", []clusterv1alpha1.ClusterSelector{
{
ClusterNames: []string{"cluster1"},
},
}, false),
},
validateActions: func(t *testing.T, actions []clienttesting.Action) {
testinghelpers.AssertActions(t, actions, "update")
clusterSet := actions[0].(clienttesting.UpdateAction).GetObject().(*clusterv1alpha1.ManagedClusterSet)
if !hasCondition(
clusterSet.Status.Conditions,
clusterv1alpha1.ManagedClusterSetConditionEmpty,
metav1.ConditionFalse,
"ClustersSelected",
"1 ManagedClusters selected") {
t.Errorf("expected conditon is not found: %v", clusterSet.Status.Conditions)
}
},
},
{
name: "sync a cluster set with multiple selectors",
queueKey: "mcs1",
existingClusters: []*clusterv1.ManagedCluster{
newManagedCluster("cluster1", nil),
newManagedCluster("cluster2", nil),
},
existingClusterSets: []*clusterv1alpha1.ManagedClusterSet{
newManagedClusterSet("mcs1", []clusterv1alpha1.ClusterSelector{
{
ClusterNames: []string{"cluster1"},
},
{
ClusterNames: []string{"cluster2"},
},
}, false),
},
validateActions: func(t *testing.T, actions []clienttesting.Action) {
testinghelpers.AssertActions(t, actions, "update")
clusterSet := actions[0].(clienttesting.UpdateAction).GetObject().(*clusterv1alpha1.ManagedClusterSet)
if !hasCondition(
clusterSet.Status.Conditions,
clusterv1alpha1.ManagedClusterSetConditionEmpty,
metav1.ConditionFalse,
"ClustersSelected",
"2 ManagedClusters selected") {
t.Errorf("expected conditon is not found: %v", clusterSet.Status.Conditions)
}
},
},
{
name: "sync a empty cluster set",
queueKey: "mcs1",
existingClusterSets: []*clusterv1alpha1.ManagedClusterSet{
newManagedClusterSet("mcs1", []clusterv1alpha1.ClusterSelector{
{
LabelSelector: &metav1.LabelSelector{
MatchLabels: map[string]string{
"env": "dev",
},
},
},
}, false),
},
validateActions: func(t *testing.T, actions []clienttesting.Action) {
testinghelpers.AssertActions(t, actions, "update")
clusterSet := actions[0].(clienttesting.UpdateAction).GetObject().(*clusterv1alpha1.ManagedClusterSet)
if !hasCondition(
clusterSet.Status.Conditions,
clusterv1alpha1.ManagedClusterSetConditionEmpty,
metav1.ConditionTrue,
"NoClusterMatched",
"No ManagedCluster selected") {
t.Errorf("expected conditon is not found: %v", clusterSet.Status.Conditions)
}
},
},
{
name: "sync all cluster sets",
queueKey: "key",
existingClusters: []*clusterv1.ManagedCluster{
newManagedCluster("cluster1", nil),
newManagedCluster("cluster2", nil),
newManagedCluster("cluster3", nil),
},
existingClusterSets: []*clusterv1alpha1.ManagedClusterSet{
newManagedClusterSet("mcs1", []clusterv1alpha1.ClusterSelector{
{
ClusterNames: []string{"cluster1", "cluster2"},
},
}, false),
newManagedClusterSet("mcs2", []clusterv1alpha1.ClusterSelector{
{
ClusterNames: []string{"cluster3"},
},
}, false),
},
validateActions: func(t *testing.T, actions []clienttesting.Action) {
if len(actions) != 2 {
t.Errorf("expected %d actions but got: %d, %v", 2, len(actions), actions)
}
clusterSet := actions[0].(clienttesting.UpdateAction).GetObject().(*clusterv1alpha1.ManagedClusterSet)
if !hasCondition(
clusterSet.Status.Conditions,
clusterv1alpha1.ManagedClusterSetConditionEmpty,
metav1.ConditionFalse,
"ClustersSelected",
"2 ManagedClusters selected") {
t.Errorf("expected conditon is not found: %v", clusterSet.Status.Conditions)
}
clusterSet = actions[1].(clienttesting.UpdateAction).GetObject().(*clusterv1alpha1.ManagedClusterSet)
if !hasCondition(
clusterSet.Status.Conditions,
clusterv1alpha1.ManagedClusterSetConditionEmpty,
metav1.ConditionFalse,
"ClustersSelected",
"1 ManagedClusters selected") {
t.Errorf("expected conditon is not found: %v", clusterSet.Status.Conditions)
}
},
},
}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
objects := []runtime.Object{}
for _, cluster := range c.existingClusters {
objects = append(objects, cluster)
}
for _, clusterSet := range c.existingClusterSets {
objects = append(objects, clusterSet)
}
clusterClient := clusterfake.NewSimpleClientset(objects...)
informerFactory := clusterinformers.NewSharedInformerFactory(clusterClient, 5*time.Minute)
for _, cluster := range c.existingClusters {
informerFactory.Cluster().V1().ManagedClusters().Informer().GetStore().Add(cluster)
}
for _, clusterSet := range c.existingClusterSets {
informerFactory.Cluster().V1alpha1().ManagedClusterSets().Informer().GetStore().Add(clusterSet)
}
ctrl := managedClusterSetController{
clusterClient,
informerFactory.Cluster().V1().ManagedClusters().Lister(),
informerFactory.Cluster().V1alpha1().ManagedClusterSets().Lister(),
eventstesting.NewTestingEventRecorder(t)}
syncErr := ctrl.sync(context.TODO(), testinghelpers.NewFakeSyncContext(t, c.queueKey))
if syncErr != nil {
t.Errorf("unexpected err: %v", syncErr)
}
c.validateActions(t, clusterClient.Actions())
})
}
}
func newManagedCluster(name string, labels map[string]string) *clusterv1.ManagedCluster {
return &clusterv1.ManagedCluster{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Labels: labels,
},
}
}
func newManagedClusterSet(name string, clusterSelectors []clusterv1alpha1.ClusterSelector, terminating bool) *clusterv1alpha1.ManagedClusterSet {
clusterSet := &clusterv1alpha1.ManagedClusterSet{
ObjectMeta: metav1.ObjectMeta{
Name: name,
},
Spec: clusterv1alpha1.ManagedClusterSetSpec{
ClusterSelectors: clusterSelectors,
},
}
if terminating {
now := metav1.Now()
clusterSet.DeletionTimestamp = &now
}
return clusterSet
}
func hasCondition(conditions []clusterv1alpha1.StatusCondition, conditionType string, status metav1.ConditionStatus, reason, message string) bool {
for _, condition := range conditions {
if condition.Type != conditionType {
continue
}
if condition.Status != status {
continue
}
if condition.Reason != reason {
continue
}
if condition.Message != message {
continue
}
return true
}
return false
}
+9
View File
@@ -14,6 +14,7 @@ import (
"github.com/open-cluster-management/registration/pkg/hub/csr"
"github.com/open-cluster-management/registration/pkg/hub/lease"
"github.com/open-cluster-management/registration/pkg/hub/managedcluster"
"github.com/open-cluster-management/registration/pkg/hub/managedclusterset"
"github.com/open-cluster-management/registration/pkg/hub/rbacfinalizerdeletion"
kubeinformers "k8s.io/client-go/informers"
@@ -72,6 +73,13 @@ func RunControllerManager(ctx context.Context, controllerContext *controllercmd.
controllerContext.EventRecorder,
)
managedClusterSetController := managedclusterset.NewManagedClusterSetController(
clusterClient,
clusterInformers.Cluster().V1().ManagedClusters(),
clusterInformers.Cluster().V1alpha1().ManagedClusterSets(),
controllerContext.EventRecorder,
)
go clusterInformers.Start(ctx.Done())
go workInformers.Start(ctx.Done())
go kubeInfomers.Start(ctx.Done())
@@ -80,6 +88,7 @@ func RunControllerManager(ctx context.Context, controllerContext *controllercmd.
go csrController.Run(ctx, 1)
go leaseController.Run(ctx, 1)
go rbacFinalizerController.Run(ctx, 1)
go managedClusterSetController.Run(ctx, 1)
<-ctx.Done()
return nil
@@ -84,6 +84,7 @@ var _ = ginkgo.BeforeSuite(func(done ginkgo.Done) {
ErrorIfCRDPathMissing: true,
CRDDirectoryPaths: []string{
filepath.Join(".", "vendor", "github.com", "open-cluster-management", "api", "cluster", "v1"),
filepath.Join(".", "vendor", "github.com", "open-cluster-management", "api", "cluster", "v1alpha1"),
filepath.Join(".", "vendor", "github.com", "open-cluster-management", "api", "work", "v1"),
},
KubeAPIServerFlags: apiServerFlags,
@@ -0,0 +1,99 @@
package integration_test
import (
"context"
"fmt"
"github.com/onsi/ginkgo"
"github.com/onsi/gomega"
clusterv1 "github.com/open-cluster-management/api/cluster/v1"
clusterv1alpha1 "github.com/open-cluster-management/api/cluster/v1alpha1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/rand"
)
var _ = ginkgo.Describe("ManagedClusterSet", func() {
ginkgo.It("should create cluster set and keep it synced successfully ", func() {
ginkgo.By("Create a ManagedClusterSet")
managedClusterSetName := "cs1"
managedClusterSet := &clusterv1alpha1.ManagedClusterSet{
ObjectMeta: metav1.ObjectMeta{
Name: managedClusterSetName,
},
Spec: clusterv1alpha1.ManagedClusterSetSpec{
ClusterSelectors: []clusterv1alpha1.ClusterSelector{
{
LabelSelector: &metav1.LabelSelector{
MatchLabels: map[string]string{
"env": "prod",
},
},
},
},
},
}
_, err := clusterClient.ClusterV1alpha1().ManagedClusterSets().Create(context.Background(), managedClusterSet, metav1.CreateOptions{})
gomega.Expect(err).NotTo(gomega.HaveOccurred())
ginkgo.By("Check if ManagedClusterSet is reconciled")
gomega.Eventually(func() bool {
managedClusterSet, err = clusterClient.ClusterV1alpha1().ManagedClusterSets().Get(context.Background(), managedClusterSetName, metav1.GetOptions{})
if err != nil {
return false
}
for _, condition := range managedClusterSet.Status.Conditions {
if condition.Type != clusterv1alpha1.ManagedClusterSetConditionEmpty {
continue
}
if condition.Status != metav1.ConditionTrue {
return false
}
if condition.Reason != "NoClusterMatched" {
return false
}
return true
}
return false
}, eventuallyTimeout, eventuallyInterval).Should(gomega.BeTrue())
ginkgo.By("Create a ManagedCluster")
managedClusterName := fmt.Sprintf("managedcluster-%s", rand.String(6))
managedCluster := &clusterv1.ManagedCluster{
ObjectMeta: metav1.ObjectMeta{
Name: managedClusterName,
Labels: map[string]string{
"env": "prod",
},
},
Spec: clusterv1.ManagedClusterSpec{
HubAcceptsClient: true,
},
}
_, err = clusterClient.ClusterV1().ManagedClusters().Create(context.Background(), managedCluster, metav1.CreateOptions{})
gomega.Expect(err).NotTo(gomega.HaveOccurred())
ginkgo.By("Check if ManagedClusterSet is reconciled again")
gomega.Eventually(func() bool {
managedClusterSet, err = clusterClient.ClusterV1alpha1().ManagedClusterSets().Get(context.Background(), managedClusterSetName, metav1.GetOptions{})
if err != nil {
return false
}
for _, condition := range managedClusterSet.Status.Conditions {
if condition.Type != clusterv1alpha1.ManagedClusterSetConditionEmpty {
continue
}
if condition.Status != metav1.ConditionFalse {
return false
}
if condition.Reason != "ClustersSelected" {
return false
}
return true
}
return false
}, eventuallyTimeout, eventuallyInterval).Should(gomega.BeTrue())
})
})
@@ -6,6 +6,7 @@ import (
"fmt"
clusterv1 "github.com/open-cluster-management/api/client/cluster/clientset/versioned/typed/cluster/v1"
clusterv1alpha1 "github.com/open-cluster-management/api/client/cluster/clientset/versioned/typed/cluster/v1alpha1"
discovery "k8s.io/client-go/discovery"
rest "k8s.io/client-go/rest"
flowcontrol "k8s.io/client-go/util/flowcontrol"
@@ -14,13 +15,15 @@ import (
type Interface interface {
Discovery() discovery.DiscoveryInterface
ClusterV1() clusterv1.ClusterV1Interface
ClusterV1alpha1() clusterv1alpha1.ClusterV1alpha1Interface
}
// Clientset contains the clients for groups. Each group has exactly one
// version included in a Clientset.
type Clientset struct {
*discovery.DiscoveryClient
clusterV1 *clusterv1.ClusterV1Client
clusterV1 *clusterv1.ClusterV1Client
clusterV1alpha1 *clusterv1alpha1.ClusterV1alpha1Client
}
// ClusterV1 retrieves the ClusterV1Client
@@ -28,6 +31,11 @@ func (c *Clientset) ClusterV1() clusterv1.ClusterV1Interface {
return c.clusterV1
}
// ClusterV1alpha1 retrieves the ClusterV1alpha1Client
func (c *Clientset) ClusterV1alpha1() clusterv1alpha1.ClusterV1alpha1Interface {
return c.clusterV1alpha1
}
// Discovery retrieves the DiscoveryClient
func (c *Clientset) Discovery() discovery.DiscoveryInterface {
if c == nil {
@@ -53,6 +61,10 @@ func NewForConfig(c *rest.Config) (*Clientset, error) {
if err != nil {
return nil, err
}
cs.clusterV1alpha1, err = clusterv1alpha1.NewForConfig(&configShallowCopy)
if err != nil {
return nil, err
}
cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy)
if err != nil {
@@ -66,6 +78,7 @@ func NewForConfig(c *rest.Config) (*Clientset, error) {
func NewForConfigOrDie(c *rest.Config) *Clientset {
var cs Clientset
cs.clusterV1 = clusterv1.NewForConfigOrDie(c)
cs.clusterV1alpha1 = clusterv1alpha1.NewForConfigOrDie(c)
cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c)
return &cs
@@ -75,6 +88,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset {
func New(c rest.Interface) *Clientset {
var cs Clientset
cs.clusterV1 = clusterv1.New(c)
cs.clusterV1alpha1 = clusterv1alpha1.New(c)
cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
return &cs
@@ -6,6 +6,8 @@ import (
clientset "github.com/open-cluster-management/api/client/cluster/clientset/versioned"
clusterv1 "github.com/open-cluster-management/api/client/cluster/clientset/versioned/typed/cluster/v1"
fakeclusterv1 "github.com/open-cluster-management/api/client/cluster/clientset/versioned/typed/cluster/v1/fake"
clusterv1alpha1 "github.com/open-cluster-management/api/client/cluster/clientset/versioned/typed/cluster/v1alpha1"
fakeclusterv1alpha1 "github.com/open-cluster-management/api/client/cluster/clientset/versioned/typed/cluster/v1alpha1/fake"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/discovery"
@@ -64,3 +66,8 @@ var _ clientset.Interface = &Clientset{}
func (c *Clientset) ClusterV1() clusterv1.ClusterV1Interface {
return &fakeclusterv1.FakeClusterV1{Fake: &c.Fake}
}
// ClusterV1alpha1 retrieves the ClusterV1alpha1Client
func (c *Clientset) ClusterV1alpha1() clusterv1alpha1.ClusterV1alpha1Interface {
return &fakeclusterv1alpha1.FakeClusterV1alpha1{Fake: &c.Fake}
}
@@ -4,6 +4,7 @@ package fake
import (
clusterv1 "github.com/open-cluster-management/api/cluster/v1"
clusterv1alpha1 "github.com/open-cluster-management/api/cluster/v1alpha1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
schema "k8s.io/apimachinery/pkg/runtime/schema"
@@ -16,6 +17,7 @@ var codecs = serializer.NewCodecFactory(scheme)
var parameterCodec = runtime.NewParameterCodec(scheme)
var localSchemeBuilder = runtime.SchemeBuilder{
clusterv1.AddToScheme,
clusterv1alpha1.AddToScheme,
}
// AddToScheme adds all types of this clientset into the given scheme. This allows composition
@@ -4,6 +4,7 @@ package scheme
import (
clusterv1 "github.com/open-cluster-management/api/cluster/v1"
clusterv1alpha1 "github.com/open-cluster-management/api/cluster/v1alpha1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
schema "k8s.io/apimachinery/pkg/runtime/schema"
@@ -16,6 +17,7 @@ var Codecs = serializer.NewCodecFactory(Scheme)
var ParameterCodec = runtime.NewParameterCodec(Scheme)
var localSchemeBuilder = runtime.SchemeBuilder{
clusterv1.AddToScheme,
clusterv1alpha1.AddToScheme,
}
// AddToScheme adds all types of this clientset into the given scheme. This allows composition
@@ -0,0 +1,78 @@
// Code generated by client-gen. DO NOT EDIT.
package v1alpha1
import (
"github.com/open-cluster-management/api/client/cluster/clientset/versioned/scheme"
v1alpha1 "github.com/open-cluster-management/api/cluster/v1alpha1"
rest "k8s.io/client-go/rest"
)
type ClusterV1alpha1Interface interface {
RESTClient() rest.Interface
ManagedClusterSetsGetter
ManagedClusterSetBindingsGetter
}
// ClusterV1alpha1Client is used to interact with features provided by the cluster.open-cluster-management.io group.
type ClusterV1alpha1Client struct {
restClient rest.Interface
}
func (c *ClusterV1alpha1Client) ManagedClusterSets() ManagedClusterSetInterface {
return newManagedClusterSets(c)
}
func (c *ClusterV1alpha1Client) ManagedClusterSetBindings(namespace string) ManagedClusterSetBindingInterface {
return newManagedClusterSetBindings(c, namespace)
}
// NewForConfig creates a new ClusterV1alpha1Client for the given config.
func NewForConfig(c *rest.Config) (*ClusterV1alpha1Client, error) {
config := *c
if err := setConfigDefaults(&config); err != nil {
return nil, err
}
client, err := rest.RESTClientFor(&config)
if err != nil {
return nil, err
}
return &ClusterV1alpha1Client{client}, nil
}
// NewForConfigOrDie creates a new ClusterV1alpha1Client for the given config and
// panics if there is an error in the config.
func NewForConfigOrDie(c *rest.Config) *ClusterV1alpha1Client {
client, err := NewForConfig(c)
if err != nil {
panic(err)
}
return client
}
// New creates a new ClusterV1alpha1Client for the given RESTClient.
func New(c rest.Interface) *ClusterV1alpha1Client {
return &ClusterV1alpha1Client{c}
}
func setConfigDefaults(config *rest.Config) error {
gv := v1alpha1.SchemeGroupVersion
config.GroupVersion = &gv
config.APIPath = "/apis"
config.NegotiatedSerializer = scheme.Codecs.WithoutConversion()
if config.UserAgent == "" {
config.UserAgent = rest.DefaultKubernetesUserAgent()
}
return nil
}
// RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation.
func (c *ClusterV1alpha1Client) RESTClient() rest.Interface {
if c == nil {
return nil
}
return c.restClient
}
@@ -0,0 +1,4 @@
// Code generated by client-gen. DO NOT EDIT.
// This package has the automatically generated typed clients.
package v1alpha1
@@ -0,0 +1,4 @@
// Code generated by client-gen. DO NOT EDIT.
// Package fake has the automatically generated clients.
package fake
@@ -0,0 +1,28 @@
// Code generated by client-gen. DO NOT EDIT.
package fake
import (
v1alpha1 "github.com/open-cluster-management/api/client/cluster/clientset/versioned/typed/cluster/v1alpha1"
rest "k8s.io/client-go/rest"
testing "k8s.io/client-go/testing"
)
type FakeClusterV1alpha1 struct {
*testing.Fake
}
func (c *FakeClusterV1alpha1) ManagedClusterSets() v1alpha1.ManagedClusterSetInterface {
return &FakeManagedClusterSets{c}
}
func (c *FakeClusterV1alpha1) ManagedClusterSetBindings(namespace string) v1alpha1.ManagedClusterSetBindingInterface {
return &FakeManagedClusterSetBindings{c, namespace}
}
// RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation.
func (c *FakeClusterV1alpha1) RESTClient() rest.Interface {
var ret *rest.RESTClient
return ret
}
@@ -0,0 +1,117 @@
// Code generated by client-gen. DO NOT EDIT.
package fake
import (
"context"
v1alpha1 "github.com/open-cluster-management/api/cluster/v1alpha1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
labels "k8s.io/apimachinery/pkg/labels"
schema "k8s.io/apimachinery/pkg/runtime/schema"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
testing "k8s.io/client-go/testing"
)
// FakeManagedClusterSets implements ManagedClusterSetInterface
type FakeManagedClusterSets struct {
Fake *FakeClusterV1alpha1
}
var managedclustersetsResource = schema.GroupVersionResource{Group: "cluster.open-cluster-management.io", Version: "v1alpha1", Resource: "managedclustersets"}
var managedclustersetsKind = schema.GroupVersionKind{Group: "cluster.open-cluster-management.io", Version: "v1alpha1", Kind: "ManagedClusterSet"}
// Get takes name of the managedClusterSet, and returns the corresponding managedClusterSet object, and an error if there is any.
func (c *FakeManagedClusterSets) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ManagedClusterSet, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootGetAction(managedclustersetsResource, name), &v1alpha1.ManagedClusterSet{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.ManagedClusterSet), err
}
// List takes label and field selectors, and returns the list of ManagedClusterSets that match those selectors.
func (c *FakeManagedClusterSets) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ManagedClusterSetList, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootListAction(managedclustersetsResource, managedclustersetsKind, opts), &v1alpha1.ManagedClusterSetList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &v1alpha1.ManagedClusterSetList{ListMeta: obj.(*v1alpha1.ManagedClusterSetList).ListMeta}
for _, item := range obj.(*v1alpha1.ManagedClusterSetList).Items {
if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item)
}
}
return list, err
}
// Watch returns a watch.Interface that watches the requested managedClusterSets.
func (c *FakeManagedClusterSets) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewRootWatchAction(managedclustersetsResource, opts))
}
// Create takes the representation of a managedClusterSet and creates it. Returns the server's representation of the managedClusterSet, and an error, if there is any.
func (c *FakeManagedClusterSets) Create(ctx context.Context, managedClusterSet *v1alpha1.ManagedClusterSet, opts v1.CreateOptions) (result *v1alpha1.ManagedClusterSet, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootCreateAction(managedclustersetsResource, managedClusterSet), &v1alpha1.ManagedClusterSet{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.ManagedClusterSet), err
}
// Update takes the representation of a managedClusterSet and updates it. Returns the server's representation of the managedClusterSet, and an error, if there is any.
func (c *FakeManagedClusterSets) Update(ctx context.Context, managedClusterSet *v1alpha1.ManagedClusterSet, opts v1.UpdateOptions) (result *v1alpha1.ManagedClusterSet, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootUpdateAction(managedclustersetsResource, managedClusterSet), &v1alpha1.ManagedClusterSet{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.ManagedClusterSet), err
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *FakeManagedClusterSets) UpdateStatus(ctx context.Context, managedClusterSet *v1alpha1.ManagedClusterSet, opts v1.UpdateOptions) (*v1alpha1.ManagedClusterSet, error) {
obj, err := c.Fake.
Invokes(testing.NewRootUpdateSubresourceAction(managedclustersetsResource, "status", managedClusterSet), &v1alpha1.ManagedClusterSet{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.ManagedClusterSet), err
}
// Delete takes name of the managedClusterSet and deletes it. Returns an error if one occurs.
func (c *FakeManagedClusterSets) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewRootDeleteAction(managedclustersetsResource, name), &v1alpha1.ManagedClusterSet{})
return err
}
// DeleteCollection deletes a collection of objects.
func (c *FakeManagedClusterSets) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
action := testing.NewRootDeleteCollectionAction(managedclustersetsResource, listOpts)
_, err := c.Fake.Invokes(action, &v1alpha1.ManagedClusterSetList{})
return err
}
// Patch applies the patch and returns the patched managedClusterSet.
func (c *FakeManagedClusterSets) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ManagedClusterSet, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootPatchSubresourceAction(managedclustersetsResource, name, pt, data, subresources...), &v1alpha1.ManagedClusterSet{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.ManagedClusterSet), err
}
@@ -0,0 +1,114 @@
// Code generated by client-gen. DO NOT EDIT.
package fake
import (
"context"
v1alpha1 "github.com/open-cluster-management/api/cluster/v1alpha1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
labels "k8s.io/apimachinery/pkg/labels"
schema "k8s.io/apimachinery/pkg/runtime/schema"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
testing "k8s.io/client-go/testing"
)
// FakeManagedClusterSetBindings implements ManagedClusterSetBindingInterface
type FakeManagedClusterSetBindings struct {
Fake *FakeClusterV1alpha1
ns string
}
var managedclustersetbindingsResource = schema.GroupVersionResource{Group: "cluster.open-cluster-management.io", Version: "v1alpha1", Resource: "managedclustersetbindings"}
var managedclustersetbindingsKind = schema.GroupVersionKind{Group: "cluster.open-cluster-management.io", Version: "v1alpha1", Kind: "ManagedClusterSetBinding"}
// Get takes name of the managedClusterSetBinding, and returns the corresponding managedClusterSetBinding object, and an error if there is any.
func (c *FakeManagedClusterSetBindings) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ManagedClusterSetBinding, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(managedclustersetbindingsResource, c.ns, name), &v1alpha1.ManagedClusterSetBinding{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.ManagedClusterSetBinding), err
}
// List takes label and field selectors, and returns the list of ManagedClusterSetBindings that match those selectors.
func (c *FakeManagedClusterSetBindings) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ManagedClusterSetBindingList, err error) {
obj, err := c.Fake.
Invokes(testing.NewListAction(managedclustersetbindingsResource, managedclustersetbindingsKind, c.ns, opts), &v1alpha1.ManagedClusterSetBindingList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &v1alpha1.ManagedClusterSetBindingList{ListMeta: obj.(*v1alpha1.ManagedClusterSetBindingList).ListMeta}
for _, item := range obj.(*v1alpha1.ManagedClusterSetBindingList).Items {
if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item)
}
}
return list, err
}
// Watch returns a watch.Interface that watches the requested managedClusterSetBindings.
func (c *FakeManagedClusterSetBindings) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewWatchAction(managedclustersetbindingsResource, c.ns, opts))
}
// Create takes the representation of a managedClusterSetBinding and creates it. Returns the server's representation of the managedClusterSetBinding, and an error, if there is any.
func (c *FakeManagedClusterSetBindings) Create(ctx context.Context, managedClusterSetBinding *v1alpha1.ManagedClusterSetBinding, opts v1.CreateOptions) (result *v1alpha1.ManagedClusterSetBinding, err error) {
obj, err := c.Fake.
Invokes(testing.NewCreateAction(managedclustersetbindingsResource, c.ns, managedClusterSetBinding), &v1alpha1.ManagedClusterSetBinding{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.ManagedClusterSetBinding), err
}
// Update takes the representation of a managedClusterSetBinding and updates it. Returns the server's representation of the managedClusterSetBinding, and an error, if there is any.
func (c *FakeManagedClusterSetBindings) Update(ctx context.Context, managedClusterSetBinding *v1alpha1.ManagedClusterSetBinding, opts v1.UpdateOptions) (result *v1alpha1.ManagedClusterSetBinding, err error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateAction(managedclustersetbindingsResource, c.ns, managedClusterSetBinding), &v1alpha1.ManagedClusterSetBinding{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.ManagedClusterSetBinding), err
}
// Delete takes name of the managedClusterSetBinding and deletes it. Returns an error if one occurs.
func (c *FakeManagedClusterSetBindings) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewDeleteAction(managedclustersetbindingsResource, c.ns, name), &v1alpha1.ManagedClusterSetBinding{})
return err
}
// DeleteCollection deletes a collection of objects.
func (c *FakeManagedClusterSetBindings) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
action := testing.NewDeleteCollectionAction(managedclustersetbindingsResource, c.ns, listOpts)
_, err := c.Fake.Invokes(action, &v1alpha1.ManagedClusterSetBindingList{})
return err
}
// Patch applies the patch and returns the patched managedClusterSetBinding.
func (c *FakeManagedClusterSetBindings) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ManagedClusterSetBinding, err error) {
obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(managedclustersetbindingsResource, c.ns, name, pt, data, subresources...), &v1alpha1.ManagedClusterSetBinding{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.ManagedClusterSetBinding), err
}
@@ -0,0 +1,7 @@
// Code generated by client-gen. DO NOT EDIT.
package v1alpha1
type ManagedClusterSetExpansion interface{}
type ManagedClusterSetBindingExpansion interface{}
@@ -0,0 +1,168 @@
// Code generated by client-gen. DO NOT EDIT.
package v1alpha1
import (
"context"
"time"
scheme "github.com/open-cluster-management/api/client/cluster/clientset/versioned/scheme"
v1alpha1 "github.com/open-cluster-management/api/cluster/v1alpha1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
rest "k8s.io/client-go/rest"
)
// ManagedClusterSetsGetter has a method to return a ManagedClusterSetInterface.
// A group's client should implement this interface.
type ManagedClusterSetsGetter interface {
ManagedClusterSets() ManagedClusterSetInterface
}
// ManagedClusterSetInterface has methods to work with ManagedClusterSet resources.
type ManagedClusterSetInterface interface {
Create(ctx context.Context, managedClusterSet *v1alpha1.ManagedClusterSet, opts v1.CreateOptions) (*v1alpha1.ManagedClusterSet, error)
Update(ctx context.Context, managedClusterSet *v1alpha1.ManagedClusterSet, opts v1.UpdateOptions) (*v1alpha1.ManagedClusterSet, error)
UpdateStatus(ctx context.Context, managedClusterSet *v1alpha1.ManagedClusterSet, opts v1.UpdateOptions) (*v1alpha1.ManagedClusterSet, error)
Delete(ctx context.Context, name string, opts v1.DeleteOptions) error
DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error
Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.ManagedClusterSet, error)
List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.ManagedClusterSetList, error)
Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error)
Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ManagedClusterSet, err error)
ManagedClusterSetExpansion
}
// managedClusterSets implements ManagedClusterSetInterface
type managedClusterSets struct {
client rest.Interface
}
// newManagedClusterSets returns a ManagedClusterSets
func newManagedClusterSets(c *ClusterV1alpha1Client) *managedClusterSets {
return &managedClusterSets{
client: c.RESTClient(),
}
}
// Get takes name of the managedClusterSet, and returns the corresponding managedClusterSet object, and an error if there is any.
func (c *managedClusterSets) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ManagedClusterSet, err error) {
result = &v1alpha1.ManagedClusterSet{}
err = c.client.Get().
Resource("managedclustersets").
Name(name).
VersionedParams(&options, scheme.ParameterCodec).
Do(ctx).
Into(result)
return
}
// List takes label and field selectors, and returns the list of ManagedClusterSets that match those selectors.
func (c *managedClusterSets) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ManagedClusterSetList, err error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
result = &v1alpha1.ManagedClusterSetList{}
err = c.client.Get().
Resource("managedclustersets").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Do(ctx).
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested managedClusterSets.
func (c *managedClusterSets) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
opts.Watch = true
return c.client.Get().
Resource("managedclustersets").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Watch(ctx)
}
// Create takes the representation of a managedClusterSet and creates it. Returns the server's representation of the managedClusterSet, and an error, if there is any.
func (c *managedClusterSets) Create(ctx context.Context, managedClusterSet *v1alpha1.ManagedClusterSet, opts v1.CreateOptions) (result *v1alpha1.ManagedClusterSet, err error) {
result = &v1alpha1.ManagedClusterSet{}
err = c.client.Post().
Resource("managedclustersets").
VersionedParams(&opts, scheme.ParameterCodec).
Body(managedClusterSet).
Do(ctx).
Into(result)
return
}
// Update takes the representation of a managedClusterSet and updates it. Returns the server's representation of the managedClusterSet, and an error, if there is any.
func (c *managedClusterSets) Update(ctx context.Context, managedClusterSet *v1alpha1.ManagedClusterSet, opts v1.UpdateOptions) (result *v1alpha1.ManagedClusterSet, err error) {
result = &v1alpha1.ManagedClusterSet{}
err = c.client.Put().
Resource("managedclustersets").
Name(managedClusterSet.Name).
VersionedParams(&opts, scheme.ParameterCodec).
Body(managedClusterSet).
Do(ctx).
Into(result)
return
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *managedClusterSets) UpdateStatus(ctx context.Context, managedClusterSet *v1alpha1.ManagedClusterSet, opts v1.UpdateOptions) (result *v1alpha1.ManagedClusterSet, err error) {
result = &v1alpha1.ManagedClusterSet{}
err = c.client.Put().
Resource("managedclustersets").
Name(managedClusterSet.Name).
SubResource("status").
VersionedParams(&opts, scheme.ParameterCodec).
Body(managedClusterSet).
Do(ctx).
Into(result)
return
}
// Delete takes name of the managedClusterSet and deletes it. Returns an error if one occurs.
func (c *managedClusterSets) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
return c.client.Delete().
Resource("managedclustersets").
Name(name).
Body(&opts).
Do(ctx).
Error()
}
// DeleteCollection deletes a collection of objects.
func (c *managedClusterSets) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
var timeout time.Duration
if listOpts.TimeoutSeconds != nil {
timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second
}
return c.client.Delete().
Resource("managedclustersets").
VersionedParams(&listOpts, scheme.ParameterCodec).
Timeout(timeout).
Body(&opts).
Do(ctx).
Error()
}
// Patch applies the patch and returns the patched managedClusterSet.
func (c *managedClusterSets) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ManagedClusterSet, err error) {
result = &v1alpha1.ManagedClusterSet{}
err = c.client.Patch(pt).
Resource("managedclustersets").
Name(name).
SubResource(subresources...).
VersionedParams(&opts, scheme.ParameterCodec).
Body(data).
Do(ctx).
Into(result)
return
}
@@ -0,0 +1,162 @@
// Code generated by client-gen. DO NOT EDIT.
package v1alpha1
import (
"context"
"time"
scheme "github.com/open-cluster-management/api/client/cluster/clientset/versioned/scheme"
v1alpha1 "github.com/open-cluster-management/api/cluster/v1alpha1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
rest "k8s.io/client-go/rest"
)
// ManagedClusterSetBindingsGetter has a method to return a ManagedClusterSetBindingInterface.
// A group's client should implement this interface.
type ManagedClusterSetBindingsGetter interface {
ManagedClusterSetBindings(namespace string) ManagedClusterSetBindingInterface
}
// ManagedClusterSetBindingInterface has methods to work with ManagedClusterSetBinding resources.
type ManagedClusterSetBindingInterface interface {
Create(ctx context.Context, managedClusterSetBinding *v1alpha1.ManagedClusterSetBinding, opts v1.CreateOptions) (*v1alpha1.ManagedClusterSetBinding, error)
Update(ctx context.Context, managedClusterSetBinding *v1alpha1.ManagedClusterSetBinding, opts v1.UpdateOptions) (*v1alpha1.ManagedClusterSetBinding, error)
Delete(ctx context.Context, name string, opts v1.DeleteOptions) error
DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error
Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.ManagedClusterSetBinding, error)
List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.ManagedClusterSetBindingList, error)
Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error)
Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ManagedClusterSetBinding, err error)
ManagedClusterSetBindingExpansion
}
// managedClusterSetBindings implements ManagedClusterSetBindingInterface
type managedClusterSetBindings struct {
client rest.Interface
ns string
}
// newManagedClusterSetBindings returns a ManagedClusterSetBindings
func newManagedClusterSetBindings(c *ClusterV1alpha1Client, namespace string) *managedClusterSetBindings {
return &managedClusterSetBindings{
client: c.RESTClient(),
ns: namespace,
}
}
// Get takes name of the managedClusterSetBinding, and returns the corresponding managedClusterSetBinding object, and an error if there is any.
func (c *managedClusterSetBindings) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ManagedClusterSetBinding, err error) {
result = &v1alpha1.ManagedClusterSetBinding{}
err = c.client.Get().
Namespace(c.ns).
Resource("managedclustersetbindings").
Name(name).
VersionedParams(&options, scheme.ParameterCodec).
Do(ctx).
Into(result)
return
}
// List takes label and field selectors, and returns the list of ManagedClusterSetBindings that match those selectors.
func (c *managedClusterSetBindings) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ManagedClusterSetBindingList, err error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
result = &v1alpha1.ManagedClusterSetBindingList{}
err = c.client.Get().
Namespace(c.ns).
Resource("managedclustersetbindings").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Do(ctx).
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested managedClusterSetBindings.
func (c *managedClusterSetBindings) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
opts.Watch = true
return c.client.Get().
Namespace(c.ns).
Resource("managedclustersetbindings").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Watch(ctx)
}
// Create takes the representation of a managedClusterSetBinding and creates it. Returns the server's representation of the managedClusterSetBinding, and an error, if there is any.
func (c *managedClusterSetBindings) Create(ctx context.Context, managedClusterSetBinding *v1alpha1.ManagedClusterSetBinding, opts v1.CreateOptions) (result *v1alpha1.ManagedClusterSetBinding, err error) {
result = &v1alpha1.ManagedClusterSetBinding{}
err = c.client.Post().
Namespace(c.ns).
Resource("managedclustersetbindings").
VersionedParams(&opts, scheme.ParameterCodec).
Body(managedClusterSetBinding).
Do(ctx).
Into(result)
return
}
// Update takes the representation of a managedClusterSetBinding and updates it. Returns the server's representation of the managedClusterSetBinding, and an error, if there is any.
func (c *managedClusterSetBindings) Update(ctx context.Context, managedClusterSetBinding *v1alpha1.ManagedClusterSetBinding, opts v1.UpdateOptions) (result *v1alpha1.ManagedClusterSetBinding, err error) {
result = &v1alpha1.ManagedClusterSetBinding{}
err = c.client.Put().
Namespace(c.ns).
Resource("managedclustersetbindings").
Name(managedClusterSetBinding.Name).
VersionedParams(&opts, scheme.ParameterCodec).
Body(managedClusterSetBinding).
Do(ctx).
Into(result)
return
}
// Delete takes name of the managedClusterSetBinding and deletes it. Returns an error if one occurs.
func (c *managedClusterSetBindings) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
return c.client.Delete().
Namespace(c.ns).
Resource("managedclustersetbindings").
Name(name).
Body(&opts).
Do(ctx).
Error()
}
// DeleteCollection deletes a collection of objects.
func (c *managedClusterSetBindings) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
var timeout time.Duration
if listOpts.TimeoutSeconds != nil {
timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second
}
return c.client.Delete().
Namespace(c.ns).
Resource("managedclustersetbindings").
VersionedParams(&listOpts, scheme.ParameterCodec).
Timeout(timeout).
Body(&opts).
Do(ctx).
Error()
}
// Patch applies the patch and returns the patched managedClusterSetBinding.
func (c *managedClusterSetBindings) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ManagedClusterSetBinding, err error) {
result = &v1alpha1.ManagedClusterSetBinding{}
err = c.client.Patch(pt).
Namespace(c.ns).
Resource("managedclustersetbindings").
Name(name).
SubResource(subresources...).
VersionedParams(&opts, scheme.ParameterCodec).
Body(data).
Do(ctx).
Into(result)
return
}
@@ -4,6 +4,7 @@ package cluster
import (
v1 "github.com/open-cluster-management/api/client/cluster/informers/externalversions/cluster/v1"
v1alpha1 "github.com/open-cluster-management/api/client/cluster/informers/externalversions/cluster/v1alpha1"
internalinterfaces "github.com/open-cluster-management/api/client/cluster/informers/externalversions/internalinterfaces"
)
@@ -11,6 +12,8 @@ import (
type Interface interface {
// V1 provides access to shared informers for resources in V1.
V1() v1.Interface
// V1alpha1 provides access to shared informers for resources in V1alpha1.
V1alpha1() v1alpha1.Interface
}
type group struct {
@@ -28,3 +31,8 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList
func (g *group) V1() v1.Interface {
return v1.New(g.factory, g.namespace, g.tweakListOptions)
}
// V1alpha1 returns a new v1alpha1.Interface.
func (g *group) V1alpha1() v1alpha1.Interface {
return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions)
}
@@ -0,0 +1,36 @@
// Code generated by informer-gen. DO NOT EDIT.
package v1alpha1
import (
internalinterfaces "github.com/open-cluster-management/api/client/cluster/informers/externalversions/internalinterfaces"
)
// Interface provides access to all the informers in this group version.
type Interface interface {
// ManagedClusterSets returns a ManagedClusterSetInformer.
ManagedClusterSets() ManagedClusterSetInformer
// ManagedClusterSetBindings returns a ManagedClusterSetBindingInformer.
ManagedClusterSetBindings() ManagedClusterSetBindingInformer
}
type version struct {
factory internalinterfaces.SharedInformerFactory
namespace string
tweakListOptions internalinterfaces.TweakListOptionsFunc
}
// New returns a new Interface.
func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface {
return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions}
}
// ManagedClusterSets returns a ManagedClusterSetInformer.
func (v *version) ManagedClusterSets() ManagedClusterSetInformer {
return &managedClusterSetInformer{factory: v.factory, tweakListOptions: v.tweakListOptions}
}
// ManagedClusterSetBindings returns a ManagedClusterSetBindingInformer.
func (v *version) ManagedClusterSetBindings() ManagedClusterSetBindingInformer {
return &managedClusterSetBindingInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
}
@@ -0,0 +1,73 @@
// Code generated by informer-gen. DO NOT EDIT.
package v1alpha1
import (
"context"
time "time"
versioned "github.com/open-cluster-management/api/client/cluster/clientset/versioned"
internalinterfaces "github.com/open-cluster-management/api/client/cluster/informers/externalversions/internalinterfaces"
v1alpha1 "github.com/open-cluster-management/api/client/cluster/listers/cluster/v1alpha1"
clusterv1alpha1 "github.com/open-cluster-management/api/cluster/v1alpha1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
watch "k8s.io/apimachinery/pkg/watch"
cache "k8s.io/client-go/tools/cache"
)
// ManagedClusterSetInformer provides access to a shared informer and lister for
// ManagedClusterSets.
type ManagedClusterSetInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1alpha1.ManagedClusterSetLister
}
type managedClusterSetInformer struct {
factory internalinterfaces.SharedInformerFactory
tweakListOptions internalinterfaces.TweakListOptionsFunc
}
// NewManagedClusterSetInformer constructs a new informer for ManagedClusterSet type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewManagedClusterSetInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
return NewFilteredManagedClusterSetInformer(client, resyncPeriod, indexers, nil)
}
// NewFilteredManagedClusterSetInformer constructs a new informer for ManagedClusterSet type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewFilteredManagedClusterSetInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
return cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.ClusterV1alpha1().ManagedClusterSets().List(context.TODO(), options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.ClusterV1alpha1().ManagedClusterSets().Watch(context.TODO(), options)
},
},
&clusterv1alpha1.ManagedClusterSet{},
resyncPeriod,
indexers,
)
}
func (f *managedClusterSetInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewFilteredManagedClusterSetInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
}
func (f *managedClusterSetInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&clusterv1alpha1.ManagedClusterSet{}, f.defaultInformer)
}
func (f *managedClusterSetInformer) Lister() v1alpha1.ManagedClusterSetLister {
return v1alpha1.NewManagedClusterSetLister(f.Informer().GetIndexer())
}
@@ -0,0 +1,74 @@
// Code generated by informer-gen. DO NOT EDIT.
package v1alpha1
import (
"context"
time "time"
versioned "github.com/open-cluster-management/api/client/cluster/clientset/versioned"
internalinterfaces "github.com/open-cluster-management/api/client/cluster/informers/externalversions/internalinterfaces"
v1alpha1 "github.com/open-cluster-management/api/client/cluster/listers/cluster/v1alpha1"
clusterv1alpha1 "github.com/open-cluster-management/api/cluster/v1alpha1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
watch "k8s.io/apimachinery/pkg/watch"
cache "k8s.io/client-go/tools/cache"
)
// ManagedClusterSetBindingInformer provides access to a shared informer and lister for
// ManagedClusterSetBindings.
type ManagedClusterSetBindingInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1alpha1.ManagedClusterSetBindingLister
}
type managedClusterSetBindingInformer struct {
factory internalinterfaces.SharedInformerFactory
tweakListOptions internalinterfaces.TweakListOptionsFunc
namespace string
}
// NewManagedClusterSetBindingInformer constructs a new informer for ManagedClusterSetBinding type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewManagedClusterSetBindingInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
return NewFilteredManagedClusterSetBindingInformer(client, namespace, resyncPeriod, indexers, nil)
}
// NewFilteredManagedClusterSetBindingInformer constructs a new informer for ManagedClusterSetBinding type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewFilteredManagedClusterSetBindingInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
return cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.ClusterV1alpha1().ManagedClusterSetBindings(namespace).List(context.TODO(), options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.ClusterV1alpha1().ManagedClusterSetBindings(namespace).Watch(context.TODO(), options)
},
},
&clusterv1alpha1.ManagedClusterSetBinding{},
resyncPeriod,
indexers,
)
}
func (f *managedClusterSetBindingInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewFilteredManagedClusterSetBindingInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
}
func (f *managedClusterSetBindingInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&clusterv1alpha1.ManagedClusterSetBinding{}, f.defaultInformer)
}
func (f *managedClusterSetBindingInformer) Lister() v1alpha1.ManagedClusterSetBindingLister {
return v1alpha1.NewManagedClusterSetBindingLister(f.Informer().GetIndexer())
}
@@ -6,6 +6,7 @@ import (
"fmt"
v1 "github.com/open-cluster-management/api/cluster/v1"
v1alpha1 "github.com/open-cluster-management/api/cluster/v1alpha1"
schema "k8s.io/apimachinery/pkg/runtime/schema"
cache "k8s.io/client-go/tools/cache"
)
@@ -40,6 +41,12 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource
case v1.SchemeGroupVersion.WithResource("managedclusters"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Cluster().V1().ManagedClusters().Informer()}, nil
// Group=cluster.open-cluster-management.io, Version=v1alpha1
case v1alpha1.SchemeGroupVersion.WithResource("managedclustersets"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Cluster().V1alpha1().ManagedClusterSets().Informer()}, nil
case v1alpha1.SchemeGroupVersion.WithResource("managedclustersetbindings"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Cluster().V1alpha1().ManagedClusterSetBindings().Informer()}, nil
}
return nil, fmt.Errorf("no informer found for %v", resource)
@@ -0,0 +1,15 @@
// Code generated by lister-gen. DO NOT EDIT.
package v1alpha1
// ManagedClusterSetListerExpansion allows custom methods to be added to
// ManagedClusterSetLister.
type ManagedClusterSetListerExpansion interface{}
// ManagedClusterSetBindingListerExpansion allows custom methods to be added to
// ManagedClusterSetBindingLister.
type ManagedClusterSetBindingListerExpansion interface{}
// ManagedClusterSetBindingNamespaceListerExpansion allows custom methods to be added to
// ManagedClusterSetBindingNamespaceLister.
type ManagedClusterSetBindingNamespaceListerExpansion interface{}
@@ -0,0 +1,49 @@
// Code generated by lister-gen. DO NOT EDIT.
package v1alpha1
import (
v1alpha1 "github.com/open-cluster-management/api/cluster/v1alpha1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/tools/cache"
)
// ManagedClusterSetLister helps list ManagedClusterSets.
type ManagedClusterSetLister interface {
// List lists all ManagedClusterSets in the indexer.
List(selector labels.Selector) (ret []*v1alpha1.ManagedClusterSet, err error)
// Get retrieves the ManagedClusterSet from the index for a given name.
Get(name string) (*v1alpha1.ManagedClusterSet, error)
ManagedClusterSetListerExpansion
}
// managedClusterSetLister implements the ManagedClusterSetLister interface.
type managedClusterSetLister struct {
indexer cache.Indexer
}
// NewManagedClusterSetLister returns a new ManagedClusterSetLister.
func NewManagedClusterSetLister(indexer cache.Indexer) ManagedClusterSetLister {
return &managedClusterSetLister{indexer: indexer}
}
// List lists all ManagedClusterSets in the indexer.
func (s *managedClusterSetLister) List(selector labels.Selector) (ret []*v1alpha1.ManagedClusterSet, err error) {
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
ret = append(ret, m.(*v1alpha1.ManagedClusterSet))
})
return ret, err
}
// Get retrieves the ManagedClusterSet from the index for a given name.
func (s *managedClusterSetLister) Get(name string) (*v1alpha1.ManagedClusterSet, error) {
obj, exists, err := s.indexer.GetByKey(name)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(v1alpha1.Resource("managedclusterset"), name)
}
return obj.(*v1alpha1.ManagedClusterSet), nil
}
@@ -0,0 +1,78 @@
// Code generated by lister-gen. DO NOT EDIT.
package v1alpha1
import (
v1alpha1 "github.com/open-cluster-management/api/cluster/v1alpha1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/tools/cache"
)
// ManagedClusterSetBindingLister helps list ManagedClusterSetBindings.
type ManagedClusterSetBindingLister interface {
// List lists all ManagedClusterSetBindings in the indexer.
List(selector labels.Selector) (ret []*v1alpha1.ManagedClusterSetBinding, err error)
// ManagedClusterSetBindings returns an object that can list and get ManagedClusterSetBindings.
ManagedClusterSetBindings(namespace string) ManagedClusterSetBindingNamespaceLister
ManagedClusterSetBindingListerExpansion
}
// managedClusterSetBindingLister implements the ManagedClusterSetBindingLister interface.
type managedClusterSetBindingLister struct {
indexer cache.Indexer
}
// NewManagedClusterSetBindingLister returns a new ManagedClusterSetBindingLister.
func NewManagedClusterSetBindingLister(indexer cache.Indexer) ManagedClusterSetBindingLister {
return &managedClusterSetBindingLister{indexer: indexer}
}
// List lists all ManagedClusterSetBindings in the indexer.
func (s *managedClusterSetBindingLister) List(selector labels.Selector) (ret []*v1alpha1.ManagedClusterSetBinding, err error) {
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
ret = append(ret, m.(*v1alpha1.ManagedClusterSetBinding))
})
return ret, err
}
// ManagedClusterSetBindings returns an object that can list and get ManagedClusterSetBindings.
func (s *managedClusterSetBindingLister) ManagedClusterSetBindings(namespace string) ManagedClusterSetBindingNamespaceLister {
return managedClusterSetBindingNamespaceLister{indexer: s.indexer, namespace: namespace}
}
// ManagedClusterSetBindingNamespaceLister helps list and get ManagedClusterSetBindings.
type ManagedClusterSetBindingNamespaceLister interface {
// List lists all ManagedClusterSetBindings in the indexer for a given namespace.
List(selector labels.Selector) (ret []*v1alpha1.ManagedClusterSetBinding, err error)
// Get retrieves the ManagedClusterSetBinding from the indexer for a given namespace and name.
Get(name string) (*v1alpha1.ManagedClusterSetBinding, error)
ManagedClusterSetBindingNamespaceListerExpansion
}
// managedClusterSetBindingNamespaceLister implements the ManagedClusterSetBindingNamespaceLister
// interface.
type managedClusterSetBindingNamespaceLister struct {
indexer cache.Indexer
namespace string
}
// List lists all ManagedClusterSetBindings in the indexer for a given namespace.
func (s managedClusterSetBindingNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.ManagedClusterSetBinding, err error) {
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
ret = append(ret, m.(*v1alpha1.ManagedClusterSetBinding))
})
return ret, err
}
// Get retrieves the ManagedClusterSetBinding from the indexer for a given namespace and name.
func (s managedClusterSetBindingNamespaceLister) Get(name string) (*v1alpha1.ManagedClusterSetBinding, error) {
obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(v1alpha1.Resource("managedclustersetbinding"), name)
}
return obj.(*v1alpha1.ManagedClusterSetBinding), nil
}
@@ -0,0 +1,168 @@
// Code generated by client-gen. DO NOT EDIT.
package v1
import (
"context"
"time"
scheme "github.com/open-cluster-management/api/client/work/clientset/versioned/scheme"
v1 "github.com/open-cluster-management/api/work/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
rest "k8s.io/client-go/rest"
)
// AppliedManifestWorksGetter has a method to return a AppliedManifestWorkInterface.
// A group's client should implement this interface.
type AppliedManifestWorksGetter interface {
AppliedManifestWorks() AppliedManifestWorkInterface
}
// AppliedManifestWorkInterface has methods to work with AppliedManifestWork resources.
type AppliedManifestWorkInterface interface {
Create(ctx context.Context, appliedManifestWork *v1.AppliedManifestWork, opts metav1.CreateOptions) (*v1.AppliedManifestWork, error)
Update(ctx context.Context, appliedManifestWork *v1.AppliedManifestWork, opts metav1.UpdateOptions) (*v1.AppliedManifestWork, error)
UpdateStatus(ctx context.Context, appliedManifestWork *v1.AppliedManifestWork, opts metav1.UpdateOptions) (*v1.AppliedManifestWork, error)
Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error
DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error
Get(ctx context.Context, name string, opts metav1.GetOptions) (*v1.AppliedManifestWork, error)
List(ctx context.Context, opts metav1.ListOptions) (*v1.AppliedManifestWorkList, error)
Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error)
Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.AppliedManifestWork, err error)
AppliedManifestWorkExpansion
}
// appliedManifestWorks implements AppliedManifestWorkInterface
type appliedManifestWorks struct {
client rest.Interface
}
// newAppliedManifestWorks returns a AppliedManifestWorks
func newAppliedManifestWorks(c *WorkV1Client) *appliedManifestWorks {
return &appliedManifestWorks{
client: c.RESTClient(),
}
}
// Get takes name of the appliedManifestWork, and returns the corresponding appliedManifestWork object, and an error if there is any.
func (c *appliedManifestWorks) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.AppliedManifestWork, err error) {
result = &v1.AppliedManifestWork{}
err = c.client.Get().
Resource("appliedmanifestworks").
Name(name).
VersionedParams(&options, scheme.ParameterCodec).
Do(ctx).
Into(result)
return
}
// List takes label and field selectors, and returns the list of AppliedManifestWorks that match those selectors.
func (c *appliedManifestWorks) List(ctx context.Context, opts metav1.ListOptions) (result *v1.AppliedManifestWorkList, err error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
result = &v1.AppliedManifestWorkList{}
err = c.client.Get().
Resource("appliedmanifestworks").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Do(ctx).
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested appliedManifestWorks.
func (c *appliedManifestWorks) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
opts.Watch = true
return c.client.Get().
Resource("appliedmanifestworks").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Watch(ctx)
}
// Create takes the representation of a appliedManifestWork and creates it. Returns the server's representation of the appliedManifestWork, and an error, if there is any.
func (c *appliedManifestWorks) Create(ctx context.Context, appliedManifestWork *v1.AppliedManifestWork, opts metav1.CreateOptions) (result *v1.AppliedManifestWork, err error) {
result = &v1.AppliedManifestWork{}
err = c.client.Post().
Resource("appliedmanifestworks").
VersionedParams(&opts, scheme.ParameterCodec).
Body(appliedManifestWork).
Do(ctx).
Into(result)
return
}
// Update takes the representation of a appliedManifestWork and updates it. Returns the server's representation of the appliedManifestWork, and an error, if there is any.
func (c *appliedManifestWorks) Update(ctx context.Context, appliedManifestWork *v1.AppliedManifestWork, opts metav1.UpdateOptions) (result *v1.AppliedManifestWork, err error) {
result = &v1.AppliedManifestWork{}
err = c.client.Put().
Resource("appliedmanifestworks").
Name(appliedManifestWork.Name).
VersionedParams(&opts, scheme.ParameterCodec).
Body(appliedManifestWork).
Do(ctx).
Into(result)
return
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *appliedManifestWorks) UpdateStatus(ctx context.Context, appliedManifestWork *v1.AppliedManifestWork, opts metav1.UpdateOptions) (result *v1.AppliedManifestWork, err error) {
result = &v1.AppliedManifestWork{}
err = c.client.Put().
Resource("appliedmanifestworks").
Name(appliedManifestWork.Name).
SubResource("status").
VersionedParams(&opts, scheme.ParameterCodec).
Body(appliedManifestWork).
Do(ctx).
Into(result)
return
}
// Delete takes name of the appliedManifestWork and deletes it. Returns an error if one occurs.
func (c *appliedManifestWorks) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error {
return c.client.Delete().
Resource("appliedmanifestworks").
Name(name).
Body(&opts).
Do(ctx).
Error()
}
// DeleteCollection deletes a collection of objects.
func (c *appliedManifestWorks) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error {
var timeout time.Duration
if listOpts.TimeoutSeconds != nil {
timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second
}
return c.client.Delete().
Resource("appliedmanifestworks").
VersionedParams(&listOpts, scheme.ParameterCodec).
Timeout(timeout).
Body(&opts).
Do(ctx).
Error()
}
// Patch applies the patch and returns the patched appliedManifestWork.
func (c *appliedManifestWorks) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.AppliedManifestWork, err error) {
result = &v1.AppliedManifestWork{}
err = c.client.Patch(pt).
Resource("appliedmanifestworks").
Name(name).
SubResource(subresources...).
VersionedParams(&opts, scheme.ParameterCodec).
Body(data).
Do(ctx).
Into(result)
return
}
@@ -0,0 +1,117 @@
// Code generated by client-gen. DO NOT EDIT.
package fake
import (
"context"
workv1 "github.com/open-cluster-management/api/work/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
labels "k8s.io/apimachinery/pkg/labels"
schema "k8s.io/apimachinery/pkg/runtime/schema"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
testing "k8s.io/client-go/testing"
)
// FakeAppliedManifestWorks implements AppliedManifestWorkInterface
type FakeAppliedManifestWorks struct {
Fake *FakeWorkV1
}
var appliedmanifestworksResource = schema.GroupVersionResource{Group: "work.open-cluster-management.io", Version: "v1", Resource: "appliedmanifestworks"}
var appliedmanifestworksKind = schema.GroupVersionKind{Group: "work.open-cluster-management.io", Version: "v1", Kind: "AppliedManifestWork"}
// Get takes name of the appliedManifestWork, and returns the corresponding appliedManifestWork object, and an error if there is any.
func (c *FakeAppliedManifestWorks) Get(ctx context.Context, name string, options v1.GetOptions) (result *workv1.AppliedManifestWork, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootGetAction(appliedmanifestworksResource, name), &workv1.AppliedManifestWork{})
if obj == nil {
return nil, err
}
return obj.(*workv1.AppliedManifestWork), err
}
// List takes label and field selectors, and returns the list of AppliedManifestWorks that match those selectors.
func (c *FakeAppliedManifestWorks) List(ctx context.Context, opts v1.ListOptions) (result *workv1.AppliedManifestWorkList, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootListAction(appliedmanifestworksResource, appliedmanifestworksKind, opts), &workv1.AppliedManifestWorkList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &workv1.AppliedManifestWorkList{ListMeta: obj.(*workv1.AppliedManifestWorkList).ListMeta}
for _, item := range obj.(*workv1.AppliedManifestWorkList).Items {
if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item)
}
}
return list, err
}
// Watch returns a watch.Interface that watches the requested appliedManifestWorks.
func (c *FakeAppliedManifestWorks) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewRootWatchAction(appliedmanifestworksResource, opts))
}
// Create takes the representation of a appliedManifestWork and creates it. Returns the server's representation of the appliedManifestWork, and an error, if there is any.
func (c *FakeAppliedManifestWorks) Create(ctx context.Context, appliedManifestWork *workv1.AppliedManifestWork, opts v1.CreateOptions) (result *workv1.AppliedManifestWork, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootCreateAction(appliedmanifestworksResource, appliedManifestWork), &workv1.AppliedManifestWork{})
if obj == nil {
return nil, err
}
return obj.(*workv1.AppliedManifestWork), err
}
// Update takes the representation of a appliedManifestWork and updates it. Returns the server's representation of the appliedManifestWork, and an error, if there is any.
func (c *FakeAppliedManifestWorks) Update(ctx context.Context, appliedManifestWork *workv1.AppliedManifestWork, opts v1.UpdateOptions) (result *workv1.AppliedManifestWork, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootUpdateAction(appliedmanifestworksResource, appliedManifestWork), &workv1.AppliedManifestWork{})
if obj == nil {
return nil, err
}
return obj.(*workv1.AppliedManifestWork), err
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *FakeAppliedManifestWorks) UpdateStatus(ctx context.Context, appliedManifestWork *workv1.AppliedManifestWork, opts v1.UpdateOptions) (*workv1.AppliedManifestWork, error) {
obj, err := c.Fake.
Invokes(testing.NewRootUpdateSubresourceAction(appliedmanifestworksResource, "status", appliedManifestWork), &workv1.AppliedManifestWork{})
if obj == nil {
return nil, err
}
return obj.(*workv1.AppliedManifestWork), err
}
// Delete takes name of the appliedManifestWork and deletes it. Returns an error if one occurs.
func (c *FakeAppliedManifestWorks) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewRootDeleteAction(appliedmanifestworksResource, name), &workv1.AppliedManifestWork{})
return err
}
// DeleteCollection deletes a collection of objects.
func (c *FakeAppliedManifestWorks) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
action := testing.NewRootDeleteCollectionAction(appliedmanifestworksResource, listOpts)
_, err := c.Fake.Invokes(action, &workv1.AppliedManifestWorkList{})
return err
}
// Patch applies the patch and returns the patched appliedManifestWork.
func (c *FakeAppliedManifestWorks) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *workv1.AppliedManifestWork, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootPatchSubresourceAction(appliedmanifestworksResource, name, pt, data, subresources...), &workv1.AppliedManifestWork{})
if obj == nil {
return nil, err
}
return obj.(*workv1.AppliedManifestWork), err
}
@@ -12,6 +12,10 @@ type FakeWorkV1 struct {
*testing.Fake
}
func (c *FakeWorkV1) AppliedManifestWorks() v1.AppliedManifestWorkInterface {
return &FakeAppliedManifestWorks{c}
}
func (c *FakeWorkV1) ManifestWorks(namespace string) v1.ManifestWorkInterface {
return &FakeManifestWorks{c, namespace}
}
@@ -2,4 +2,6 @@
package v1
type AppliedManifestWorkExpansion interface{}
type ManifestWorkExpansion interface{}
@@ -10,6 +10,7 @@ import (
type WorkV1Interface interface {
RESTClient() rest.Interface
AppliedManifestWorksGetter
ManifestWorksGetter
}
@@ -18,6 +19,10 @@ type WorkV1Client struct {
restClient rest.Interface
}
func (c *WorkV1Client) AppliedManifestWorks() AppliedManifestWorkInterface {
return newAppliedManifestWorks(c)
}
func (c *WorkV1Client) ManifestWorks(namespace string) ManifestWorkInterface {
return newManifestWorks(c, namespace)
}
@@ -37,6 +37,8 @@ func (f *genericInformer) Lister() cache.GenericLister {
func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) {
switch resource {
// Group=work.open-cluster-management.io, Version=v1
case v1.SchemeGroupVersion.WithResource("appliedmanifestworks"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Work().V1().AppliedManifestWorks().Informer()}, nil
case v1.SchemeGroupVersion.WithResource("manifestworks"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Work().V1().ManifestWorks().Informer()}, nil
@@ -0,0 +1,73 @@
// Code generated by informer-gen. DO NOT EDIT.
package v1
import (
"context"
time "time"
versioned "github.com/open-cluster-management/api/client/work/clientset/versioned"
internalinterfaces "github.com/open-cluster-management/api/client/work/informers/externalversions/internalinterfaces"
v1 "github.com/open-cluster-management/api/client/work/listers/work/v1"
workv1 "github.com/open-cluster-management/api/work/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
watch "k8s.io/apimachinery/pkg/watch"
cache "k8s.io/client-go/tools/cache"
)
// AppliedManifestWorkInformer provides access to a shared informer and lister for
// AppliedManifestWorks.
type AppliedManifestWorkInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1.AppliedManifestWorkLister
}
type appliedManifestWorkInformer struct {
factory internalinterfaces.SharedInformerFactory
tweakListOptions internalinterfaces.TweakListOptionsFunc
}
// NewAppliedManifestWorkInformer constructs a new informer for AppliedManifestWork type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewAppliedManifestWorkInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
return NewFilteredAppliedManifestWorkInformer(client, resyncPeriod, indexers, nil)
}
// NewFilteredAppliedManifestWorkInformer constructs a new informer for AppliedManifestWork type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewFilteredAppliedManifestWorkInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
return cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.WorkV1().AppliedManifestWorks().List(context.TODO(), options)
},
WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.WorkV1().AppliedManifestWorks().Watch(context.TODO(), options)
},
},
&workv1.AppliedManifestWork{},
resyncPeriod,
indexers,
)
}
func (f *appliedManifestWorkInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewFilteredAppliedManifestWorkInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
}
func (f *appliedManifestWorkInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&workv1.AppliedManifestWork{}, f.defaultInformer)
}
func (f *appliedManifestWorkInformer) Lister() v1.AppliedManifestWorkLister {
return v1.NewAppliedManifestWorkLister(f.Informer().GetIndexer())
}
@@ -8,6 +8,8 @@ import (
// Interface provides access to all the informers in this group version.
type Interface interface {
// AppliedManifestWorks returns a AppliedManifestWorkInformer.
AppliedManifestWorks() AppliedManifestWorkInformer
// ManifestWorks returns a ManifestWorkInformer.
ManifestWorks() ManifestWorkInformer
}
@@ -23,6 +25,11 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList
return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions}
}
// AppliedManifestWorks returns a AppliedManifestWorkInformer.
func (v *version) AppliedManifestWorks() AppliedManifestWorkInformer {
return &appliedManifestWorkInformer{factory: v.factory, tweakListOptions: v.tweakListOptions}
}
// ManifestWorks returns a ManifestWorkInformer.
func (v *version) ManifestWorks() ManifestWorkInformer {
return &manifestWorkInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
@@ -0,0 +1,49 @@
// Code generated by lister-gen. DO NOT EDIT.
package v1
import (
v1 "github.com/open-cluster-management/api/work/v1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/tools/cache"
)
// AppliedManifestWorkLister helps list AppliedManifestWorks.
type AppliedManifestWorkLister interface {
// List lists all AppliedManifestWorks in the indexer.
List(selector labels.Selector) (ret []*v1.AppliedManifestWork, err error)
// Get retrieves the AppliedManifestWork from the index for a given name.
Get(name string) (*v1.AppliedManifestWork, error)
AppliedManifestWorkListerExpansion
}
// appliedManifestWorkLister implements the AppliedManifestWorkLister interface.
type appliedManifestWorkLister struct {
indexer cache.Indexer
}
// NewAppliedManifestWorkLister returns a new AppliedManifestWorkLister.
func NewAppliedManifestWorkLister(indexer cache.Indexer) AppliedManifestWorkLister {
return &appliedManifestWorkLister{indexer: indexer}
}
// List lists all AppliedManifestWorks in the indexer.
func (s *appliedManifestWorkLister) List(selector labels.Selector) (ret []*v1.AppliedManifestWork, err error) {
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
ret = append(ret, m.(*v1.AppliedManifestWork))
})
return ret, err
}
// Get retrieves the AppliedManifestWork from the index for a given name.
func (s *appliedManifestWorkLister) Get(name string) (*v1.AppliedManifestWork, error) {
obj, exists, err := s.indexer.GetByKey(name)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(v1.Resource("appliedmanifestwork"), name)
}
return obj.(*v1.AppliedManifestWork), nil
}
@@ -2,6 +2,10 @@
package v1
// AppliedManifestWorkListerExpansion allows custom methods to be added to
// AppliedManifestWorkLister.
type AppliedManifestWorkListerExpansion interface{}
// ManifestWorkListerExpansion allows custom methods to be added to
// ManifestWorkLister.
type ManifestWorkListerExpansion interface{}
@@ -3,13 +3,29 @@ kind: CustomResourceDefinition
metadata:
name: managedclusters.cluster.open-cluster-management.io
spec:
additionalPrinterColumns:
- JSONPath: .spec.hubAcceptsClient
name: Hub Accepted
type: boolean
- JSONPath: .spec.managedClusterClientConfigs[*].url
name: Managed Cluster URLs
type: string
- JSONPath: .status.conditions[?(@.type=="ManagedClusterJoined")].status
name: Joined
type: string
- JSONPath: .status.conditions[?(@.type=="ManagedClusterConditionAvailable")].status
name: Available
type: string
- JSONPath: .metadata.creationTimestamp
name: Age
type: date
group: cluster.open-cluster-management.io
names:
kind: ManagedCluster
listKind: ManagedClusterList
plural: managedclusters
singular: managedcluster
scope: "Cluster"
scope: Cluster
subresources:
status: {}
preserveUnknownFields: false
+7
View File
@@ -8,6 +8,13 @@ import (
// +genclient
// +genclient:nonNamespaced
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope="Cluster"
// +kubebuilder:printcolumn:JSONPath=`.spec.hubAcceptsClient`,name="Hub Accepted",type=boolean
// +kubebuilder:printcolumn:JSONPath=`.spec.managedClusterClientConfigs[*].url`,name="Managed Cluster URLs",type=string
// +kubebuilder:printcolumn:JSONPath=`.status.conditions[?(@.type=="ManagedClusterJoined")].status`,name="Joined",type=string
// +kubebuilder:printcolumn:JSONPath=`.status.conditions[?(@.type=="ManagedClusterConditionAvailable")].status`,name="Available",type=string
// +kubebuilder:printcolumn:JSONPath=`.metadata.creationTimestamp`,name="Age",type=date
// ManagedCluster represents the desired state and current status of managed
// cluster. ManagedCluster is a cluster scoped resource. The name is the cluster
@@ -0,0 +1,149 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
creationTimestamp: null
name: managedclustersets.cluster.open-cluster-management.io
spec:
group: cluster.open-cluster-management.io
names:
kind: ManagedClusterSet
listKind: ManagedClusterSetList
plural: managedclustersets
singular: managedclusterset
scope: Cluster
subresources:
status: {}
preserveUnknownFields: false
validation:
openAPIV3Schema:
description: "ManagedClusterSet defines a group of ManagedClusters that user's
workload can run on. A workload can be defined to deployed on a ManagedClusterSet,
which mean: \n 1. The workload can run on any ManagedCluster in the ManagedClusterSet
2. The workload cannot run on any ManagedCluster outside the ManagedClusterSet
3. The service exposed by the workload can be shared in any ManagedCluster
in the ManagedClusterSet"
type: object
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: Spec defines the attributes of the desired ManagedClusters
type: object
properties:
clusterSelectors:
description: ClusterSelectors represents a slice of selectors to select
ManagedClusters If empty, the ManagedClusterSet will include all ManagedClusters
If more than one ClusterSelector are specified in the slice, OR operation
will be used between them.
type: array
items:
description: ClusterSelector represents a selector of ManagedClusters
ClusterNames and LabelSelector are mutually exclusive. They cannot
be set at the same time. If none of them is set, all ManagedClusters
will be selected
type: object
properties:
clusterNames:
description: ClusterNames represents a list of cluster name
type: array
items:
type: string
labelSelector:
description: LabelSelector represents a label selector to select
cluster by label
type: object
properties:
matchExpressions:
description: matchExpressions is a list of label selector
requirements. The requirements are ANDed.
type: array
items:
description: A label selector requirement is a selector
that contains values, a key, and an operator that relates
the key and values.
type: object
required:
- key
- operator
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.
type: array
items:
type: string
matchLabels:
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
additionalProperties:
type: string
status:
description: Status represents the current status of the ManagedClusterSet
type: object
properties:
conditions:
description: Conditions contains the different condition statuses for
this ManagedClusterSet.
type: array
items:
description: StatusCondition contains condition information for a
ManagedClusterSet.
type: object
properties:
lastTransitionTime:
description: LastTransitionTime is the last time the condition
changed from one status to another.
type: string
format: date-time
message:
description: Message is a human-readable message indicating details
about the last status change.
type: string
reason:
description: Reason is a (brief) reason for the condition's last
status change.
type: string
status:
description: Status is the status of the condition. One of True,
False, Unknown.
type: string
type:
description: Type is the type of the ManagedClusterSet condition.
type: string
version: v1alpha1
versions:
- name: v1alpha1
served: true
storage: true
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
@@ -0,0 +1,56 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
creationTimestamp: null
name: managedclustersetbindings.cluster.open-cluster-management.io
spec:
group: cluster.open-cluster-management.io
names:
kind: ManagedClusterSetBinding
listKind: ManagedClusterSetBindingList
plural: managedclustersetbindings
singular: managedclustersetbinding
scope: Namespaced
preserveUnknownFields: false
validation:
openAPIV3Schema:
description: ManagedClusterSetBinding projects a ManagedClusterSet into a certain
namespace. User is able to create a ManagedClusterSetBinding in a namespace
and bind it to a ManagedClusterSet if they have an RBAC rule to GET on the
virtual subresource of managedclustersets/bind. Workloads created in the same
namespace can only be distributed to ManagedClusters in ManagedClustersets
bound in this namespace by higher level controllers.
type: object
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: Spec defines the attributes of ManagedClusterSetBinding.
type: object
properties:
clusterSet:
description: ClusterSet is the name of the ManagedClusterSet to bind.
User is allowed to set or update this field if they have an RBAC rule
to GET on the virtual subresource of managedclustersets/bind.
type: string
version: v1alpha1
versions:
- name: v1alpha1
served: true
storage: true
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
@@ -0,0 +1,9 @@
// Package v1alpha1 contains API Schema definitions for the cluster v1alpha1 API group
// +k8s:deepcopy-gen=package,register
// +k8s:conversion-gen=github.com/open-cluster-management/api/cluster
// +k8s:defaulter-gen=TypeMeta
// +k8s:openapi-gen=true
// +kubebuilder:validation:Optional
// +groupName=cluster.open-cluster-management.io
package v1alpha1
@@ -0,0 +1,40 @@
package v1alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)
var (
GroupName = "cluster.open-cluster-management.io"
GroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"}
schemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
// Install is a function which adds this version to a scheme
Install = schemeBuilder.AddToScheme
// SchemeGroupVersion generated code relies on this name
// Deprecated
SchemeGroupVersion = GroupVersion
// AddToScheme exists solely to keep the old generators creating valid code
// DEPRECATED
AddToScheme = schemeBuilder.AddToScheme
)
// Resource generated code relies on this being here, but it logically belongs to the group
// DEPRECATED
func Resource(resource string) schema.GroupResource {
return schema.GroupResource{Group: GroupName, Resource: resource}
}
// Adds the list of known types to api.Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(GroupVersion,
&ManagedClusterSet{},
&ManagedClusterSetList{},
&ManagedClusterSetBinding{},
&ManagedClusterSetBindingList{},
)
metav1.AddToGroupVersion(scheme, GroupVersion)
return nil
}
+141
View File
@@ -0,0 +1,141 @@
package v1alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// +genclient
// +genclient:nonNamespaced
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope="Cluster"
// ManagedClusterSet defines a group of ManagedClusters that user's workload can run on.
// A workload can be defined to deployed on a ManagedClusterSet, which mean:
//
// 1. The workload can run on any ManagedCluster in the ManagedClusterSet
// 2. The workload cannot run on any ManagedCluster outside the ManagedClusterSet
// 3. The service exposed by the workload can be shared in any ManagedCluster in the ManagedClusterSet
type ManagedClusterSet struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
// Spec defines the attributes of the desired ManagedClusters
Spec ManagedClusterSetSpec `json:"spec"`
// Status represents the current status of the ManagedClusterSet
// +optional
Status ManagedClusterSetStatus `json:"status,omitempty"`
}
// ManagedClusterSetSpec describes the attributes of the desired ManagedClusters
type ManagedClusterSetSpec struct {
// ClusterSelectors represents a slice of selectors to select ManagedClusters
// If empty, the ManagedClusterSet will include all ManagedClusters
// If more than one ClusterSelector are specified in the slice, OR operation
// will be used between them.
// +optional
ClusterSelectors []ClusterSelector `json:"clusterSelectors,omitempty"`
}
// ClusterSelector represents a selector of ManagedClusters
// ClusterNames and LabelSelector are mutually exclusive. They cannot be set at the
// same time. If none of them is set, all ManagedClusters will be selected
type ClusterSelector struct {
// ClusterNames represents a list of cluster name
// +optional
ClusterNames []string `json:"clusterNames,omitempty"`
// LabelSelector represents a label selector to select cluster by label
// +optional
LabelSelector *metav1.LabelSelector `json:"labelSelector,omitempty"`
}
// ManagedClusterSetStatus represents the current status of the ManagedClusterSet.
type ManagedClusterSetStatus struct {
// Conditions contains the different condition statuses for this ManagedClusterSet.
Conditions []StatusCondition `json:"conditions"`
}
// StatusCondition contains condition information for a ManagedClusterSet.
type StatusCondition struct {
// Type is the type of the ManagedClusterSet condition.
// +required
Type string `json:"type"`
// Status is the status of the condition. One of True, False, Unknown.
// +required
Status metav1.ConditionStatus `json:"status"`
// LastTransitionTime is the last time the condition changed from one status to another.
// +required
LastTransitionTime metav1.Time `json:"lastTransitionTime"`
// Reason is a (brief) reason for the condition's last status change.
// +required
Reason string `json:"reason"`
// Message is a human-readable message indicating details about the last status change.
// +required
Message string `json:"message"`
}
const (
// ManagedClusterSetConditionEmpty means no ManagedCluster is included in the
// ManagedClusterSet.
ManagedClusterSetConditionEmpty string = "ClusterSetEmpty"
)
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ManagedClusterSetList is a collection of ManagedClusterSet.
type ManagedClusterSetList struct {
metav1.TypeMeta `json:",inline"`
// Standard list metadata.
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds
// +optional
metav1.ListMeta `json:"metadata,omitempty"`
// Items is a list of ManagedClusterSet.
Items []ManagedClusterSet `json:"items"`
}
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:resource:scope="Namespaced"
// ManagedClusterSetBinding projects a ManagedClusterSet into a certain namespace.
// User is able to create a ManagedClusterSetBinding in a namespace and bind it to a
// ManagedClusterSet if they have an RBAC rule to GET on the virtual subresource of
// managedclustersets/bind. Workloads created in the same namespace can only be
// distributed to ManagedClusters in ManagedClustersets bound in this namespace by
// higher level controllers.
type ManagedClusterSetBinding struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
// Spec defines the attributes of ManagedClusterSetBinding.
Spec ManagedClusterSetBindingSpec `json:"spec"`
}
// ManagedClusterSetBindingSpec defines the attributes of ManagedClusterSetBinding.
type ManagedClusterSetBindingSpec struct {
// ClusterSet is the name of the ManagedClusterSet to bind. User is allowed
// to set or update this field if they have an RBAC rule to GET on the
// virtual subresource of managedclustersets/bind.
ClusterSet string `json:"clusterSet"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ManagedClusterSetBindingList is a collection of ManagedClusterSetBinding.
type ManagedClusterSetBindingList struct {
metav1.TypeMeta `json:",inline"`
// Standard list metadata.
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds
// +optional
metav1.ListMeta `json:"metadata,omitempty"`
// Items is a list of ManagedClusterSetBinding.
Items []ManagedClusterSetBinding `json:"items"`
}
@@ -0,0 +1,236 @@
// +build !ignore_autogenerated
// Code generated by deepcopy-gen. DO NOT EDIT.
package v1alpha1
import (
v1 "k8s.io/apimachinery/pkg/apis/meta/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 *ClusterSelector) DeepCopyInto(out *ClusterSelector) {
*out = *in
if in.ClusterNames != nil {
in, out := &in.ClusterNames, &out.ClusterNames
*out = make([]string, len(*in))
copy(*out, *in)
}
if in.LabelSelector != nil {
in, out := &in.LabelSelector, &out.LabelSelector
*out = new(v1.LabelSelector)
(*in).DeepCopyInto(*out)
}
return
}
// 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 *ManagedClusterSet) DeepCopyInto(out *ManagedClusterSet) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
in.Status.DeepCopyInto(&out.Status)
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManagedClusterSet.
func (in *ManagedClusterSet) DeepCopy() *ManagedClusterSet {
if in == nil {
return nil
}
out := new(ManagedClusterSet)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *ManagedClusterSet) 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 *ManagedClusterSetBinding) DeepCopyInto(out *ManagedClusterSetBinding) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
out.Spec = in.Spec
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManagedClusterSetBinding.
func (in *ManagedClusterSetBinding) DeepCopy() *ManagedClusterSetBinding {
if in == nil {
return nil
}
out := new(ManagedClusterSetBinding)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *ManagedClusterSetBinding) 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 *ManagedClusterSetBindingList) DeepCopyInto(out *ManagedClusterSetBindingList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]ManagedClusterSetBinding, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManagedClusterSetBindingList.
func (in *ManagedClusterSetBindingList) DeepCopy() *ManagedClusterSetBindingList {
if in == nil {
return nil
}
out := new(ManagedClusterSetBindingList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *ManagedClusterSetBindingList) 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 *ManagedClusterSetBindingSpec) DeepCopyInto(out *ManagedClusterSetBindingSpec) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManagedClusterSetBindingSpec.
func (in *ManagedClusterSetBindingSpec) DeepCopy() *ManagedClusterSetBindingSpec {
if in == nil {
return nil
}
out := new(ManagedClusterSetBindingSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ManagedClusterSetList) DeepCopyInto(out *ManagedClusterSetList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]ManagedClusterSet, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManagedClusterSetList.
func (in *ManagedClusterSetList) DeepCopy() *ManagedClusterSetList {
if in == nil {
return nil
}
out := new(ManagedClusterSetList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *ManagedClusterSetList) 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 *ManagedClusterSetSpec) DeepCopyInto(out *ManagedClusterSetSpec) {
*out = *in
if in.ClusterSelectors != nil {
in, out := &in.ClusterSelectors, &out.ClusterSelectors
*out = make([]ClusterSelector, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManagedClusterSetSpec.
func (in *ManagedClusterSetSpec) DeepCopy() *ManagedClusterSetSpec {
if in == nil {
return nil
}
out := new(ManagedClusterSetSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ManagedClusterSetStatus) DeepCopyInto(out *ManagedClusterSetStatus) {
*out = *in
if in.Conditions != nil {
in, out := &in.Conditions, &out.Conditions
*out = make([]StatusCondition, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManagedClusterSetStatus.
func (in *ManagedClusterSetStatus) DeepCopy() *ManagedClusterSetStatus {
if in == nil {
return nil
}
out := new(ManagedClusterSetStatus)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *StatusCondition) DeepCopyInto(out *StatusCondition) {
*out = *in
in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime)
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StatusCondition.
func (in *StatusCondition) DeepCopy() *StatusCondition {
if in == nil {
return nil
}
out := new(StatusCondition)
in.DeepCopyInto(out)
return out
}
@@ -0,0 +1,103 @@
package v1alpha1
// This file contains a collection of methods that can be used from go-restful to
// generate Swagger API documentation for its models. Please read this PR for more
// information on the implementation: https://github.com/emicklei/go-restful/pull/215
//
// TODOs are ignored from the parser (e.g. TODO(andronat):... || TODO:...) if and only if
// they are on one line! For multiple line or blocks that you want to ignore use ---.
// Any context after a --- is ignored.
//
// Those methods can be generated by using hack/update-swagger-docs.sh
// AUTO-GENERATED FUNCTIONS START HERE
var map_ClusterSelector = map[string]string{
"": "ClusterSelector represents a selector of ManagedClusters ClusterNames and LabelSelector are mutually exclusive. They cannot be set at the same time. If none of them is set, all ManagedClusters will be selected",
"clusterNames": "ClusterNames represents a list of cluster name",
"labelSelector": "LabelSelector represents a label selector to select cluster by label",
}
func (ClusterSelector) SwaggerDoc() map[string]string {
return map_ClusterSelector
}
var map_ManagedClusterSet = map[string]string{
"": "ManagedClusterSet defines a group of ManagedClusters that user's workload can run on. A workload can be defined to deployed on a ManagedClusterSet, which mean:\n\n1. The workload can run on any ManagedCluster in the ManagedClusterSet 2. The workload cannot run on any ManagedCluster outside the ManagedClusterSet 3. The service exposed by the workload can be shared in any ManagedCluster in the ManagedClusterSet",
"spec": "Spec defines the attributes of the desired ManagedClusters",
"status": "Status represents the current status of the ManagedClusterSet",
}
func (ManagedClusterSet) SwaggerDoc() map[string]string {
return map_ManagedClusterSet
}
var map_ManagedClusterSetBinding = map[string]string{
"": "ManagedClusterSetBinding projects a ManagedClusterSet into a certain namespace. User is able to create a ManagedClusterSetBinding in a namespace and bind it to a ManagedClusterSet if they have an RBAC rule to GET on the virtual subresource of managedclustersets/bind. Workloads created in the same namespace can only be distributed to ManagedClusters in ManagedClustersets bound in this namespace by higher level controllers.",
"spec": "Spec defines the attributes of ManagedClusterSetBinding.",
}
func (ManagedClusterSetBinding) SwaggerDoc() map[string]string {
return map_ManagedClusterSetBinding
}
var map_ManagedClusterSetBindingList = map[string]string{
"": "ManagedClusterSetBindingList is a collection of ManagedClusterSetBinding.",
"metadata": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds",
"items": "Items is a list of ManagedClusterSetBinding.",
}
func (ManagedClusterSetBindingList) SwaggerDoc() map[string]string {
return map_ManagedClusterSetBindingList
}
var map_ManagedClusterSetBindingSpec = map[string]string{
"": "ManagedClusterSetBindingSpec defines the attributes of ManagedClusterSetBinding.",
"clusterSet": "ClusterSet is the name of the ManagedClusterSet to bind. User is allowed to set or update this field if they have an RBAC rule to GET on the virtual subresource of managedclustersets/bind.",
}
func (ManagedClusterSetBindingSpec) SwaggerDoc() map[string]string {
return map_ManagedClusterSetBindingSpec
}
var map_ManagedClusterSetList = map[string]string{
"": "ManagedClusterSetList is a collection of ManagedClusterSet.",
"metadata": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds",
"items": "Items is a list of ManagedClusterSet.",
}
func (ManagedClusterSetList) SwaggerDoc() map[string]string {
return map_ManagedClusterSetList
}
var map_ManagedClusterSetSpec = map[string]string{
"": "ManagedClusterSetSpec describes the attributes of the desired ManagedClusters",
"clusterSelectors": "ClusterSelectors represents a slice of selectors to select ManagedClusters If empty, the ManagedClusterSet will include all ManagedClusters If more than one ClusterSelector are specified in the slice, OR operation will be used between them.",
}
func (ManagedClusterSetSpec) SwaggerDoc() map[string]string {
return map_ManagedClusterSetSpec
}
var map_ManagedClusterSetStatus = map[string]string{
"": "ManagedClusterSetStatus represents the current status of the ManagedClusterSet.",
"conditions": "Conditions contains the different condition statuses for this ManagedClusterSet.",
}
func (ManagedClusterSetStatus) SwaggerDoc() map[string]string {
return map_ManagedClusterSetStatus
}
var map_StatusCondition = map[string]string{
"": "StatusCondition contains condition information for a ManagedClusterSet.",
"type": "Type is the type of the ManagedClusterSet condition.",
"status": "Status is the status of the condition. One of True, False, Unknown.",
"lastTransitionTime": "LastTransitionTime is the last time the condition changed from one status to another.",
"reason": "Reason is a (brief) reason for the condition's last status change.",
"message": "Message is a human-readable message indicating details about the last status change.",
}
func (StatusCondition) SwaggerDoc() map[string]string {
return map_StatusCondition
}
// AUTO-GENERATED FUNCTIONS END HERE
@@ -59,39 +59,6 @@ spec:
description: Status represents the current status of work
type: object
properties:
appliedResources:
description: AppliedResources represents a list of resources defined
within the manifestwork that are applied. Only resources with valid
GroupVersionResource, namespace, and name are suitable. An item in
this slice is deleted when there is no mapped manifest in manifestwork.Spec
or by finalizer. The resource relating to the item will also be removed
from managed cluster. The deleted resource may still be present until
the finalizers for that resource are finished. However, the resource
will not be undeleted, so it can be removed from this list and eventual
consistency is preserved.
type: array
items:
description: AppliedManifestResourceMeta represents the gvr, name
and namespace of a resource. Since these resources have been created,
they must have valid group, version, resource, namespace, and name.
type: object
properties:
group:
description: Group is the API Group of the kubernetes resource
type: string
name:
description: Name is the name of the kubernetes resource
type: string
namespace:
description: Name is the namespace of the kubernetes resource,
empty string indicates it is a cluster scoped resource.
type: string
resource:
description: Resource is the resource name of the kubernetes resource
type: string
version:
description: Version is the version of the kubernetes resource
type: string
conditions:
description: 'Conditions contains the different condition statuses for
this work. Valid condition types are: 1. Applied represents workload
@@ -0,0 +1,105 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
creationTimestamp: null
name: appliedmanifestworks.work.open-cluster-management.io
spec:
group: work.open-cluster-management.io
names:
kind: AppliedManifestWork
listKind: AppliedManifestWorkList
plural: appliedmanifestworks
singular: appliedmanifestwork
scope: "Cluster"
preserveUnknownFields: false
subresources:
status: {}
validation:
openAPIV3Schema:
description: AppliedManifestWork represents an applied manifestwork on managed
cluster. It is placed on managed cluster. An AppliedManifestWork links to
a manifestwork on a hub recording resources deployed in the managed cluster.
When the agent is removed from managed cluster, cluster-admin on managed cluster
can delete appliedmanifestwork to remove resources deployed by the agent.
The name of the appliedmanifestwork must be in the format of {hash of hub's
first kube-apiserver url}-{manifestwork name}
type: object
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: Spec represents the desired configuration of AppliedManifestWork
type: object
properties:
hubHash:
description: HubHash represents the hash of the first hub kube apiserver
to identify which hub this AppliedManifestWork links to.
type: string
manifestWorkName:
description: ManifestWorkName represents the name of the related manifestwork
on hub.
type: string
status:
description: Status represents the current status of AppliedManifestWork
type: object
properties:
appliedResources:
description: AppliedResources represents a list of resources defined
within the manifestwork that are applied. Only resources with valid
GroupVersionResource, namespace, and name are suitable. An item in
this slice is deleted when there is no mapped manifest in manifestwork.Spec
or by finalizer. The resource relating to the item will also be removed
from managed cluster. The deleted resource may still be present until
the finalizers for that resource are finished. However, the resource
will not be undeleted, so it can be removed from this list and eventual
consistency is preserved.
type: array
items:
description: AppliedManifestResourceMeta represents the gvr, name
and namespace of a resource. Since these resources have been created,
they must have valid group, version, resource, namespace, and name.
type: object
properties:
group:
description: Group is the API Group of the kubernetes resource
type: string
name:
description: Name is the name of the kubernetes resource
type: string
namespace:
description: Name is the namespace of the kubernetes resource,
empty string indicates it is a cluster scoped resource.
type: string
resource:
description: Resource is the resource name of the kubernetes resource
type: string
uid:
description: UID is set on successful deletion of the kubernetes
resource by controller. The resource might be still visible
on the managed cluster after this field is set. It is not directly
settable by a client.
type: string
version:
description: Version is the version of the kubernetes resource
type: string
version: v1
versions:
- name: v1
served: true
storage: true
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
+2
View File
@@ -32,6 +32,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(GroupVersion,
&ManifestWork{},
&ManifestWorkList{},
&AppliedManifestWork{},
&AppliedManifestWorkList{},
)
metav1.AddToGroupVersion(scheme, GroupVersion)
return nil
+68 -9
View File
@@ -123,6 +123,12 @@ type AppliedManifestResourceMeta struct {
// it is a cluster scoped resource.
// +required
Namespace string `json:"namespace"`
// UID is set on successful deletion of the kubernetes resource by controller. The
// resource might be still visible on the managed cluster after this field is set.
// It is not directly settable by a client.
// +optional
UID string `json:"uid,omitempty"`
}
// ManifestWorkStatus represents the current status of managed cluster ManifestWork
@@ -140,15 +146,6 @@ type ManifestWorkStatus struct {
// managed cluster. The Klusterlet agent on managed cluster syncs the condition from managed to the hub.
// +optional
ResourceStatus ManifestResourceStatus `json:"resourceStatus,omitempty"`
// AppliedResources represents a list of resources defined within the manifestwork that are applied.
// Only resources with valid GroupVersionResource, namespace, and name are suitable.
// An item in this slice is deleted when there is no mapped manifest in manifestwork.Spec or by finalizer.
// The resource relating to the item will also be removed from managed cluster.
// The deleted resource may still be present until the finalizers for that resource are finished.
// However, the resource will not be undeleted, so it can be removed from this list and eventual consistency is preserved.
// +optional
AppliedResources []AppliedManifestResourceMeta `json:"appliedResources,omitempty"`
}
// ManifestResourceStatus represents the status of each resource in manifest work deployed on
@@ -225,3 +222,65 @@ type ManifestWorkList struct {
// Items is a list of manifestworks.
Items []ManifestWork `json:"items"`
}
// +genclient
// +genclient:nonNamespaced
// +kubebuilder:subresource:status
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// AppliedManifestWork represents an applied manifestwork on managed cluster. It is placed
// on managed cluster. An AppliedManifestWork links to a manifestwork on a hub recording resources
// deployed in the managed cluster.
// When the agent is removed from managed cluster, cluster-admin on managed cluster
// can delete appliedmanifestwork to remove resources deployed by the agent.
// The name of the appliedmanifestwork must be in the format of
// {hash of hub's first kube-apiserver url}-{manifestwork name}
type AppliedManifestWork struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
// Spec represents the desired configuration of AppliedManifestWork
Spec AppliedManifestWorkSpec `json:"spec,omitempty"`
// Status represents the current status of AppliedManifestWork
// +optional
Status AppliedManifestWorkStatus `json:"status,omitempty"`
}
// AppliedManifestWorkSpec represents the desired configuration of AppliedManifestWork
type AppliedManifestWorkSpec struct {
// HubHash represents the hash of the first hub kube apiserver to identify which hub
// this AppliedManifestWork links to.
// +required
HubHash string `json:"hubHash"`
// ManifestWorkName represents the name of the related manifestwork on hub.
// +required
ManifestWorkName string `json:"manifestWorkName"`
}
// AppliedManifestWorkStatus represents the current status of AppliedManifestWork
type AppliedManifestWorkStatus struct {
// AppliedResources represents a list of resources defined within the manifestwork that are applied.
// Only resources with valid GroupVersionResource, namespace, and name are suitable.
// An item in this slice is deleted when there is no mapped manifest in manifestwork.Spec or by finalizer.
// The resource relating to the item will also be removed from managed cluster.
// The deleted resource may still be present until the finalizers for that resource are finished.
// However, the resource will not be undeleted, so it can be removed from this list and eventual consistency is preserved.
// +optional
AppliedResources []AppliedManifestResourceMeta `json:"appliedResources,omitempty"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// AppliedManifestWorkList is a collection of appliedmanifestworks.
type AppliedManifestWorkList struct {
metav1.TypeMeta `json:",inline"`
// Standard list metadata.
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds
// +optional
metav1.ListMeta `json:"metadata,omitempty"`
// Items is a list of appliedmanifestworks.
Items []AppliedManifestWork `json:"items"`
}
@@ -24,6 +24,104 @@ func (in *AppliedManifestResourceMeta) DeepCopy() *AppliedManifestResourceMeta {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *AppliedManifestWork) DeepCopyInto(out *AppliedManifestWork) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
out.Spec = in.Spec
in.Status.DeepCopyInto(&out.Status)
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AppliedManifestWork.
func (in *AppliedManifestWork) DeepCopy() *AppliedManifestWork {
if in == nil {
return nil
}
out := new(AppliedManifestWork)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *AppliedManifestWork) 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 *AppliedManifestWorkList) DeepCopyInto(out *AppliedManifestWorkList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]AppliedManifestWork, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AppliedManifestWorkList.
func (in *AppliedManifestWorkList) DeepCopy() *AppliedManifestWorkList {
if in == nil {
return nil
}
out := new(AppliedManifestWorkList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *AppliedManifestWorkList) 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 *AppliedManifestWorkSpec) DeepCopyInto(out *AppliedManifestWorkSpec) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AppliedManifestWorkSpec.
func (in *AppliedManifestWorkSpec) DeepCopy() *AppliedManifestWorkSpec {
if in == nil {
return nil
}
out := new(AppliedManifestWorkSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *AppliedManifestWorkStatus) DeepCopyInto(out *AppliedManifestWorkStatus) {
*out = *in
if in.AppliedResources != nil {
in, out := &in.AppliedResources, &out.AppliedResources
*out = make([]AppliedManifestResourceMeta, len(*in))
copy(*out, *in)
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AppliedManifestWorkStatus.
func (in *AppliedManifestWorkStatus) DeepCopy() *AppliedManifestWorkStatus {
if in == nil {
return nil
}
out := new(AppliedManifestWorkStatus)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Manifest) DeepCopyInto(out *Manifest) {
*out = *in
@@ -193,11 +291,6 @@ func (in *ManifestWorkStatus) DeepCopyInto(out *ManifestWorkStatus) {
}
}
in.ResourceStatus.DeepCopyInto(&out.ResourceStatus)
if in.AppliedResources != nil {
in, out := &in.AppliedResources, &out.AppliedResources
*out = make([]AppliedManifestResourceMeta, len(*in))
copy(*out, *in)
}
return
}
@@ -18,12 +18,52 @@ var map_AppliedManifestResourceMeta = map[string]string{
"resource": "Resource is the resource name of the kubernetes resource",
"name": "Name is the name of the kubernetes resource",
"namespace": "Name is the namespace of the kubernetes resource, empty string indicates it is a cluster scoped resource.",
"uid": "UID is set on successful deletion of the kubernetes resource by controller. The resource might be still visible on the managed cluster after this field is set. It is not directly settable by a client.",
}
func (AppliedManifestResourceMeta) SwaggerDoc() map[string]string {
return map_AppliedManifestResourceMeta
}
var map_AppliedManifestWork = map[string]string{
"": "AppliedManifestWork represents an applied manifestwork on managed cluster. It is placed on managed cluster. An AppliedManifestWork links to a manifestwork on a hub recording resources deployed in the managed cluster. When the agent is removed from managed cluster, cluster-admin on managed cluster can delete appliedmanifestwork to remove resources deployed by the agent. The name of the appliedmanifestwork must be in the format of {hash of hub's first kube-apiserver url}-{manifestwork name}",
"spec": "Spec represents the desired configuration of AppliedManifestWork",
"status": "Status represents the current status of AppliedManifestWork",
}
func (AppliedManifestWork) SwaggerDoc() map[string]string {
return map_AppliedManifestWork
}
var map_AppliedManifestWorkList = map[string]string{
"": "AppliedManifestWorkList is a collection of appliedmanifestworks.",
"metadata": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds",
"items": "Items is a list of appliedmanifestworks.",
}
func (AppliedManifestWorkList) SwaggerDoc() map[string]string {
return map_AppliedManifestWorkList
}
var map_AppliedManifestWorkSpec = map[string]string{
"": "AppliedManifestWorkSpec represents the desired configuration of AppliedManifestWork",
"hubHash": "HubHash represents the hash of the first hub kube apiserver to identify which hub this AppliedManifestWork links to.",
"manifestWorkName": "ManifestWorkName represents the name of the related manifestwork on hub.",
}
func (AppliedManifestWorkSpec) SwaggerDoc() map[string]string {
return map_AppliedManifestWorkSpec
}
var map_AppliedManifestWorkStatus = map[string]string{
"": "AppliedManifestWorkStatus represents the current status of AppliedManifestWork",
"appliedResources": "AppliedResources represents a list of resources defined within the manifestwork that are applied. Only resources with valid GroupVersionResource, namespace, and name are suitable. An item in this slice is deleted when there is no mapped manifest in manifestwork.Spec or by finalizer. The resource relating to the item will also be removed from managed cluster. The deleted resource may still be present until the finalizers for that resource are finished. However, the resource will not be undeleted, so it can be removed from this list and eventual consistency is preserved.",
}
func (AppliedManifestWorkStatus) SwaggerDoc() map[string]string {
return map_AppliedManifestWorkStatus
}
var map_Manifest = map[string]string{
"": "Manifest represents a resource to be deployed on managed cluster",
}
@@ -96,10 +136,9 @@ func (ManifestWorkSpec) SwaggerDoc() map[string]string {
}
var map_ManifestWorkStatus = map[string]string{
"": "ManifestWorkStatus represents the current status of managed cluster ManifestWork",
"conditions": "Conditions contains the different condition statuses for this work. Valid condition types are: 1. Applied represents workload in ManifestWork is applied successfully on managed cluster. 2. Progressing represents workload in ManifestWork is being applied on managed cluster. 3. Available represents workload in ManifestWork exists on the managed cluster. 4. Degraded represents the current state of workload does not match the desired state for a certain period.",
"resourceStatus": "ResourceStatus represents the status of each resource in manifestwork deployed on managed cluster. The Klusterlet agent on managed cluster syncs the condition from managed to the hub.",
"appliedResources": "AppliedResources represents a list of resources defined within the manifestwork that are applied. Only resources with valid GroupVersionResource, namespace, and name are suitable. An item in this slice is deleted when there is no mapped manifest in manifestwork.Spec or by finalizer. The resource relating to the item will also be removed from managed cluster. The deleted resource may still be present until the finalizers for that resource are finished. However, the resource will not be undeleted, so it can be removed from this list and eventual consistency is preserved.",
"": "ManifestWorkStatus represents the current status of managed cluster ManifestWork",
"conditions": "Conditions contains the different condition statuses for this work. Valid condition types are: 1. Applied represents workload in ManifestWork is applied successfully on managed cluster. 2. Progressing represents workload in ManifestWork is being applied on managed cluster. 3. Available represents workload in ManifestWork exists on the managed cluster. 4. Degraded represents the current state of workload does not match the desired state for a certain period.",
"resourceStatus": "ResourceStatus represents the status of each resource in manifestwork deployed on managed cluster. The Klusterlet agent on managed cluster syncs the condition from managed to the hub.",
}
func (ManifestWorkStatus) SwaggerDoc() map[string]string {
+6 -1
View File
@@ -133,17 +133,21 @@ github.com/onsi/gomega/matchers/support/goraph/edge
github.com/onsi/gomega/matchers/support/goraph/node
github.com/onsi/gomega/matchers/support/goraph/util
github.com/onsi/gomega/types
# github.com/open-cluster-management/api v0.0.0-20200610161514-939cead3902c
# github.com/open-cluster-management/api v0.0.0-20200824150602-69fc6a00e4f8
github.com/open-cluster-management/api/client/cluster/clientset/versioned
github.com/open-cluster-management/api/client/cluster/clientset/versioned/fake
github.com/open-cluster-management/api/client/cluster/clientset/versioned/scheme
github.com/open-cluster-management/api/client/cluster/clientset/versioned/typed/cluster/v1
github.com/open-cluster-management/api/client/cluster/clientset/versioned/typed/cluster/v1/fake
github.com/open-cluster-management/api/client/cluster/clientset/versioned/typed/cluster/v1alpha1
github.com/open-cluster-management/api/client/cluster/clientset/versioned/typed/cluster/v1alpha1/fake
github.com/open-cluster-management/api/client/cluster/informers/externalversions
github.com/open-cluster-management/api/client/cluster/informers/externalversions/cluster
github.com/open-cluster-management/api/client/cluster/informers/externalversions/cluster/v1
github.com/open-cluster-management/api/client/cluster/informers/externalversions/cluster/v1alpha1
github.com/open-cluster-management/api/client/cluster/informers/externalversions/internalinterfaces
github.com/open-cluster-management/api/client/cluster/listers/cluster/v1
github.com/open-cluster-management/api/client/cluster/listers/cluster/v1alpha1
github.com/open-cluster-management/api/client/work/clientset/versioned
github.com/open-cluster-management/api/client/work/clientset/versioned/fake
github.com/open-cluster-management/api/client/work/clientset/versioned/scheme
@@ -155,6 +159,7 @@ github.com/open-cluster-management/api/client/work/informers/externalversions/wo
github.com/open-cluster-management/api/client/work/informers/externalversions/work/v1
github.com/open-cluster-management/api/client/work/listers/work/v1
github.com/open-cluster-management/api/cluster/v1
github.com/open-cluster-management/api/cluster/v1alpha1
github.com/open-cluster-management/api/work/v1
# github.com/openshift/api v0.0.0-20200521101457-60c476765272
github.com/openshift/api