diff --git a/.goreleaser.yaml b/.goreleaser.yaml index e5a22af60..861482c01 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -80,6 +80,14 @@ archives: builds_info: group: root owner: root + - id: syncer_archives + format: binary + builds: + - vcluster + name_template: "syncer-{{ .Os }}-{{ .Arch }}" + builds_info: + group: root + owner: root sboms: - id: vcluster_sbom diff --git a/cmd/vcluster/cmd/start.go b/cmd/vcluster/cmd/start.go index 74be79683..58ff79f30 100644 --- a/cmd/vcluster/cmd/start.go +++ b/cmd/vcluster/cmd/start.go @@ -76,17 +76,17 @@ func NewStartCommand() *cobra.Command { func ExecuteStart(ctx context.Context, options *options.VirtualClusterOptions) error { // set suffix - translate.Suffix = options.Name - if translate.Suffix == "" { - translate.Suffix = options.DeprecatedSuffix + translate.VClusterName = options.Name + if translate.VClusterName == "" { + translate.VClusterName = options.DeprecatedSuffix } - if translate.Suffix == "" { - translate.Suffix = "vcluster" + if translate.VClusterName == "" { + translate.VClusterName = "vcluster" } // set service name if options.ServiceName == "" { - options.ServiceName = translate.Suffix + options.ServiceName = translate.VClusterName } // get current namespace @@ -115,7 +115,7 @@ func ExecuteStart(ctx context.Context, options *options.VirtualClusterOptions) e inClusterClient, currentNamespace, currentNamespace, - translate.Suffix, + translate.VClusterName, options, ) if err != nil { diff --git a/hack/build-cli.sh b/hack/build-cli.sh deleted file mode 100644 index 38d89ef47..000000000 --- a/hack/build-cli.sh +++ /dev/null @@ -1,77 +0,0 @@ -#!/usr/bin/env bash -# This script will build vcluster and calculate hash for each -# (VCLUSTER_BUILD_PLATFORMS, VCLUSTER_BUILD_ARCHS) pair. -# VCLUSTER_BUILD_PLATFORMS="linux" VCLUSTER_BUILD_ARCHS="amd64" ./hack/build-all.bash -# can be called to build only for linux-amd64 - -set -e - -export GO111MODULE=on -export GOFLAGS=-mod=vendor - -# Update vendor directory -# go mod vendor - -VCLUSTER_ROOT=$(git rev-parse --show-toplevel) -COMMIT_HASH=$(git rev-parse --short HEAD 2>/dev/null) -DATE=$(date "+%Y-%m-%d") -BUILD_PLATFORM=$(uname -a | awk '{print tolower($1);}') - -echo "Current working directory is $(pwd)" -echo "PATH is $PATH" -echo "GOPATH is $GOPATH" - -if [[ "$(pwd)" != "${VCLUSTER_ROOT}" ]]; then - echo "you are not in the root of the repo" 1>&2 - echo "please cd to ${VCLUSTER_ROOT} before running this script" 1>&2 - exit 1 -fi - -RELEASE_VERSION="${RELEASE_VERSION}" go generate ${VCLUSTER_ROOT}/... - -GO_BUILD_CMD="go build -a" -GO_BUILD_LDFLAGS="-s -w -X main.commitHash=${COMMIT_HASH} -X main.buildDate=${DATE} -X main.version=${RELEASE_VERSION}" - -if [[ -z "${VCLUSTER_BUILD_PLATFORMS}" ]]; then - VCLUSTER_BUILD_PLATFORMS="linux windows darwin" -fi - -if [[ -z "${VCLUSTER_BUILD_ARCHS}" ]]; then - VCLUSTER_BUILD_ARCHS="amd64 386 arm64" -fi - -# Create the release directory -mkdir -p "${VCLUSTER_ROOT}/release" - -# copy assets -cp -a "${VCLUSTER_ROOT}/assets/." "${VCLUSTER_ROOT}/release/" - -# generate vcluster-images.txt -go run -mod vendor "${VCLUSTER_ROOT}/hack/assets/main.go" ${RELEASE_VERSION} > "${VCLUSTER_ROOT}/release/vcluster-images.txt" - -for OS in ${VCLUSTER_BUILD_PLATFORMS[@]}; do - for ARCH in ${VCLUSTER_BUILD_ARCHS[@]}; do - NAME="vcluster-${OS}-${ARCH}" - if [[ "${OS}" == "windows" ]]; then - NAME="${NAME}.exe" - fi - - # darwin 386 is deprecated and shouldn't be used anymore - if [[ "${ARCH}" == "386" && "${OS}" == "darwin" ]]; then - echo "Building for ${OS}/${ARCH} not supported." - continue - fi - - # arm64 build is only supported for darwin - if [[ "${ARCH}" == "arm64" && "${OS}" == "windows" ]]; then - echo "Building for ${OS}/${ARCH} not supported." - continue - fi - - echo "Building for ${OS}/${ARCH}" - CGO_ENABLED=0 GOARCH=${ARCH} GOOS=${OS} ${GO_BUILD_CMD} -tags embed_charts -ldflags "${GO_BUILD_LDFLAGS}"\ - -o "${VCLUSTER_ROOT}/release/${NAME}" cmd/vclusterctl/main.go - shasum -a 256 "${VCLUSTER_ROOT}/release/${NAME}" | cut -d ' ' -f 1 > "${VCLUSTER_ROOT}/release/${NAME}".sha256 - cosign sign-blob --yes --output-signature "${VCLUSTER_ROOT}/release/${NAME}".sha256.sig --output-certificate "${VCLUSTER_ROOT}/release/${NAME}".sha256.pem "${VCLUSTER_ROOT}/release/${NAME}".sha256 - done -done diff --git a/pkg/controllers/generic/import_syncer.go b/pkg/controllers/generic/import_syncer.go index 37e70d734..d56e0b780 100644 --- a/pkg/controllers/generic/import_syncer.go +++ b/pkg/controllers/generic/import_syncer.go @@ -153,7 +153,7 @@ func (s *importer) ExcludePhysical(pObj client.Object) bool { func (s *importer) excludeObject(obj client.Object) bool { // check if back sync is disabled eg. for service account token secrets if obj.GetAnnotations() != nil && - obj.GetAnnotations()[translate.SkipBacksyncInMultiNamespaceMode] == "true" { + obj.GetAnnotations()[translate.SkipBackSyncInMultiNamespaceMode] == "true" { return true } diff --git a/pkg/controllers/manifests/init.go b/pkg/controllers/manifests/init.go index 9192417b8..42834cce2 100644 --- a/pkg/controllers/manifests/init.go +++ b/pkg/controllers/manifests/init.go @@ -60,7 +60,7 @@ type InitManifestsConfigMapReconciler struct { func (r *InitManifestsConfigMapReconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ctrl.Result, err error) { // TODO: implement better filtration through predicates - if req.Name != translate.Suffix+InitManifestSuffix { + if req.Name != translate.VClusterName+InitManifestSuffix { return ctrl.Result{}, nil } diff --git a/pkg/controllers/register.go b/pkg/controllers/register.go index 848cfe1dd..446c6e087 100644 --- a/pkg/controllers/register.go +++ b/pkg/controllers/register.go @@ -280,7 +280,7 @@ func RegisterInitManifestsController(controllerCtx *options.ControllerContext) e result, err := controller.Reconcile(ctx, ctrl.Request{ NamespacedName: types.NamespacedName{ Namespace: controllerCtx.CurrentNamespace, - Name: translate.Suffix + manifests.InitManifestSuffix, + Name: translate.VClusterName + manifests.InitManifestSuffix, }, }) if err != nil { diff --git a/pkg/controllers/resources/configmaps/syncer.go b/pkg/controllers/resources/configmaps/syncer.go index ad7929688..735234991 100644 --- a/pkg/controllers/resources/configmaps/syncer.go +++ b/pkg/controllers/resources/configmaps/syncer.go @@ -40,7 +40,7 @@ type configMapSyncer struct { func ConfigMapNameTranslator(vNN types.NamespacedName, _ client.Object) string { name := translate.Default.PhysicalName(vNN.Name, vNN.Namespace) if name == "kube-root-ca.crt" { - name = translate.SafeConcatName("vcluster", "kube-root-ca.crt", "x", translate.Suffix) + name = translate.SafeConcatName("vcluster", "kube-root-ca.crt", "x", translate.VClusterName) } return name } diff --git a/pkg/controllers/resources/ingressclasses/syncer_test.go b/pkg/controllers/resources/ingressclasses/syncer_test.go index 5483e05bc..990bc8224 100644 --- a/pkg/controllers/resources/ingressclasses/syncer_test.go +++ b/pkg/controllers/resources/ingressclasses/syncer_test.go @@ -34,7 +34,7 @@ func TestSync(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: vObjectMeta.Name, Labels: map[string]string{ - translate.MarkerLabel: translate.Suffix, + translate.MarkerLabel: translate.VClusterName, }, Annotations: map[string]string{ translate.NameAnnotation: "test-ingc", @@ -62,7 +62,7 @@ func TestSync(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: translate.Default.PhysicalNameClusterScoped(vObjectMeta.Name), Labels: map[string]string{ - translate.MarkerLabel: translate.Suffix, + translate.MarkerLabel: translate.VClusterName, }, Annotations: map[string]string{ translate.NameAnnotation: "test-ingc", diff --git a/pkg/controllers/resources/ingresses/legacy/syncer_test.go b/pkg/controllers/resources/ingresses/legacy/syncer_test.go index 2336c08e3..28bb8d20d 100644 --- a/pkg/controllers/resources/ingresses/legacy/syncer_test.go +++ b/pkg/controllers/resources/ingresses/legacy/syncer_test.go @@ -103,7 +103,7 @@ func TestSync(t *testing.T) { translate.UIDAnnotation: "", }, Labels: map[string]string{ - translate.MarkerLabel: translate.Suffix, + translate.MarkerLabel: translate.VClusterName, translate.NamespaceLabel: vObjectMeta.Namespace, }, } diff --git a/pkg/controllers/resources/ingresses/syncer_test.go b/pkg/controllers/resources/ingresses/syncer_test.go index 25b9286d1..ebb39776a 100644 --- a/pkg/controllers/resources/ingresses/syncer_test.go +++ b/pkg/controllers/resources/ingresses/syncer_test.go @@ -111,7 +111,7 @@ func TestSync(t *testing.T) { translate.UIDAnnotation: "", }, Labels: map[string]string{ - translate.MarkerLabel: translate.Suffix, + translate.MarkerLabel: translate.VClusterName, translate.NamespaceLabel: vObjectMeta.Namespace, }, } diff --git a/pkg/controllers/resources/networkpolicies/syncer_test.go b/pkg/controllers/resources/networkpolicies/syncer_test.go index 3b8658cf9..4d775df83 100644 --- a/pkg/controllers/resources/networkpolicies/syncer_test.go +++ b/pkg/controllers/resources/networkpolicies/syncer_test.go @@ -52,7 +52,7 @@ func TestSync(t *testing.T) { MatchLabels: map[string]string{ translate.Default.ConvertLabelKey("mykey"): "mylabel", translate.NamespaceLabel: vObjectMeta.Namespace, - translate.MarkerLabel: translate.Suffix, + translate.MarkerLabel: translate.VClusterName, }, MatchExpressions: []metav1.LabelSelectorRequirement{ { @@ -72,7 +72,7 @@ func TestSync(t *testing.T) { translate.UIDAnnotation: "", }, Labels: map[string]string{ - translate.MarkerLabel: translate.Suffix, + translate.MarkerLabel: translate.VClusterName, translate.NamespaceLabel: vObjectMeta.Namespace, }, } @@ -92,7 +92,7 @@ func TestSync(t *testing.T) { pnetworkPolicyNoPodSelector.Spec.PodSelector = metav1.LabelSelector{ MatchLabels: map[string]string{ translate.NamespaceLabel: vObjectMeta.Namespace, - translate.MarkerLabel: translate.Suffix, + translate.MarkerLabel: translate.VClusterName, }, } @@ -125,7 +125,7 @@ func TestSync(t *testing.T) { From: []networkingv1.NetworkPolicyPeer{{PodSelector: &metav1.LabelSelector{ MatchLabels: map[string]string{ translate.Default.ConvertLabelKey("random-key"): "value", - translate.MarkerLabel: translate.Suffix, + translate.MarkerLabel: translate.VClusterName, translate.NamespaceLabel: vnetworkPolicyWithPodSelectorNoNs.GetNamespace(), }, MatchExpressions: []metav1.LabelSelectorRequirement{}, @@ -196,7 +196,7 @@ func TestSync(t *testing.T) { From: []networkingv1.NetworkPolicyPeer{{ PodSelector: &metav1.LabelSelector{ MatchLabels: map[string]string{ - translate.MarkerLabel: translate.Suffix, + translate.MarkerLabel: translate.VClusterName, }, MatchExpressions: []metav1.LabelSelectorRequirement{ { diff --git a/pkg/controllers/resources/networkpolicies/translate.go b/pkg/controllers/resources/networkpolicies/translate.go index 3028d8bf6..c072a43f8 100644 --- a/pkg/controllers/resources/networkpolicies/translate.go +++ b/pkg/controllers/resources/networkpolicies/translate.go @@ -72,7 +72,7 @@ func translateSpec(spec *networkingv1.NetworkPolicySpec, namespace string) *netw // add selector for namespace as NetworkPolicy podSelector applies to pods within it's namespace outSpec.PodSelector.MatchLabels[translate.NamespaceLabel] = namespace // add selector for the marker label to select only from pods belonging this vcluster instance - outSpec.PodSelector.MatchLabels[translate.MarkerLabel] = translate.Suffix + outSpec.PodSelector.MatchLabels[translate.MarkerLabel] = translate.VClusterName outSpec.PolicyTypes = spec.PolicyTypes return outSpec @@ -99,7 +99,7 @@ func translateNetworkPolicyPeers(peers []networkingv1.NetworkPolicyPeer, namespa newPeer.PodSelector.MatchLabels[translate.NamespaceLabel] = namespace } // add selector for the marker label to select only from pods belonging this vcluster instance - newPeer.PodSelector.MatchLabels[translate.MarkerLabel] = translate.Suffix + newPeer.PodSelector.MatchLabels[translate.MarkerLabel] = translate.VClusterName } else { newPeer.IPBlock = peer.IPBlock.DeepCopy() } diff --git a/pkg/controllers/resources/nodes/fake_syncer.go b/pkg/controllers/resources/nodes/fake_syncer.go index d9911ac74..38cb6c33f 100644 --- a/pkg/controllers/resources/nodes/fake_syncer.go +++ b/pkg/controllers/resources/nodes/fake_syncer.go @@ -326,7 +326,7 @@ func GetNodeHost(nodeName string) string { // GetNodeHostLegacy returns Node hostname in a format used in 0.14.x release. // This function is added for backwards compatibility and may be removed in a future release. func GetNodeHostLegacy(nodeName, currentNamespace string) string { - hostname := strings.ReplaceAll(nodeName, ".", "-") + "." + translate.Suffix + "." + currentNamespace + "." + constants.NodeSuffix + hostname := strings.ReplaceAll(nodeName, ".", "-") + "." + translate.VClusterName + "." + currentNamespace + "." + constants.NodeSuffix log := loghelper.New("GetNodeHostLegacy()") log.Debugf("translating nodename %q into hostname: %q", nodeName, hostname) return hostname diff --git a/pkg/controllers/resources/nodes/nodeservice/node_service.go b/pkg/controllers/resources/nodes/nodeservice/node_service.go index b99a891b5..d88103dbf 100644 --- a/pkg/controllers/resources/nodes/nodeservice/node_service.go +++ b/pkg/controllers/resources/nodes/nodeservice/node_service.go @@ -75,7 +75,7 @@ func (n *nodeServiceProvider) cleanupNodeServices(ctx context.Context) error { serviceList := &corev1.ServiceList{} err := n.currentNamespaceClient.List(ctx, serviceList, client.InNamespace(n.currentNamespace), client.MatchingLabels{ - ServiceClusterLabel: translate.Suffix, + ServiceClusterLabel: translate.VClusterName, }) if err != nil { return errors.Wrap(err, "list services") @@ -124,7 +124,7 @@ func (n *nodeServiceProvider) Unlock() { } func (n *nodeServiceProvider) GetNodeIP(ctx context.Context, name string) (string, error) { - serviceName := translate.SafeConcatName(translate.Suffix, "node", strings.ReplaceAll(name, ".", "-")) + serviceName := translate.SafeConcatName(translate.VClusterName, "node", strings.ReplaceAll(name, ".", "-")) service := &corev1.Service{} err := n.currentNamespaceClient.Get(ctx, types.NamespacedName{Name: serviceName, Namespace: n.currentNamespace}, service) @@ -158,7 +158,7 @@ func (n *nodeServiceProvider) GetNodeIP(ctx context.Context, name string) (strin Namespace: n.currentNamespace, Name: serviceName, Labels: map[string]string{ - ServiceClusterLabel: translate.Suffix, + ServiceClusterLabel: translate.VClusterName, ServiceNodeLabel: name, }, }, diff --git a/pkg/controllers/resources/nodes/syncer.go b/pkg/controllers/resources/nodes/syncer.go index 3bbcf0901..9c8955752 100644 --- a/pkg/controllers/resources/nodes/syncer.go +++ b/pkg/controllers/resources/nodes/syncer.go @@ -99,7 +99,7 @@ var _ syncertypes.ControllerModifier = &nodeSyncer{} func (s *nodeSyncer) ModifyController(ctx *synccontext.RegisterContext, bld *builder.Builder) (*builder.Builder, error) { if s.enableScheduler { - notManagedSelector, err := labels.NewRequirement(translate.MarkerLabel, selection.NotEquals, []string{translate.Suffix}) + notManagedSelector, err := labels.NewRequirement(translate.MarkerLabel, selection.NotEquals, []string{translate.VClusterName}) if err != nil { return bld, fmt.Errorf("constructing label selector for non-vcluster pods: %w", err) } diff --git a/pkg/controllers/resources/persistentvolumeclaims/syncer_test.go b/pkg/controllers/resources/persistentvolumeclaims/syncer_test.go index cd9e1331d..12ff4b13d 100644 --- a/pkg/controllers/resources/persistentvolumeclaims/syncer_test.go +++ b/pkg/controllers/resources/persistentvolumeclaims/syncer_test.go @@ -33,7 +33,7 @@ func TestSync(t *testing.T) { translate.UIDAnnotation: "", }, Labels: map[string]string{ - translate.MarkerLabel: translate.Suffix, + translate.MarkerLabel: translate.VClusterName, translate.NamespaceLabel: vObjectMeta.Namespace, }, } diff --git a/pkg/controllers/resources/poddisruptionbudgets/syncer_test.go b/pkg/controllers/resources/poddisruptionbudgets/syncer_test.go index 1b0ffb19e..7a9a94498 100644 --- a/pkg/controllers/resources/poddisruptionbudgets/syncer_test.go +++ b/pkg/controllers/resources/poddisruptionbudgets/syncer_test.go @@ -33,7 +33,7 @@ func TestSync(t *testing.T) { }, Labels: map[string]string{ translate.NamespaceLabel: vObjectMeta.Namespace, - translate.MarkerLabel: translate.Suffix, + translate.MarkerLabel: translate.VClusterName, }, ResourceVersion: generictesting.FakeClientResourceVersion, } diff --git a/pkg/controllers/resources/pods/syncer_test.go b/pkg/controllers/resources/pods/syncer_test.go index 5828bf784..4b52afd63 100644 --- a/pkg/controllers/resources/pods/syncer_test.go +++ b/pkg/controllers/resources/pods/syncer_test.go @@ -69,7 +69,7 @@ func TestSync(t *testing.T) { ClusterIP: "1.2.3.4", }, } - translate.Suffix = generictesting.DefaultTestVclusterName + translate.VClusterName = generictesting.DefaultTestVclusterName pDNSService := corev1.Service{ ObjectMeta: metav1.ObjectMeta{ Name: translate.Default.PhysicalName("kube-dns", "kube-system"), @@ -104,7 +104,7 @@ func TestSync(t *testing.T) { }, Labels: map[string]string{ translate.NamespaceLabel: vObjectMeta.Namespace, - translate.MarkerLabel: translate.Suffix, + translate.MarkerLabel: translate.VClusterName, }, } pPodBase := &corev1.Pod{ @@ -248,7 +248,7 @@ func TestSync(t *testing.T) { }, Labels: map[string]string{ translate.NamespaceLabel: vHostPathPod.Namespace, - translate.MarkerLabel: translate.Suffix, + translate.MarkerLabel: translate.VClusterName, }, // CreationTimestamp: metav1.Time{}, // ResourceVersion: "999", diff --git a/pkg/controllers/resources/pods/translate/sa_token_secret.go b/pkg/controllers/resources/pods/translate/sa_token_secret.go index 95bf109f9..e37a31871 100644 --- a/pkg/controllers/resources/pods/translate/sa_token_secret.go +++ b/pkg/controllers/resources/pods/translate/sa_token_secret.go @@ -66,7 +66,7 @@ func SATokenSecret(ctx context.Context, pClient client.Client, vPod *corev1.Pod, Namespace: translate.Default.PhysicalNamespace(vPod.Namespace), Annotations: map[string]string{ - translate.SkipBacksyncInMultiNamespaceMode: "true", + translate.SkipBackSyncInMultiNamespaceMode: "true", }, }, Type: corev1.SecretTypeOpaque, diff --git a/pkg/controllers/resources/pods/translate/translator.go b/pkg/controllers/resources/pods/translate/translator.go index 534db2892..1c3e8b43b 100644 --- a/pkg/controllers/resources/pods/translate/translator.go +++ b/pkg/controllers/resources/pods/translate/translator.go @@ -450,7 +450,7 @@ func (t *translator) translateProjectedVolume( if projectedVolume.Sources[i].ConfigMap != nil { projectedVolume.Sources[i].ConfigMap.Name = translate.Default.PhysicalName(projectedVolume.Sources[i].ConfigMap.Name, vPod.Namespace) if projectedVolume.Sources[i].ConfigMap.Name == "kube-root-ca.crt" { - projectedVolume.Sources[i].ConfigMap.Name = translate.SafeConcatName("vcluster", "kube-root-ca.crt", "x", translate.Suffix) + projectedVolume.Sources[i].ConfigMap.Name = translate.SafeConcatName("vcluster", "kube-root-ca.crt", "x", translate.VClusterName) } } if projectedVolume.Sources[i].DownwardAPI != nil { @@ -782,7 +782,7 @@ func (t *translator) translatePodAffinityTerm(vPod *corev1.Pod, term corev1.PodA if newAffinityTerm.LabelSelector.MatchLabels == nil { newAffinityTerm.LabelSelector.MatchLabels = map[string]string{} } - newAffinityTerm.LabelSelector.MatchLabels[translate.MarkerLabel] = translate.Suffix + newAffinityTerm.LabelSelector.MatchLabels[translate.MarkerLabel] = translate.VClusterName } return newAffinityTerm } @@ -797,7 +797,7 @@ func translateTopologySpreadConstraints(vPod *corev1.Pod, pPod *corev1.Pod) { pPod.Spec.TopologySpreadConstraints[i].LabelSelector.MatchLabels = map[string]string{} } pPod.Spec.TopologySpreadConstraints[i].LabelSelector.MatchLabels[translate.NamespaceLabel] = vPod.Namespace - pPod.Spec.TopologySpreadConstraints[i].LabelSelector.MatchLabels[translate.MarkerLabel] = translate.Suffix + pPod.Spec.TopologySpreadConstraints[i].LabelSelector.MatchLabels[translate.MarkerLabel] = translate.VClusterName } } } diff --git a/pkg/controllers/resources/pods/translate/translator_test.go b/pkg/controllers/resources/pods/translate/translator_test.go index eb0d41963..1083de2a8 100644 --- a/pkg/controllers/resources/pods/translate/translator_test.go +++ b/pkg/controllers/resources/pods/translate/translator_test.go @@ -29,7 +29,7 @@ func TestPodAffinityTermsTranslation(t *testing.T) { for k, v := range basicSelector.MatchLabels { basicSelectorTranslatedWithMarker.MatchLabels[translate.Default.ConvertLabelKey(k)] = v } - basicSelectorTranslatedWithMarker.MatchLabels[translate.MarkerLabel] = translate.Suffix + basicSelectorTranslatedWithMarker.MatchLabels[translate.MarkerLabel] = translate.VClusterName testCases := []translatePodAffinityTermTestCase{ { @@ -97,7 +97,7 @@ func TestPodAffinityTermsTranslation(t *testing.T) { MatchLabels: map[string]string{ translate.ConvertLabelKeyWithPrefix(NamespaceLabelPrefix, longKey): "good-value", }, - }, translate.MarkerLabel, translate.Suffix), + }, translate.MarkerLabel, translate.VClusterName), }, }, { @@ -123,7 +123,7 @@ func TestPodAffinityTermsTranslation(t *testing.T) { Values: []string{"bad-value"}, }, }, - }, translate.MarkerLabel, translate.Suffix), + }, translate.MarkerLabel, translate.VClusterName), }, }, } diff --git a/pkg/controllers/resources/services/syncer_test.go b/pkg/controllers/resources/services/syncer_test.go index dfad8d1a4..3459a08b1 100644 --- a/pkg/controllers/resources/services/syncer_test.go +++ b/pkg/controllers/resources/services/syncer_test.go @@ -34,7 +34,7 @@ func TestSync(t *testing.T) { }, Labels: map[string]string{ translate.NamespaceLabel: vObjectMeta.Namespace, - translate.MarkerLabel: translate.Suffix, + translate.MarkerLabel: translate.VClusterName, }, } vKubernetesObjectMeta := metav1.ObjectMeta{ @@ -295,7 +295,7 @@ func TestSync(t *testing.T) { Selector: map[string]string{ translate.ConvertLabelKeyWithPrefix(translate.LabelPrefix, selectorKey): vServiceNodePortFromExternal.Spec.Selector[selectorKey], translate.NamespaceLabel: vServiceNodePortFromExternal.Namespace, - translate.MarkerLabel: translate.Suffix, + translate.MarkerLabel: translate.VClusterName, }, Type: corev1.ServiceTypeNodePort, Ports: vServiceNodePortFromExternal.Spec.Ports, diff --git a/pkg/controllers/resources/storageclasses/syncer_test.go b/pkg/controllers/resources/storageclasses/syncer_test.go index fe0aae6ea..94343c9be 100644 --- a/pkg/controllers/resources/storageclasses/syncer_test.go +++ b/pkg/controllers/resources/storageclasses/syncer_test.go @@ -28,7 +28,7 @@ func TestSync(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: translate.Default.PhysicalNameClusterScoped(vObjectMeta.Name), Labels: map[string]string{ - translate.MarkerLabel: translate.Suffix, + translate.MarkerLabel: translate.VClusterName, }, Annotations: map[string]string{ translate.NameAnnotation: "testsc", @@ -48,7 +48,7 @@ func TestSync(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: translate.Default.PhysicalNameClusterScoped(vObjectMeta.Name), Labels: map[string]string{ - translate.MarkerLabel: translate.Suffix, + translate.MarkerLabel: translate.VClusterName, }, Annotations: map[string]string{ translate.NameAnnotation: "testsc", diff --git a/pkg/controllers/resources/volumesnapshots/volumesnapshots/syncer_test.go b/pkg/controllers/resources/volumesnapshots/volumesnapshots/syncer_test.go index b36525bff..14a4f02a5 100644 --- a/pkg/controllers/resources/volumesnapshots/volumesnapshots/syncer_test.go +++ b/pkg/controllers/resources/volumesnapshots/volumesnapshots/syncer_test.go @@ -63,7 +63,7 @@ func TestSync(t *testing.T) { translate.UIDAnnotation: "", }, Labels: map[string]string{ - translate.MarkerLabel: translate.Suffix, + translate.MarkerLabel: translate.VClusterName, translate.NamespaceLabel: vObjectMeta.Namespace, }, } diff --git a/pkg/controllers/syncer/syncer.go b/pkg/controllers/syncer/syncer.go index 23c5ac6dc..c53444e33 100644 --- a/pkg/controllers/syncer/syncer.go +++ b/pkg/controllers/syncer/syncer.go @@ -150,7 +150,7 @@ func (r *syncerController) Reconcile(ctx context.Context, req ctrl.Request) (ctr return r.syncer.Sync(syncContext, pObj, vObj) } else if vObj == nil && pObj != nil { if pObj.GetAnnotations() != nil { - if shouldSkip, ok := pObj.GetAnnotations()[translate.SkipBacksyncInMultiNamespaceMode]; ok && shouldSkip == "true" { + if shouldSkip, ok := pObj.GetAnnotations()[translate.SkipBackSyncInMultiNamespaceMode]; ok && shouldSkip == "true" { // do not delete return ctrl.Result{}, nil } @@ -174,13 +174,10 @@ func (r *syncerController) excludePhysical(pObj client.Object) bool { return excluder.ExcludePhysical(pObj) } - if pObj.GetLabels() != nil && - pObj.GetLabels()[translate.ControllerLabel] != "" { + if pObj.GetLabels() != nil && pObj.GetLabels()[translate.ControllerLabel] != "" { return true } - if pObj.GetAnnotations() != nil && - pObj.GetAnnotations()[translate.ControllerLabel] != "" && - pObj.GetAnnotations()[translate.ControllerLabel] != r.syncer.Name() { + if pObj.GetAnnotations() != nil && pObj.GetAnnotations()[translate.ControllerLabel] != "" && pObj.GetAnnotations()[translate.ControllerLabel] != r.syncer.Name() { return true } @@ -193,13 +190,10 @@ func (r *syncerController) excludeVirtual(vObj client.Object) bool { return excluder.ExcludeVirtual(vObj) } - if vObj.GetLabels() != nil && - vObj.GetLabels()[translate.ControllerLabel] != "" { + if vObj.GetLabels() != nil && vObj.GetLabels()[translate.ControllerLabel] != "" { return true } - if vObj.GetAnnotations() != nil && - vObj.GetAnnotations()[translate.ControllerLabel] != "" && - vObj.GetAnnotations()[translate.ControllerLabel] != r.syncer.Name() { + if vObj.GetAnnotations() != nil && vObj.GetAnnotations()[translate.ControllerLabel] != "" && vObj.GetAnnotations()[translate.ControllerLabel] != r.syncer.Name() { return true } diff --git a/pkg/leaderelection/leaderelection.go b/pkg/leaderelection/leaderelection.go index c41c586cc..d44f2f7ea 100644 --- a/pkg/leaderelection/leaderelection.go +++ b/pkg/leaderelection/leaderelection.go @@ -50,7 +50,7 @@ func StartLeaderElection(ctx *options.ControllerContext, scheme *runtime.Scheme, rl, err := resourcelock.New( resourcelock.LeasesResourceLock, ctx.CurrentNamespace, - translate.SafeConcatName("vcluster", translate.Suffix, "controller"), + translate.SafeConcatName("vcluster", translate.VClusterName, "controller"), leaderElectionClient.CoreV1(), leaderElectionClient.CoordinationV1(), resourcelock.ResourceLockConfig{ diff --git a/pkg/patches/patch_test.go b/pkg/patches/patch_test.go index e2369b154..cee53c637 100644 --- a/pkg/patches/patch_test.go +++ b/pkg/patches/patch_test.go @@ -240,7 +240,7 @@ test2: {}`, targetNamespace: "vcluster", }, obj1: `name: abc`, - expected: fmt.Sprint(`name: abc-x-default-x-`, translate.Suffix), + expected: fmt.Sprint(`name: abc-x-default-x-`, translate.VClusterName), }, { name: "rewrite name - invalid object", @@ -271,9 +271,9 @@ test2: {}`, ns: xyz`, expected: `root: list: - - nm: abc-x-pqr-x-` + fmt.Sprint(translate.Suffix) + ` + - nm: abc-x-pqr-x-` + fmt.Sprint(translate.VClusterName) + ` ns: vcluster - - nm: def-x-xyz-x-` + fmt.Sprint(translate.Suffix) + ` + - nm: def-x-xyz-x-` + fmt.Sprint(translate.VClusterName) + ` ns: vcluster`, }, { @@ -295,9 +295,9 @@ test2: {}`, ns: pqr`, expected: `root: list: - - nm: abc-x-default-x-` + fmt.Sprint(translate.Suffix) + ` + - nm: abc-x-default-x-` + fmt.Sprint(translate.VClusterName) + ` ns: pqr - - nm: def-x-default-x-` + fmt.Sprint(translate.Suffix) + ` + - nm: def-x-default-x-` + fmt.Sprint(translate.VClusterName) + ` ns: pqr`, }, { @@ -321,8 +321,8 @@ test2: {}`, expected: `root: includes: - names: - - nm: abc-x-pqr-x-` + fmt.Sprint(translate.Suffix) + ` - - nm: def-x-pqr-x-` + fmt.Sprint(translate.Suffix) + ` + - nm: abc-x-pqr-x-` + fmt.Sprint(translate.VClusterName) + ` + - nm: def-x-pqr-x-` + fmt.Sprint(translate.VClusterName) + ` namespace: vcluster`, }, { @@ -343,7 +343,7 @@ test2: {}`, namespace: pqr`, expected: `root: includes: - nm: abc-x-pqr-x-` + fmt.Sprint(translate.Suffix) + ` + nm: abc-x-pqr-x-` + fmt.Sprint(translate.VClusterName) + ` namespace: vcluster`, }, { diff --git a/pkg/plugin/v2/config.go b/pkg/plugin/v2/config.go new file mode 100644 index 000000000..f67d96207 --- /dev/null +++ b/pkg/plugin/v2/config.go @@ -0,0 +1,35 @@ +package v2 + +import "encoding/json" + +// InitConfig is the config the syncer sends to the plugin +type InitConfig struct { + VirtualClusterConfig []byte `json:"virtualClusterConfig,omitempty"` + PhysicalClusterConfig []byte `json:"physicalClusterConfig,omitempty"` + SyncerConfig []byte `json:"syncerConfig,omitempty"` + TargetNamespace string `json:"targetNamespace,omitempty"` + CurrentNamespace string `json:"currentNamespace,omitempty"` + Options []byte `json:"options,omitempty"` + WorkingDir string `json:"workingDir,omitempty"` +} + +// PluginConfig is the config the plugin sends back to the syncer +type PluginConfig struct { + ClientHooks []*ClientHook `json:"clientHooks,omitempty"` +} + +type ClientHook struct { + APIVersion string `json:"apiVersion,omitempty"` + Kind string `json:"kind,omitempty"` + Types []string `json:"types,omitempty"` +} + +func parsePluginConfig(config string) (*PluginConfig, error) { + pluginConfig := &PluginConfig{} + err := json.Unmarshal([]byte(config), pluginConfig) + if err != nil { + return nil, err + } + + return pluginConfig, nil +} diff --git a/pkg/plugin/v2/plugin.go b/pkg/plugin/v2/plugin.go index 1c2f816ef..e39afd1e3 100644 --- a/pkg/plugin/v2/plugin.go +++ b/pkg/plugin/v2/plugin.go @@ -7,6 +7,7 @@ import ( "os" "os/exec" "path" + "path/filepath" "time" "github.com/hashicorp/go-plugin" @@ -81,28 +82,34 @@ func (m *Manager) Start( } } - // build the start request - startRequest, err := m.buildStartRequest(currentNamespace, targetNamespace, virtualKubeConfig, physicalKubeConfig, syncerConfig, options) - if err != nil { - return fmt.Errorf("build start request: %w", err) - } - // after loading all plugins we start them for _, vClusterPlugin := range m.Plugins { + // build the start request + initRequest, err := m.buildInitRequest(filepath.Dir(vClusterPlugin.Path), currentNamespace, targetNamespace, virtualKubeConfig, physicalKubeConfig, syncerConfig, options) + if err != nil { + return fmt.Errorf("build start request: %w", err) + } + // start the plugin - _, err = vClusterPlugin.GRPCClient.Start(ctx, startRequest) + _, err = vClusterPlugin.GRPCClient.Initialize(ctx, initRequest) if err != nil { return fmt.Errorf("error starting plugin %s: %w", vClusterPlugin.Path, err) } - // get client hooks - clientHooks, err := vClusterPlugin.GRPCClient.GetClientHooks(ctx, &pluginv2.GetClientHooks_Request{}) + // get plugin config + pluginConfigResponse, err := vClusterPlugin.GRPCClient.GetPluginConfig(ctx, &pluginv2.GetPluginConfig_Request{}) if err != nil { return fmt.Errorf("error retrieving client hooks for plugin %s: %w", vClusterPlugin.Path, err) } - // add client hooks - err = m.addClientHooks(vClusterPlugin, clientHooks.ClientHooks) + // parse plugin config + pluginConfig, err := parsePluginConfig(pluginConfigResponse.Config) + if err != nil { + return fmt.Errorf("error parsing plugin config: %w", err) + } + + // register client hooks + err = m.registerClientHooks(vClusterPlugin, pluginConfig.ClientHooks) if err != nil { return fmt.Errorf("error adding client hook for plugin %s: %w", vClusterPlugin.Path, err) } @@ -192,9 +199,9 @@ func (m *Manager) HasPlugins() bool { return len(m.Plugins) > 0 } -func (m *Manager) addClientHooks(vClusterPlugin *vClusterPlugin, clientHooks []*pluginv2.GetClientHooks_ClientHook) error { +func (m *Manager) registerClientHooks(vClusterPlugin *vClusterPlugin, clientHooks []*ClientHook) error { for _, clientHookInfo := range clientHooks { - if clientHookInfo.ApiVersion == "" { + if clientHookInfo.APIVersion == "" { return fmt.Errorf("api version is empty in plugin %s hook", vClusterPlugin.Path) } else if clientHookInfo.Kind == "" { return fmt.Errorf("kind is empty in plugin %s hook", vClusterPlugin.Path) @@ -206,7 +213,7 @@ func (m *Manager) addClientHooks(vClusterPlugin *vClusterPlugin, clientHooks []* } versionKindType := plugintypes.VersionKindType{ - APIVersion: clientHookInfo.ApiVersion, + APIVersion: clientHookInfo.APIVersion, Kind: clientHookInfo.Kind, Type: t, } @@ -214,19 +221,21 @@ func (m *Manager) addClientHooks(vClusterPlugin *vClusterPlugin, clientHooks []* m.ClientHooks[versionKindType] = append(m.ClientHooks[versionKindType], vClusterPlugin) } - klog.Infof("Register client hook for %s %s in plugin %s", clientHookInfo.ApiVersion, clientHookInfo.Kind, vClusterPlugin.Path) + klog.Infof("Register client hook for %s %s in plugin %s", clientHookInfo.APIVersion, clientHookInfo.Kind, vClusterPlugin.Path) } return nil } -func (m *Manager) buildStartRequest( - currentNamespace, targetNamespace string, +func (m *Manager) buildInitRequest( + workingDir, + currentNamespace, + targetNamespace string, virtualKubeConfig *rest.Config, physicalKubeConfig *rest.Config, syncerConfig *clientcmdapi.Config, options *options.VirtualClusterOptions, -) (*pluginv2.Start_Request, error) { +) (*pluginv2.Initialize_Request, error) { // Context options encodedOptions, err := json.Marshal(options) if err != nil { @@ -267,13 +276,22 @@ func (m *Manager) buildStartRequest( return nil, fmt.Errorf("marshal syncer client config: %w", err) } - return &pluginv2.Start_Request{ - VirtualClusterConfig: string(virtualConfigBytes), - PhysicalClusterConfig: string(phyisicalConfigBytes), - SyncerConfig: string(syncerConfigBytes), + // marshal init config + initConfig, err := json.Marshal(&InitConfig{ + VirtualClusterConfig: virtualConfigBytes, + PhysicalClusterConfig: phyisicalConfigBytes, + SyncerConfig: syncerConfigBytes, TargetNamespace: targetNamespace, CurrentNamespace: currentNamespace, - Options: string(encodedOptions), + Options: encodedOptions, + WorkingDir: workingDir, + }) + if err != nil { + return nil, fmt.Errorf("error encoding init config: %w", err) + } + + return &pluginv2.Initialize_Request{ + Config: string(initConfig), }, nil } diff --git a/pkg/plugin/v2/pluginv2/pluginv2.pb.go b/pkg/plugin/v2/pluginv2/pluginv2.pb.go index 2fa0a2f32..ea35e9ae9 100644 --- a/pkg/plugin/v2/pluginv2/pluginv2.pb.go +++ b/pkg/plugin/v2/pluginv2/pluginv2.pb.go @@ -22,14 +22,14 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -type Start struct { +type Initialize struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields } -func (x *Start) Reset() { - *x = Start{} +func (x *Initialize) Reset() { + *x = Initialize{} if protoimpl.UnsafeEnabled { mi := &file_pluginv2_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -37,13 +37,13 @@ func (x *Start) Reset() { } } -func (x *Start) String() string { +func (x *Initialize) String() string { return protoimpl.X.MessageStringOf(x) } -func (*Start) ProtoMessage() {} +func (*Initialize) ProtoMessage() {} -func (x *Start) ProtoReflect() protoreflect.Message { +func (x *Initialize) ProtoReflect() protoreflect.Message { mi := &file_pluginv2_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -55,19 +55,19 @@ func (x *Start) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use Start.ProtoReflect.Descriptor instead. -func (*Start) Descriptor() ([]byte, []int) { +// Deprecated: Use Initialize.ProtoReflect.Descriptor instead. +func (*Initialize) Descriptor() ([]byte, []int) { return file_pluginv2_proto_rawDescGZIP(), []int{0} } -type GetClientHooks struct { +type GetPluginConfig struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields } -func (x *GetClientHooks) Reset() { - *x = GetClientHooks{} +func (x *GetPluginConfig) Reset() { + *x = GetPluginConfig{} if protoimpl.UnsafeEnabled { mi := &file_pluginv2_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -75,13 +75,13 @@ func (x *GetClientHooks) Reset() { } } -func (x *GetClientHooks) String() string { +func (x *GetPluginConfig) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GetClientHooks) ProtoMessage() {} +func (*GetPluginConfig) ProtoMessage() {} -func (x *GetClientHooks) ProtoReflect() protoreflect.Message { +func (x *GetPluginConfig) ProtoReflect() protoreflect.Message { mi := &file_pluginv2_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -93,8 +93,8 @@ func (x *GetClientHooks) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use GetClientHooks.ProtoReflect.Descriptor instead. -func (*GetClientHooks) Descriptor() ([]byte, []int) { +// Deprecated: Use GetPluginConfig.ProtoReflect.Descriptor instead. +func (*GetPluginConfig) Descriptor() ([]byte, []int) { return file_pluginv2_proto_rawDescGZIP(), []int{1} } @@ -174,21 +174,16 @@ func (*SetLeader) Descriptor() ([]byte, []int) { return file_pluginv2_proto_rawDescGZIP(), []int{3} } -type Start_Request struct { +type Initialize_Request struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - VirtualClusterConfig string `protobuf:"bytes,1,opt,name=virtualClusterConfig,proto3" json:"virtualClusterConfig,omitempty"` - PhysicalClusterConfig string `protobuf:"bytes,2,opt,name=physicalClusterConfig,proto3" json:"physicalClusterConfig,omitempty"` - SyncerConfig string `protobuf:"bytes,3,opt,name=syncerConfig,proto3" json:"syncerConfig,omitempty"` - TargetNamespace string `protobuf:"bytes,4,opt,name=targetNamespace,proto3" json:"targetNamespace,omitempty"` - CurrentNamespace string `protobuf:"bytes,5,opt,name=currentNamespace,proto3" json:"currentNamespace,omitempty"` - Options string `protobuf:"bytes,6,opt,name=options,proto3" json:"options,omitempty"` + Config string `protobuf:"bytes,1,opt,name=config,proto3" json:"config,omitempty"` } -func (x *Start_Request) Reset() { - *x = Start_Request{} +func (x *Initialize_Request) Reset() { + *x = Initialize_Request{} if protoimpl.UnsafeEnabled { mi := &file_pluginv2_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -196,13 +191,13 @@ func (x *Start_Request) Reset() { } } -func (x *Start_Request) String() string { +func (x *Initialize_Request) String() string { return protoimpl.X.MessageStringOf(x) } -func (*Start_Request) ProtoMessage() {} +func (*Initialize_Request) ProtoMessage() {} -func (x *Start_Request) ProtoReflect() protoreflect.Message { +func (x *Initialize_Request) ProtoReflect() protoreflect.Message { mi := &file_pluginv2_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -214,61 +209,26 @@ func (x *Start_Request) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use Start_Request.ProtoReflect.Descriptor instead. -func (*Start_Request) Descriptor() ([]byte, []int) { +// Deprecated: Use Initialize_Request.ProtoReflect.Descriptor instead. +func (*Initialize_Request) Descriptor() ([]byte, []int) { return file_pluginv2_proto_rawDescGZIP(), []int{0, 0} } -func (x *Start_Request) GetVirtualClusterConfig() string { +func (x *Initialize_Request) GetConfig() string { if x != nil { - return x.VirtualClusterConfig + return x.Config } return "" } -func (x *Start_Request) GetPhysicalClusterConfig() string { - if x != nil { - return x.PhysicalClusterConfig - } - return "" -} - -func (x *Start_Request) GetSyncerConfig() string { - if x != nil { - return x.SyncerConfig - } - return "" -} - -func (x *Start_Request) GetTargetNamespace() string { - if x != nil { - return x.TargetNamespace - } - return "" -} - -func (x *Start_Request) GetCurrentNamespace() string { - if x != nil { - return x.CurrentNamespace - } - return "" -} - -func (x *Start_Request) GetOptions() string { - if x != nil { - return x.Options - } - return "" -} - -type Start_Response struct { +type Initialize_Response struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields } -func (x *Start_Response) Reset() { - *x = Start_Response{} +func (x *Initialize_Response) Reset() { + *x = Initialize_Response{} if protoimpl.UnsafeEnabled { mi := &file_pluginv2_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -276,13 +236,13 @@ func (x *Start_Response) Reset() { } } -func (x *Start_Response) String() string { +func (x *Initialize_Response) String() string { return protoimpl.X.MessageStringOf(x) } -func (*Start_Response) ProtoMessage() {} +func (*Initialize_Response) ProtoMessage() {} -func (x *Start_Response) ProtoReflect() protoreflect.Message { +func (x *Initialize_Response) ProtoReflect() protoreflect.Message { mi := &file_pluginv2_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -294,19 +254,19 @@ func (x *Start_Response) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use Start_Response.ProtoReflect.Descriptor instead. -func (*Start_Response) Descriptor() ([]byte, []int) { +// Deprecated: Use Initialize_Response.ProtoReflect.Descriptor instead. +func (*Initialize_Response) Descriptor() ([]byte, []int) { return file_pluginv2_proto_rawDescGZIP(), []int{0, 1} } -type GetClientHooks_Request struct { +type GetPluginConfig_Request struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields } -func (x *GetClientHooks_Request) Reset() { - *x = GetClientHooks_Request{} +func (x *GetPluginConfig_Request) Reset() { + *x = GetPluginConfig_Request{} if protoimpl.UnsafeEnabled { mi := &file_pluginv2_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -314,13 +274,13 @@ func (x *GetClientHooks_Request) Reset() { } } -func (x *GetClientHooks_Request) String() string { +func (x *GetPluginConfig_Request) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GetClientHooks_Request) ProtoMessage() {} +func (*GetPluginConfig_Request) ProtoMessage() {} -func (x *GetClientHooks_Request) ProtoReflect() protoreflect.Message { +func (x *GetPluginConfig_Request) ProtoReflect() protoreflect.Message { mi := &file_pluginv2_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -332,21 +292,21 @@ func (x *GetClientHooks_Request) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use GetClientHooks_Request.ProtoReflect.Descriptor instead. -func (*GetClientHooks_Request) Descriptor() ([]byte, []int) { +// Deprecated: Use GetPluginConfig_Request.ProtoReflect.Descriptor instead. +func (*GetPluginConfig_Request) Descriptor() ([]byte, []int) { return file_pluginv2_proto_rawDescGZIP(), []int{1, 0} } -type GetClientHooks_Response struct { +type GetPluginConfig_Response struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - ClientHooks []*GetClientHooks_ClientHook `protobuf:"bytes,1,rep,name=clientHooks,proto3" json:"clientHooks,omitempty"` + Config string `protobuf:"bytes,1,opt,name=config,proto3" json:"config,omitempty"` } -func (x *GetClientHooks_Response) Reset() { - *x = GetClientHooks_Response{} +func (x *GetPluginConfig_Response) Reset() { + *x = GetPluginConfig_Response{} if protoimpl.UnsafeEnabled { mi := &file_pluginv2_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -354,13 +314,13 @@ func (x *GetClientHooks_Response) Reset() { } } -func (x *GetClientHooks_Response) String() string { +func (x *GetPluginConfig_Response) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GetClientHooks_Response) ProtoMessage() {} +func (*GetPluginConfig_Response) ProtoMessage() {} -func (x *GetClientHooks_Response) ProtoReflect() protoreflect.Message { +func (x *GetPluginConfig_Response) ProtoReflect() protoreflect.Message { mi := &file_pluginv2_proto_msgTypes[7] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -372,81 +332,18 @@ func (x *GetClientHooks_Response) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use GetClientHooks_Response.ProtoReflect.Descriptor instead. -func (*GetClientHooks_Response) Descriptor() ([]byte, []int) { +// Deprecated: Use GetPluginConfig_Response.ProtoReflect.Descriptor instead. +func (*GetPluginConfig_Response) Descriptor() ([]byte, []int) { return file_pluginv2_proto_rawDescGZIP(), []int{1, 1} } -func (x *GetClientHooks_Response) GetClientHooks() []*GetClientHooks_ClientHook { - if x != nil { - return x.ClientHooks - } - return nil -} - -type GetClientHooks_ClientHook struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - ApiVersion string `protobuf:"bytes,1,opt,name=apiVersion,proto3" json:"apiVersion,omitempty"` - Kind string `protobuf:"bytes,2,opt,name=kind,proto3" json:"kind,omitempty"` - Types []string `protobuf:"bytes,3,rep,name=types,proto3" json:"types,omitempty"` -} - -func (x *GetClientHooks_ClientHook) Reset() { - *x = GetClientHooks_ClientHook{} - if protoimpl.UnsafeEnabled { - mi := &file_pluginv2_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GetClientHooks_ClientHook) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetClientHooks_ClientHook) ProtoMessage() {} - -func (x *GetClientHooks_ClientHook) ProtoReflect() protoreflect.Message { - mi := &file_pluginv2_proto_msgTypes[8] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GetClientHooks_ClientHook.ProtoReflect.Descriptor instead. -func (*GetClientHooks_ClientHook) Descriptor() ([]byte, []int) { - return file_pluginv2_proto_rawDescGZIP(), []int{1, 2} -} - -func (x *GetClientHooks_ClientHook) GetApiVersion() string { +func (x *GetPluginConfig_Response) GetConfig() string { if x != nil { - return x.ApiVersion + return x.Config } return "" } -func (x *GetClientHooks_ClientHook) GetKind() string { - if x != nil { - return x.Kind - } - return "" -} - -func (x *GetClientHooks_ClientHook) GetTypes() []string { - if x != nil { - return x.Types - } - return nil -} - type Mutate_Request struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -461,7 +358,7 @@ type Mutate_Request struct { func (x *Mutate_Request) Reset() { *x = Mutate_Request{} if protoimpl.UnsafeEnabled { - mi := &file_pluginv2_proto_msgTypes[9] + mi := &file_pluginv2_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -474,7 +371,7 @@ func (x *Mutate_Request) String() string { func (*Mutate_Request) ProtoMessage() {} func (x *Mutate_Request) ProtoReflect() protoreflect.Message { - mi := &file_pluginv2_proto_msgTypes[9] + mi := &file_pluginv2_proto_msgTypes[8] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -530,7 +427,7 @@ type Mutate_Response struct { func (x *Mutate_Response) Reset() { *x = Mutate_Response{} if protoimpl.UnsafeEnabled { - mi := &file_pluginv2_proto_msgTypes[10] + mi := &file_pluginv2_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -543,7 +440,7 @@ func (x *Mutate_Response) String() string { func (*Mutate_Response) ProtoMessage() {} func (x *Mutate_Response) ProtoReflect() protoreflect.Message { - mi := &file_pluginv2_proto_msgTypes[10] + mi := &file_pluginv2_proto_msgTypes[9] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -582,7 +479,7 @@ type SetLeader_Request struct { func (x *SetLeader_Request) Reset() { *x = SetLeader_Request{} if protoimpl.UnsafeEnabled { - mi := &file_pluginv2_proto_msgTypes[11] + mi := &file_pluginv2_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -595,7 +492,7 @@ func (x *SetLeader_Request) String() string { func (*SetLeader_Request) ProtoMessage() {} func (x *SetLeader_Request) ProtoReflect() protoreflect.Message { - mi := &file_pluginv2_proto_msgTypes[11] + mi := &file_pluginv2_proto_msgTypes[10] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -620,7 +517,7 @@ type SetLeader_Response struct { func (x *SetLeader_Response) Reset() { *x = SetLeader_Response{} if protoimpl.UnsafeEnabled { - mi := &file_pluginv2_proto_msgTypes[12] + mi := &file_pluginv2_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -633,7 +530,7 @@ func (x *SetLeader_Response) String() string { func (*SetLeader_Response) ProtoMessage() {} func (x *SetLeader_Response) ProtoReflect() protoreflect.Message { - mi := &file_pluginv2_proto_msgTypes[12] + mi := &file_pluginv2_proto_msgTypes[11] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -653,73 +550,52 @@ var File_pluginv2_proto protoreflect.FileDescriptor var file_pluginv2_proto_rawDesc = []byte{ 0x0a, 0x0e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x76, 0x32, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x12, 0x08, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x76, 0x32, 0x22, 0x9d, 0x02, 0x0a, 0x05, 0x53, - 0x74, 0x61, 0x72, 0x74, 0x1a, 0x87, 0x02, 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x12, 0x32, 0x0a, 0x14, 0x76, 0x69, 0x72, 0x74, 0x75, 0x61, 0x6c, 0x43, 0x6c, 0x75, 0x73, 0x74, - 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x14, - 0x76, 0x69, 0x72, 0x74, 0x75, 0x61, 0x6c, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x43, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x12, 0x34, 0x0a, 0x15, 0x70, 0x68, 0x79, 0x73, 0x69, 0x63, 0x61, 0x6c, - 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x15, 0x70, 0x68, 0x79, 0x73, 0x69, 0x63, 0x61, 0x6c, 0x43, 0x6c, 0x75, - 0x73, 0x74, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x22, 0x0a, 0x0c, 0x73, 0x79, - 0x6e, 0x63, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0c, 0x73, 0x79, 0x6e, 0x63, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x28, - 0x0a, 0x0f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, - 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x4e, - 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x2a, 0x0a, 0x10, 0x63, 0x75, 0x72, 0x72, - 0x65, 0x6e, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x05, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x10, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x73, - 0x70, 0x61, 0x63, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, - 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x1a, 0x0a, - 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0xc6, 0x01, 0x0a, 0x0e, 0x47, - 0x65, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x48, 0x6f, 0x6f, 0x6b, 0x73, 0x1a, 0x09, 0x0a, - 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x51, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x45, 0x0a, 0x0b, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x48, 0x6f, - 0x6f, 0x6b, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x70, 0x6c, 0x75, 0x67, - 0x69, 0x6e, 0x76, 0x32, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x48, 0x6f, - 0x6f, 0x6b, 0x73, 0x2e, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x48, 0x6f, 0x6f, 0x6b, 0x52, 0x0b, - 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x48, 0x6f, 0x6f, 0x6b, 0x73, 0x1a, 0x56, 0x0a, 0x0a, 0x43, - 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x48, 0x6f, 0x6f, 0x6b, 0x12, 0x1e, 0x0a, 0x0a, 0x61, 0x70, 0x69, - 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x61, - 0x70, 0x69, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x69, 0x6e, - 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x12, 0x14, 0x0a, - 0x05, 0x74, 0x79, 0x70, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x74, 0x79, - 0x70, 0x65, 0x73, 0x22, 0xb1, 0x01, 0x0a, 0x06, 0x4d, 0x75, 0x74, 0x61, 0x74, 0x65, 0x1a, 0x69, - 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x61, 0x70, 0x69, - 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x61, - 0x70, 0x69, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x69, 0x6e, - 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x12, 0x16, 0x0a, - 0x06, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6f, - 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x1a, 0x3c, 0x0a, 0x08, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x18, 0x0a, - 0x07, 0x6d, 0x75, 0x74, 0x61, 0x74, 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, - 0x6d, 0x75, 0x74, 0x61, 0x74, 0x65, 0x64, 0x22, 0x22, 0x0a, 0x09, 0x53, 0x65, 0x74, 0x4c, 0x65, - 0x61, 0x64, 0x65, 0x72, 0x1a, 0x09, 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x0a, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xa2, 0x02, 0x0a, 0x06, - 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x12, 0x3a, 0x0a, 0x05, 0x53, 0x74, 0x61, 0x72, 0x74, 0x12, - 0x17, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x76, 0x32, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x74, - 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, - 0x6e, 0x76, 0x32, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x74, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x55, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x48, - 0x6f, 0x6f, 0x6b, 0x73, 0x12, 0x20, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x76, 0x32, 0x2e, - 0x47, 0x65, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x48, 0x6f, 0x6f, 0x6b, 0x73, 0x2e, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x76, - 0x32, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x48, 0x6f, 0x6f, 0x6b, 0x73, + 0x12, 0x08, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x76, 0x32, 0x22, 0x3b, 0x0a, 0x0a, 0x49, 0x6e, + 0x69, 0x74, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x1a, 0x21, 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x1a, 0x0a, 0x0a, 0x08, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x40, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x50, 0x6c, + 0x75, 0x67, 0x69, 0x6e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x1a, 0x09, 0x0a, 0x07, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x22, 0xb1, 0x01, 0x0a, 0x06, 0x4d, 0x75, + 0x74, 0x61, 0x74, 0x65, 0x1a, 0x69, 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x1e, 0x0a, 0x0a, 0x61, 0x70, 0x69, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0a, 0x61, 0x70, 0x69, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, + 0x12, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6b, + 0x69, 0x6e, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x06, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x74, + 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x1a, + 0x3c, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6f, + 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6f, 0x62, 0x6a, + 0x65, 0x63, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x75, 0x74, 0x61, 0x74, 0x65, 0x64, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x6d, 0x75, 0x74, 0x61, 0x74, 0x65, 0x64, 0x22, 0x22, 0x0a, + 0x09, 0x53, 0x65, 0x74, 0x4c, 0x65, 0x61, 0x64, 0x65, 0x72, 0x1a, 0x09, 0x0a, 0x07, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0a, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x32, 0xb4, 0x02, 0x0a, 0x06, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x12, 0x49, 0x0a, 0x0a, + 0x49, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x12, 0x1c, 0x2e, 0x70, 0x6c, 0x75, + 0x67, 0x69, 0x6e, 0x76, 0x32, 0x2e, 0x49, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x65, + 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, + 0x6e, 0x76, 0x32, 0x2e, 0x49, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x2e, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x46, 0x0a, 0x09, 0x53, 0x65, 0x74, 0x4c, 0x65, + 0x61, 0x64, 0x65, 0x72, 0x12, 0x1b, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x76, 0x32, 0x2e, + 0x53, 0x65, 0x74, 0x4c, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x1c, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x76, 0x32, 0x2e, 0x53, 0x65, 0x74, + 0x4c, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x58, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x43, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x12, 0x21, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x76, 0x32, 0x2e, 0x47, 0x65, + 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x76, 0x32, + 0x2e, 0x47, 0x65, 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3d, 0x0a, 0x06, 0x4d, 0x75, 0x74, 0x61, 0x74, 0x65, 0x12, 0x18, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x76, 0x32, 0x2e, 0x4d, 0x75, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x76, 0x32, 0x2e, 0x4d, 0x75, 0x74, 0x61, 0x74, 0x65, 0x2e, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x46, 0x0a, 0x09, 0x53, 0x65, 0x74, 0x4c, - 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x1b, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x76, 0x32, - 0x2e, 0x53, 0x65, 0x74, 0x4c, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x76, 0x32, 0x2e, 0x53, 0x65, - 0x74, 0x4c, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x42, 0x34, 0x5a, 0x32, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6c, - 0x6f, 0x66, 0x74, 0x2d, 0x73, 0x68, 0x2f, 0x76, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x2f, - 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2f, 0x76, 0x32, 0x2f, 0x70, 0x6c, - 0x75, 0x67, 0x69, 0x6e, 0x76, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x34, 0x5a, 0x32, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6c, 0x6f, 0x66, 0x74, 0x2d, 0x73, 0x68, 0x2f, 0x76, + 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x6c, 0x75, 0x67, + 0x69, 0x6e, 0x2f, 0x76, 0x32, 0x2f, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x76, 0x32, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -734,37 +610,35 @@ func file_pluginv2_proto_rawDescGZIP() []byte { return file_pluginv2_proto_rawDescData } -var file_pluginv2_proto_msgTypes = make([]protoimpl.MessageInfo, 13) +var file_pluginv2_proto_msgTypes = make([]protoimpl.MessageInfo, 12) var file_pluginv2_proto_goTypes = []interface{}{ - (*Start)(nil), // 0: pluginv2.Start - (*GetClientHooks)(nil), // 1: pluginv2.GetClientHooks - (*Mutate)(nil), // 2: pluginv2.Mutate - (*SetLeader)(nil), // 3: pluginv2.SetLeader - (*Start_Request)(nil), // 4: pluginv2.Start.Request - (*Start_Response)(nil), // 5: pluginv2.Start.Response - (*GetClientHooks_Request)(nil), // 6: pluginv2.GetClientHooks.Request - (*GetClientHooks_Response)(nil), // 7: pluginv2.GetClientHooks.Response - (*GetClientHooks_ClientHook)(nil), // 8: pluginv2.GetClientHooks.ClientHook - (*Mutate_Request)(nil), // 9: pluginv2.Mutate.Request - (*Mutate_Response)(nil), // 10: pluginv2.Mutate.Response - (*SetLeader_Request)(nil), // 11: pluginv2.SetLeader.Request - (*SetLeader_Response)(nil), // 12: pluginv2.SetLeader.Response + (*Initialize)(nil), // 0: pluginv2.Initialize + (*GetPluginConfig)(nil), // 1: pluginv2.GetPluginConfig + (*Mutate)(nil), // 2: pluginv2.Mutate + (*SetLeader)(nil), // 3: pluginv2.SetLeader + (*Initialize_Request)(nil), // 4: pluginv2.Initialize.Request + (*Initialize_Response)(nil), // 5: pluginv2.Initialize.Response + (*GetPluginConfig_Request)(nil), // 6: pluginv2.GetPluginConfig.Request + (*GetPluginConfig_Response)(nil), // 7: pluginv2.GetPluginConfig.Response + (*Mutate_Request)(nil), // 8: pluginv2.Mutate.Request + (*Mutate_Response)(nil), // 9: pluginv2.Mutate.Response + (*SetLeader_Request)(nil), // 10: pluginv2.SetLeader.Request + (*SetLeader_Response)(nil), // 11: pluginv2.SetLeader.Response } var file_pluginv2_proto_depIdxs = []int32{ - 8, // 0: pluginv2.GetClientHooks.Response.clientHooks:type_name -> pluginv2.GetClientHooks.ClientHook - 4, // 1: pluginv2.Plugin.Start:input_type -> pluginv2.Start.Request - 6, // 2: pluginv2.Plugin.GetClientHooks:input_type -> pluginv2.GetClientHooks.Request - 9, // 3: pluginv2.Plugin.Mutate:input_type -> pluginv2.Mutate.Request - 11, // 4: pluginv2.Plugin.SetLeader:input_type -> pluginv2.SetLeader.Request - 5, // 5: pluginv2.Plugin.Start:output_type -> pluginv2.Start.Response - 7, // 6: pluginv2.Plugin.GetClientHooks:output_type -> pluginv2.GetClientHooks.Response - 10, // 7: pluginv2.Plugin.Mutate:output_type -> pluginv2.Mutate.Response - 12, // 8: pluginv2.Plugin.SetLeader:output_type -> pluginv2.SetLeader.Response - 5, // [5:9] is the sub-list for method output_type - 1, // [1:5] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name + 4, // 0: pluginv2.Plugin.Initialize:input_type -> pluginv2.Initialize.Request + 10, // 1: pluginv2.Plugin.SetLeader:input_type -> pluginv2.SetLeader.Request + 6, // 2: pluginv2.Plugin.GetPluginConfig:input_type -> pluginv2.GetPluginConfig.Request + 8, // 3: pluginv2.Plugin.Mutate:input_type -> pluginv2.Mutate.Request + 5, // 4: pluginv2.Plugin.Initialize:output_type -> pluginv2.Initialize.Response + 11, // 5: pluginv2.Plugin.SetLeader:output_type -> pluginv2.SetLeader.Response + 7, // 6: pluginv2.Plugin.GetPluginConfig:output_type -> pluginv2.GetPluginConfig.Response + 9, // 7: pluginv2.Plugin.Mutate:output_type -> pluginv2.Mutate.Response + 4, // [4:8] is the sub-list for method output_type + 0, // [0:4] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name } func init() { file_pluginv2_proto_init() } @@ -774,7 +648,7 @@ func file_pluginv2_proto_init() { } if !protoimpl.UnsafeEnabled { file_pluginv2_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Start); i { + switch v := v.(*Initialize); i { case 0: return &v.state case 1: @@ -786,7 +660,7 @@ func file_pluginv2_proto_init() { } } file_pluginv2_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetClientHooks); i { + switch v := v.(*GetPluginConfig); i { case 0: return &v.state case 1: @@ -822,7 +696,7 @@ func file_pluginv2_proto_init() { } } file_pluginv2_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Start_Request); i { + switch v := v.(*Initialize_Request); i { case 0: return &v.state case 1: @@ -834,7 +708,7 @@ func file_pluginv2_proto_init() { } } file_pluginv2_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Start_Response); i { + switch v := v.(*Initialize_Response); i { case 0: return &v.state case 1: @@ -846,7 +720,7 @@ func file_pluginv2_proto_init() { } } file_pluginv2_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetClientHooks_Request); i { + switch v := v.(*GetPluginConfig_Request); i { case 0: return &v.state case 1: @@ -858,7 +732,7 @@ func file_pluginv2_proto_init() { } } file_pluginv2_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetClientHooks_Response); i { + switch v := v.(*GetPluginConfig_Response); i { case 0: return &v.state case 1: @@ -870,18 +744,6 @@ func file_pluginv2_proto_init() { } } file_pluginv2_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetClientHooks_ClientHook); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pluginv2_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Mutate_Request); i { case 0: return &v.state @@ -893,7 +755,7 @@ func file_pluginv2_proto_init() { return nil } } - file_pluginv2_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + file_pluginv2_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Mutate_Response); i { case 0: return &v.state @@ -905,7 +767,7 @@ func file_pluginv2_proto_init() { return nil } } - file_pluginv2_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + file_pluginv2_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*SetLeader_Request); i { case 0: return &v.state @@ -917,7 +779,7 @@ func file_pluginv2_proto_init() { return nil } } - file_pluginv2_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + file_pluginv2_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*SetLeader_Response); i { case 0: return &v.state @@ -936,7 +798,7 @@ func file_pluginv2_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_pluginv2_proto_rawDesc, NumEnums: 0, - NumMessages: 13, + NumMessages: 12, NumExtensions: 0, NumServices: 1, }, diff --git a/pkg/plugin/v2/pluginv2/pluginv2.proto b/pkg/plugin/v2/pluginv2/pluginv2.proto index 4b29a1be4..53c86f128 100644 --- a/pkg/plugin/v2/pluginv2/pluginv2.proto +++ b/pkg/plugin/v2/pluginv2/pluginv2.proto @@ -6,38 +6,26 @@ package pluginv2; option go_package = "github.com/loft-sh/vcluster/pkg/plugin/v2/pluginv2"; service Plugin { - rpc Start(Start.Request) returns (Start.Response); - rpc GetClientHooks(GetClientHooks.Request) returns (GetClientHooks.Response); - rpc Mutate(Mutate.Request) returns (Mutate.Response); + rpc Initialize(Initialize.Request) returns (Initialize.Response); rpc SetLeader(SetLeader.Request) returns (SetLeader.Response); + rpc GetPluginConfig(GetPluginConfig.Request) returns (GetPluginConfig.Response); + + rpc Mutate(Mutate.Request) returns (Mutate.Response); } -message Start { +message Initialize { message Request { - string virtualClusterConfig = 1; - string physicalClusterConfig = 2; - string syncerConfig = 3; - - string targetNamespace = 4; - string currentNamespace = 5; - - string options = 6; + string config = 1; } message Response {} } -message GetClientHooks { +message GetPluginConfig { message Request {} message Response { - repeated ClientHook clientHooks = 1; - } - - message ClientHook { - string apiVersion = 1; - string kind = 2; - repeated string types = 3; + string config = 1; } } diff --git a/pkg/plugin/v2/pluginv2/pluginv2_grpc.pb.go b/pkg/plugin/v2/pluginv2/pluginv2_grpc.pb.go index b08b2129f..dfe860000 100644 --- a/pkg/plugin/v2/pluginv2/pluginv2_grpc.pb.go +++ b/pkg/plugin/v2/pluginv2/pluginv2_grpc.pb.go @@ -22,10 +22,10 @@ const _ = grpc.SupportPackageIsVersion7 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type PluginClient interface { - Start(ctx context.Context, in *Start_Request, opts ...grpc.CallOption) (*Start_Response, error) - GetClientHooks(ctx context.Context, in *GetClientHooks_Request, opts ...grpc.CallOption) (*GetClientHooks_Response, error) - Mutate(ctx context.Context, in *Mutate_Request, opts ...grpc.CallOption) (*Mutate_Response, error) + Initialize(ctx context.Context, in *Initialize_Request, opts ...grpc.CallOption) (*Initialize_Response, error) SetLeader(ctx context.Context, in *SetLeader_Request, opts ...grpc.CallOption) (*SetLeader_Response, error) + GetPluginConfig(ctx context.Context, in *GetPluginConfig_Request, opts ...grpc.CallOption) (*GetPluginConfig_Response, error) + Mutate(ctx context.Context, in *Mutate_Request, opts ...grpc.CallOption) (*Mutate_Response, error) } type pluginClient struct { @@ -36,36 +36,36 @@ func NewPluginClient(cc grpc.ClientConnInterface) PluginClient { return &pluginClient{cc} } -func (c *pluginClient) Start(ctx context.Context, in *Start_Request, opts ...grpc.CallOption) (*Start_Response, error) { - out := new(Start_Response) - err := c.cc.Invoke(ctx, "/pluginv2.Plugin/Start", in, out, opts...) +func (c *pluginClient) Initialize(ctx context.Context, in *Initialize_Request, opts ...grpc.CallOption) (*Initialize_Response, error) { + out := new(Initialize_Response) + err := c.cc.Invoke(ctx, "/pluginv2.Plugin/Initialize", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *pluginClient) GetClientHooks(ctx context.Context, in *GetClientHooks_Request, opts ...grpc.CallOption) (*GetClientHooks_Response, error) { - out := new(GetClientHooks_Response) - err := c.cc.Invoke(ctx, "/pluginv2.Plugin/GetClientHooks", in, out, opts...) +func (c *pluginClient) SetLeader(ctx context.Context, in *SetLeader_Request, opts ...grpc.CallOption) (*SetLeader_Response, error) { + out := new(SetLeader_Response) + err := c.cc.Invoke(ctx, "/pluginv2.Plugin/SetLeader", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *pluginClient) Mutate(ctx context.Context, in *Mutate_Request, opts ...grpc.CallOption) (*Mutate_Response, error) { - out := new(Mutate_Response) - err := c.cc.Invoke(ctx, "/pluginv2.Plugin/Mutate", in, out, opts...) +func (c *pluginClient) GetPluginConfig(ctx context.Context, in *GetPluginConfig_Request, opts ...grpc.CallOption) (*GetPluginConfig_Response, error) { + out := new(GetPluginConfig_Response) + err := c.cc.Invoke(ctx, "/pluginv2.Plugin/GetPluginConfig", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *pluginClient) SetLeader(ctx context.Context, in *SetLeader_Request, opts ...grpc.CallOption) (*SetLeader_Response, error) { - out := new(SetLeader_Response) - err := c.cc.Invoke(ctx, "/pluginv2.Plugin/SetLeader", in, out, opts...) +func (c *pluginClient) Mutate(ctx context.Context, in *Mutate_Request, opts ...grpc.CallOption) (*Mutate_Response, error) { + out := new(Mutate_Response) + err := c.cc.Invoke(ctx, "/pluginv2.Plugin/Mutate", in, out, opts...) if err != nil { return nil, err } @@ -76,10 +76,10 @@ func (c *pluginClient) SetLeader(ctx context.Context, in *SetLeader_Request, opt // All implementations must embed UnimplementedPluginServer // for forward compatibility type PluginServer interface { - Start(context.Context, *Start_Request) (*Start_Response, error) - GetClientHooks(context.Context, *GetClientHooks_Request) (*GetClientHooks_Response, error) - Mutate(context.Context, *Mutate_Request) (*Mutate_Response, error) + Initialize(context.Context, *Initialize_Request) (*Initialize_Response, error) SetLeader(context.Context, *SetLeader_Request) (*SetLeader_Response, error) + GetPluginConfig(context.Context, *GetPluginConfig_Request) (*GetPluginConfig_Response, error) + Mutate(context.Context, *Mutate_Request) (*Mutate_Response, error) mustEmbedUnimplementedPluginServer() } @@ -87,18 +87,18 @@ type PluginServer interface { type UnimplementedPluginServer struct { } -func (UnimplementedPluginServer) Start(context.Context, *Start_Request) (*Start_Response, error) { - return nil, status.Errorf(codes.Unimplemented, "method Start not implemented") +func (UnimplementedPluginServer) Initialize(context.Context, *Initialize_Request) (*Initialize_Response, error) { + return nil, status.Errorf(codes.Unimplemented, "method Initialize not implemented") +} +func (UnimplementedPluginServer) SetLeader(context.Context, *SetLeader_Request) (*SetLeader_Response, error) { + return nil, status.Errorf(codes.Unimplemented, "method SetLeader not implemented") } -func (UnimplementedPluginServer) GetClientHooks(context.Context, *GetClientHooks_Request) (*GetClientHooks_Response, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetClientHooks not implemented") +func (UnimplementedPluginServer) GetPluginConfig(context.Context, *GetPluginConfig_Request) (*GetPluginConfig_Response, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetPluginConfig not implemented") } func (UnimplementedPluginServer) Mutate(context.Context, *Mutate_Request) (*Mutate_Response, error) { return nil, status.Errorf(codes.Unimplemented, "method Mutate not implemented") } -func (UnimplementedPluginServer) SetLeader(context.Context, *SetLeader_Request) (*SetLeader_Response, error) { - return nil, status.Errorf(codes.Unimplemented, "method SetLeader not implemented") -} func (UnimplementedPluginServer) mustEmbedUnimplementedPluginServer() {} // UnsafePluginServer may be embedded to opt out of forward compatibility for this service. @@ -112,74 +112,74 @@ func RegisterPluginServer(s grpc.ServiceRegistrar, srv PluginServer) { s.RegisterService(&Plugin_ServiceDesc, srv) } -func _Plugin_Start_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(Start_Request) +func _Plugin_Initialize_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(Initialize_Request) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(PluginServer).Start(ctx, in) + return srv.(PluginServer).Initialize(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/pluginv2.Plugin/Start", + FullMethod: "/pluginv2.Plugin/Initialize", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PluginServer).Start(ctx, req.(*Start_Request)) + return srv.(PluginServer).Initialize(ctx, req.(*Initialize_Request)) } return interceptor(ctx, in, info, handler) } -func _Plugin_GetClientHooks_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetClientHooks_Request) +func _Plugin_SetLeader_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SetLeader_Request) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(PluginServer).GetClientHooks(ctx, in) + return srv.(PluginServer).SetLeader(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/pluginv2.Plugin/GetClientHooks", + FullMethod: "/pluginv2.Plugin/SetLeader", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PluginServer).GetClientHooks(ctx, req.(*GetClientHooks_Request)) + return srv.(PluginServer).SetLeader(ctx, req.(*SetLeader_Request)) } return interceptor(ctx, in, info, handler) } -func _Plugin_Mutate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(Mutate_Request) +func _Plugin_GetPluginConfig_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetPluginConfig_Request) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(PluginServer).Mutate(ctx, in) + return srv.(PluginServer).GetPluginConfig(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/pluginv2.Plugin/Mutate", + FullMethod: "/pluginv2.Plugin/GetPluginConfig", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PluginServer).Mutate(ctx, req.(*Mutate_Request)) + return srv.(PluginServer).GetPluginConfig(ctx, req.(*GetPluginConfig_Request)) } return interceptor(ctx, in, info, handler) } -func _Plugin_SetLeader_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(SetLeader_Request) +func _Plugin_Mutate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(Mutate_Request) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(PluginServer).SetLeader(ctx, in) + return srv.(PluginServer).Mutate(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/pluginv2.Plugin/SetLeader", + FullMethod: "/pluginv2.Plugin/Mutate", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PluginServer).SetLeader(ctx, req.(*SetLeader_Request)) + return srv.(PluginServer).Mutate(ctx, req.(*Mutate_Request)) } return interceptor(ctx, in, info, handler) } @@ -192,21 +192,21 @@ var Plugin_ServiceDesc = grpc.ServiceDesc{ HandlerType: (*PluginServer)(nil), Methods: []grpc.MethodDesc{ { - MethodName: "Start", - Handler: _Plugin_Start_Handler, + MethodName: "Initialize", + Handler: _Plugin_Initialize_Handler, + }, + { + MethodName: "SetLeader", + Handler: _Plugin_SetLeader_Handler, }, { - MethodName: "GetClientHooks", - Handler: _Plugin_GetClientHooks_Handler, + MethodName: "GetPluginConfig", + Handler: _Plugin_GetPluginConfig_Handler, }, { MethodName: "Mutate", Handler: _Plugin_Mutate_Handler, }, - { - MethodName: "SetLeader", - Handler: _Plugin_SetLeader_Handler, - }, }, Streams: []grpc.StreamDesc{}, Metadata: "pluginv2.proto", diff --git a/pkg/server/cert/syncer.go b/pkg/server/cert/syncer.go index 76399a400..02636ba87 100644 --- a/pkg/server/cert/syncer.go +++ b/pkg/server/cert/syncer.go @@ -168,14 +168,14 @@ func (s *syncer) getSANs(ctx context.Context) ([]string, error) { // append hostnames for load balancer service retSANs = append(retSANs, lbSVCName, - lbSVCName+"."+s.currentNamespace, "*."+translate.Suffix+"."+s.currentNamespace+"."+constants.NodeSuffix, + lbSVCName+"."+s.currentNamespace, "*."+translate.VClusterName+"."+s.currentNamespace+"."+constants.NodeSuffix, ) } if s.fakeKubeletIPs { // get cluster ips of node services svcs := &corev1.ServiceList{} - err = s.currentNamespaceCient.List(ctx, svcs, client.InNamespace(s.currentNamespace), client.MatchingLabels{nodeservice.ServiceClusterLabel: translate.Suffix}) + err = s.currentNamespaceCient.List(ctx, svcs, client.InNamespace(s.currentNamespace), client.MatchingLabels{nodeservice.ServiceClusterLabel: translate.VClusterName}) if err != nil { return nil, err } diff --git a/pkg/server/server.go b/pkg/server/server.go index 7e7cffaa1..842e0cb79 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -100,7 +100,7 @@ func NewServer(ctx *options.ControllerContext, requestHeaderCaFile, clientCaFile if ctx.Options.FakeKubeletIPs { err := cache.IndexField(ctx.Context, &corev1.Service{}, constants.IndexByClusterIP, func(object client.Object) []string { svc := object.(*corev1.Service) - if len(svc.Labels) == 0 || svc.Labels[nodeservice.ServiceClusterLabel] != translate.Suffix { + if len(svc.Labels) == 0 || svc.Labels[nodeservice.ServiceClusterLabel] != translate.VClusterName { return nil } diff --git a/pkg/setup/controller_context.go b/pkg/setup/controller_context.go index 3defeba0d..ceb01a3ff 100644 --- a/pkg/setup/controller_context.go +++ b/pkg/setup/controller_context.go @@ -341,7 +341,7 @@ func WriteKubeConfigToSecret(ctx context.Context, currentNamespace string, curre } // write the default Secret - return kubeconfig.WriteKubeConfig(ctx, currentNamespaceClient, kubeconfig.GetDefaultSecretName(translate.Suffix), currentNamespace, config, isRemote) + return kubeconfig.WriteKubeConfig(ctx, currentNamespaceClient, kubeconfig.GetDefaultSecretName(translate.VClusterName), currentNamespace, config, isRemote) } func InitControllerContext( @@ -367,7 +367,7 @@ func InitControllerContext( klog.Infof("Can connect to virtual cluster with version " + virtualClusterVersion.GitVersion) // create a new current namespace client - currentNamespaceClient, err := newCurrentNamespaceClient(ctx, currentNamespace, localManager, vClusterOptions) + currentNamespaceClient, err := NewCurrentNamespaceClient(ctx, currentNamespace, localManager, vClusterOptions) if err != nil { return nil, err } @@ -404,7 +404,7 @@ func InitControllerContext( }, nil } -func newCurrentNamespaceClient(ctx context.Context, currentNamespace string, localManager ctrl.Manager, options *options.VirtualClusterOptions) (client.Client, error) { +func NewCurrentNamespaceClient(ctx context.Context, currentNamespace string, localManager ctrl.Manager, options *options.VirtualClusterOptions) (client.Client, error) { var err error // currentNamespaceCache is needed for tasks such as finding out fake kubelet ips diff --git a/pkg/setup/controllers.go b/pkg/setup/controllers.go index faf857247..8c08298cd 100644 --- a/pkg/setup/controllers.go +++ b/pkg/setup/controllers.go @@ -23,6 +23,7 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/klog/v2" + "sigs.k8s.io/controller-runtime/pkg/client" ) func StartControllers(controllerContext *options.ControllerContext) error { @@ -90,17 +91,18 @@ func ApplyCoreDNS(controllerContext *options.ControllerContext) { }) } -func FindOwner(ctx *options.ControllerContext) error { - if ctx.CurrentNamespace != ctx.Options.TargetNamespace { - if ctx.Options.SetOwner { - klog.Warningf("Skip setting owner, because current namespace %s != target namespace %s", ctx.CurrentNamespace, ctx.Options.TargetNamespace) +func SetGlobalOwner(ctx context.Context, currentNamespaceClient client.Client, currentNamespace, targetNamespace string, setOwner bool, serviceName string) error { + if currentNamespace != targetNamespace { + if setOwner { + klog.Warningf("Skip setting owner, because current namespace %s != target namespace %s", currentNamespace, targetNamespace) } + return nil } - if ctx.Options.SetOwner { + if setOwner { service := &corev1.Service{} - err := ctx.CurrentNamespaceClient.Get(ctx.Context, types.NamespacedName{Namespace: ctx.CurrentNamespace, Name: ctx.Options.ServiceName}, service) + err := currentNamespaceClient.Get(ctx, types.NamespacedName{Namespace: currentNamespace, Name: serviceName}, service) if err != nil { return errors.Wrap(err, "get vcluster service") } @@ -180,7 +182,14 @@ func StartManagers(controllerContext *options.ControllerContext, syncers []synce go RegisterOrDeregisterAPIService(controllerContext) // make sure owner is set if it is there - err = FindOwner(controllerContext) + err = SetGlobalOwner( + controllerContext.Context, + controllerContext.CurrentNamespaceClient, + controllerContext.CurrentNamespace, + controllerContext.Options.TargetNamespace, + controllerContext.Options.SetOwner, + controllerContext.Options.ServiceName, + ) if err != nil { return errors.Wrap(err, "finding vcluster pod owner") } diff --git a/pkg/telemetry/helpers.go b/pkg/telemetry/helpers.go index f64b371c3..ebc1e6b9b 100644 --- a/pkg/telemetry/helpers.go +++ b/pkg/telemetry/helpers.go @@ -30,7 +30,7 @@ func getChartInfo(ctx context.Context, hostClient *kubernetes.Clientset, vCluste return nil, fmt.Errorf("host client is empty") } - release, err := helm.NewSecrets(hostClient).Get(ctx, translate.Suffix, vClusterNamespace) + release, err := helm.NewSecrets(hostClient).Get(ctx, translate.VClusterName, vClusterNamespace) if err != nil { return nil, err } else if release == nil { diff --git a/pkg/types/types.go b/pkg/types/types.go index 43d8b24f6..5e07abed6 100644 --- a/pkg/types/types.go +++ b/pkg/types/types.go @@ -56,6 +56,12 @@ type ControllerModifier interface { ModifyController(ctx *synccontext.RegisterContext, builder *builder.Builder) (*builder.Builder, error) } +// ControllerStarter is a generic controller that can be used if the syncer abstraction does not fit +// the use case +type ControllerStarter interface { + Register(ctx *synccontext.RegisterContext) error +} + // Initializer is used to create and update the prerequisites of the syncer before the controller is started type Initializer interface { Init(registerContext *synccontext.RegisterContext) error diff --git a/pkg/util/translate/multi_namespace.go b/pkg/util/translate/multi_namespace.go index 1d2384bb1..986adb317 100644 --- a/pkg/util/translate/multi_namespace.go +++ b/pkg/util/translate/multi_namespace.go @@ -53,7 +53,7 @@ func (s *multiNamespace) PhysicalNameClusterScoped(name string) string { if name == "" { return "" } - return SafeConcatName("vcluster", name, "x", s.currentNamespace, "x", Suffix) + return SafeConcatName("vcluster", name, "x", s.currentNamespace, "x", VClusterName) } func (s *multiNamespace) IsManaged(obj runtime.Object) bool { @@ -86,16 +86,16 @@ func (s *multiNamespace) IsManagedCluster(obj runtime.Object) bool { return false } - return metaAccessor.GetLabels()[MarkerLabel] == SafeConcatName(s.currentNamespace, "x", Suffix) + return metaAccessor.GetLabels()[MarkerLabel] == SafeConcatName(s.currentNamespace, "x", VClusterName) } func (s *multiNamespace) IsTargetedNamespace(ns string) bool { - return strings.HasPrefix(ns, s.getNamespacePrefix()) && strings.HasSuffix(ns, getNamespaceSuffix(s.currentNamespace, Suffix)) + return strings.HasPrefix(ns, s.getNamespacePrefix()) && strings.HasSuffix(ns, getNamespaceSuffix(s.currentNamespace, VClusterName)) } func (s *multiNamespace) convertLabelKey(key string) string { digest := sha256.Sum256([]byte(key)) - return SafeConcatName(LabelPrefix, s.currentNamespace, "x", Suffix, "x", hex.EncodeToString(digest[0:])[0:10]) + return SafeConcatName(LabelPrefix, s.currentNamespace, "x", VClusterName, "x", hex.EncodeToString(digest[0:])[0:10]) } func (s *multiNamespace) getNamespacePrefix() string { @@ -103,7 +103,7 @@ func (s *multiNamespace) getNamespacePrefix() string { } func (s *multiNamespace) PhysicalNamespace(vNamespace string) string { - return PhysicalNamespace(s.currentNamespace, vNamespace, s.getNamespacePrefix(), Suffix) + return PhysicalNamespace(s.currentNamespace, vNamespace, s.getNamespacePrefix(), VClusterName) } func PhysicalNamespace(currentNamespace, vNamespace, prefix, suffix string) string { @@ -147,7 +147,7 @@ func (s *multiNamespace) TranslateLabelsCluster(vObj client.Object, pObj client. newLabels[ControllerLabel] = pObjLabels[ControllerLabel] } } - newLabels[MarkerLabel] = SafeConcatName(s.currentNamespace, "x", Suffix) + newLabels[MarkerLabel] = SafeConcatName(s.currentNamespace, "x", VClusterName) return newLabels } diff --git a/pkg/util/translate/single_namespace.go b/pkg/util/translate/single_namespace.go index 9769e3ecb..aa81221d1 100644 --- a/pkg/util/translate/single_namespace.go +++ b/pkg/util/translate/single_namespace.go @@ -31,7 +31,7 @@ func (s *singleNamespace) SingleNamespaceTarget() bool { // PhysicalName returns the physical name of the name / namespace resource func (s *singleNamespace) PhysicalName(name, namespace string) string { - return SingleNamespacePhysicalName(name, namespace, Suffix) + return SingleNamespacePhysicalName(name, namespace, VClusterName) } func SingleNamespacePhysicalName(name, namespace, suffix string) string { @@ -58,7 +58,7 @@ func (s *singleNamespace) PhysicalNameClusterScoped(name string) string { if name == "" { return "" } - return SafeConcatName("vcluster", name, "x", s.targetNamespace, "x", Suffix) + return SafeConcatName("vcluster", name, "x", s.targetNamespace, "x", VClusterName) } func (s *singleNamespace) IsManaged(obj runtime.Object) bool { @@ -78,7 +78,7 @@ func (s *singleNamespace) IsManaged(obj runtime.Object) bool { return false } - return metaAccessor.GetLabels()[MarkerLabel] == Suffix + return metaAccessor.GetLabels()[MarkerLabel] == VClusterName } func (s *singleNamespace) IsManagedCluster(obj runtime.Object) bool { @@ -89,7 +89,7 @@ func (s *singleNamespace) IsManagedCluster(obj runtime.Object) bool { return false } - return metaAccessor.GetLabels()[MarkerLabel] == SafeConcatName(s.targetNamespace, "x", Suffix) + return metaAccessor.GetLabels()[MarkerLabel] == SafeConcatName(s.targetNamespace, "x", VClusterName) } func (s *singleNamespace) IsTargetedNamespace(ns string) bool { @@ -98,7 +98,7 @@ func (s *singleNamespace) IsTargetedNamespace(ns string) bool { func (s *singleNamespace) convertNamespacedLabelKey(key string) string { digest := sha256.Sum256([]byte(key)) - return SafeConcatName(LabelPrefix, s.targetNamespace, "x", Suffix, "x", hex.EncodeToString(digest[0:])[0:10]) + return SafeConcatName(LabelPrefix, s.targetNamespace, "x", VClusterName, "x", hex.EncodeToString(digest[0:])[0:10]) } func (s *singleNamespace) PhysicalNamespace(_ string) string { @@ -136,7 +136,7 @@ func (s *singleNamespace) TranslateLabelsCluster(vObj client.Object, pObj client newLabels[ControllerLabel] = pObjLabels[ControllerLabel] } } - newLabels[MarkerLabel] = SafeConcatName(s.targetNamespace, "x", Suffix) + newLabels[MarkerLabel] = SafeConcatName(s.targetNamespace, "x", VClusterName) return newLabels } @@ -249,7 +249,7 @@ func (s *singleNamespace) TranslateLabels(fromLabels map[string]string, vNamespa } } - newLabels[MarkerLabel] = Suffix + newLabels[MarkerLabel] = VClusterName if vNamespace != "" { newLabels[NamespaceLabel] = vNamespace } else { @@ -317,7 +317,7 @@ func (s *singleNamespace) ConvertLabelKey(key string) string { func ConvertLabelKeyWithPrefix(prefix, key string) string { digest := sha256.Sum256([]byte(key)) - return SafeConcatName(prefix, Suffix, "x", hex.EncodeToString(digest[0:])[0:10]) + return SafeConcatName(prefix, VClusterName, "x", hex.EncodeToString(digest[0:])[0:10]) } func MergeLabelSelectors(elems ...*metav1.LabelSelector) *metav1.LabelSelector { diff --git a/pkg/util/translate/translate.go b/pkg/util/translate/translate.go index a0e03623d..293c4ae95 100644 --- a/pkg/util/translate/translate.go +++ b/pkg/util/translate/translate.go @@ -29,15 +29,16 @@ var ( MarkerLabel = "vcluster.loft.sh/managed-by" LabelPrefix = "vcluster.loft.sh/label" ControllerLabel = "vcluster.loft.sh/controlled-by" - // Suffix is the vcluster name, usually set at start time - Suffix = "suffix" + + // VClusterName is the vcluster name, usually set at start time + VClusterName = "suffix" ManagedAnnotationsAnnotation = "vcluster.loft.sh/managed-annotations" ManagedLabelsAnnotation = "vcluster.loft.sh/managed-labels" ) const ( - SkipBacksyncInMultiNamespaceMode = "vcluster.loft.sh/skip-backsync" + SkipBackSyncInMultiNamespaceMode = "vcluster.loft.sh/skip-backsync" ) var Owner client.Object diff --git a/test/e2e/servicesync/servicesync.go b/test/e2e/servicesync/servicesync.go index d5b97cc8f..ffd0af819 100644 --- a/test/e2e/servicesync/servicesync.go +++ b/test/e2e/servicesync/servicesync.go @@ -119,7 +119,7 @@ func testMapping(ctx context.Context, fromClient kubernetes.Interface, fromNames framework.ExpectEqual(toService.Spec.Ports[0].Port, int32(8080)) framework.ExpectEqual(len(toService.Spec.Selector), 3) framework.ExpectEqual(toService.Spec.Selector[translate.NamespaceLabel], fromNamespace) - framework.ExpectEqual(toService.Spec.Selector[translate.MarkerLabel], translate.Suffix) + framework.ExpectEqual(toService.Spec.Selector[translate.MarkerLabel], translate.VClusterName) framework.ExpectEqual(toService.Spec.Selector[translate.ConvertLabelKeyWithPrefix(translate.LabelPrefix, "test")], "test") } diff --git a/test/framework/framework.go b/test/framework/framework.go index 43e29d676..e9a540a5b 100644 --- a/test/framework/framework.go +++ b/test/framework/framework.go @@ -114,7 +114,7 @@ func CreateFramework(ctx context.Context, scheme *runtime.Scheme) error { //TODO: maybe implement some autodiscovery of the suffix value that would work with dev and prod setups suffix = "vcluster" } - translate.Suffix = suffix + translate.VClusterName = suffix var multiNamespaceMode bool if os.Getenv("MULTINAMESPACE_MODE") == "true" {