@@ -40,12 +40,6 @@ import (
40
40
"github.com/openservicemesh/osm/pkg/version"
41
41
)
42
42
43
- const (
44
- meshConfigName = "osm-mesh-config"
45
- presetMeshConfigName = "preset-mesh-config"
46
- presetMeshConfigJSONKey = "preset-mesh-config.json"
47
- )
48
-
49
43
var (
50
44
verbosity string
51
45
osmNamespace string
@@ -146,7 +140,7 @@ func main() {
146
140
147
141
err = bootstrap .ensureMeshConfig ()
148
142
if err != nil {
149
- log .Fatal ().Err (err ).Msgf ("Error setting up default MeshConfig %s from ConfigMap %s" , meshConfigName , presetMeshConfigName )
143
+ log .Fatal ().Err (err ).Msgf ("Error setting up default MeshConfig %s from ConfigMap %s" , constants . OSMMeshConfig , constants . PresetMeshConfig )
150
144
return
151
145
}
152
146
@@ -213,7 +207,7 @@ func main() {
213
207
214
208
func (b * bootstrap ) createDefaultMeshConfig () error {
215
209
// find presets config map to build the default MeshConfig from that
216
- presetsConfigMap , err := b .kubeClient .CoreV1 ().ConfigMaps (b .namespace ).Get (context .TODO (), presetMeshConfigName , metav1.GetOptions {})
210
+ presetsConfigMap , err := b .kubeClient .CoreV1 ().ConfigMaps (b .namespace ).Get (context .TODO (), constants . PresetMeshConfig , metav1.GetOptions {})
217
211
218
212
// If the presets MeshConfig could not be loaded return the error
219
213
if err != nil {
@@ -223,7 +217,7 @@ func (b *bootstrap) createDefaultMeshConfig() error {
223
217
// Create a default meshConfig
224
218
defaultMeshConfig := buildDefaultMeshConfig (presetsConfigMap )
225
219
if _ , err := b .meshConfigClient .ConfigV1alpha1 ().MeshConfigs (b .namespace ).Create (context .TODO (), defaultMeshConfig , metav1.CreateOptions {}); err == nil {
226
- log .Info ().Msgf ("MeshConfig (%s) created in namespace %s" , meshConfigName , b .namespace )
220
+ log .Info ().Msgf ("MeshConfig (%s) created in namespace %s" , constants . OSMMeshConfig , b .namespace )
227
221
return nil
228
222
}
229
223
@@ -236,7 +230,7 @@ func (b *bootstrap) createDefaultMeshConfig() error {
236
230
}
237
231
238
232
func (b * bootstrap ) ensureMeshConfig () error {
239
- _ , err := b .meshConfigClient .ConfigV1alpha1 ().MeshConfigs (b .namespace ).Get (context .TODO (), meshConfigName , metav1.GetOptions {})
233
+ _ , err := b .meshConfigClient .ConfigV1alpha1 ().MeshConfigs (b .namespace ).Get (context .TODO (), constants . OSMMeshConfig , metav1.GetOptions {})
240
234
if err == nil {
241
235
return nil // default meshConfig was found
242
236
}
@@ -302,7 +296,7 @@ func validateCLIParams() error {
302
296
}
303
297
304
298
func buildDefaultMeshConfig (presetMeshConfigMap * corev1.ConfigMap ) * v1alpha1.MeshConfig {
305
- presetMeshConfig := presetMeshConfigMap .Data [presetMeshConfigJSONKey ]
299
+ presetMeshConfig := presetMeshConfigMap .Data [constants . PresetMeshConfigJSONKey ]
306
300
presetMeshConfigSpec := v1alpha1.MeshConfigSpec {}
307
301
err := json .Unmarshal ([]byte (presetMeshConfig ), & presetMeshConfigSpec )
308
302
if err != nil {
@@ -315,7 +309,7 @@ func buildDefaultMeshConfig(presetMeshConfigMap *corev1.ConfigMap) *v1alpha1.Mes
315
309
APIVersion : "config.openservicemesh.io/v1alpha1" ,
316
310
},
317
311
ObjectMeta : metav1.ObjectMeta {
318
- Name : meshConfigName ,
312
+ Name : constants . OSMMeshConfig ,
319
313
},
320
314
Spec : presetMeshConfigSpec ,
321
315
}
0 commit comments