bat-go

command module
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 12, 2021 License: MPL-2.0 Imports: 7 Imported by: 0

README

pass "go" and collect 200 BAT

CI

Developer Setup

  1. Install Go 1.12 (NOTE: Go 1.10 and earlier will not work!)

  2. Install GolangCI-Lint

  3. go get -u github.com/hexdigest/gowrap/cmd/gowrap

  4. Clone this repo via git clone https://github.com/brave-intl/bat-go

  5. Build via make

Consider adding a pre-commit hook

  1. Use your favorite editor to open .git/hooks/pre-commit

  2. Add the following contents

    make test lint
    
  3. Make the executable runnable by executing chmod +x .git/hooks/pre-commit

  4. Commit away!

Full environment via docker-compose

Ensure docker and docker-compose are installed.

Ensure that your .env file is populated with values for each of the env vars that does not have a default in docker-compose.yml.

Local prod-like environment

To bring up a prod-like environment, run docker-compose up -d.

Local dev environment

To bring up a dev environment, run make docker-dev.

This brings up an additional vault service, used for integration testing of some auxiliary binaries.

You can run the unit and integration tests via make docker-test

Once you are in the Docker container you can run the web server via go run bin/grant-server/main.go.

If you want to run tests you can do so via the command go test --tags=integration -v For example in promotion you can run specific tests by running a command similar to go test --tags=integration -run TestControllersTestSuite/TestCreateOrder.

Rapid Iteration dev Environment

On occasion it is desirable to re-run the development environment at will quickly. To this end you can run make docker-refresh-dev which will spin up the bat-go services including a container named grant-refresh-dev. If you want to recompile this service you merely need to perform a docker restart grant-refresh-dev and it will recompile and run the service.

A particularly interesting use case is marrying this with utilities such as fswatch to watch for file changes. There is an example below which will restart this grant-refresh-dev container on any file change in the source directory:

fswatch . | xargs -I {} sh -c '$(docker ps -f "name=grant-refresh-dev" --format "docker restart {{.ID}}")'

Building a prod image using docker

You can build a docker image without installing the go toolchain. Ensure docker is installed then run make docker.

Build mock files

make mock

Documentation

Overview

main - main entry-point to bat-go commands through cobra individual commands are outlined in ./cmd/

Directories

Path Synopsis
cmd
datastore
Package grant is a generated GoMock package.
Package grant is a generated GoMock package.
libs module
main module
Package promotion is a generated GoMock package.
Package promotion is a generated GoMock package.
serverless
email/status Module
email/webhook Module
services module
tools module
payments Module
utils
altcurrency
Package altcurrency provides an enum-like representation of acceptable cryptocurrencies as well as helper functions for tasks like validating addresses and converting currency units.
Package altcurrency provides an enum-like representation of acceptable cryptocurrencies as well as helper functions for tasks like validating addresses and converting currency units.
clients/cbr/mock
Package mock_cbr is a generated GoMock package.
Package mock_cbr is a generated GoMock package.
clients/gemini/mock
Package mock_gemini is a generated GoMock package.
Package mock_gemini is a generated GoMock package.
clients/ratios/mock
Package mock_ratios is a generated GoMock package.
Package mock_ratios is a generated GoMock package.
clients/reputation/mock
Package mock_reputation is a generated GoMock package.
Package mock_reputation is a generated GoMock package.
digest
Package digest implements an instance which serializes to / from the Digest header per rfc3230 https://tools.ietf.org/html/rfc3230
Package digest implements an instance which serializes to / from the Digest header per rfc3230 https://tools.ietf.org/html/rfc3230
httpsignature
Package httpsignature contains methods for signing and verifing HTTP requests per https://www.ietf.org/id/draft-cavage-http-signatures-08.txt
Package httpsignature contains methods for signing and verifing HTTP requests per https://www.ietf.org/id/draft-cavage-http-signatures-08.txt
kv
Package kv contains "key-value" stores used for testing
Package kv contains "key-value" stores used for testing
passphrase
Package passphrase implements passphrase based signing key derivation / backup from github.com/brave/crypto.
Package passphrase implements passphrase based signing key derivation / backup from github.com/brave/crypto.
pindialer
Package pindialer contains a basic implementation of a pinned HTTPS dialer
Package pindialer contains a basic implementation of a pinned HTTPS dialer
set
wallet
Package wallet defines common datastructures and an interface for cryptocurrency wallets
Package wallet defines common datastructures and an interface for cryptocurrency wallets

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL