in pilot/pkg/config/kube/crdclient/types.gen.go [426:765]
func patch(ic versionedclient.Interface, sc gatewayapiclient.Interface, orig config.Config, origMeta metav1.ObjectMeta, mod config.Config, modMeta metav1.ObjectMeta, typ types.PatchType) (metav1.Object, error) {
if orig.GroupVersionKind != mod.GroupVersionKind {
return nil, fmt.Errorf("gvk mismatch: %v, modified: %v", orig.GroupVersionKind, mod.GroupVersionKind)
}
// TODO support setting field manager
switch orig.GroupVersionKind {
case collections.IstioExtensionsV1Alpha1Servicemetadatas.Resource().GroupVersionKind():
oldRes := &clientextensionsv1alpha1.ServiceMetadata{
ObjectMeta: origMeta,
Spec: *(orig.Spec.(*extensionsv1alpha1.ServiceMetadata)),
}
modRes := &clientextensionsv1alpha1.ServiceMetadata{
ObjectMeta: modMeta,
Spec: *(mod.Spec.(*extensionsv1alpha1.ServiceMetadata)),
}
patchBytes, err := genPatchBytes(oldRes, modRes, typ)
if err != nil {
return nil, err
}
return ic.ExtensionsV1alpha1().ServiceMetadatas(orig.Namespace).
Patch(context.TODO(), orig.Name, typ, patchBytes, metav1.PatchOptions{FieldManager: "pilot-discovery"})
case collections.IstioExtensionsV1Alpha1Servicenamemappings.Resource().GroupVersionKind():
oldRes := &clientextensionsv1alpha1.ServiceNameMapping{
ObjectMeta: origMeta,
Spec: *(orig.Spec.(*extensionsv1alpha1.ServiceNameMapping)),
}
modRes := &clientextensionsv1alpha1.ServiceNameMapping{
ObjectMeta: modMeta,
Spec: *(mod.Spec.(*extensionsv1alpha1.ServiceNameMapping)),
}
patchBytes, err := genPatchBytes(oldRes, modRes, typ)
if err != nil {
return nil, err
}
return ic.ExtensionsV1alpha1().ServiceNameMappings(orig.Namespace).
Patch(context.TODO(), orig.Name, typ, patchBytes, metav1.PatchOptions{FieldManager: "pilot-discovery"})
case collections.IstioExtensionsV1Alpha1Wasmplugins.Resource().GroupVersionKind():
oldRes := &clientextensionsv1alpha1.WasmPlugin{
ObjectMeta: origMeta,
Spec: *(orig.Spec.(*extensionsv1alpha1.WasmPlugin)),
}
modRes := &clientextensionsv1alpha1.WasmPlugin{
ObjectMeta: modMeta,
Spec: *(mod.Spec.(*extensionsv1alpha1.WasmPlugin)),
}
patchBytes, err := genPatchBytes(oldRes, modRes, typ)
if err != nil {
return nil, err
}
return ic.ExtensionsV1alpha1().WasmPlugins(orig.Namespace).
Patch(context.TODO(), orig.Name, typ, patchBytes, metav1.PatchOptions{FieldManager: "pilot-discovery"})
case collections.IstioNetworkingV1Alpha3Destinationrules.Resource().GroupVersionKind():
oldRes := &clientnetworkingv1alpha3.DestinationRule{
ObjectMeta: origMeta,
Spec: *(orig.Spec.(*networkingv1alpha3.DestinationRule)),
}
modRes := &clientnetworkingv1alpha3.DestinationRule{
ObjectMeta: modMeta,
Spec: *(mod.Spec.(*networkingv1alpha3.DestinationRule)),
}
patchBytes, err := genPatchBytes(oldRes, modRes, typ)
if err != nil {
return nil, err
}
return ic.NetworkingV1alpha3().DestinationRules(orig.Namespace).
Patch(context.TODO(), orig.Name, typ, patchBytes, metav1.PatchOptions{FieldManager: "pilot-discovery"})
case collections.IstioNetworkingV1Alpha3Envoyfilters.Resource().GroupVersionKind():
oldRes := &clientnetworkingv1alpha3.EnvoyFilter{
ObjectMeta: origMeta,
Spec: *(orig.Spec.(*networkingv1alpha3.EnvoyFilter)),
}
modRes := &clientnetworkingv1alpha3.EnvoyFilter{
ObjectMeta: modMeta,
Spec: *(mod.Spec.(*networkingv1alpha3.EnvoyFilter)),
}
patchBytes, err := genPatchBytes(oldRes, modRes, typ)
if err != nil {
return nil, err
}
return ic.NetworkingV1alpha3().EnvoyFilters(orig.Namespace).
Patch(context.TODO(), orig.Name, typ, patchBytes, metav1.PatchOptions{FieldManager: "pilot-discovery"})
case collections.IstioNetworkingV1Alpha3Gateways.Resource().GroupVersionKind():
oldRes := &clientnetworkingv1alpha3.Gateway{
ObjectMeta: origMeta,
Spec: *(orig.Spec.(*networkingv1alpha3.Gateway)),
}
modRes := &clientnetworkingv1alpha3.Gateway{
ObjectMeta: modMeta,
Spec: *(mod.Spec.(*networkingv1alpha3.Gateway)),
}
patchBytes, err := genPatchBytes(oldRes, modRes, typ)
if err != nil {
return nil, err
}
return ic.NetworkingV1alpha3().Gateways(orig.Namespace).
Patch(context.TODO(), orig.Name, typ, patchBytes, metav1.PatchOptions{FieldManager: "pilot-discovery"})
case collections.IstioNetworkingV1Alpha3Serviceentries.Resource().GroupVersionKind():
oldRes := &clientnetworkingv1alpha3.ServiceEntry{
ObjectMeta: origMeta,
Spec: *(orig.Spec.(*networkingv1alpha3.ServiceEntry)),
}
modRes := &clientnetworkingv1alpha3.ServiceEntry{
ObjectMeta: modMeta,
Spec: *(mod.Spec.(*networkingv1alpha3.ServiceEntry)),
}
patchBytes, err := genPatchBytes(oldRes, modRes, typ)
if err != nil {
return nil, err
}
return ic.NetworkingV1alpha3().ServiceEntries(orig.Namespace).
Patch(context.TODO(), orig.Name, typ, patchBytes, metav1.PatchOptions{FieldManager: "pilot-discovery"})
case collections.IstioNetworkingV1Alpha3Sidecars.Resource().GroupVersionKind():
oldRes := &clientnetworkingv1alpha3.Sidecar{
ObjectMeta: origMeta,
Spec: *(orig.Spec.(*networkingv1alpha3.Sidecar)),
}
modRes := &clientnetworkingv1alpha3.Sidecar{
ObjectMeta: modMeta,
Spec: *(mod.Spec.(*networkingv1alpha3.Sidecar)),
}
patchBytes, err := genPatchBytes(oldRes, modRes, typ)
if err != nil {
return nil, err
}
return ic.NetworkingV1alpha3().Sidecars(orig.Namespace).
Patch(context.TODO(), orig.Name, typ, patchBytes, metav1.PatchOptions{FieldManager: "pilot-discovery"})
case collections.IstioNetworkingV1Alpha3Virtualservices.Resource().GroupVersionKind():
oldRes := &clientnetworkingv1alpha3.VirtualService{
ObjectMeta: origMeta,
Spec: *(orig.Spec.(*networkingv1alpha3.VirtualService)),
}
modRes := &clientnetworkingv1alpha3.VirtualService{
ObjectMeta: modMeta,
Spec: *(mod.Spec.(*networkingv1alpha3.VirtualService)),
}
patchBytes, err := genPatchBytes(oldRes, modRes, typ)
if err != nil {
return nil, err
}
return ic.NetworkingV1alpha3().VirtualServices(orig.Namespace).
Patch(context.TODO(), orig.Name, typ, patchBytes, metav1.PatchOptions{FieldManager: "pilot-discovery"})
case collections.IstioNetworkingV1Alpha3Workloadentries.Resource().GroupVersionKind():
oldRes := &clientnetworkingv1alpha3.WorkloadEntry{
ObjectMeta: origMeta,
Spec: *(orig.Spec.(*networkingv1alpha3.WorkloadEntry)),
}
modRes := &clientnetworkingv1alpha3.WorkloadEntry{
ObjectMeta: modMeta,
Spec: *(mod.Spec.(*networkingv1alpha3.WorkloadEntry)),
}
patchBytes, err := genPatchBytes(oldRes, modRes, typ)
if err != nil {
return nil, err
}
return ic.NetworkingV1alpha3().WorkloadEntries(orig.Namespace).
Patch(context.TODO(), orig.Name, typ, patchBytes, metav1.PatchOptions{FieldManager: "pilot-discovery"})
case collections.IstioNetworkingV1Alpha3Workloadgroups.Resource().GroupVersionKind():
oldRes := &clientnetworkingv1alpha3.WorkloadGroup{
ObjectMeta: origMeta,
Spec: *(orig.Spec.(*networkingv1alpha3.WorkloadGroup)),
}
modRes := &clientnetworkingv1alpha3.WorkloadGroup{
ObjectMeta: modMeta,
Spec: *(mod.Spec.(*networkingv1alpha3.WorkloadGroup)),
}
patchBytes, err := genPatchBytes(oldRes, modRes, typ)
if err != nil {
return nil, err
}
return ic.NetworkingV1alpha3().WorkloadGroups(orig.Namespace).
Patch(context.TODO(), orig.Name, typ, patchBytes, metav1.PatchOptions{FieldManager: "pilot-discovery"})
case collections.IstioNetworkingV1Beta1Proxyconfigs.Resource().GroupVersionKind():
oldRes := &clientnetworkingv1beta1.ProxyConfig{
ObjectMeta: origMeta,
Spec: *(orig.Spec.(*networkingv1beta1.ProxyConfig)),
}
modRes := &clientnetworkingv1beta1.ProxyConfig{
ObjectMeta: modMeta,
Spec: *(mod.Spec.(*networkingv1beta1.ProxyConfig)),
}
patchBytes, err := genPatchBytes(oldRes, modRes, typ)
if err != nil {
return nil, err
}
return ic.NetworkingV1beta1().ProxyConfigs(orig.Namespace).
Patch(context.TODO(), orig.Name, typ, patchBytes, metav1.PatchOptions{FieldManager: "pilot-discovery"})
case collections.IstioSecurityV1Beta1Authorizationpolicies.Resource().GroupVersionKind():
oldRes := &clientsecurityv1beta1.AuthorizationPolicy{
ObjectMeta: origMeta,
Spec: *(orig.Spec.(*securityv1beta1.AuthorizationPolicy)),
}
modRes := &clientsecurityv1beta1.AuthorizationPolicy{
ObjectMeta: modMeta,
Spec: *(mod.Spec.(*securityv1beta1.AuthorizationPolicy)),
}
patchBytes, err := genPatchBytes(oldRes, modRes, typ)
if err != nil {
return nil, err
}
return ic.SecurityV1beta1().AuthorizationPolicies(orig.Namespace).
Patch(context.TODO(), orig.Name, typ, patchBytes, metav1.PatchOptions{FieldManager: "pilot-discovery"})
case collections.IstioSecurityV1Beta1Peerauthentications.Resource().GroupVersionKind():
oldRes := &clientsecurityv1beta1.PeerAuthentication{
ObjectMeta: origMeta,
Spec: *(orig.Spec.(*securityv1beta1.PeerAuthentication)),
}
modRes := &clientsecurityv1beta1.PeerAuthentication{
ObjectMeta: modMeta,
Spec: *(mod.Spec.(*securityv1beta1.PeerAuthentication)),
}
patchBytes, err := genPatchBytes(oldRes, modRes, typ)
if err != nil {
return nil, err
}
return ic.SecurityV1beta1().PeerAuthentications(orig.Namespace).
Patch(context.TODO(), orig.Name, typ, patchBytes, metav1.PatchOptions{FieldManager: "pilot-discovery"})
case collections.IstioSecurityV1Beta1Requestauthentications.Resource().GroupVersionKind():
oldRes := &clientsecurityv1beta1.RequestAuthentication{
ObjectMeta: origMeta,
Spec: *(orig.Spec.(*securityv1beta1.RequestAuthentication)),
}
modRes := &clientsecurityv1beta1.RequestAuthentication{
ObjectMeta: modMeta,
Spec: *(mod.Spec.(*securityv1beta1.RequestAuthentication)),
}
patchBytes, err := genPatchBytes(oldRes, modRes, typ)
if err != nil {
return nil, err
}
return ic.SecurityV1beta1().RequestAuthentications(orig.Namespace).
Patch(context.TODO(), orig.Name, typ, patchBytes, metav1.PatchOptions{FieldManager: "pilot-discovery"})
case collections.IstioTelemetryV1Alpha1Telemetries.Resource().GroupVersionKind():
oldRes := &clienttelemetryv1alpha1.Telemetry{
ObjectMeta: origMeta,
Spec: *(orig.Spec.(*telemetryv1alpha1.Telemetry)),
}
modRes := &clienttelemetryv1alpha1.Telemetry{
ObjectMeta: modMeta,
Spec: *(mod.Spec.(*telemetryv1alpha1.Telemetry)),
}
patchBytes, err := genPatchBytes(oldRes, modRes, typ)
if err != nil {
return nil, err
}
return ic.TelemetryV1alpha1().Telemetries(orig.Namespace).
Patch(context.TODO(), orig.Name, typ, patchBytes, metav1.PatchOptions{FieldManager: "pilot-discovery"})
case collections.K8SGatewayApiV1Alpha2Gatewayclasses.Resource().GroupVersionKind():
oldRes := &gatewayv1alpha2.GatewayClass{
ObjectMeta: origMeta,
Spec: *(orig.Spec.(*gatewayv1alpha2.GatewayClassSpec)),
}
modRes := &gatewayv1alpha2.GatewayClass{
ObjectMeta: modMeta,
Spec: *(mod.Spec.(*gatewayv1alpha2.GatewayClassSpec)),
}
patchBytes, err := genPatchBytes(oldRes, modRes, typ)
if err != nil {
return nil, err
}
return sc.GatewayV1alpha2().GatewayClasses().
Patch(context.TODO(), orig.Name, typ, patchBytes, metav1.PatchOptions{FieldManager: "pilot-discovery"})
case collections.K8SGatewayApiV1Alpha2Gateways.Resource().GroupVersionKind():
oldRes := &gatewayv1alpha2.Gateway{
ObjectMeta: origMeta,
Spec: *(orig.Spec.(*gatewayv1alpha2.GatewaySpec)),
}
modRes := &gatewayv1alpha2.Gateway{
ObjectMeta: modMeta,
Spec: *(mod.Spec.(*gatewayv1alpha2.GatewaySpec)),
}
patchBytes, err := genPatchBytes(oldRes, modRes, typ)
if err != nil {
return nil, err
}
return sc.GatewayV1alpha2().Gateways(orig.Namespace).
Patch(context.TODO(), orig.Name, typ, patchBytes, metav1.PatchOptions{FieldManager: "pilot-discovery"})
case collections.K8SGatewayApiV1Alpha2Httproutes.Resource().GroupVersionKind():
oldRes := &gatewayv1alpha2.HTTPRoute{
ObjectMeta: origMeta,
Spec: *(orig.Spec.(*gatewayv1alpha2.HTTPRouteSpec)),
}
modRes := &gatewayv1alpha2.HTTPRoute{
ObjectMeta: modMeta,
Spec: *(mod.Spec.(*gatewayv1alpha2.HTTPRouteSpec)),
}
patchBytes, err := genPatchBytes(oldRes, modRes, typ)
if err != nil {
return nil, err
}
return sc.GatewayV1alpha2().HTTPRoutes(orig.Namespace).
Patch(context.TODO(), orig.Name, typ, patchBytes, metav1.PatchOptions{FieldManager: "pilot-discovery"})
case collections.K8SGatewayApiV1Alpha2Referencepolicies.Resource().GroupVersionKind():
oldRes := &gatewayv1alpha2.ReferencePolicy{
ObjectMeta: origMeta,
Spec: *(orig.Spec.(*gatewayv1alpha2.ReferencePolicySpec)),
}
modRes := &gatewayv1alpha2.ReferencePolicy{
ObjectMeta: modMeta,
Spec: *(mod.Spec.(*gatewayv1alpha2.ReferencePolicySpec)),
}
patchBytes, err := genPatchBytes(oldRes, modRes, typ)
if err != nil {
return nil, err
}
return sc.GatewayV1alpha2().ReferencePolicies(orig.Namespace).
Patch(context.TODO(), orig.Name, typ, patchBytes, metav1.PatchOptions{FieldManager: "pilot-discovery"})
case collections.K8SGatewayApiV1Alpha2Tcproutes.Resource().GroupVersionKind():
oldRes := &gatewayv1alpha2.TCPRoute{
ObjectMeta: origMeta,
Spec: *(orig.Spec.(*gatewayv1alpha2.TCPRouteSpec)),
}
modRes := &gatewayv1alpha2.TCPRoute{
ObjectMeta: modMeta,
Spec: *(mod.Spec.(*gatewayv1alpha2.TCPRouteSpec)),
}
patchBytes, err := genPatchBytes(oldRes, modRes, typ)
if err != nil {
return nil, err
}
return sc.GatewayV1alpha2().TCPRoutes(orig.Namespace).
Patch(context.TODO(), orig.Name, typ, patchBytes, metav1.PatchOptions{FieldManager: "pilot-discovery"})
case collections.K8SGatewayApiV1Alpha2Tlsroutes.Resource().GroupVersionKind():
oldRes := &gatewayv1alpha2.TLSRoute{
ObjectMeta: origMeta,
Spec: *(orig.Spec.(*gatewayv1alpha2.TLSRouteSpec)),
}
modRes := &gatewayv1alpha2.TLSRoute{
ObjectMeta: modMeta,
Spec: *(mod.Spec.(*gatewayv1alpha2.TLSRouteSpec)),
}
patchBytes, err := genPatchBytes(oldRes, modRes, typ)
if err != nil {
return nil, err
}
return sc.GatewayV1alpha2().TLSRoutes(orig.Namespace).
Patch(context.TODO(), orig.Name, typ, patchBytes, metav1.PatchOptions{FieldManager: "pilot-discovery"})
default:
return nil, fmt.Errorf("unsupported type: %v", orig.GroupVersionKind)
}
}