A service to be used to store Insights operator configuration and to offer the configuration to selected operator.
Use the standard Go command:
go build
This command should create an executable file named insights-operator-controller.
Just run the executable file created by go build:
./insights-operator-controller
Change the following lines in config.toml:
- use_https=false
- address=":4443"
Please note that the service (when run locally) use the self-signed certificate.
You'd need to use certs.pem file on client side (curl, web browser etc.)
Default configuration file is config.toml. It is possible to specify config file via environment variable
named INSIGHTS_CONTROLLER_CONFIG_FILE. For example:
export INSIGHTS_CONTROLLER_CONFIG_FILE=~/config.toml
./insights-operator-controller
Data storage used by the service is configurable via the command line parameters. Currently it is possible to configure the following data storages:
- SQLite local database:
controller.dbfor the local deployment anddata.dbfor functional tests - PostgreSQL database: for local deployment and to be able to deploy the application to developer development
Use the following scripts from the local_storage subdirectory to work with SQLite database:
create_database_sqlite.shto create new database stored in filecontroller.dbcreate_test_database_sqlite.shto create new database stored in filetest.db, this database will be used by tests
PostgreSQL needs to be setup correcty:
- User
postgresshould have password set topostgres - In the configuration file
/var/lib/pgsql/data/pg_hba.conf, the methodmd5needs to be selected for userpostgresandall - The PostgreSQL daemon (service) has to be started, of course:
sudo systemctl start postgresql
For more information how to install PostgreSQL on Fedora (or RHEL) machine, please follow this guide: https://computingforgeeks.com/how-to-install-postgresql-on-fedora/
Use the following scripts from the local_storage subdirectory to work with SQLite database:
create_database_postgres.shto create new database namedcontrollercreate_test_database_postgres.shto create new database namedtest_db
The following two scripts can be used to drop existing database(s):
drop_database_postgres.shto drop database namedcontrollerdrop_test_database_postgres.shto drop database namedtest_db
The following command run all unit tests:
go test ./...
It is also possible to increase verbosity level:
go test -v ./...
REST API tests needs the running service and the test database to be prepared. In order to perform REST API tests, start the following script:
./test.sh
Please note that the service should not be running at the same moment (as it used the same port).
Travis CI is configured for this repository. Several tests and checks are started for all pull requests:
- Unit tests that use the standard tool
go test go fmttool to check code formatting. That tool is run with-sflag to perform following transformationsgo vetto report likely mistakes in source code, for example suspicious constructs, such as Printf calls whose arguments do not align with the format string.golintas a linter for all Go sources stored in this repositorygocycloto report all functions and methods with too high cyclomatic complexity. The cyclomatic complexity of a function is calculated according to the following rules: 1 is the base complexity of a function +1 for each 'if', 'for', 'case', '&&' or '||' Go Report Card warns on functions with cyclomatic complexity > 9
History of checks done by CI is available at RedHatInsights / insights-operator-controller.