MCPcopy Create free account
hub / github.com/apache/camel-k / valueSource

Function valueSource

pkg/platform/env_platform.go:320–360  ·  view source on GitHub ↗

valueSource expects any var to contain : @ .

(envName string)

Source from the content-addressed store, hash-verified

318 log.Error(err, "could not parse MAVEN_SETTINGS env variable, this setting will be skipped")
319 }
320 settingsSecurity, err := valueSource("MAVEN_SETTINGS_SECURITY")
321 if err != nil {
322 log.Error(err, "could not parse MAVEN_SETTINGS_SECURITY env variable, this setting will be skipped")
323 }
324
325 return v1.MavenSpec{
326 LocalRepository: "",
327 Settings: settings,
328 SettingsSecurity: settingsSecurity,
329 CASecrets: caSecrets(),
330 CLIOptions: getEnvOrDefaultSlice("MAVEN_CLI_OPTIONS", DefaultMavenCLIOptions),
331 }
332}
333
334// valueSource expects any var to contain <configmap|secret>:<my-name>@<my-key>.
335func valueSource(envName string) (v1.ValueSource, error) {
336 valueSource := v1.ValueSource{}
337 vs := GetEnvOrDefault(envName, "")
338 if vs != "" {
339 // Split kind from the rest
340 parts := strings.SplitN(vs, ":", 2)
341 if len(parts) != 2 {
342 return valueSource, errors.New("invalid value source format: missing ':'")
343 }
344 kind := parts[0]
345
346 // Split name and key
347 subparts := strings.SplitN(parts[1], "@", 2)
348 if len(subparts) != 2 {
349 return valueSource, errors.New("invalid value source format for: missing '@'")
350 }
351 name := subparts[0]
352 key := subparts[1]
353
354 switch kind {
355 case "configmap":
356 valueSource.ConfigMapKeyRef = &corev1.ConfigMapKeySelector{
357 LocalObjectReference: corev1.LocalObjectReference{
358 Name: name,
359 },
360 Key: key,
361 }
362 case "secret":
363 valueSource.SecretKeyRef = &corev1.SecretKeySelector{

Callers 2

mavenSpecFunction · 0.85

Calls 1

GetEnvOrDefaultFunction · 0.70

Tested by 1