| 1034 | } |
| 1035 | |
| 1036 | func getUserContextId() (string, error) { |
| 1037 | var guid string |
| 1038 | var err error |
| 1039 | |
| 1040 | // If the context id override has been set, use it instead of the default |
| 1041 | if len(ContextId) > 0 { |
| 1042 | guid = ContextId |
| 1043 | } else { |
| 1044 | props, errprops := ReadProps(Properties.PropsFile) |
| 1045 | if errprops == nil { |
| 1046 | if len(props["AUTH"]) > 0 { |
| 1047 | guid = strings.Split(props["AUTH"], ":")[0] |
| 1048 | } else { |
| 1049 | whisk.Debug(whisk.DbgError, "AUTH property not set in properties file: '%s'\n", Properties.PropsFile) |
| 1050 | errStr := wski18n.T("Authorization key is not configured (--auth is required)") |
| 1051 | err = whisk.MakeWskError(errors.New(errStr), whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) |
| 1052 | } |
| 1053 | } else { |
| 1054 | whisk.Debug(whisk.DbgError, "readProps(%s) failed: %s\n", Properties.PropsFile, err) |
| 1055 | errStr := wski18n.T("Unable to obtain the auth key from the properties file: {{.err}}", map[string]interface{}{"err": err}) |
| 1056 | err = whisk.MakeWskError(errors.New(errStr), whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) |
| 1057 | } |
| 1058 | } |
| 1059 | |
| 1060 | return guid, err |
| 1061 | } |
| 1062 | |
| 1063 | /////////// |
| 1064 | // Flags // |