Newer
Older
/*
Licensed under the GNU AFFERO GENERAL PUBLIC LICENSE Version 3 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.gnu.org/licenses/agpl-3.0.html
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package settings
import (
"k8s.libre.sh/meta"
"sigs.k8s.io/controller-runtime/pkg/client"
)
type Settings interface {
GetMeta() meta.Instance
GetSecretMeta() meta.Instance
GetConfigMapMeta() meta.Instance
GetConfig() Config
SetDefaults()
Init(c client.Client) error
GetCreateOptions() *CreateOptions
GetObjects() map[int]objects.Object
}
func NewSettings(s Settings) *Component {
return &Component{
CreateOptions: s.GetCreateOptions(),
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
ConfigSpec: &ConfigSpec{
Sources: s.GetConfig().GetSources(),
Parameters: s.GetConfig().GetParameters(),
},
}
}
/* func GetObjects(s Settings) map[int]objects.Object {
cm := &configmap.ConfigMap{
ObjectMeta: &meta.ObjectMeta{},
}
secret := &secret.Secret{
ObjectMeta: &meta.ObjectMeta{},
}
objs := make(map[int]objects.Object, 2)
meta.SetObjectMeta(s.GetConfigMapMeta(), cm.ObjectMeta)
meta.SetObjectMeta(s.GetSecretMeta(), secret.ObjectMeta)
params := s.GetConfig()
for _, p := range *params.GetParameters() {
if p.MountType == parameters.MountEnvFile &&
// TO FIX
p.Type == parameters.SecretParameter &&
len(p.Value) > 0 {
secret.Parameters = append(secret.Parameters, p)
}
if p.MountType == parameters.MountEnvFile &&
p.Type == parameters.ConfigParameter &&
len(p.Value) > 0 {
cm.Parameters = append(cm.Parameters, p)
}
}
// TODO IMPROVE
if len(cm.Parameters) > 0 {
objs[0] = cm
}
if len(secret.Parameters) > 0 {
if objs[0] == nil {
objs[0] = secret
} else {
objs[1] = secret
}
}
return objs
}
*/