From 369cbabfd05582c919751ec84816403e48829645 Mon Sep 17 00:00:00 2001 From: Iceber Gu Date: Fri, 21 Jun 2024 15:11:10 +0800 Subject: [PATCH] move discovery, scheme and informer to pkg/runtime Signed-off-by: Iceber Gu --- cmd/controller-manager/app/controllermanager.go | 2 +- hack/verify-forked-code.sh | 8 ++++---- pkg/controller/dependentresource_manager.go | 2 +- pkg/kube_state_metrics/metrics_store.go | 2 +- pkg/kubeapiserver/restmanager.go | 4 ++-- pkg/{ => runtime}/discovery/controller/apiservice.go | 0 pkg/{ => runtime}/discovery/controller/crd.go | 4 ++-- pkg/{ => runtime}/discovery/discovery_cache.go | 0 pkg/{ => runtime}/discovery/dynamic_discovery.go | 2 +- pkg/{ => runtime}/discovery/server_version.go | 0 .../informer/cache/.reflector.go | 0 .../clustersynchro => runtime}/informer/event_handler.go | 0 .../clustersynchro => runtime}/informer/informer.go | 0 .../clustersynchro => runtime}/informer/listwatch.go | 0 .../informer/named_controller.go | 0 .../informer/pager/.pager.go.copy | 0 .../clustersynchro => runtime}/informer/pager/pager.go | 0 .../informer/pager/result_stream.go | 0 .../clustersynchro => runtime}/informer/queue.go | 0 .../clustersynchro => runtime}/informer/reflector.go | 2 +- .../informer/resourceversion_informer.go | 0 .../informer/resourceversion_storage.go | 0 pkg/{ => runtime}/scheme/import_known_versions.go | 0 pkg/{ => runtime}/scheme/scheme.go | 2 +- pkg/{ => runtime}/scheme/unstructured/scheme.go | 0 pkg/storage/internalstorage/collectionresource.go | 2 +- pkg/storage/memorystorage/watchcache/watch_cache.go | 2 +- pkg/storageconfig/storageconfig_factory.go | 2 +- pkg/synchromanager/clustersynchro/cluster_synchro.go | 4 ++-- pkg/synchromanager/clustersynchro/resource_negotiator.go | 4 ++-- pkg/synchromanager/clustersynchro/resource_synchro.go | 2 +- 31 files changed, 22 insertions(+), 22 deletions(-) rename pkg/{ => runtime}/discovery/controller/apiservice.go (100%) rename pkg/{ => runtime}/discovery/controller/crd.go (97%) rename pkg/{ => runtime}/discovery/discovery_cache.go (100%) rename pkg/{ => runtime}/discovery/dynamic_discovery.go (99%) rename pkg/{ => runtime}/discovery/server_version.go (100%) rename pkg/{synchromanager/clustersynchro => runtime}/informer/cache/.reflector.go (100%) rename pkg/{synchromanager/clustersynchro => runtime}/informer/event_handler.go (100%) rename pkg/{synchromanager/clustersynchro => runtime}/informer/informer.go (100%) rename pkg/{synchromanager/clustersynchro => runtime}/informer/listwatch.go (100%) rename pkg/{synchromanager/clustersynchro => runtime}/informer/named_controller.go (100%) rename pkg/{synchromanager/clustersynchro => runtime}/informer/pager/.pager.go.copy (100%) rename pkg/{synchromanager/clustersynchro => runtime}/informer/pager/pager.go (100%) rename pkg/{synchromanager/clustersynchro => runtime}/informer/pager/result_stream.go (100%) rename pkg/{synchromanager/clustersynchro => runtime}/informer/queue.go (100%) rename pkg/{synchromanager/clustersynchro => runtime}/informer/reflector.go (99%) rename pkg/{synchromanager/clustersynchro => runtime}/informer/resourceversion_informer.go (100%) rename pkg/{synchromanager/clustersynchro => runtime}/informer/resourceversion_storage.go (100%) rename pkg/{ => runtime}/scheme/import_known_versions.go (100%) rename pkg/{ => runtime}/scheme/scheme.go (94%) rename pkg/{ => runtime}/scheme/unstructured/scheme.go (100%) diff --git a/cmd/controller-manager/app/controllermanager.go b/cmd/controller-manager/app/controllermanager.go index 7f3177655..7a6744d5a 100644 --- a/cmd/controller-manager/app/controllermanager.go +++ b/cmd/controller-manager/app/controllermanager.go @@ -29,7 +29,7 @@ import ( "github.com/clusterpedia-io/clusterpedia/pkg/controller/pediaclusterlifecycle" clientset "github.com/clusterpedia-io/clusterpedia/pkg/generated/clientset/versioned" "github.com/clusterpedia-io/clusterpedia/pkg/generated/informers/externalversions" - "github.com/clusterpedia-io/clusterpedia/pkg/synchromanager/clustersynchro/informer" + "github.com/clusterpedia-io/clusterpedia/pkg/runtime/informer" clusterpediafeature "github.com/clusterpedia-io/clusterpedia/pkg/utils/feature" "github.com/clusterpedia-io/clusterpedia/pkg/version/verflag" ) diff --git a/hack/verify-forked-code.sh b/hack/verify-forked-code.sh index 883cc81ac..aa1a6d0d6 100644 --- a/hack/verify-forked-code.sh +++ b/hack/verify-forked-code.sh @@ -5,23 +5,23 @@ set -o nounset set -o pipefail reflector=0 -diff vendor/k8s.io/client-go/tools/cache/reflector.go pkg/synchromanager/clustersynchro/informer/cache/.reflector.go || reflector=$? +diff vendor/k8s.io/client-go/tools/cache/reflector.go pkg/runtime/informer/cache/.reflector.go || reflector=$? if [[ $reflector -eq 0 ]] then echo "'reflector.go' is up to date." else - echo "the file 'reflector.go' in vendor has been changed, please update the 'cache/.reflector.go' and 'reflector.go' in the pkg/synchromanager/clustersynchro/informer" + echo "the file 'reflector.go' in vendor has been changed, please update the 'cache/.reflector.go' and 'reflector.go' in the pkg/runtime/informer" exit 1 fi pager=0 -diff vendor/k8s.io/client-go/tools/pager/pager.go pkg/synchromanager/clustersynchro/informer/pager/.pager.go.copy || pager=$? +diff vendor/k8s.io/client-go/tools/pager/pager.go pkg/runtime/informer/pager/.pager.go.copy || pager=$? if [[ $pager -eq 0 ]] then echo "'pager.go' is up to date." else - echo "the file 'pager.go' in vendor has been changed, please update the '.pager.go.copy' and 'pager.go' in the pkg/synchromanager/clustersynchro/informer/pager" + echo "the file 'pager.go' in vendor has been changed, please update the '.pager.go.copy' and 'pager.go' in the pkg/runtime/informer/pager" exit 1 fi diff --git a/pkg/controller/dependentresource_manager.go b/pkg/controller/dependentresource_manager.go index 32b280735..fc33f11b3 100644 --- a/pkg/controller/dependentresource_manager.go +++ b/pkg/controller/dependentresource_manager.go @@ -16,7 +16,7 @@ import ( "k8s.io/klog/v2" policyv1alpha1 "github.com/clusterpedia-io/api/policy/v1alpha1" - "github.com/clusterpedia-io/clusterpedia/pkg/synchromanager/clustersynchro/informer" + "github.com/clusterpedia-io/clusterpedia/pkg/runtime/informer" ) type DependentResourceManager struct { diff --git a/pkg/kube_state_metrics/metrics_store.go b/pkg/kube_state_metrics/metrics_store.go index 0feb0c532..34d0b3b62 100644 --- a/pkg/kube_state_metrics/metrics_store.go +++ b/pkg/kube_state_metrics/metrics_store.go @@ -16,7 +16,7 @@ import ( "k8s.io/kube-state-metrics/v2/pkg/optin" "k8s.io/kube-state-metrics/v2/pkg/options" - "github.com/clusterpedia-io/clusterpedia/pkg/scheme" + "github.com/clusterpedia-io/clusterpedia/pkg/runtime/scheme" "github.com/clusterpedia-io/clusterpedia/pkg/storageconfig" ) diff --git a/pkg/kubeapiserver/restmanager.go b/pkg/kubeapiserver/restmanager.go index 160e53786..7da80fe37 100644 --- a/pkg/kubeapiserver/restmanager.go +++ b/pkg/kubeapiserver/restmanager.go @@ -28,8 +28,8 @@ import ( "github.com/clusterpedia-io/clusterpedia/pkg/kubeapiserver/discovery" "github.com/clusterpedia-io/clusterpedia/pkg/kubeapiserver/printers" "github.com/clusterpedia-io/clusterpedia/pkg/kubeapiserver/resourcerest" - "github.com/clusterpedia-io/clusterpedia/pkg/scheme" - unstructuredscheme "github.com/clusterpedia-io/clusterpedia/pkg/scheme/unstructured" + "github.com/clusterpedia-io/clusterpedia/pkg/runtime/scheme" + unstructuredscheme "github.com/clusterpedia-io/clusterpedia/pkg/runtime/scheme/unstructured" "github.com/clusterpedia-io/clusterpedia/pkg/storage" "github.com/clusterpedia-io/clusterpedia/pkg/storageconfig" ) diff --git a/pkg/discovery/controller/apiservice.go b/pkg/runtime/discovery/controller/apiservice.go similarity index 100% rename from pkg/discovery/controller/apiservice.go rename to pkg/runtime/discovery/controller/apiservice.go diff --git a/pkg/discovery/controller/crd.go b/pkg/runtime/discovery/controller/crd.go similarity index 97% rename from pkg/discovery/controller/crd.go rename to pkg/runtime/discovery/controller/crd.go index da2b0d784..78109d2e8 100644 --- a/pkg/discovery/controller/crd.go +++ b/pkg/runtime/discovery/controller/crd.go @@ -17,8 +17,8 @@ import ( "k8s.io/client-go/tools/cache" "k8s.io/klog/v2" - "github.com/clusterpedia-io/clusterpedia/pkg/scheme" - "github.com/clusterpedia-io/clusterpedia/pkg/synchromanager/clustersynchro/informer" + "github.com/clusterpedia-io/clusterpedia/pkg/runtime/informer" + "github.com/clusterpedia-io/clusterpedia/pkg/runtime/scheme" ) type CRDController struct { diff --git a/pkg/discovery/discovery_cache.go b/pkg/runtime/discovery/discovery_cache.go similarity index 100% rename from pkg/discovery/discovery_cache.go rename to pkg/runtime/discovery/discovery_cache.go diff --git a/pkg/discovery/dynamic_discovery.go b/pkg/runtime/discovery/dynamic_discovery.go similarity index 99% rename from pkg/discovery/dynamic_discovery.go rename to pkg/runtime/discovery/dynamic_discovery.go index 9b20f4407..1a82ccb5b 100644 --- a/pkg/discovery/dynamic_discovery.go +++ b/pkg/runtime/discovery/dynamic_discovery.go @@ -17,7 +17,7 @@ import ( "k8s.io/client-go/tools/cache" "k8s.io/klog/v2" - "github.com/clusterpedia-io/clusterpedia/pkg/discovery/controller" + "github.com/clusterpedia-io/clusterpedia/pkg/runtime/discovery/controller" ) type DynamicDiscoveryInterface interface { diff --git a/pkg/discovery/server_version.go b/pkg/runtime/discovery/server_version.go similarity index 100% rename from pkg/discovery/server_version.go rename to pkg/runtime/discovery/server_version.go diff --git a/pkg/synchromanager/clustersynchro/informer/cache/.reflector.go b/pkg/runtime/informer/cache/.reflector.go similarity index 100% rename from pkg/synchromanager/clustersynchro/informer/cache/.reflector.go rename to pkg/runtime/informer/cache/.reflector.go diff --git a/pkg/synchromanager/clustersynchro/informer/event_handler.go b/pkg/runtime/informer/event_handler.go similarity index 100% rename from pkg/synchromanager/clustersynchro/informer/event_handler.go rename to pkg/runtime/informer/event_handler.go diff --git a/pkg/synchromanager/clustersynchro/informer/informer.go b/pkg/runtime/informer/informer.go similarity index 100% rename from pkg/synchromanager/clustersynchro/informer/informer.go rename to pkg/runtime/informer/informer.go diff --git a/pkg/synchromanager/clustersynchro/informer/listwatch.go b/pkg/runtime/informer/listwatch.go similarity index 100% rename from pkg/synchromanager/clustersynchro/informer/listwatch.go rename to pkg/runtime/informer/listwatch.go diff --git a/pkg/synchromanager/clustersynchro/informer/named_controller.go b/pkg/runtime/informer/named_controller.go similarity index 100% rename from pkg/synchromanager/clustersynchro/informer/named_controller.go rename to pkg/runtime/informer/named_controller.go diff --git a/pkg/synchromanager/clustersynchro/informer/pager/.pager.go.copy b/pkg/runtime/informer/pager/.pager.go.copy similarity index 100% rename from pkg/synchromanager/clustersynchro/informer/pager/.pager.go.copy rename to pkg/runtime/informer/pager/.pager.go.copy diff --git a/pkg/synchromanager/clustersynchro/informer/pager/pager.go b/pkg/runtime/informer/pager/pager.go similarity index 100% rename from pkg/synchromanager/clustersynchro/informer/pager/pager.go rename to pkg/runtime/informer/pager/pager.go diff --git a/pkg/synchromanager/clustersynchro/informer/pager/result_stream.go b/pkg/runtime/informer/pager/result_stream.go similarity index 100% rename from pkg/synchromanager/clustersynchro/informer/pager/result_stream.go rename to pkg/runtime/informer/pager/result_stream.go diff --git a/pkg/synchromanager/clustersynchro/informer/queue.go b/pkg/runtime/informer/queue.go similarity index 100% rename from pkg/synchromanager/clustersynchro/informer/queue.go rename to pkg/runtime/informer/queue.go diff --git a/pkg/synchromanager/clustersynchro/informer/reflector.go b/pkg/runtime/informer/reflector.go similarity index 99% rename from pkg/synchromanager/clustersynchro/informer/reflector.go rename to pkg/runtime/informer/reflector.go index 701a0a8ee..3b6b66da9 100644 --- a/pkg/synchromanager/clustersynchro/informer/reflector.go +++ b/pkg/runtime/informer/reflector.go @@ -27,7 +27,7 @@ import ( "k8s.io/utils/clock" "k8s.io/utils/trace" - clspager "github.com/clusterpedia-io/clusterpedia/pkg/synchromanager/clustersynchro/informer/pager" + clspager "github.com/clusterpedia-io/clusterpedia/pkg/runtime/informer/pager" ) const defaultExpectedTypeName = "" diff --git a/pkg/synchromanager/clustersynchro/informer/resourceversion_informer.go b/pkg/runtime/informer/resourceversion_informer.go similarity index 100% rename from pkg/synchromanager/clustersynchro/informer/resourceversion_informer.go rename to pkg/runtime/informer/resourceversion_informer.go diff --git a/pkg/synchromanager/clustersynchro/informer/resourceversion_storage.go b/pkg/runtime/informer/resourceversion_storage.go similarity index 100% rename from pkg/synchromanager/clustersynchro/informer/resourceversion_storage.go rename to pkg/runtime/informer/resourceversion_storage.go diff --git a/pkg/scheme/import_known_versions.go b/pkg/runtime/scheme/import_known_versions.go similarity index 100% rename from pkg/scheme/import_known_versions.go rename to pkg/runtime/scheme/import_known_versions.go diff --git a/pkg/scheme/scheme.go b/pkg/runtime/scheme/scheme.go similarity index 94% rename from pkg/scheme/scheme.go rename to pkg/runtime/scheme/scheme.go index 856ff8bf5..36ea8a205 100644 --- a/pkg/scheme/scheme.go +++ b/pkg/runtime/scheme/scheme.go @@ -4,7 +4,7 @@ import ( "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/kubernetes/pkg/api/legacyscheme" - unstructuredscheme "github.com/clusterpedia-io/clusterpedia/pkg/scheme/unstructured" + unstructuredscheme "github.com/clusterpedia-io/clusterpedia/pkg/runtime/scheme/unstructured" ) var ( diff --git a/pkg/scheme/unstructured/scheme.go b/pkg/runtime/scheme/unstructured/scheme.go similarity index 100% rename from pkg/scheme/unstructured/scheme.go rename to pkg/runtime/scheme/unstructured/scheme.go diff --git a/pkg/storage/internalstorage/collectionresource.go b/pkg/storage/internalstorage/collectionresource.go index fa86494e0..f8d5bbdf9 100644 --- a/pkg/storage/internalstorage/collectionresource.go +++ b/pkg/storage/internalstorage/collectionresource.go @@ -5,7 +5,7 @@ import ( "k8s.io/apimachinery/pkg/util/sets" internal "github.com/clusterpedia-io/api/clusterpedia" - "github.com/clusterpedia-io/clusterpedia/pkg/scheme" + "github.com/clusterpedia-io/clusterpedia/pkg/runtime/scheme" ) const ( diff --git a/pkg/storage/memorystorage/watchcache/watch_cache.go b/pkg/storage/memorystorage/watchcache/watch_cache.go index 0c0aa97dd..605fa5162 100644 --- a/pkg/storage/memorystorage/watchcache/watch_cache.go +++ b/pkg/storage/memorystorage/watchcache/watch_cache.go @@ -20,7 +20,7 @@ import ( "k8s.io/utils/strings/slices" internal "github.com/clusterpedia-io/api/clusterpedia" - "github.com/clusterpedia-io/clusterpedia/pkg/scheme" + "github.com/clusterpedia-io/clusterpedia/pkg/runtime/scheme" utilwatch "github.com/clusterpedia-io/clusterpedia/pkg/utils/watch" ) diff --git a/pkg/storageconfig/storageconfig_factory.go b/pkg/storageconfig/storageconfig_factory.go index 4462583bd..93f13d46e 100644 --- a/pkg/storageconfig/storageconfig_factory.go +++ b/pkg/storageconfig/storageconfig_factory.go @@ -8,7 +8,7 @@ import ( serverstorage "k8s.io/apiserver/pkg/server/storage" apisstorage "k8s.io/kubernetes/pkg/apis/storage" - "github.com/clusterpedia-io/clusterpedia/pkg/scheme" + "github.com/clusterpedia-io/clusterpedia/pkg/runtime/scheme" "github.com/clusterpedia-io/clusterpedia/pkg/storage" ) diff --git a/pkg/synchromanager/clustersynchro/cluster_synchro.go b/pkg/synchromanager/clustersynchro/cluster_synchro.go index 527c7a259..09f82f387 100644 --- a/pkg/synchromanager/clustersynchro/cluster_synchro.go +++ b/pkg/synchromanager/clustersynchro/cluster_synchro.go @@ -16,11 +16,11 @@ import ( metricsstore "k8s.io/kube-state-metrics/v2/pkg/metrics_store" clusterv1alpha2 "github.com/clusterpedia-io/api/cluster/v1alpha2" - "github.com/clusterpedia-io/clusterpedia/pkg/discovery" kubestatemetrics "github.com/clusterpedia-io/clusterpedia/pkg/kube_state_metrics" + "github.com/clusterpedia-io/clusterpedia/pkg/runtime/discovery" + "github.com/clusterpedia-io/clusterpedia/pkg/runtime/informer" "github.com/clusterpedia-io/clusterpedia/pkg/storage" "github.com/clusterpedia-io/clusterpedia/pkg/storageconfig" - "github.com/clusterpedia-io/clusterpedia/pkg/synchromanager/clustersynchro/informer" "github.com/clusterpedia-io/clusterpedia/pkg/synchromanager/features" clusterpediafeature "github.com/clusterpedia-io/clusterpedia/pkg/utils/feature" ) diff --git a/pkg/synchromanager/clustersynchro/resource_negotiator.go b/pkg/synchromanager/clustersynchro/resource_negotiator.go index 42b111af8..4f41c6d70 100644 --- a/pkg/synchromanager/clustersynchro/resource_negotiator.go +++ b/pkg/synchromanager/clustersynchro/resource_negotiator.go @@ -13,8 +13,8 @@ import ( "k8s.io/klog/v2" clusterv1alpha2 "github.com/clusterpedia-io/api/cluster/v1alpha2" - "github.com/clusterpedia-io/clusterpedia/pkg/discovery" - "github.com/clusterpedia-io/clusterpedia/pkg/scheme" + "github.com/clusterpedia-io/clusterpedia/pkg/runtime/discovery" + "github.com/clusterpedia-io/clusterpedia/pkg/runtime/scheme" "github.com/clusterpedia-io/clusterpedia/pkg/storage" "github.com/clusterpedia-io/clusterpedia/pkg/storageconfig" "github.com/clusterpedia-io/clusterpedia/pkg/synchromanager/features" diff --git a/pkg/synchromanager/clustersynchro/resource_synchro.go b/pkg/synchromanager/clustersynchro/resource_synchro.go index dbf0a37a6..403a0b50a 100644 --- a/pkg/synchromanager/clustersynchro/resource_synchro.go +++ b/pkg/synchromanager/clustersynchro/resource_synchro.go @@ -20,8 +20,8 @@ import ( clusterv1alpha2 "github.com/clusterpedia-io/api/cluster/v1alpha2" kubestatemetrics "github.com/clusterpedia-io/clusterpedia/pkg/kube_state_metrics" + "github.com/clusterpedia-io/clusterpedia/pkg/runtime/informer" "github.com/clusterpedia-io/clusterpedia/pkg/storage" - "github.com/clusterpedia-io/clusterpedia/pkg/synchromanager/clustersynchro/informer" "github.com/clusterpedia-io/clusterpedia/pkg/synchromanager/clustersynchro/queue" "github.com/clusterpedia-io/clusterpedia/pkg/synchromanager/features" "github.com/clusterpedia-io/clusterpedia/pkg/utils"