This is the server component of the AeroGear Mobile Security Service. It is a RESTful API that allows developers to view, enable and disable specific versions of applications on demand, with the information stored in a PostgreSQL database.
See the Contributing Guide for more information.
If youβd like to simply run the entire application in docker-compose
, follow these instructions.
Golang projects are kept in a workspace that follows a very specific architecture. Before cloning this repo, be sure you have a $GOPATH
environment variable set up.
git clone [email protected]:aerogear/mobile-security-service.git $GOPATH/src/github.com/aerogear/mobile-security-service
make setup
π
|
This is using the dep package manager under the hood. You will see the dependencies installed in the vendor folder.
|
This section shows how to start the entire application with docker-compose
. This is useful for doing some quick tests (using the SDKs) for example.
First, compile a Linux compatible binary:
go build -o mobile-security-service cmd/mobile-security-service/main.go
This binary will be used to build the Docker image. Now start the entire application.
docker-compose up
The mobile-security-service is configured using environment variables.
-
By default, the application will look for system environment variables to use.
-
If a system environment variable cannot be found, the application will then check the
.env
file in the application root. -
If the
.env
file does not exist, or if the variable is not defined in the file, the application will use the default value defined in config.go.
Make a copy of the example file .env.example
.
cp .env.example .env
Now the application will use the values defined in .env
.
Variable |
Default |
Description |
PORT |
3000 |
The port the server will listen on |
LOG_LEVEL |
info |
Can be one of |
LOG_FORMAT |
text |
Can be one of |
ACCESS_CONTROL_ALLOW_ORIGIN |
* |
Can be multiple URL values separated with commas. Example: |
ACCESS_CONTROL_ALLOW_CREDENTIALS |
false |
Can be one of |
DBMAX_CONNECTIONS |
100 |
The maximum number of concurrent database connections the server will open |
The database connection is configured using the table of environment variables below. These environment variables correspond to the PostgreSQL libpq environment variables. The table below shows all of the environment variables supported by the pq
driver used in this server.
Variable |
Default |
Description |
PGDATABASE |
mobile_security_service |
The database to connect to |
PGUSER |
postgresql |
The database user |
PGPASSWORD |
postgres |
The database password |
PGHOST |
localhost |
The database hostname to connect to |
PGPORT |
5432 |
The database port to connect to |
PGSSLMODE |
disable |
The SSL mode |
PGCONNECT_TIMEOUT |
5 |
The default connection timeout (seconds) |
PGAPPNAME |
The application_name connection parameter |
|
PGSSLCERT |
The sslcert connection parameter. |
|
PGSSLKEY |
The sslkey connection parameter. |
|
PGSSLROOTCERT |
The sslrootcert connection parameter |
A Swagger UI can be used for testing the mobile-security-service service.
docker run -p 8080:8080 -e API_URL=https://raw.githubusercontent.com/aerogear/mobile-security-service/master/api/swagger.yaml swaggerapi/swagger-ui
Or you can run the container with docker-compose up -d swagger
.
The Swagger UI is available at localhost:8080.
There is also a Chrome extension you can use instead of running a Docker container.
Paste https://raw.githubusercontent.com/aerogear/mobile-security-service/master/api/swagger.yaml and press Explore.
The Makefile
provides commands for building and testing the code. Some dependencies are required to run these commands.
Dependencies may be required to run some of the Make
commands. Below are instructions on how to install them.
This project is using teh dependency moq. Follow the steps below to use it.
Execute the following command to generate the mock file.
$ moq -out <name_of_mock_file> . <name of interface>
Following an example.
moq -out app_service_mock.go . Service
β
|
This command need to be executed from the same directory where the interface is or it need to be called as, for example, $ moq -out ./pkg/web/apps/app_service_mock.go ./pkg/web/apps Service
|
π
|
See more over it in the Readme of moq |
The errcheck is required to run the make errcheck
command.
Install:
go get -u github.com/kisielk/errcheck
Command |
Description |
|
Downloads dependencies into |
|
Symlink all Git hooks from |
|
Compile a binary compatible with your current system into |
|
Compile a Linux binary into |
|
Generate swagger API documentation from the source code |
|
Compile a binary and create a Docker image from it. |
|
Compile a binary and create a Docker image with a release tag |
|
Compile a binary and create a Docker image tagged |
|
Runs unit tests |
|
Runs all tests |
|
Runs integration tests |
|
Runs integration tests and outputs results to a log file |
|
Checks for unchecked errors using errcheck |
|
Examines source code and reports suspicious constructs using vet |
|
Formats code using gofmt |
|
Removes binary compiled using |
|
Pushes release image to Docker image hosting repository |
|
Pushes master image to Docker image hosting repository |
All contributions are hugely appreciated. Please see our Contributing Guide for guidelines on how to open issues and pull requests. Please check out our Code of Conduct too.
There are a number of ways you can get in in touch with us, please see the AeroGear community.