Skip to content

Commit 7224234

Browse files
Update resourece interpreter pkg/file name and variable/parameter/comment naming
Signed-off-by: changzhen <changzhen5@huawei.com>
1 parent f8af036 commit 7224234

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+282
-712
lines changed

artifacts/deploy/webhook-configuration.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,10 @@ webhooks:
116116
- operations: ["CREATE", "UPDATE"]
117117
apiGroups: ["config.karmada.io"]
118118
apiVersions: ["*"]
119-
resources: ["resourceexploringwebhookconfigurations"]
119+
resources: ["resourceinterpreterwebhookconfigurations"]
120120
scope: "Cluster"
121121
clientConfig:
122-
url: https://karmada-webhook.karmada-system.svc:443/validate-resourceexploringwebhookconfiguration
122+
url: https://karmada-webhook.karmada-system.svc:443/validate-resourceinterpreterwebhookconfiguration
123123
caBundle: {{caBundle}}
124124
failurePolicy: Fail
125125
sideEffects: None

charts/_crds/bases/config.karmada.io_resourceinterpreterwebhookconfigurations.yaml

+3-8
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ spec:
100100
and query parameters (\"?...\") are not allowed, either."
101101
type: string
102102
type: object
103-
exploreReviewVersions:
104-
description: ExploreReviewVersions is an ordered list of preferred
103+
interpreterContextVersions:
104+
description: InterpreterContextVersions is an ordered list of preferred
105105
`ResourceInterpreterContext` versions the Webhook expects. Karmada
106106
will try to use first version in the list which it supports. If
107107
none of the versions specified in this list supported by Karmada,
@@ -112,11 +112,6 @@ spec:
112112
items:
113113
type: string
114114
type: array
115-
failurePolicy:
116-
description: FailurePolicy defines how unrecognized errors from
117-
the webhook are handled, allowed values are Ignore or Fail. Defaults
118-
to Fail.
119-
type: string
120115
name:
121116
description: Name is the full-qualified name of the webhook.
122117
type: string
@@ -180,7 +175,7 @@ spec:
180175
type: integer
181176
required:
182177
- clientConfig
183-
- exploreReviewVersions
178+
- interpreterContextVersions
184179
- name
185180
type: object
186181
type: array

charts/_crds/kustomization.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ resources:
1010
- bases/work.karmada.io_resourcebindings.yaml
1111
- bases/work.karmada.io_clusterresourcebindings.yaml
1212
- bases/work.karmada.io_works.yaml
13-
- bases/config.karmada.io_resourceexploringwebhookconfigurations.yaml
13+
- bases/config.karmada.io_resourceinterpreterwebhookconfigurations.yaml
1414

1515
patchesStrategicMerge:
1616
- patches/webhook_in_resourcebindings.yaml

charts/templates/_karmada_webhook_configuration.tpl

+2-2
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@ webhooks:
120120
- operations: ["CREATE", "UPDATE"]
121121
apiGroups: ["config.karmada.io"]
122122
apiVersions: ["*"]
123-
resources: ["resourceexploringwebhookconfigurations"]
123+
resources: ["resourceinterpreterwebhookconfigurations"]
124124
scope: "Cluster"
125125
clientConfig:
126-
url: https://{{ $name }}-webhook.{{ $namespace }}.svc:443/validate-resourceexploringwebhookconfiguration
126+
url: https://{{ $name }}-webhook.{{ $namespace }}.svc:443/validate-resourceinterpreterwebhookconfiguration
127127
{{- include "karmada.webhook.caBundle" . | nindent 6 }}
128128
failurePolicy: Fail
129129
sideEffects: None

cmd/agent/app/agent.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import (
2020
"github.com/karmada-io/karmada/pkg/controllers/execution"
2121
"github.com/karmada-io/karmada/pkg/controllers/mcs"
2222
"github.com/karmada-io/karmada/pkg/controllers/status"
23-
"github.com/karmada-io/karmada/pkg/crdexplorer"
2423
"github.com/karmada-io/karmada/pkg/karmadactl"
24+
"github.com/karmada-io/karmada/pkg/resourceinterpreter"
2525
"github.com/karmada-io/karmada/pkg/util"
2626
"github.com/karmada-io/karmada/pkg/util/gclient"
2727
"github.com/karmada-io/karmada/pkg/util/helper"
@@ -131,12 +131,12 @@ func setupControllers(mgr controllerruntime.Manager, opts *options.Options, stop
131131
restConfig := mgr.GetConfig()
132132
dynamicClientSet := dynamic.NewForConfigOrDie(restConfig)
133133
controlPlaneInformerManager := informermanager.NewSingleClusterInformerManager(dynamicClientSet, 0, stopChan)
134-
crdExplorer := crdexplorer.NewCustomResourceExplorer("", controlPlaneInformerManager)
135-
if err := mgr.Add(crdExplorer); err != nil {
136-
klog.Fatalf("Failed to setup custom resource explorer: %v", err)
134+
resourceInterpreter := resourceinterpreter.NewResourceInterpreter("", controlPlaneInformerManager)
135+
if err := mgr.Add(resourceInterpreter); err != nil {
136+
klog.Fatalf("Failed to setup custom resource interpreter: %v", err)
137137
}
138138

139-
objectWatcher := objectwatcher.NewObjectWatcher(mgr.GetClient(), mgr.GetRESTMapper(), util.NewClusterDynamicClientSetForAgent, crdExplorer)
139+
objectWatcher := objectwatcher.NewObjectWatcher(mgr.GetClient(), mgr.GetRESTMapper(), util.NewClusterDynamicClientSetForAgent, resourceInterpreter)
140140
executionController := &execution.Controller{
141141
Client: mgr.GetClient(),
142142
EventRecorder: mgr.GetEventRecorderFor(execution.ControllerName),

cmd/controller-manager/app/controllermanager.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ import (
2727
"github.com/karmada-io/karmada/pkg/controllers/mcs"
2828
"github.com/karmada-io/karmada/pkg/controllers/namespace"
2929
"github.com/karmada-io/karmada/pkg/controllers/status"
30-
"github.com/karmada-io/karmada/pkg/crdexplorer"
3130
"github.com/karmada-io/karmada/pkg/detector"
3231
"github.com/karmada-io/karmada/pkg/karmadactl"
32+
"github.com/karmada-io/karmada/pkg/resourceinterpreter"
3333
"github.com/karmada-io/karmada/pkg/util"
3434
"github.com/karmada-io/karmada/pkg/util/gclient"
3535
"github.com/karmada-io/karmada/pkg/util/helper"
@@ -124,12 +124,12 @@ func setupControllers(mgr controllerruntime.Manager, opts *options.Options, stop
124124

125125
controlPlaneInformerManager := informermanager.NewSingleClusterInformerManager(dynamicClientSet, 0, stopChan)
126126

127-
crdExplorer := crdexplorer.NewCustomResourceExplorer("", controlPlaneInformerManager)
128-
if err := mgr.Add(crdExplorer); err != nil {
129-
klog.Fatalf("Failed to setup custom resource explorer: %v", err)
127+
resourceInterpreter := resourceinterpreter.NewResourceInterpreter("", controlPlaneInformerManager)
128+
if err := mgr.Add(resourceInterpreter); err != nil {
129+
klog.Fatalf("Failed to setup custom resource interpreter: %v", err)
130130
}
131131

132-
objectWatcher := objectwatcher.NewObjectWatcher(mgr.GetClient(), mgr.GetRESTMapper(), util.NewClusterDynamicClientSet, crdExplorer)
132+
objectWatcher := objectwatcher.NewObjectWatcher(mgr.GetClient(), mgr.GetRESTMapper(), util.NewClusterDynamicClientSet, resourceInterpreter)
133133

134134
resourceDetector := &detector.ResourceDetector{
135135
DiscoveryClientSet: discoverClientSet,
@@ -139,7 +139,7 @@ func setupControllers(mgr controllerruntime.Manager, opts *options.Options, stop
139139
DynamicClient: dynamicClientSet,
140140
SkippedResourceConfig: skippedResourceConfig,
141141
SkippedPropagatingNamespaces: skippedPropagatingNamespaces,
142-
ResourceExplorer: crdExplorer,
142+
ResourceInterpreter: resourceInterpreter,
143143
}
144144
if err := mgr.Add(resourceDetector); err != nil {
145145
klog.Fatalf("Failed to setup resource detector: %v", err)

cmd/webhook/app/webhook.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"github.com/karmada-io/karmada/pkg/version/sharedcommand"
2121
"github.com/karmada-io/karmada/pkg/webhook/cluster"
2222
"github.com/karmada-io/karmada/pkg/webhook/clusterpropagationpolicy"
23-
"github.com/karmada-io/karmada/pkg/webhook/crdexplorer"
23+
"github.com/karmada-io/karmada/pkg/webhook/configuration"
2424
"github.com/karmada-io/karmada/pkg/webhook/overridepolicy"
2525
"github.com/karmada-io/karmada/pkg/webhook/propagationpolicy"
2626
"github.com/karmada-io/karmada/pkg/webhook/work"
@@ -79,7 +79,7 @@ func Run(ctx context.Context, opts *options.Options) error {
7979
hookServer.Register("/mutate-overridepolicy", &webhook.Admission{Handler: &overridepolicy.MutatingAdmission{}})
8080
hookServer.Register("/mutate-work", &webhook.Admission{Handler: &work.MutatingAdmission{}})
8181
hookServer.Register("/convert", &conversion.Webhook{})
82-
hookServer.Register("/validate-resourceexploringwebhookconfiguration", &webhook.Admission{Handler: &crdexplorer.ValidatingAdmission{}})
82+
hookServer.Register("/validate-resourceinterpreterwebhookconfiguration", &webhook.Admission{Handler: &configuration.ValidatingAdmission{}})
8383
hookServer.WebhookMux.Handle("/readyz/", http.StripPrefix("/readyz/", &healthz.Handler{}))
8484

8585
// blocks until the context is done.

examples/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Examples
22

3-
### Custom Resource Explorer
4-
This example implements a new CustomResourceDefinition(CRD), `Workload`, and creates a custom resource explorer webhook.
3+
### Resource Interpreter
4+
This example implements a new CustomResourceDefinition(CRD), `Workload`, and creates a resource interpreter webhook.

hack/update-codegen.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ deepcopy-gen \
4040
--output-file-base=zz_generated.deepcopy
4141
deepcopy-gen \
4242
--go-header-file hack/boilerplate/boilerplate.go.txt \
43-
--input-dirs=github.com/karmada-io/karmada/examples/customresourceexplorer/apis/workload/v1alpha1 \
44-
--output-package=github.com/karmada-io/karmada/examples/customresourceexplorer/apis/workload/v1alpha1 \
43+
--input-dirs=github.com/karmada-io/karmada/examples/customresourceinterpreter/apis/workload/v1alpha1 \
44+
--output-package=github.com/karmada-io/karmada/examples/customresourceinterpreter/apis/workload/v1alpha1 \
4545
--output-file-base=zz_generated.deepcopy
4646

4747
echo "Generating with register-gen"
@@ -73,8 +73,8 @@ register-gen \
7373
--output-file-base=zz_generated.register
7474
register-gen \
7575
--go-header-file hack/boilerplate/boilerplate.go.txt \
76-
--input-dirs=github.com/karmada-io/karmada/examples/customresourceexplorer/apis/workload/v1alpha1 \
77-
--output-package=github.com/karmada-io/karmada/examples/customresourceexplorer/apis/workload/v1alpha1 \
76+
--input-dirs=github.com/karmada-io/karmada/examples/customresourceinterpreter/apis/workload/v1alpha1 \
77+
--output-package=github.com/karmada-io/karmada/examples/customresourceinterpreter/apis/workload/v1alpha1 \
7878
--output-file-base=zz_generated.register
7979

8080
echo "Generating with client-gen"

hack/update-crdgen.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ util::install_tools ${CONTROLLER_GEN_PKG} ${CONTROLLER_GEN_VER} >/dev/null 2>&1
1414

1515
# Unify the crds used by helm chart and the installation scripts
1616
controller-gen crd paths=./pkg/apis/... output:crd:dir=./charts/_crds/bases
17-
controller-gen crd paths=./examples/customresourceexplorer/apis/... output:crd:dir=./examples/customresourceexplorer/apis/
17+
controller-gen crd paths=./examples/customresourceinterpreter/apis/... output:crd:dir=./examples/customresourceinterpreter/apis/

pkg/apis/config/v1alpha1/interpretercontext_types.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@ import (
1111

1212
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
1313

14-
// ResourceInterpreterContext describes an explore review request and response.
14+
// ResourceInterpreterContext describes an interpreter context request and response.
1515
type ResourceInterpreterContext struct {
1616
metav1.TypeMeta `json:",inline"`
1717

18-
// Request describes the attributes for the explore request.
18+
// Request describes the attributes for the interpreter request.
1919
// +optional
2020
Request *ResourceInterpreterRequest `json:"request,omitempty"`
2121

22-
// Response describes the attributes for the explore response.
22+
// Response describes the attributes for the interpreter response.
2323
// +optional
2424
Response *ResourceInterpreterResponse `json:"response,omitempty"`
2525
}
2626

27-
// ResourceInterpreterRequest describes the explore.Attributes for the explore request.
27+
// ResourceInterpreterRequest describes the interpreter.Attributes for the interpreter request.
2828
type ResourceInterpreterRequest struct {
2929
// UID is an identifier for the individual request/response.
3030
// The UID is meant to track the round trip (request/response) between the karmada and the WebHook, not the user request.
@@ -53,7 +53,7 @@ type ResourceInterpreterRequest struct {
5353
Object runtime.RawExtension `json:"object,omitempty"`
5454

5555
// ObservedObject is the object observed from the kube-apiserver of member clusters.
56-
// Not nil only when InterpreterOperation is InterpreterOperationRetention.
56+
// Not nil only when InterpreterOperation is InterpreterOperationRetain.
5757
// +optional
5858
ObservedObject *runtime.RawExtension `json:"observedObject,omitempty"`
5959

@@ -67,7 +67,7 @@ type ResourceInterpreterRequest struct {
6767
AggregatedStatus []workv1alpha1.AggregatedStatusItem `json:"aggregatedStatus,omitempty"`
6868
}
6969

70-
// ResourceInterpreterResponse describes an explore response.
70+
// ResourceInterpreterResponse describes an interpreter response.
7171
type ResourceInterpreterResponse struct {
7272
// UID is an identifier for the individual request/response.
7373
// This must be copied over from the corresponding ResourceInterpreterRequest.

pkg/apis/config/v1alpha1/resourceinterpreterwebhook_types.go

+4-9
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@ type ResourceInterpreterWebhook struct {
3737
// +optional
3838
Rules []RuleWithOperations `json:"rules,omitempty"`
3939

40-
// FailurePolicy defines how unrecognized errors from the webhook are handled,
41-
// allowed values are Ignore or Fail. Defaults to Fail.
42-
// +optional
43-
FailurePolicy *admissionregistrationv1.FailurePolicyType `json:"failurePolicy,omitempty"`
44-
4540
// TimeoutSeconds specifies the timeout for this webhook. After the timeout passes,
4641
// the webhook call will be ignored or the API call will fail based on the
4742
// failure policy.
@@ -50,14 +45,14 @@ type ResourceInterpreterWebhook struct {
5045
// +optional
5146
TimeoutSeconds *int32 `json:"timeoutSeconds,omitempty"`
5247

53-
// ExploreReviewVersions is an ordered list of preferred `ResourceInterpreterContext`
48+
// InterpreterContextVersions is an ordered list of preferred `ResourceInterpreterContext`
5449
// versions the Webhook expects. Karmada will try to use first version in
5550
// the list which it supports. If none of the versions specified in this list
5651
// supported by Karmada, validation will fail for this object.
5752
// If a persisted webhook configuration specifies allowed versions and does not
5853
// include any versions known to the Karmada, calls to the webhook will fail
5954
// and be subject to the failure policy.
60-
ExploreReviewVersions []string `json:"exploreReviewVersions"`
55+
InterpreterContextVersions []string `json:"interpreterContextVersions"`
6156
}
6257

6358
// RuleWithOperations is a tuple of Operations and Resources. It is recommended to make
@@ -94,9 +89,9 @@ const (
9489
// InterpreterOperationPrune indicates that karmada want to figure out how to package resource template to Work.
9590
InterpreterOperationPrune InterpreterOperation = "Prune"
9691

97-
// InterpreterOperationRetention indicates that karmada request webhook to retain the desired resource template.
92+
// InterpreterOperationRetain indicates that karmada request webhook to retain the desired resource template.
9893
// Only necessary for those resources which specification will be updated by their controllers running in member cluster.
99-
InterpreterOperationRetention InterpreterOperation = "Retention"
94+
InterpreterOperationRetain InterpreterOperation = "Retain"
10095

10196
// InterpreterOperationAggregateStatus indicates that karmada want to figure out how to aggregate status to resource template.
10297
// Only necessary for those resource types that want to aggregate status to resource template.

pkg/apis/config/v1alpha1/zz_generated.deepcopy.go

+2-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/crdexplorer/defaultexplorer/default.go

-65
This file was deleted.

0 commit comments

Comments
 (0)