MCPcopy Create free account
hub / github.com/apache/openwhisk-cli / loadProperties

Function loadProperties

commands/property.go:427–483  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

425}
426
427func loadProperties() error {
428 var err error
429
430 SetDefaultProperties()
431
432 Properties.PropsFile, err = GetPropertiesFilePath()
433 if err != nil {
434 return nil
435 //whisk.Debug(whisk.DbgError, "GetPropertiesFilePath() failed: %s\n", err)
436 //errStr := fmt.Sprintf("Unable to load the properties file: %s", err)
437 //werr := whisk.MakeWskError(errors.New(errStr), whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE)
438 //return werr
439 }
440
441 props, err := ReadProps(Properties.PropsFile)
442 if err != nil {
443 whisk.Debug(whisk.DbgError, "readProps(%s) failed: %s\n", Properties.PropsFile, err)
444 errStr := wski18n.T("Unable to read the properties file '{{.filename}}': {{.err}}",
445 map[string]interface{}{"filename": Properties.PropsFile, "err": err})
446 werr := whisk.MakeWskError(errors.New(errStr), whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE)
447 return werr
448 }
449
450 if cert, hasProp := props["CERT"]; hasProp {
451 Properties.Cert = cert
452 }
453
454 if key, hasProp := props["KEY"]; hasProp {
455 Properties.Key = key
456 }
457
458 if authToken, hasProp := props["AUTH"]; hasProp {
459 Properties.Auth = authToken
460 }
461
462 if authToken := os.Getenv("WHISK_AUTH"); len(authToken) > 0 {
463 Properties.Auth = authToken
464 }
465
466 if apiVersion, hasProp := props["APIVERSION"]; hasProp {
467 Properties.APIVersion = apiVersion
468 }
469
470 if apiVersion := os.Getenv("WHISK_APIVERSION"); len(apiVersion) > 0 {
471 Properties.APIVersion = apiVersion
472 }
473
474 if apiHost, hasProp := props["APIHOST"]; hasProp {
475 Properties.APIHost = strings.TrimRight(apiHost, "/")
476 }
477
478 if apiHost := os.Getenv("WHISK_APIHOST"); len(apiHost) > 0 {
479 Properties.APIHost = apiHost
480 }
481
482 return nil
483}
484

Callers 2

ExecuteFunction · 0.85
property.goFile · 0.85

Calls 3

SetDefaultPropertiesFunction · 0.85
GetPropertiesFilePathFunction · 0.85
ReadPropsFunction · 0.85

Tested by

no test coverage detected