Welcome to the SCANOSS platform. This repository serves up the REST API supporting all the scanning capabilities written in golang.
This is a replacement for the WAYUU and API REST service/projects.
The API defines a number of endpoints (exact ones can be found in server.go). The documentation for the API can be found here.
Here are some example implementations of these endpoints:
This repository is made up of the following components:
- cmd contains the entry point for launching the API Server
- pkg contains the source code to process the REST requests
- config contains sample configuration files to run the service
- scripts contain helper scripts for installing the service onto a Linux server
To build a deployable binary, please refer to the Makefile for target options, including:
- build_amd
- build_arm
- package_amd
- package_arm
All of these build commands target the Linux platform and focus on either AMD64 of ARM64 architectures. For example:
make build_amdThis will produce a binary in the target folder called scanoss-go-api-amd64. Similarly, using build_arm will produce a file called scanoss-go-api-linux-arm64.
Inside the scripts folder is a set of convenience utilities to aid deployment and running of the scanning API as a service.
For example, running the following will put a Linux AMD64 binary into the scripts for deployment:
make package_amdThe version of the API is calculated at compile time from the git tags (see version.sh). This is injected into server.go at compile time.
To get the desired version in the deployed binary, please commit and tag the source before building. Standard semantic versioning should be followed:
git tag v1.0.1This scripts folder contains convenience utilities for deploying, configuring and running the SCANOSS GO API server. More details can be found here.
Once the service has been deployed on a server, it can be managed using the systemctl command. For example:
systemctl status scanoss-go-api
systemctl start scanoss-go-api
systemctl stop scanoss-go-api
systemctl restart scanoss-go-apiConfiguration for service can be handled in three different ways:
The order in which these are loaded is as follows:
dot-env --> env.json --> Actual Environment Variable
The most up-to-date configuration options can be found in server_config.go.
This service supports emitting metrics/traces using the Open Telemetry framework (OTEL).
By default, this is disabled. It can be switched on from the configuration (Telemetry -> Enabled).
The service emits the following to OLTP gRPC collector:
- Traces
- HTTP requests
- Including traces/spans in logging
- Metrics
- Request counts
- Request duration
To run locally on your desktop, please use the following command:
make run_localTo use a different config file, simply run the command manually using:
go run cmd/server/main.go -json-config config/app-config-dev.json -debugNote, this will simulate the scanoss binary (using scanoss.sh), so you might need to change this if you have the actual binary on your system.
This project contains unit tests and can be invoked using:
make unit_testThis project contains integration tests and can be invoked using:
make int_testThis requires the service to be running locally listening on port 5443.
It is also possible to run the whole test via containers:
make e2e_testAfter changing a dependency or version, please run the following command:
go mod tidy -compat=1.19To request features or alert about bugs, please do so here.
Details of major changes to the library can be found in CHANGELOG.md.