Skip to content

Commit

Permalink
Upgrade go.mod open-cluster-management.io api. (#167)
Browse files Browse the repository at this point in the history
Signed-off-by: xuezhaojun <zxue@redhat.com>
  • Loading branch information
xuezhaojun authored Sep 5, 2023
1 parent 366272a commit f2cfda4
Show file tree
Hide file tree
Showing 14 changed files with 412 additions and 434 deletions.
6 changes: 3 additions & 3 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/rest"
clusterv1client "open-cluster-management.io/api/client/cluster/clientset/versioned"
clusterv1beta1 "open-cluster-management.io/api/cluster/v1beta1"
clusterv1beta2 "open-cluster-management.io/api/cluster/v1beta2"
"open-cluster-management.io/cluster-proxy/pkg/generated/clientset/versioned"
"open-cluster-management.io/cluster-proxy/pkg/util"
)
Expand Down Expand Up @@ -36,11 +36,11 @@ func GetProxyHost(ctx context.Context, kubeconfig *rest.Config, clusterName stri
continue
}

set, err := clusterClient.ClusterV1beta1().ManagedClusterSets().Get(ctx, sr.Spec.ManagedClusterSelector.ManagedClusterSet.Name, v1.GetOptions{})
set, err := clusterClient.ClusterV1beta2().ManagedClusterSets().Get(ctx, sr.Spec.ManagedClusterSelector.ManagedClusterSet.Name, v1.GetOptions{})
if err != nil {
return "", err
}
selector, err := clusterv1beta1.BuildClusterSelector(set)
selector, err := clusterv1beta2.BuildClusterSelector(set)
if err != nil {
return "", err
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/addon-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import (
"open-cluster-management.io/api/client/addon/clientset/versioned"
addonclient "open-cluster-management.io/api/client/addon/clientset/versioned"
"open-cluster-management.io/api/client/addon/informers/externalversions"
clusterv1beta1 "open-cluster-management.io/api/cluster/v1beta1"
clusterv1beta2 "open-cluster-management.io/api/cluster/v1beta2"
proxyv1alpha1 "open-cluster-management.io/cluster-proxy/pkg/apis/proxy/v1alpha1"
"open-cluster-management.io/cluster-proxy/pkg/config"
"open-cluster-management.io/cluster-proxy/pkg/proxyagent/agent"
Expand All @@ -60,7 +60,7 @@ func init() {

utilruntime.Must(addonv1alpha1.AddToScheme(scheme))
utilruntime.Must(proxyv1alpha1.AddToScheme(scheme))
utilruntime.Must(clusterv1beta1.AddToScheme(scheme))
utilruntime.Must(clusterv1beta2.AddToScheme(scheme))
//+kubebuilder:scaffold:scheme
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
k8s.io/klog/v2 v2.80.1
k8s.io/utils v0.0.0-20221128185143-99ec85e7a448
open-cluster-management.io/addon-framework v0.6.1
open-cluster-management.io/api v0.10.1
open-cluster-management.io/api v0.11.1-0.20230905055724-cf1ead467a83
sigs.k8s.io/apiserver-network-proxy v0.0.27
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.37
sigs.k8s.io/controller-runtime v0.14.4
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -710,8 +710,8 @@ k8s.io/utils v0.0.0-20221128185143-99ec85e7a448 h1:KTgPnR10d5zhztWptI952TNtt/4u5
k8s.io/utils v0.0.0-20221128185143-99ec85e7a448/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
open-cluster-management.io/addon-framework v0.6.1 h1:gnBZaCRgtiPRjCBJoaRqMivajng/XOKp0NQhJUqLd+U=
open-cluster-management.io/addon-framework v0.6.1/go.mod h1:Uu4XC3Ec0ATS7U73PJtzAP4NCDfbDBVy1k5RUUwQDqY=
open-cluster-management.io/api v0.10.1 h1:/qv1qfIkAVSz6RQmKGehSv6zYI34Xmb8hK7sIUVmduM=
open-cluster-management.io/api v0.10.1/go.mod h1:6BB/Y6r3hXlPjpJgDwIs6Ubxyx/kXXOg6D9Cntg1I9E=
open-cluster-management.io/api v0.11.1-0.20230905055724-cf1ead467a83 h1:3zbT3sT/tEAQbpjIk6uRiTQGknQ3kQlfd11ElVuXyyQ=
open-cluster-management.io/api v0.11.1-0.20230905055724-cf1ead467a83/go.mod h1:nsQ/G5JpfjQUg7dHpblyywWC6BRqklNaF6fIswVCHyY=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
Expand Down
375 changes: 182 additions & 193 deletions hack/crd/bases/cluster.open-cluster-management.io_managedclustersets.yaml

Large diffs are not rendered by default.

375 changes: 182 additions & 193 deletions hack/crd/cluster/managedclusterset.yaml

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions pkg/proxyagent/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
addonv1alpha1 "open-cluster-management.io/api/addon/v1alpha1"
addonclient "open-cluster-management.io/api/client/addon/clientset/versioned"
clusterv1 "open-cluster-management.io/api/cluster/v1"
clusterv1beta1 "open-cluster-management.io/api/cluster/v1beta1"
clusterv1beta2 "open-cluster-management.io/api/cluster/v1beta2"
proxyv1alpha1 "open-cluster-management.io/cluster-proxy/pkg/apis/proxy/v1alpha1"
"open-cluster-management.io/cluster-proxy/pkg/common"
"open-cluster-management.io/cluster-proxy/pkg/config"
Expand Down Expand Up @@ -247,7 +247,7 @@ func GetClusterProxyValueFunc(
// servicesToExpose defines the services we want to expose to the hub.

// List all available managedClusterSets
managedClusterSetList := &clusterv1beta1.ManagedClusterSetList{}
managedClusterSetList := &clusterv1beta2.ManagedClusterSetList{}
err = runtimeClient.List(context.TODO(), managedClusterSetList)
if err != nil {
return nil, err
Expand Down Expand Up @@ -328,8 +328,8 @@ const (
AgentCASecretName = "cluster-proxy-ca"
)

func managedClusterSetsToFilteredMap(managedClusterSets []clusterv1beta1.ManagedClusterSet, clusterlabels map[string]string) (map[string]clusterv1beta1.ManagedClusterSet, error) {
managedClusterSetMap := map[string]clusterv1beta1.ManagedClusterSet{}
func managedClusterSetsToFilteredMap(managedClusterSets []clusterv1beta2.ManagedClusterSet, clusterlabels map[string]string) (map[string]clusterv1beta2.ManagedClusterSet, error) {
managedClusterSetMap := map[string]clusterv1beta2.ManagedClusterSet{}
for i := range managedClusterSets {
mcs := managedClusterSets[i]

Expand All @@ -339,7 +339,7 @@ func managedClusterSetsToFilteredMap(managedClusterSets []clusterv1beta1.Managed
}

// only cluseterSet cover current cluster include in the list.
selector, err := clusterv1beta1.BuildClusterSelector(&mcs)
selector, err := clusterv1beta2.BuildClusterSelector(&mcs)
if err != nil {
return nil, err
}
Expand All @@ -352,7 +352,7 @@ func managedClusterSetsToFilteredMap(managedClusterSets []clusterv1beta1.Managed
return managedClusterSetMap, nil
}

func managedProxyServiceResolverToFilterServiceToExpose(serviceResolvers []proxyv1alpha1.ManagedProxyServiceResolver, managedClusterSetMap map[string]clusterv1beta1.ManagedClusterSet, clusterName string) []serviceToExpose {
func managedProxyServiceResolverToFilterServiceToExpose(serviceResolvers []proxyv1alpha1.ManagedProxyServiceResolver, managedClusterSetMap map[string]clusterv1beta2.ManagedClusterSet, clusterName string) []serviceToExpose {
servicesToExpose := []serviceToExpose{}
for i := range serviceResolvers {
sr := serviceResolvers[i]
Expand Down
26 changes: 13 additions & 13 deletions pkg/proxyagent/agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
addonv1alpha1 "open-cluster-management.io/api/addon/v1alpha1"
fakeaddon "open-cluster-management.io/api/client/addon/clientset/versioned/fake"
clusterv1 "open-cluster-management.io/api/cluster/v1"
clusterv1beta1 "open-cluster-management.io/api/cluster/v1beta1"
clusterv1beta2 "open-cluster-management.io/api/cluster/v1beta2"
proxyv1alpha1 "open-cluster-management.io/cluster-proxy/pkg/apis/proxy/v1alpha1"
"open-cluster-management.io/cluster-proxy/pkg/config"
"open-cluster-management.io/cluster-proxy/pkg/proxyserver/operator/authentication/selfsigned"
Expand All @@ -49,15 +49,15 @@ var (

func init() {
testscheme.AddKnownTypes(proxyv1alpha1.SchemeGroupVersion, &proxyv1alpha1.ManagedProxyConfiguration{})
testscheme.AddKnownTypes(clusterv1beta1.SchemeGroupVersion, &clusterv1beta1.ManagedClusterSetList{})
testscheme.AddKnownTypes(clusterv1beta2.SchemeGroupVersion, &clusterv1beta2.ManagedClusterSetList{})
testscheme.AddKnownTypes(proxyv1alpha1.SchemeGroupVersion, &proxyv1alpha1.ManagedProxyServiceResolverList{})
}

func TestFilterMPSR(t *testing.T) {
testcases := []struct {
name string
resolvers []proxyv1alpha1.ManagedProxyServiceResolver
mcsMap map[string]clusterv1beta1.ManagedClusterSet
mcsMap map[string]clusterv1beta2.ManagedClusterSet
expected []serviceToExpose
}{
{
Expand Down Expand Up @@ -105,7 +105,7 @@ func TestFilterMPSR(t *testing.T) {
},
},
},
mcsMap: map[string]clusterv1beta1.ManagedClusterSet{
mcsMap: map[string]clusterv1beta2.ManagedClusterSet{
"set-1": {
ObjectMeta: metav1.ObjectMeta{
Name: "set-1",
Expand Down Expand Up @@ -163,7 +163,7 @@ func TestFilterMPSR(t *testing.T) {
},
},
},
mcsMap: map[string]clusterv1beta1.ManagedClusterSet{
mcsMap: map[string]clusterv1beta2.ManagedClusterSet{
"set-1": {
ObjectMeta: metav1.ObjectMeta{
Name: "set-1",
Expand Down Expand Up @@ -197,30 +197,30 @@ func TestFilterMCS(t *testing.T) {
testcases := []struct {
name string
clusterlabels map[string]string
clusters []clusterv1beta1.ManagedClusterSet
expected map[string]clusterv1beta1.ManagedClusterSet
clusters []clusterv1beta2.ManagedClusterSet
expected map[string]clusterv1beta2.ManagedClusterSet
}{
{
name: "filter out the cluster with deletion timestamp",
clusterlabels: map[string]string{
clusterv1beta1.ClusterSetLabel: "set-1",
clusterv1beta2.ClusterSetLabel: "set-1",
},
clusters: []clusterv1beta1.ManagedClusterSet{
clusters: []clusterv1beta2.ManagedClusterSet{
{
ObjectMeta: metav1.ObjectMeta{
Name: "set-1",
DeletionTimestamp: &metav1.Time{Time: time.Now()},
},
},
},
expected: map[string]clusterv1beta1.ManagedClusterSet{},
expected: map[string]clusterv1beta2.ManagedClusterSet{},
},
{
name: "filter out the cluster without the current cluster label",
clusterlabels: map[string]string{
clusterv1beta1.ClusterSetLabel: "set-1",
clusterv1beta2.ClusterSetLabel: "set-1",
},
clusters: []clusterv1beta1.ManagedClusterSet{
clusters: []clusterv1beta2.ManagedClusterSet{
{
ObjectMeta: metav1.ObjectMeta{
Name: "set-1",
Expand All @@ -232,7 +232,7 @@ func TestFilterMCS(t *testing.T) {
},
},
},
expected: map[string]clusterv1beta1.ManagedClusterSet{
expected: map[string]clusterv1beta2.ManagedClusterSet{
"set-1": {
ObjectMeta: metav1.ObjectMeta{
Name: "set-1",
Expand Down
6 changes: 3 additions & 3 deletions pkg/proxyserver/controllers/service_resolver_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
utilerrors "k8s.io/apimachinery/pkg/util/errors"
clusterv1beta1 "open-cluster-management.io/api/cluster/v1beta1"
clusterv1beta2 "open-cluster-management.io/api/cluster/v1beta2"
proxyv1alpha1 "open-cluster-management.io/cluster-proxy/pkg/apis/proxy/v1alpha1"
"open-cluster-management.io/cluster-proxy/pkg/proxyserver/operator/eventhandler"
"open-cluster-management.io/cluster-proxy/pkg/util"
Expand Down Expand Up @@ -42,7 +42,7 @@ func (c *ServiceResolverReconciler) SetupWithManager(mgr ctrl.Manager) error {
).
Watches(
&source.Kind{
Type: &clusterv1beta1.ManagedClusterSet{},
Type: &clusterv1beta2.ManagedClusterSet{},
},
&eventhandler.ClustersetHandler{
Client: mgr.GetClient(),
Expand Down Expand Up @@ -82,7 +82,7 @@ func (c *ServiceResolverReconciler) refreshManageProxyServiceResolversStatus() e
}
} else {
// get managedclusterset
managedClusterSet := &clusterv1beta1.ManagedClusterSet{}
managedClusterSet := &clusterv1beta2.ManagedClusterSet{}
if err := c.Client.Get(context.TODO(), types.NamespacedName{
Name: resolver.Spec.ManagedClusterSelector.ManagedClusterSet.Name,
}, managedClusterSet); err != nil {
Expand Down
12 changes: 6 additions & 6 deletions pkg/proxyserver/operator/eventhandler/clusterset_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"

"k8s.io/client-go/util/workqueue"
clusterv1beta1 "open-cluster-management.io/api/cluster/v1beta1"
clusterv1beta2 "open-cluster-management.io/api/cluster/v1beta2"
proxyv1alpha1 "open-cluster-management.io/cluster-proxy/pkg/apis/proxy/v1alpha1"
"open-cluster-management.io/cluster-proxy/pkg/util"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand All @@ -20,27 +20,27 @@ type ClustersetHandler struct {
}

func (m ClustersetHandler) Create(event event.CreateEvent, limitingInterface workqueue.RateLimitingInterface) {
clusterset := event.Object.(*clusterv1beta1.ManagedClusterSet)
clusterset := event.Object.(*clusterv1beta2.ManagedClusterSet)
m.findClusterProxyAddon(clusterset, limitingInterface)
}

func (m ClustersetHandler) Update(event event.UpdateEvent, limitingInterface workqueue.RateLimitingInterface) {
clusterset := event.ObjectNew.(*clusterv1beta1.ManagedClusterSet)
clusterset := event.ObjectNew.(*clusterv1beta2.ManagedClusterSet)
m.findClusterProxyAddon(clusterset, limitingInterface)
}

func (m ClustersetHandler) Delete(event event.DeleteEvent, limitingInterface workqueue.RateLimitingInterface) {
clusterset := event.Object.(*clusterv1beta1.ManagedClusterSet)
clusterset := event.Object.(*clusterv1beta2.ManagedClusterSet)
m.findClusterProxyAddon(clusterset, limitingInterface)
}

func (m ClustersetHandler) Generic(event event.GenericEvent, limitingInterface workqueue.RateLimitingInterface) {
clusterset := event.Object.(*clusterv1beta1.ManagedClusterSet)
clusterset := event.Object.(*clusterv1beta2.ManagedClusterSet)
m.findClusterProxyAddon(clusterset, limitingInterface)
}

// findClusterProxyAddon will triger clustermanagementaddon on all managed clusters to reconcile.
func (m *ClustersetHandler) findClusterProxyAddon(clusterset *clusterv1beta1.ManagedClusterSet, limitingInterface workqueue.RateLimitingInterface) {
func (m *ClustersetHandler) findClusterProxyAddon(clusterset *clusterv1beta2.ManagedClusterSet, limitingInterface workqueue.RateLimitingInterface) {
var err error
// Check whether the clusterset is related with any managedproxyserviceresolver.
mpsrList := &proxyv1alpha1.ManagedProxyServiceResolverList{}
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/connect/connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
clusterv1beta1 "open-cluster-management.io/api/cluster/v1beta1"
clusterv1beta2 "open-cluster-management.io/api/cluster/v1beta2"
proxyv1alpha1 "open-cluster-management.io/cluster-proxy/pkg/apis/proxy/v1alpha1"
"open-cluster-management.io/cluster-proxy/pkg/util"

Expand Down Expand Up @@ -250,7 +250,7 @@ func deployHelleWorldApplication(ctx context.Context, name, namespace string, e2
}

func deployMCS(ctx context.Context, clusterset string, e2eframe framework.Framework) error {
return e2eframe.HubRuntimeClient().Create(ctx, &clusterv1beta1.ManagedClusterSet{
return e2eframe.HubRuntimeClient().Create(ctx, &clusterv1beta2.ManagedClusterSet{
ObjectMeta: metav1.ObjectMeta{
Name: clusterset,
},
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/framework/scheme.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
k8sscheme "k8s.io/client-go/kubernetes/scheme"
addonv1alpha1 "open-cluster-management.io/api/addon/v1alpha1"
clusterv1 "open-cluster-management.io/api/cluster/v1"
clusterv1beta1 "open-cluster-management.io/api/cluster/v1beta1"
clusterv1beta2 "open-cluster-management.io/api/cluster/v1beta2"
proxyv1alpha1 "open-cluster-management.io/cluster-proxy/pkg/apis/proxy/v1alpha1"
)

Expand All @@ -15,7 +15,7 @@ var scheme = runtime.NewScheme()
func init() {
utilruntime.Must(proxyv1alpha1.AddToScheme(scheme))
utilruntime.Must(clusterv1.AddToScheme(scheme))
utilruntime.Must(clusterv1beta1.AddToScheme(scheme))
utilruntime.Must(clusterv1beta2.AddToScheme(scheme))
utilruntime.Must(addonv1alpha1.AddToScheme(scheme))
utilruntime.Must(k8sscheme.AddToScheme(scheme))
}
12 changes: 6 additions & 6 deletions test/integration/controllers/serviceresolver_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clusterv1beta1 "open-cluster-management.io/api/cluster/v1beta1"
clusterv1beta2 "open-cluster-management.io/api/cluster/v1beta2"
proxyv1alpha1 "open-cluster-management.io/cluster-proxy/pkg/apis/proxy/v1alpha1"
"sigs.k8s.io/controller-runtime/pkg/client"
)
Expand Down Expand Up @@ -85,7 +85,7 @@ var _ = Describe("ServiceResolver Reconciler", func() {
},
},
}
clusterset := &clusterv1beta1.ManagedClusterSet{
clusterset := &clusterv1beta2.ManagedClusterSet{
ObjectMeta: metav1.ObjectMeta{
Name: "sr-test",
},
Expand Down Expand Up @@ -193,7 +193,7 @@ var _ = Describe("ServiceResolver Reconciler", func() {
},
},
}
clusterset := &clusterv1beta1.ManagedClusterSet{
clusterset := &clusterv1beta2.ManagedClusterSet{
ObjectMeta: metav1.ObjectMeta{
Name: "sr-test3",
Finalizers: []string{
Expand Down Expand Up @@ -232,7 +232,7 @@ var _ = Describe("ServiceResolver Reconciler", func() {

It("Should return confition equals False, and reason is ManagedClusterSetDeleting", func() {
Eventually(func() error {
currentClusterSet := &clusterv1beta1.ManagedClusterSet{}
currentClusterSet := &clusterv1beta2.ManagedClusterSet{}
err := ctrlClient.Get(ctx, client.ObjectKey{Name: clusterset.Name}, currentClusterSet)
if err != nil {
return err
Expand All @@ -247,7 +247,7 @@ var _ = Describe("ServiceResolver Reconciler", func() {
return err
}

currentClusterSet := &clusterv1beta1.ManagedClusterSet{}
currentClusterSet := &clusterv1beta2.ManagedClusterSet{}
err = ctrlClient.Get(ctx, client.ObjectKey{Name: clusterset.Name}, currentClusterSet)
if err != nil {
return err
Expand Down Expand Up @@ -293,7 +293,7 @@ var _ = Describe("ServiceResolver Reconciler", func() {
},
},
}
clusterset := &clusterv1beta1.ManagedClusterSet{
clusterset := &clusterv1beta2.ManagedClusterSet{
ObjectMeta: metav1.ObjectMeta{
Name: "sr-test4",
},
Expand Down
4 changes: 2 additions & 2 deletions test/integration/controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/util/cert"
addonv1alpha1 "open-cluster-management.io/api/addon/v1alpha1"
clusterv1beta1 "open-cluster-management.io/api/cluster/v1beta1"
clusterv1beta2 "open-cluster-management.io/api/cluster/v1beta2"
proxyv1alpha1 "open-cluster-management.io/cluster-proxy/pkg/apis/proxy/v1alpha1"
"open-cluster-management.io/cluster-proxy/pkg/proxyserver/controllers"
"open-cluster-management.io/cluster-proxy/pkg/proxyserver/operator/authentication/selfsigned"
Expand Down Expand Up @@ -95,7 +95,7 @@ var _ = BeforeSuite(func() {
err = proxyv1alpha1.AddToScheme(scheme)
Expect(err).NotTo(HaveOccurred())

err = clusterv1beta1.AddToScheme(scheme)
err = clusterv1beta2.AddToScheme(scheme)
Expect(err).NotTo(HaveOccurred())

kubeClient, err = kubernetes.NewForConfig(cfg)
Expand Down

0 comments on commit f2cfda4

Please sign in to comment.