istio
57 строк · 1.6 Кб
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
15package helmreconciler
16
17import (
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.
27func (h *HelmReconciler) RenderCharts() (name.ManifestMap, error) {
28iopSpec := h.iop.Spec
29if err := validate.CheckIstioOperatorSpec(iopSpec, false); err != nil {
30if !h.opts.Force {
31return nil, err
32}
33h.opts.Log.PrintErr(fmt.Sprintf("spec invalid; continuing because of --force: %v\n", err))
34}
35
36t := translate.NewTranslator()
37ver, err := h.kubeClient.GetKubernetesVersion()
38if err != nil {
39return nil, err
40}
41cp, err := controlplane.NewIstioControlPlane(iopSpec, t, nil, ver)
42if err != nil {
43return nil, err
44}
45if err := cp.Run(); err != nil {
46return nil, fmt.Errorf("failed to create Istio control plane with spec: \n%v\nerror: %s", iopSpec, err)
47}
48
49manifests, errs := cp.RenderManifest()
50if errs != nil {
51err = errs.ToError()
52}
53
54h.manifests = manifests
55
56return manifests, err
57}
58