istio.io/istio@v0.0.0-20240520182934-d79c90f27776/operator/pkg/helmreconciler/render.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 helmreconciler 16 17 import ( 18 "fmt" 19 20 "istio.io/istio/operator/pkg/controlplane" 21 "istio.io/istio/operator/pkg/name" 22 "istio.io/istio/operator/pkg/translate" 23 "istio.io/istio/operator/pkg/validate" 24 ) 25 26 // RenderCharts renders charts for h. 27 func (h *HelmReconciler) RenderCharts() (name.ManifestMap, error) { 28 iopSpec := h.iop.Spec 29 if err := validate.CheckIstioOperatorSpec(iopSpec, false); err != nil { 30 if !h.opts.Force { 31 return nil, err 32 } 33 h.opts.Log.PrintErr(fmt.Sprintf("spec invalid; continuing because of --force: %v\n", err)) 34 } 35 36 t := translate.NewTranslator() 37 ver, err := h.kubeClient.GetKubernetesVersion() 38 if err != nil { 39 return nil, err 40 } 41 cp, err := controlplane.NewIstioControlPlane(iopSpec, t, nil, ver) 42 if err != nil { 43 return nil, err 44 } 45 if err := cp.Run(); err != nil { 46 return nil, fmt.Errorf("failed to create Istio control plane with spec: \n%v\nerror: %s", iopSpec, err) 47 } 48 49 manifests, errs := cp.RenderManifest() 50 if errs != nil { 51 err = errs.ToError() 52 } 53 54 h.manifests = manifests 55 56 return manifests, err 57 }