forked from open-component-model/ocm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
38 lines (32 loc) · 1.37 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// SPDX-FileCopyrightText: 2022 SAP SE or an SAP affiliate company and Open Component Model contributors.
//
// SPDX-License-Identifier: Apache-2.0
package app
import (
"encoding/json"
v1 "github.com/open-component-model/ocm/pkg/contexts/ocm/compdesc/meta/v1"
"github.com/open-component-model/ocm/pkg/contexts/ocm/utils/localize"
"github.com/open-component-model/ocm/pkg/errors"
)
type Config struct {
Chart v1.ResourceReference `json:"chart,omitempty"`
SubCharts map[string]v1.ResourceReference `json:"subCharts,omitempty"`
Release string `json:"release,omitempty"`
Namespace string `json:"namespace,omitempty"`
CreateNamespace bool `json:"createNamespace,omitempty"`
ImageMapping []ImageMapping `json:"imageMapping"`
Values json.RawMessage `json:"values,omitempty"`
KubeConfigName string `json:"kubeConfigName,omitempty"`
}
type ImageMapping = localize.ImageMapping
func (c *Config) GetValues() (map[string]interface{}, error) {
if len(c.Values) == 0 {
return map[string]interface{}{}, nil
}
var result map[string]interface{}
err := json.Unmarshal(c.Values, &result)
if err != nil {
return nil, errors.Wrapf(err, "cannot unmarshal values from bootstrap config")
}
return result, nil
}