Skip to content

Commit

Permalink
enh: env with viper (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
notdodo authored Jun 8, 2024
1 parent 74a3092 commit 00061fa
Show file tree
Hide file tree
Showing 6 changed files with 174 additions and 58 deletions.
4 changes: 2 additions & 2 deletions .env_example
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
NEO4J_URL="neo4j://localhost:7687"
PASSWORD=nuvola123!
NEO4J_AUTH="neo4j/${PASSWORD}"
NEO4J_PASS=nuvola123!
NEO4J_AUTH="neo4j/${NEO4J_PASS}"
NEO4J_server_memory_heap_initial__size=12G
NEO4J_server_memory_heap_max__size=16G
NEO4J_server_memory_pagecache_size=12G
17 changes: 5 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ include .env
BUILD_FLAGS=-ldflags="-s -w"
OUT_DIR=dist
OUT_PREFIX=nuvola
NEO4J_PASS ?= neo4j

define ANNOUNCE_BODY
CALL apoc.export.cypher.all("/var/lib/neo4j/import/all.cypher", {
Expand All @@ -14,18 +13,17 @@ YIELD file, batches, source, format, nodes, relationships, properties, time, row
RETURN file, batches, source, format, nodes, relationships, properties, time, rows, batchSize;
endef

.PHONY: backup
.PHONY: backup check-dependencies check-neo4j-password build compile clean restore start-containers stop-containers test

export ANNOUNCE_BODY
backup:
@echo "$$ANNOUNCE_BODY" | docker-compose exec -T neo4j cypher-shell -u neo4j -p ${PASSWORD} -d nuvoladb --non-interactive
docker-compose exec -T neo4j cp /var/lib/neo4j/import/all.cypher /backup
@echo "$$ANNOUNCE_BODY" | docker compose exec -T neo4j cypher-shell -u neo4j -p ${NEO4J_PASS} -d nuvoladb --non-interactive
docker compose exec -T neo4j cp /var/lib/neo4j/import/all.cypher /backup

.PHONY: check-dependencies
check-dependencies:
@command -v docker compose >/dev/null 2>&1 || { echo >&2 "docker compose not installed"; exit 1; }
@command -v go >/dev/null 2>&1 || { echo >&2 "Go not installed"; exit 1; }

.PHONY: check-neo4j-password
check-neo4j-password:
@if [ -z "${NEO4J_PASS}" ]; then \
echo "NEO4J_PASS is not set. Set it in the .env file"; \
Expand All @@ -42,28 +40,23 @@ compile: build
GOOS=darwin GOARCH=amd64 go build ${BUILD_FLAGS} -o ${OUT_DIR}/${OUT_PREFIX}-darwin-amd64
GOOS=darwin GOARCH=arm64 go build ${BUILD_FLAGS} -o ${OUT_DIR}/${OUT_PREFIX}-darwin-arm64

.PHONY: clean
clean: stop-containers
@rm -rf ./${OUT_DIR}
@rm -f ./${OUT_PREFIX}

.PHONY: restore
restore:
@cat ./backup/all.cypher | docker-compose exec -T neo4j cypher-shell -u neo4j -p ${PASSWORD} -d nuvoladb --non-interactive
@cat ./backup/all.cypher | docker-compose exec -T neo4j cypher-shell -u neo4j -p ${NEO4J_PASS} -d nuvoladb --non-interactive

.PHONY: start-containers
start-containers: check-dependencies
@if [ ! -f ./.env ]; then\
cp .env_example .env;\
fi
@docker compose up -d

.PHONY: stop-containers
stop-containers:
@docker compose stop
@docker compose down -v
@docker compose rm -fv

.PHONY: test
test: start-containers build
cd ./assets/ && $(MAKE) -C tests all
83 changes: 48 additions & 35 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ module github.com/primait/nuvola
go 1.21

require (
github.com/aws/aws-sdk-go-v2 v1.27.1
github.com/aws/aws-sdk-go-v2/config v1.27.17
github.com/aws/aws-sdk-go-v2/service/accessanalyzer v1.29.7
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.32.7
github.com/aws/aws-sdk-go-v2/service/ec2 v1.163.0
github.com/aws/aws-sdk-go-v2/service/iam v1.32.5
github.com/aws/aws-sdk-go-v2/service/lambda v1.54.5
github.com/aws/aws-sdk-go-v2/service/rds v1.79.5
github.com/aws/aws-sdk-go-v2/service/redshift v1.44.5
github.com/aws/aws-sdk-go-v2/service/s3 v1.55.0
github.com/aws/aws-sdk-go-v2/service/sts v1.28.11
github.com/aws/aws-sdk-go-v2 v1.27.2
github.com/aws/aws-sdk-go-v2/config v1.27.18
github.com/aws/aws-sdk-go-v2/service/accessanalyzer v1.29.8
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.32.8
github.com/aws/aws-sdk-go-v2/service/ec2 v1.163.1
github.com/aws/aws-sdk-go-v2/service/iam v1.32.6
github.com/aws/aws-sdk-go-v2/service/lambda v1.54.6
github.com/aws/aws-sdk-go-v2/service/rds v1.79.6
github.com/aws/aws-sdk-go-v2/service/redshift v1.44.6
github.com/aws/aws-sdk-go-v2/service/s3 v1.55.1
github.com/aws/aws-sdk-go-v2/service/sts v1.28.12
github.com/charmbracelet/log v0.4.0
github.com/fatih/color v1.17.0
github.com/gocarina/gocsv v0.0.0-20231116093920-b87c2d0e983a
github.com/gocarina/gocsv v0.0.0-20240520201108-78e41c74b4b1
github.com/imroc/req/v3 v3.43.7
github.com/itchyny/gojq v0.12.16
github.com/joho/godotenv v1.5.1
Expand All @@ -26,58 +26,71 @@ require (
github.com/ohler55/ojg v1.22.0
github.com/sourcegraph/conc v0.3.0
github.com/spf13/cobra v1.8.0
github.com/spf13/viper v1.19.0
golang.org/x/text v0.16.0
gopkg.in/yaml.v2 v2.4.0
)

require (
github.com/andybalholm/brotli v1.1.0 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.2 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.17.17 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.4 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.8 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.8 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.17.18 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.5 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.9 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.9 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.0 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.8 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.9 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.2 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.3.10 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.9.9 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.10 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.17.8 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.20.10 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.24.4 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.3.11 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.9.10 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.11 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.17.9 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.20.11 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.24.5 // indirect
github.com/aws/smithy-go v1.20.2 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/charmbracelet/lipgloss v0.10.0 // indirect
github.com/charmbracelet/lipgloss v0.11.0 // indirect
github.com/charmbracelet/x/ansi v0.1.2 // indirect
github.com/cloudflare/circl v1.3.8 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6 // indirect
github.com/google/pprof v0.0.0-20240528025155-186aa0362fba // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/itchyny/timefmt-go v0.1.6 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/klauspost/compress v1.17.8 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/muesli/reflow v0.3.0 // indirect
github.com/muesli/termenv v0.15.2 // indirect
github.com/onsi/ginkgo/v2 v2.17.2 // indirect
github.com/onsi/ginkgo/v2 v2.19.0 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/quic-go/qpack v0.4.0 // indirect
github.com/quic-go/quic-go v0.43.0 // indirect
github.com/refraction-networking/utls v1.6.4 // indirect
github.com/quic-go/quic-go v0.45.0 // indirect
github.com/refraction-networking/utls v1.6.6 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/sagikazarmark/locafero v0.6.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
go.uber.org/mock v0.4.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
golang.org/x/crypto v0.24.0 // indirect
golang.org/x/exp v0.0.0-20240604190554-fc45aab8b7f8 // indirect
golang.org/x/mod v0.18.0 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/tools v0.22.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 00061fa

Please sign in to comment.