Skip to content

Conversation

carlosms
Copy link
Contributor

Fixes #120

All the env vars are explained in a table. The .env file is still suggested for development in CONTRIBUTING.

The TODOs in the table need to be with the new vars from #145.

All the env vars are explained in a table. The .env
file is still suggested for development in CONTRIBUTING

Signed-off-by: Carlos Martín <carlos.martin.sanchez@gmail.com>
README.md Outdated
In order to be able to use this application while running the tool locally, make sure you add http://127.0.0.1:8080/oauth-callback to the authorization callback URL field.

2. Copy `.env.tpl` to `.env`.
Variable | Required | Default value | Meaning
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I view this file the table is rendered like this:
screen shot 2018-02-26 at 18 28 41

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

README.md Outdated

docker run --env-file .env --rm -p 8080:8080 srcd/code-annotation
```bash
$ docker run --rm -p 8080:8080 srcd/code-annotation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here should be example how to set required env variables. At least:

  • CAT_OAUTH_CLIENT_ID
  • CAT_OAUTH_CLIENT_SECRET

are there any other?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we also need to provide information how to run it with DB.
Currently, it will run the server with empty DB which isn't very usable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Regarding your second comment, I think the reordering of the steps falls into #67, to be done in a future PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imo, teaching to the user how to provide a db is out of scope for this PR, and should be done by #67

#### Set the Internal Database Connection

Before starting the application you will need to set the `CAT_DB_CONNECTION` variable in the `.env` file. It should point to the database created with the `import` command.
Before starting the application you will need to set the `CAT_DB_CONNECTION` environment variable. It should point to the database created with the `import` command.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is default variable ok? If not it should be in docker run too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the default is OK... otherwise it should not be the default value.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it's not. Opening /var/code-annotation/internal.db will fail with error: directory doesn't exist.

We have 3 options:

  • change defaults
  • change documentation
  • add mkdir in Dockerfile (I prefer this one)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@carlosms please address it somehow before merging (maybe just mention in another issue)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created issue #173 so we don't loose track of this.

Signed-off-by: Carlos Martín <carlos.martin.sanchez@gmail.com>
Signed-off-by: Carlos Martín <carlos.martin.sanchez@gmail.com>
CONTRIBUTING.md Outdated

> Please note: you will need a .env file configured with working GitHub OAuth credentials to run the application in development mode.
> Please follow the [README Installation section](./README.md#installation) for instructions on how to do it.
For convenience, you can configure a file with all the environment variables described in the [README](./README.md). To do so, copy `.env.tpl` to `.env`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, for me personally this sentence isn't clear.

Maybe we should rephrase like:

For convenience, you can configure .env file with all the environment variables described in the README.
We provide a template with the configuration suitable for development in .env.tpl. You can copy it to .env and set up GitHub OAuth credentials there.

The text isn't perfect, just to give you better understanding what I mean. What do you think?

README.md Outdated
| `CAT_ENV` | | `production` | Sets the log level. Use `dev` to enable debug log messages |
| `CAT_HOST` | | `0.0.0.0` | IP address to bind the HTTP server |
| `CAT_PORT` | | `8080` | Port address to bind the HTTP server |
| `CAT_SERVER_URL` | | `<CAT_HOST>:<CAT_PORT>` | TODO |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo? should we write a description here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, let's add the description now.
Can you please tell me the meaning of SERVER_URL, STATIC_PROXY_TARGET after the changes made in #145 ?

Copy link
Contributor

@smacker smacker Feb 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SERVER_URL doesn't change the meaning. It's server url available from outside. Frontend is using it to make http calls.

STATIC_PROXY_TARGET not sure we should document it. Normally nobody should change it.
And if they do it should be somehow be reflected in create-react-app. It should set HOST & PORT variables. https://github.com/facebook/create-react-app/blob/next/packages/react-scripts/scripts/start.js#L56

#145 isn't merged yet, it's one of the issues we need to resolve there. Maybe we will remove this variable and replace with something else.

README.md Outdated
## Installation

## Github OAuth tokens
## Environment Variables
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Installation and Environment Variables have the same size of header. It looks a bit weird:
screen shot 2018-02-26 at 18 44 48

The next sections make use of several environment variables to configure the application. In this table you will find all of them grouped as a quick reference:

In order to be able to use this application while running the tool locally, make sure you add http://127.0.0.1:8080/oauth-callback to the authorization callback URL field.
| Variable | Required | Default value | Meaning |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

people often move not mandatory variables somewhere in the bottom of README. Currently, the table is larger than my display and we are going to have more... Just as an idea for improvement.

Copy link
Contributor

@dpordomingo dpordomingo Feb 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this README.md is already huge and imho it does not strictly follow our recommendations for README.md I would not care too much about the length of the table: I'd merge as soon as possible, and improve README.md when facing issue #67

I'd reorder the mandatory ones in a way it appears first, but it's up to you @carlosms

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks both for the feedback, I moved the mandatory vars to the top of the table.

Signed-off-by: Carlos Martín <carlos.martin.sanchez@gmail.com>
Copy link
Contributor

@dpordomingo dpordomingo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but could you add some links?

README.md Outdated
| `CAT_ENV` | | `production` | Sets the log level. Use `dev` to enable debug log messages |
| `CAT_HOST` | | `0.0.0.0` | IP address to bind the HTTP server |
| `CAT_PORT` | | `8080` | Port address to bind the HTTP server |
| `CAT_SERVER_URL` | | `<CAT_HOST>:<CAT_PORT>` | TODO |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO value could be

hostname:port where the API is served

README.md Outdated
| `CAT_HOST` | | `0.0.0.0` | IP address to bind the HTTP server |
| `CAT_PORT` | | `8080` | Port address to bind the HTTP server |
| `CAT_SERVER_URL` | | `<CAT_HOST>:<CAT_PORT>` | TODO |
| `CAT_UI_DOMAIN` | | `<CAT_HOST>:<CAT_PORT>` | TODO |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO value could be

hostname:port where the frontend is served

README.md Outdated
| `CAT_PORT` | | `8080` | Port address to bind the HTTP server |
| `CAT_SERVER_URL` | | `<CAT_HOST>:<CAT_PORT>` | TODO |
| `CAT_UI_DOMAIN` | | `<CAT_HOST>:<CAT_PORT>` | TODO |
| `CAT_DB_CONNECTION` | | `sqlite:///var/code-annotation/internal.db` | Points to the internal application database. Read below for the complete syntax |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@dpordomingo dpordomingo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but I'd add some links

README.md Outdated
| `CAT_EXPORTS_PATH` | | `./exports` | Folder where the SQLite files will be created when requested from `http://<your-hostname>/export` |
| `CAT_OAUTH_CLIENT_ID` | YES | - | GitHub application OAuth credentials |
| `CAT_OAUTH_CLIENT_SECRET` | YES | - | GitHub application OAuth credentials |
| `CAT_OAUTH_RESTRICT_ACCESS` | | - | Application access control based on GitHub groups or teams |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd add a link to #access-control

README.md Outdated
| `CAT_OAUTH_CLIENT_ID` | YES | - | GitHub application OAuth credentials |
| `CAT_OAUTH_CLIENT_SECRET` | YES | - | GitHub application OAuth credentials |
| `CAT_OAUTH_RESTRICT_ACCESS` | | - | Application access control based on GitHub groups or teams |
| `CAT_OAUTH_RESTRICT_REQUESTER_ACCESS` | | - | User role control based on GitHub groups or teams |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd add a link to #access-control

README.md Outdated
| `CAT_UI_DOMAIN` | | `<CAT_HOST>:<CAT_PORT>` | TODO |
| `CAT_DB_CONNECTION` | | `sqlite:///var/code-annotation/internal.db` | Points to the internal application database. Read below for the complete syntax |
| `CAT_EXPORTS_PATH` | | `./exports` | Folder where the SQLite files will be created when requested from `http://<your-hostname>/export` |
| `CAT_OAUTH_CLIENT_ID` | YES | - | GitHub application OAuth credentials |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd add a link to #github-oauth-tokens

README.md Outdated
| `CAT_DB_CONNECTION` | | `sqlite:///var/code-annotation/internal.db` | Points to the internal application database. Read below for the complete syntax |
| `CAT_EXPORTS_PATH` | | `./exports` | Folder where the SQLite files will be created when requested from `http://<your-hostname>/export` |
| `CAT_OAUTH_CLIENT_ID` | YES | - | GitHub application OAuth credentials |
| `CAT_OAUTH_CLIENT_SECRET` | YES | - | GitHub application OAuth credentials |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd add a link to #github-oauth-tokens

Signed-off-by: Carlos Martín <carlos.martin.sanchez@gmail.com>
CONTRIBUTING.md Outdated

> Please note: you will need a .env file configured with working GitHub OAuth credentials to run the application in development mode.
> Please follow the [README Installation section](./README.md#installation) for instructions on how to do it.
For convenience, you can configure a `.env` file with all the environment variables described in the [README](./README.md). A template with a sample configuration suitable for development is provided in `.env.tpl`. You can copy it to `.env` and set up the variables there.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For convenience, you can create a ..

CONTRIBUTING.md Outdated
> Please follow the [README Installation section](./README.md#installation) for instructions on how to do it.
For convenience, you can configure a `.env` file with all the environment variables described in the [README](./README.md). A template with a sample configuration suitable for development is provided in `.env.tpl`. You can copy it to `.env` and set up the variables there.

_Note_: you will need a `.env` file configured with working GitHub OAuth credentials to run the application in development mode. In order to be able to use this application while running the tool locally, make sure you use `http://127.0.0.1:8080/oauth-callback` as the "Authorization callback URL". Please follow the [README Installation section](./README.md#installation) for instructions on how to do it.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about changing
you will need a .env file ... to run the app in dev mode -> you will need to customize the configuration, either by setting env vars, or though an .env file .... to

to communicate more clearly the optional nature of .env file?

README.md Outdated
### Github OAuth Tokens

3. Retrieve the values for your application's Client ID and Client Secret from the [GitHub Developer Settings page](https://github.com/settings/developers) and add them to the end of the corresponding lines in .env.
You need an OAuth application on GitHub. See [how to create OAuth applications on GitHub](https://developer.github.com/apps/building-oauth-apps/creating-an-oauth-app/). Make sure the "Authorization callback URL" points to `http://<your-hostname>/oauth-callback`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's always good to explain a bit of rationale for a need, so what do you think about re-phrasing by adding:
In order for authentication \w Github to work on your environment, you need to set up OAuth application on Github platform.

Copy link
Contributor

@dpordomingo dpordomingo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, imo you can merge once you've addressed @bzz suggestions

Signed-off-by: Carlos Martín <carlos.martin.sanchez@gmail.com>
Copy link
Contributor

@dpordomingo dpordomingo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks Carlos

@dpordomingo
Copy link
Contributor

Now that Carlos already addressed all the provided feedback, could you PTAL @bzz @smacker ?

@dpordomingo dpordomingo requested review from bzz and smacker and removed request for bzz and smacker February 27, 2018 18:21
Copy link
Contributor

@bzz bzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome 📜 !

@bzz bzz removed the request for review from smacker February 28, 2018 11:30
README.md Outdated
| `CAT_DB_CONNECTION` | | `sqlite:///var/code-annotation/internal.db` | Points to the internal application database. [Read below](#importing-and-exporting-data) for the complete syntax |
| `CAT_EXPORTS_PATH` | | `./exports` | Folder where the SQLite files will be created when requested from `http://<your-hostname>/export` |
| `CAT_ENV` | | `production` | Sets the log level. Use `dev` to enable debug log messages |
| `CAT_STATIC_PROXY_TARGET` | | - | :exclamation: TODO: to be reviewed when [#145](https://github.com/src-d/code-annotation/pull/145) is closed |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove it. #145 may never be merged in master or this variable will be replaced by something

@dpordomingo
Copy link
Contributor

@carlosms Let's remove CAT_STATIC_PROXY_TARGET as suggested by prev comment, squash, rebase and merge :)

Signed-off-by: Carlos Martín <carlos.martin.sanchez@gmail.com>
@carlosms carlosms merged commit d07124e into src-d:master Feb 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants