istio.io/istio@v0.0.0-20240520182934-d79c90f27776/pilot/pkg/networking/core/extension_config_builder.go (about) 1 // Copyright Istio Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package core 16 17 import ( 18 "strings" 19 20 core "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" 21 "k8s.io/apimachinery/pkg/types" 22 23 "istio.io/istio/pilot/pkg/model" 24 "istio.io/istio/pilot/pkg/networking/core/envoyfilter" 25 "istio.io/istio/pilot/pkg/networking/core/extension" 26 "istio.io/istio/pkg/log" 27 ) 28 29 // BuildExtensionConfiguration returns the list of extension configuration for the given proxy and list of names. 30 // This is the ECDS output. 31 func (configgen *ConfigGeneratorImpl) BuildExtensionConfiguration( 32 proxy *model.Proxy, push *model.PushContext, extensionConfigNames []string, pullSecrets map[string][]byte, 33 ) []*core.TypedExtensionConfig { 34 envoyFilterPatches := push.EnvoyFilters(proxy) 35 extensions := envoyfilter.InsertedExtensionConfigurations(envoyFilterPatches, extensionConfigNames) 36 wasmPlugins := push.WasmPluginsByName(proxy, parseExtensionName(extensionConfigNames)) 37 extensions = append(extensions, extension.InsertedExtensionConfigurations(wasmPlugins, extensionConfigNames, pullSecrets)...) 38 return extensions 39 } 40 41 func parseExtensionName(names []string) []types.NamespacedName { 42 res := make([]types.NamespacedName, 0, len(names)) 43 for _, n := range names { 44 if !strings.HasPrefix(n, model.WasmPluginResourceNamePrefix) { 45 log.Warnf("ignoring unknown ECDS: %v", n) 46 continue 47 } 48 ns, name, ok := strings.Cut(n[len(model.WasmPluginResourceNamePrefix):], ".") 49 if !ok { 50 log.Warnf("ignoring unknown ECDS: %v", n) 51 continue 52 } 53 res = append(res, types.NamespacedName{Namespace: ns, Name: name}) 54 } 55 return res 56 }