Skip to content

Commit 00061fa

Browse files
authored
enh: env with viper (#32)
1 parent 74a3092 commit 00061fa

File tree

6 files changed

+174
-58
lines changed

6 files changed

+174
-58
lines changed

.env_example

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
NEO4J_URL="neo4j://localhost:7687"
2-
PASSWORD=nuvola123!
3-
NEO4J_AUTH="neo4j/${PASSWORD}"
2+
NEO4J_PASS=nuvola123!
3+
NEO4J_AUTH="neo4j/${NEO4J_PASS}"
44
NEO4J_server_memory_heap_initial__size=12G
55
NEO4J_server_memory_heap_max__size=16G
66
NEO4J_server_memory_pagecache_size=12G

Makefile

+5-12
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ include .env
33
BUILD_FLAGS=-ldflags="-s -w"
44
OUT_DIR=dist
55
OUT_PREFIX=nuvola
6-
NEO4J_PASS ?= neo4j
76

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

17-
.PHONY: backup
16+
.PHONY: backup check-dependencies check-neo4j-password build compile clean restore start-containers stop-containers test
17+
1818
export ANNOUNCE_BODY
1919
backup:
20-
@echo "$$ANNOUNCE_BODY" | docker-compose exec -T neo4j cypher-shell -u neo4j -p ${PASSWORD} -d nuvoladb --non-interactive
21-
docker-compose exec -T neo4j cp /var/lib/neo4j/import/all.cypher /backup
20+
@echo "$$ANNOUNCE_BODY" | docker compose exec -T neo4j cypher-shell -u neo4j -p ${NEO4J_PASS} -d nuvoladb --non-interactive
21+
docker compose exec -T neo4j cp /var/lib/neo4j/import/all.cypher /backup
2222

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

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

45-
.PHONY: clean
4643
clean: stop-containers
4744
@rm -rf ./${OUT_DIR}
4845
@rm -f ./${OUT_PREFIX}
4946

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

54-
.PHONY: start-containers
5550
start-containers: check-dependencies
5651
@if [ ! -f ./.env ]; then\
5752
cp .env_example .env;\
5853
fi
5954
@docker compose up -d
6055

61-
.PHONY: stop-containers
6256
stop-containers:
6357
@docker compose stop
6458
@docker compose down -v
6559
@docker compose rm -fv
6660

67-
.PHONY: test
6861
test: start-containers build
6962
cd ./assets/ && $(MAKE) -C tests all

go.mod

+48-35
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ module github.com/primait/nuvola
33
go 1.21
44

55
require (
6-
github.com/aws/aws-sdk-go-v2 v1.27.1
7-
github.com/aws/aws-sdk-go-v2/config v1.27.17
8-
github.com/aws/aws-sdk-go-v2/service/accessanalyzer v1.29.7
9-
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.32.7
10-
github.com/aws/aws-sdk-go-v2/service/ec2 v1.163.0
11-
github.com/aws/aws-sdk-go-v2/service/iam v1.32.5
12-
github.com/aws/aws-sdk-go-v2/service/lambda v1.54.5
13-
github.com/aws/aws-sdk-go-v2/service/rds v1.79.5
14-
github.com/aws/aws-sdk-go-v2/service/redshift v1.44.5
15-
github.com/aws/aws-sdk-go-v2/service/s3 v1.55.0
16-
github.com/aws/aws-sdk-go-v2/service/sts v1.28.11
6+
github.com/aws/aws-sdk-go-v2 v1.27.2
7+
github.com/aws/aws-sdk-go-v2/config v1.27.18
8+
github.com/aws/aws-sdk-go-v2/service/accessanalyzer v1.29.8
9+
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.32.8
10+
github.com/aws/aws-sdk-go-v2/service/ec2 v1.163.1
11+
github.com/aws/aws-sdk-go-v2/service/iam v1.32.6
12+
github.com/aws/aws-sdk-go-v2/service/lambda v1.54.6
13+
github.com/aws/aws-sdk-go-v2/service/rds v1.79.6
14+
github.com/aws/aws-sdk-go-v2/service/redshift v1.44.6
15+
github.com/aws/aws-sdk-go-v2/service/s3 v1.55.1
16+
github.com/aws/aws-sdk-go-v2/service/sts v1.28.12
1717
github.com/charmbracelet/log v0.4.0
1818
github.com/fatih/color v1.17.0
19-
github.com/gocarina/gocsv v0.0.0-20231116093920-b87c2d0e983a
19+
github.com/gocarina/gocsv v0.0.0-20240520201108-78e41c74b4b1
2020
github.com/imroc/req/v3 v3.43.7
2121
github.com/itchyny/gojq v0.12.16
2222
github.com/joho/godotenv v1.5.1
@@ -26,58 +26,71 @@ require (
2626
github.com/ohler55/ojg v1.22.0
2727
github.com/sourcegraph/conc v0.3.0
2828
github.com/spf13/cobra v1.8.0
29+
github.com/spf13/viper v1.19.0
2930
golang.org/x/text v0.16.0
3031
gopkg.in/yaml.v2 v2.4.0
3132
)
3233

3334
require (
3435
github.com/andybalholm/brotli v1.1.0 // indirect
3536
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.2 // indirect
36-
github.com/aws/aws-sdk-go-v2/credentials v1.17.17 // indirect
37-
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.4 // indirect
38-
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.8 // indirect
39-
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.8 // indirect
37+
github.com/aws/aws-sdk-go-v2/credentials v1.17.18 // indirect
38+
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.5 // indirect
39+
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.9 // indirect
40+
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.9 // indirect
4041
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.0 // indirect
41-
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.8 // indirect
42+
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.9 // indirect
4243
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.2 // indirect
43-
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.3.10 // indirect
44-
github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.9.9 // indirect
45-
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.10 // indirect
46-
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.17.8 // indirect
47-
github.com/aws/aws-sdk-go-v2/service/sso v1.20.10 // indirect
48-
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.24.4 // indirect
44+
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.3.11 // indirect
45+
github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.9.10 // indirect
46+
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.11 // indirect
47+
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.17.9 // indirect
48+
github.com/aws/aws-sdk-go-v2/service/sso v1.20.11 // indirect
49+
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.24.5 // indirect
4950
github.com/aws/smithy-go v1.20.2 // indirect
5051
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
51-
github.com/charmbracelet/lipgloss v0.10.0 // indirect
52+
github.com/charmbracelet/lipgloss v0.11.0 // indirect
53+
github.com/charmbracelet/x/ansi v0.1.2 // indirect
5254
github.com/cloudflare/circl v1.3.8 // indirect
55+
github.com/fsnotify/fsnotify v1.7.0 // indirect
5356
github.com/go-logfmt/logfmt v0.6.0 // indirect
5457
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
55-
github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6 // indirect
58+
github.com/google/pprof v0.0.0-20240528025155-186aa0362fba // indirect
5659
github.com/hashicorp/errwrap v1.1.0 // indirect
5760
github.com/hashicorp/go-multierror v1.1.1 // indirect
61+
github.com/hashicorp/hcl v1.0.0 // indirect
5862
github.com/inconshreveable/mousetrap v1.1.0 // indirect
5963
github.com/itchyny/timefmt-go v0.1.6 // indirect
6064
github.com/jmespath/go-jmespath v0.4.0 // indirect
6165
github.com/klauspost/compress v1.17.8 // indirect
62-
github.com/kr/pretty v0.3.1 // indirect
6366
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
67+
github.com/magiconair/properties v1.8.7 // indirect
6468
github.com/mattn/go-colorable v0.1.13 // indirect
6569
github.com/mattn/go-isatty v0.0.20 // indirect
6670
github.com/mattn/go-runewidth v0.0.15 // indirect
71+
github.com/mitchellh/mapstructure v1.5.0 // indirect
6772
github.com/muesli/reflow v0.3.0 // indirect
6873
github.com/muesli/termenv v0.15.2 // indirect
69-
github.com/onsi/ginkgo/v2 v2.17.2 // indirect
74+
github.com/onsi/ginkgo/v2 v2.19.0 // indirect
75+
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
7076
github.com/quic-go/qpack v0.4.0 // indirect
71-
github.com/quic-go/quic-go v0.43.0 // indirect
72-
github.com/refraction-networking/utls v1.6.4 // indirect
77+
github.com/quic-go/quic-go v0.45.0 // indirect
78+
github.com/refraction-networking/utls v1.6.6 // indirect
7379
github.com/rivo/uniseg v0.4.7 // indirect
80+
github.com/sagikazarmark/locafero v0.6.0 // indirect
81+
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
82+
github.com/spf13/afero v1.11.0 // indirect
83+
github.com/spf13/cast v1.6.0 // indirect
7484
github.com/spf13/pflag v1.0.5 // indirect
85+
github.com/subosito/gotenv v1.6.0 // indirect
7586
go.uber.org/mock v0.4.0 // indirect
7687
go.uber.org/multierr v1.11.0 // indirect
77-
golang.org/x/crypto v0.23.0 // indirect
78-
golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f // indirect
79-
golang.org/x/mod v0.17.0 // indirect
80-
golang.org/x/net v0.25.0 // indirect
81-
golang.org/x/sys v0.20.0 // indirect
82-
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
88+
golang.org/x/crypto v0.24.0 // indirect
89+
golang.org/x/exp v0.0.0-20240604190554-fc45aab8b7f8 // indirect
90+
golang.org/x/mod v0.18.0 // indirect
91+
golang.org/x/net v0.26.0 // indirect
92+
golang.org/x/sys v0.21.0 // indirect
93+
golang.org/x/tools v0.22.0 // indirect
94+
gopkg.in/ini.v1 v1.67.0 // indirect
95+
gopkg.in/yaml.v3 v3.0.1 // indirect
8396
)

0 commit comments

Comments
 (0)