odpi / egeria-react-ui

A multi-tenant, role based Egeria React UI for Open Metadata, that has eco-system and solutions capabilities.
Apache License 2.0
14 stars 15 forks source link

Configuration of backend server - example clarification / startup should fail? #83

Closed planetf1 closed 3 years ago

planetf1 commented 3 years ago

The current README states:

Example: EGERIA_PRESENTATIONSERVER_SERVER_aaa={"remoteServerName":"cocoView1","remoteURL":"https://localhost:9443"}

However if this is entered literally ie via the CLI, the typical shell processor will actually set something different due to quote handling.

ie

$ EGERIA_PRESENTATIONSERVER_SERVER_aaa={"remoteServerName":"cocoView1","remoteURL":"https://localhost:9443"}     
$ echo $EGERIA_PRESENTATIONSERVER_SERVER_aaa                                                                                  
{remoteServerName:cocoView1,remoteURL:https://localhost:9443}

If this is used, then 'npm start' is issues we see:

Found server name aaa SyntaxError: Unexpected token r in JSON at position 1 at JSON.parse () at getServerInfoFromEnv (/Users/jonesn/IdeaProjects/egeria-react-ui/cra-server/functions/getServerInfoFromEnv.js:27:38) at Object. (/Users/jonesn/IdeaProjects/egeria-react-ui/cra-server/index.js:34:17) at Module._compile (node:internal/modules/cjs/loader:1108:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10) at Module.load (node:internal/modules/cjs/loader:973:32) at Function.Module._load (node:internal/modules/cjs/loader:813:14) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12) at node:internal/main/run_main_module:17:47 Error occured processing environment variables. Ignore and carry on looking for more valid server content. Server listening on port: 8091 React UI listening on port: 3000

This is because the JSON could not be parsed.

It's also worth noting that the server has started up regardless - and since the env var cannot be configured this is a fatal error.
I feel that if no valid configuration can be parsed, the startup should fail.
Obviously the server specified could be invalid and discovered later - but in this case it is obviously wrong (null)

On the configuration - this works:

$ EGERIA_PRESENTATIONSERVER_SERVER_aaa="{\"remoteServerName\":\"cocoView1\",\"remoteURL\":\"https://localhost:9443\"}"
(base) jonesn:cra-server/ (issue79) $ echo $EGERIA_PRESENTATIONSERVER_SERVER_aaa [11:32:57] {"remoteServerName":"cocoView1","remoteURL":"https://localhost:9443"}



Using a typical shell approach with characters that have significant shell meaning is a little problematic. A non-JSON format may be advisable, or a file based configuration.
planetf1 commented 3 years ago

I've submitted a PR which offers some clarification