Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
8bd1acb
Automated README update (#159)
github-actions[bot] Dec 25, 2025
2b455e2
Automated README update (#161)
github-actions[bot] Dec 27, 2025
06eb1e1
Automated README update (#164)
github-actions[bot] Jan 2, 2026
6d50fa9
Automated README update (#165)
github-actions[bot] Jan 2, 2026
6519040
.
CodeShellDev Jan 2, 2026
e0dfa89
Automated README update (#166)
github-actions[bot] Jan 2, 2026
92f0abd
Automated README update (#167)
github-actions[bot] Jan 2, 2026
d8398e4
Automated README update (#168)
github-actions[bot] Jan 2, 2026
086982f
feat: Path Auth (#170)
CodeShellDev Jan 2, 2026
7136afb
update PR and issue templates
CodeShellDev Jan 2, 2026
f9f855d
Oops, fixed templates again
CodeShellDev Jan 2, 2026
ce40491
feat: Body auth (#172)
CodeShellDev Jan 2, 2026
61873bc
feat: Port per Token Config (#174)
CodeShellDev Jan 3, 2026
8434b8b
feat: Log Level per Token (#176)
CodeShellDev Jan 3, 2026
57d062b
feat: Rate Limiting (#178)
CodeShellDev Jan 3, 2026
30ac476
default: allow all
CodeShellDev Jan 6, 2026
534e5bb
maybe make INSECURE configurable
CodeShellDev Jan 6, 2026
5ee203c
DEPRECATION: @authorization => @auth (#184)
CodeShellDev Jan 6, 2026
d5182a0
feat: IP Filtering (#181)
CodeShellDev Jan 6, 2026
c376af9
misc: Santa is Dead (#186)
CodeShellDev Jan 6, 2026
973847b
.
CodeShellDev Jan 6, 2026
4e89c7c
DEPRECATION: .token, .tokens, .overrides (#187)
CodeShellDev Jan 6, 2026
7181b9d
feat: Hostnames (#188)
CodeShellDev Jan 7, 2026
d8a753a
update PR template
CodeShellDev Jan 7, 2026
21571e9
feat: Regex in Field Policies (#193)
CodeShellDev Jan 8, 2026
301c358
Merge branch 'main' into v1.5.0
CodeShellDev Jan 8, 2026
08a4b67
update deps
CodeShellDev Jan 9, 2026
fe3b02d
remove old dep versions
CodeShellDev Jan 9, 2026
faa7655
use gotl with separate pkgs
CodeShellDev Jan 9, 2026
4a82a2d
add deprecation messages
CodeShellDev Jan 11, 2026
0e0c860
add .devenv file for local testing
CodeShellDev Jan 23, 2026
c708631
add dev-env.sh in favour of .devenv
CodeShellDev Jan 23, 2026
880afcf
.
CodeShellDev Jan 23, 2026
39aa6ef
use subloggers instead of creating new ones
CodeShellDev Jan 23, 2026
33be873
chore: Improved Logger Performance (#204)
CodeShellDev Jan 23, 2026
4d1c1a5
Merge branch 'v1.5.0' of https://github.com/codeshelldev/secured-sign…
CodeShellDev Jan 23, 2026
42cb712
chore: Prevent Caching (#205)
CodeShellDev Jan 23, 2026
76cc75f
feat: Select allowed Auth Methods (#207)
CodeShellDev Jan 23, 2026
64a5b38
fix PR template
CodeShellDev Jan 23, 2026
5e6102e
add deprecation messages
CodeShellDev Jan 23, 2026
fcdfc1c
pulled of a perfectly sized
CodeShellDev Jan 23, 2026
d23ef8f
imrpvoed dep messages
CodeShellDev Jan 24, 2026
084380f
feat: Regex in Endpoints (#209)
CodeShellDev Jan 24, 2026
72db0c9
feat: Regex in Endpoints (#2) (#212)
CodeShellDev Jan 24, 2026
54298c8
update dev workflow
CodeShellDev Jan 24, 2026
96a3909
oops, wrong paste
CodeShellDev Jan 24, 2026
45c3514
.
CodeShellDev Jan 24, 2026
906d509
fix registry login
CodeShellDev Jan 24, 2026
a9380de
fix workflow
CodeShellDev Jan 24, 2026
66b6558
fix workflow output
CodeShellDev Jan 24, 2026
e756970
.
CodeShellDev Jan 24, 2026
614d17b
change image format
CodeShellDev Jan 24, 2026
3e39f86
Merge branch 'main' into v1.5.0
CodeShellDev Jan 28, 2026
d63e3a9
Merge branch 'main' into v1.5.0
CodeShellDev Jan 28, 2026
9bd29c0
update go to v1.25.6
CodeShellDev Jan 30, 2026
10c9444
update deprecation
CodeShellDev Jan 30, 2026
ff3c927
add `@authorization` breaking change
CodeShellDev Jan 30, 2026
10f1ac5
remove Authorization header after auth middleware
CodeShellDev Jan 30, 2026
67f2487
fix default auth methods not being applied
CodeShellDev Jan 30, 2026
53fb06c
more deprecation message (improvements)
CodeShellDev Jan 30, 2026
bc68083
use basic colors (due to limited feats of some consoles)
CodeShellDev Jan 30, 2026
5389b3a
fix `/auth=TOKEN` not being stripped
CodeShellDev Jan 30, 2026
973d0fa
fix mockserver using wrong env for port
CodeShellDev Jan 30, 2026
ed8432b
fix additional warn message after client failed at some auth
CodeShellDev Jan 30, 2026
3c9e0e1
Merge branch 'main' into v1.5.0
CodeShellDev Jan 30, 2026
2ed82f4
.
CodeShellDev Jan 30, 2026
6c6721e
fix port middleware not serving next middleware when port is OK
CodeShellDev Jan 30, 2026
56ea8f9
fix main config creating sublogger
CodeShellDev Jan 30, 2026
4567e05
Merge branch 'main' into v1.5.0
CodeShellDev Jan 30, 2026
da4fbfe
treat `192.168.1.10/24` as `192.168.1.0/24`
CodeShellDev Jan 30, 2026
bc48506
improve trusted proxy handling
CodeShellDev Jan 30, 2026
71a3251
feat: improve trusted proxy (#223)
CodeShellDev Jan 30, 2026
d4a3d88
use `@auth=TOKEN` in path auth instead of without `@`
CodeShellDev Jan 31, 2026
1bcc471
feat: URL to Body Injection (#224)
CodeShellDev Jan 31, 2026
5bc0a8c
Merge branch 'main' into v1.5.0
CodeShellDev Jan 31, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
# env file
*.env

# Exclude git folders
# Git folders
.git*
.github

# Dev folders
.dev
*.local.*

# Ignore yml files
*.yaml
*.yml
Expand Down
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@ go.work.sum
# .idea/
.vscode/

# Exclude git folders
# Git folders
.git*
!.github

# Docusaurus
.docusaurus
node_modules
node_modules

# Dev folders
.dev
*.local.*
7 changes: 5 additions & 2 deletions data/defaults.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
api:
auth:
methods: [bearer, basic, body]

service:
port: 8880

logLevel: info
logLevel: info

settings:
message:
Expand Down
95 changes: 95 additions & 0 deletions dev-env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#!/usr/bin/env bash

###############################################################################
# This file is version-controlled and shared across developers.
#
# It is used for setting up a developer environment for local testing.
#
# Additionally overrides can be specified in dev-env.local.sh or dev.local.env.
# Local environment variables may be added in dev.local.env.
#
# To successfully load the environment variables this file needs to be sourced.
#
# Do not commit secrets or machine-specific values.
###############################################################################

RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
END='\033[0m'

cecho() {
echo -e "$*"
}

# Exit if not sourced
(return 0 2>/dev/null) || {
cecho "${RED}ERROR${END} dev-env.sh should be sourced, not executed."
cecho "${BLUE}Usage:${END} source dev-env.sh"
exit 1
}

# Get directory path
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

#=-----------------------------------=#
#= Environment Variables & Overrides =#
#=-----------------------------------=#

export DEFAULTS_PATH=$DIR/data/defaults.yml
export FAVICON_PATH=$DIR/data/favicon.ico
export CONFIG_PATH=$DIR/.dev/config.yml
export TOKENS_DIR=$DIR/.dev/tokens

export API__URL=http://127.0.0.1:8881

export LOG_LEVEL=dev

# Load overrides if present
if [ -f "$DIR/dev-env.local.sh" ]; then
cecho "${BLUE}Found overrides:${END} $DIR/dev-env.local.sh"
source "$DIR/dev-env.local.sh"
fi
if [ -f "$DIR/dev.local.env" ]; then
cecho "${BLUE}Found overrides:${END} $DIR/dev.local.env"
source "$DIR/dev.local.env"
fi

cecho "${GREEN}Successfully loaded development environment!${END}"

#=-----------------------------------=#
#= Mock server =#
#=-----------------------------------=#

MOCK_PORT="8881"

MOCK_BIN="/tmp/mockserver-$MOCK_PORT"
MOCK_PID="/tmp/mockserver-$MOCK_PORT.pid"

# Kill mockserver if still running
if [ -f "$MOCK_PID" ]; then
OLD_PID=$(cat "$MOCK_PID")
if ps -p "$OLD_PID" > /dev/null 2>&1; then
cecho "${YELLOW}Stopping previous Mock server (PID $OLD_PID)${END}"
kill "$OLD_PID"
sleep 1
fi
fi

# Build mockserver
go build -o "$MOCK_BIN" utils/mockserver/mockserver.go

set +m

if ! nc -z 127.0.0.1 "$MOCK_PORT" >/dev/null 2>&1; then
$MOCK_BIN > "$DIR/.dev/mock.log" 2>&1 &
NEW_PID=$!
disown

echo "$NEW_PID" > "$MOCK_PID"

echo "Mock server started at http://127.0.0.1:$MOCK_PORT"
else
echo "There is already a Service running at http://127.0.0.1:$MOCK_PORT"
fi
31 changes: 24 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,23 +1,40 @@
module github.com/codeshelldev/secured-signal-api

go 1.25.5
go 1.25.6

require github.com/codeshelldev/gotl v0.0.12
require (
github.com/codeshelldev/gotl/pkg/configutils v0.0.7
github.com/codeshelldev/gotl/pkg/docker v0.0.2
github.com/codeshelldev/gotl/pkg/jsonutils v0.0.2
github.com/codeshelldev/gotl/pkg/logger v0.0.6
github.com/codeshelldev/gotl/pkg/pretty v0.0.9
github.com/codeshelldev/gotl/pkg/query v0.0.3
github.com/codeshelldev/gotl/pkg/request v0.0.4
github.com/codeshelldev/gotl/pkg/stringutils v0.0.3
github.com/codeshelldev/gotl/pkg/templating v0.0.3
)

require go.uber.org/zap v1.27.1 // indirect
require (
github.com/codeshelldev/gotl/pkg/ioutils v0.0.2
github.com/knadh/koanf/parsers/yaml v1.1.0
golang.org/x/time v0.14.0
)

require (
github.com/clipperhouse/stringish v0.1.1 // indirect
github.com/clipperhouse/uax29/v2 v2.4.0 // indirect
github.com/fsnotify/fsnotify v1.9.0 // indirect
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
github.com/go-viper/mapstructure/v2 v2.5.0 // indirect
github.com/knadh/koanf/maps v0.1.2 // indirect
github.com/knadh/koanf/parsers/yaml v1.1.0
github.com/knadh/koanf/providers/confmap v1.0.0 // indirect
github.com/knadh/koanf/providers/env/v2 v2.0.0 // indirect
github.com/knadh/koanf/providers/file v1.2.1 // indirect
github.com/knadh/koanf/v2 v2.3.0 // indirect
github.com/knadh/koanf/v2 v2.3.2 // indirect
github.com/mattn/go-runewidth v0.0.19 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.1 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/sys v0.39.0 // indirect
golang.org/x/sys v0.40.0 // indirect
)
42 changes: 34 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,11 +1,33 @@
github.com/codeshelldev/gotl v0.0.12 h1:VM3W6hiEfPgK+cCLT70S004tYAdhQWXD72FtFqCF+2Q=
github.com/codeshelldev/gotl v0.0.12/go.mod h1:rDkJma6eQSRfCr7ieX9/esn3/uAWNzjHfpjlr9j6FFk=
github.com/clipperhouse/stringish v0.1.1 h1:+NSqMOr3GR6k1FdRhhnXrLfztGzuG+VuFDfatpWHKCs=
github.com/clipperhouse/stringish v0.1.1/go.mod h1:v/WhFtE1q0ovMta2+m+UbpZ+2/HEXNWYXQgCt4hdOzA=
github.com/clipperhouse/uax29/v2 v2.4.0 h1:RXqE/l5EiAbA4u97giimKNlmpvkmz+GrBVTelsoXy9g=
github.com/clipperhouse/uax29/v2 v2.4.0/go.mod h1:Wn1g7MK6OoeDT0vL+Q0SQLDz/KpfsVRgg6W7ihQeh4g=
github.com/codeshelldev/gotl/pkg/configutils v0.0.7 h1:54zv82v87xCrilbi7gfVFpC37dIpR4a9PXw8pYs1Few=
github.com/codeshelldev/gotl/pkg/configutils v0.0.7/go.mod h1:WoWMBB8+84ePRnI2m+kbq1Rw8F/9iCWLHkVBsun3Qjc=
github.com/codeshelldev/gotl/pkg/docker v0.0.2 h1:kpseReocEBoSzWe/tOhUrIrOYeAR/inw3EF2/d+N078=
github.com/codeshelldev/gotl/pkg/docker v0.0.2/go.mod h1:odNnlRw4aO1n2hSkDZIaiuSXIoFoVeatmXtF64Yd33U=
github.com/codeshelldev/gotl/pkg/ioutils v0.0.2 h1:IRcN2M6H4v59iodw1k7gFX9lirhbVy6RZ4yRtKNcFYg=
github.com/codeshelldev/gotl/pkg/ioutils v0.0.2/go.mod h1:WPQYglNqThBatoGaQK0OGx2bwzto1oi0zb1fB9gsaUU=
github.com/codeshelldev/gotl/pkg/jsonutils v0.0.2 h1:ERsjkaWVrsyUZoEunCEeNYDXhuaIvoSetB8e/zI4Tqo=
github.com/codeshelldev/gotl/pkg/jsonutils v0.0.2/go.mod h1:oxgKaAoMu6iYVHfgR7AhkK22xbYx4K0KCkyVEfYVoWs=
github.com/codeshelldev/gotl/pkg/logger v0.0.6 h1:heo6z6yZm5PpX78vxud9HJNfVU9J46HVlW8T4EOy9nQ=
github.com/codeshelldev/gotl/pkg/logger v0.0.6/go.mod h1:pL/I7KYxbGHhyedallZlCkBvoalv9gAWNEYVXbF9BoM=
github.com/codeshelldev/gotl/pkg/pretty v0.0.9 h1:YgAZ0QpV+cUCKeLz5T0XFVByM8BXrJuz5KKLE0a6o1Y=
github.com/codeshelldev/gotl/pkg/pretty v0.0.9/go.mod h1:2Gk6UBrtkIME2RCSNytS/RJ5lHXYL/MDx0rYRpknobM=
github.com/codeshelldev/gotl/pkg/query v0.0.3 h1:Zy8k0R5HcJS00OMPRHybgFEiwMg7ceLyv6bA0G7NOfs=
github.com/codeshelldev/gotl/pkg/query v0.0.3/go.mod h1:kKaPOKXluIid3qeS7xzrmfq3NxIa8/PhKYHM6GRbwJw=
github.com/codeshelldev/gotl/pkg/request v0.0.4 h1:QyuKTJd/jGrG0XYkFyIc8JmfS4kMlqeTj6kpsYtbXfI=
github.com/codeshelldev/gotl/pkg/request v0.0.4/go.mod h1:vCXIZ2n/XxvEVInBQv9eIh0kQ2353V+WymL8kZ9yrOU=
github.com/codeshelldev/gotl/pkg/stringutils v0.0.3 h1:7k/HMnX7me8Kchm41I/M6dp3wXI0XORI3oyS87O0Viw=
github.com/codeshelldev/gotl/pkg/stringutils v0.0.3/go.mod h1:/dWlzYoTj23LmpFs+Bpal4tfUDbOVeApIgkLv9gTgUE=
github.com/codeshelldev/gotl/pkg/templating v0.0.3 h1:PAz6VN8yGBuZIdR/sDM+TmW1OFykl+I7/Zwa07uMgYA=
github.com/codeshelldev/gotl/pkg/templating v0.0.3/go.mod h1:D+wxgsPSiq9HShEzv1mhYAjGJyasWgPoIu+nRk4TPqY=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9LvH92wZUgs=
github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
github.com/go-viper/mapstructure/v2 v2.5.0 h1:vM5IJoUAy3d7zRSVtIwQgBj7BiWtMPfmPEgAXnvj1Ro=
github.com/go-viper/mapstructure/v2 v2.5.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
github.com/knadh/koanf/maps v0.1.2 h1:RBfmAW5CnZT+PJ1CVc1QSJKf4Xu9kxfQgYVQSu8hpbo=
github.com/knadh/koanf/maps v0.1.2/go.mod h1:npD/QZY3V6ghQDdcQzl1W4ICNVTkohC8E73eI2xW4yI=
github.com/knadh/koanf/parsers/yaml v1.1.0 h1:3ltfm9ljprAHt4jxgeYLlFPmUaunuCgu1yILuTXRdM4=
Expand All @@ -16,12 +38,14 @@ github.com/knadh/koanf/providers/env/v2 v2.0.0 h1:Ad5H3eun722u+FvchiIcEIJZsZ2M6o
github.com/knadh/koanf/providers/env/v2 v2.0.0/go.mod h1:1g01PE+Ve1gBfWNNw2wmULRP0tc8RJrjn5p2N/jNCIc=
github.com/knadh/koanf/providers/file v1.2.1 h1:bEWbtQwYrA+W2DtdBrQWyXqJaJSG3KrP3AESOJYp9wM=
github.com/knadh/koanf/providers/file v1.2.1/go.mod h1:bp1PM5f83Q+TOUu10J/0ApLBd9uIzg+n9UgthfY+nRA=
github.com/knadh/koanf/v2 v2.3.0 h1:Qg076dDRFHvqnKG97ZEsi9TAg2/nFTa9hCdcSa1lvlM=
github.com/knadh/koanf/v2 v2.3.0/go.mod h1:gRb40VRAbd4iJMYYD5IxZ6hfuopFcXBpc9bbQpZwo28=
github.com/knadh/koanf/v2 v2.3.2 h1:Ee6tuzQYFwcZXQpc2MiVeC6qHMandf5SMUJJNoFp/c4=
github.com/knadh/koanf/v2 v2.3.2/go.mod h1:gRb40VRAbd4iJMYYD5IxZ6hfuopFcXBpc9bbQpZwo28=
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/mattn/go-runewidth v0.0.19 h1:v++JhqYnZuu5jSKrk9RbgF5v4CGUjqRfBm05byFGLdw=
github.com/mattn/go-runewidth v0.0.19/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=
github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw=
github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s=
github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=
Expand All @@ -38,8 +62,10 @@ go.uber.org/zap v1.27.1 h1:08RqriUEv8+ArZRYSTXy1LeBScaMpVSTBhCeaZYfMYc=
go.uber.org/zap v1.27.1/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk=
golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ=
golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/time v0.14.0 h1:MRx4UaLrDotUKUdCIqzPC48t1Y9hANFKIRpNx+Te8PI=
golang.org/x/time v0.14.0/go.mod h1:eL/Oa2bBBK0TkX57Fyni+NgnyQQN4LitPmob2Hjnqw4=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
29 changes: 17 additions & 12 deletions internals/config/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"

"github.com/codeshelldev/gotl/pkg/configutils"
log "github.com/codeshelldev/gotl/pkg/logger"
"github.com/codeshelldev/gotl/pkg/logger"
"github.com/codeshelldev/gotl/pkg/stringutils"
"github.com/codeshelldev/secured-signal-api/internals/config/structure"

Expand Down Expand Up @@ -63,13 +63,13 @@ func Load() {

InitTokens()

log.Info("Finished Loading Configuration")
logger.Info("Finished Loading Configuration")
}

func Log() {
log.Dev("Loaded Config:", mainConf.Layer.Get(""))
log.Dev("Loaded Token Configs:", tokenConf.Layer.Get(""))
log.Dev("Parsed Configs: ", ENV)
logger.Dev("Loaded Config:", mainConf.Layer.Get(""))
logger.Dev("Loaded Token Configs:", tokenConf.Layer.Get(""))
logger.Dev("Parsed Configs: ", ENV)
}

func Clear() {
Expand Down Expand Up @@ -102,7 +102,7 @@ func Normalize(id string, config *configutils.Config, path string, structure any
old, ok := data.(map[string]any)

if !ok {
log.Warn("Could not load `"+path+"`")
logger.Warn("Could not load `"+path+"`")
return
}

Expand All @@ -111,7 +111,10 @@ func Normalize(id string, config *configutils.Config, path string, structure any
tmpConf.Load(old, "")

// Apply transforms to the new config
tmpConf.ApplyTransformFuncs(id, structure, "", transformFuncs)
tmpConf.ApplyTransformFuncs(id, structure, "", configutils.TransformOptions{
Transforms: transformFuncs,
OnUse: onUseFuncs,
})

// Lowercase actual config
LowercaseKeys(config)
Expand All @@ -124,7 +127,7 @@ func Normalize(id string, config *configutils.Config, path string, structure any

func InitReload() {
reload := func(path string) {
log.Debug(path, " changed, reloading...")
logger.Debug(path, " changed, reloading...")
Load()
Log()
}
Expand All @@ -139,22 +142,24 @@ func InitConfig() {

mainConf.Layer.Unmarshal("", &config)

config.TYPE = structure.MAIN

ENV.CONFIGS["*"] = &config

DEFAULT = ENV.CONFIGS["*"]
}

func LoadDefaults() {
log.Debug("Loading defaults ", ENV.DEFAULTS_PATH)
logger.Debug("Loading defaults ", ENV.DEFAULTS_PATH)
_, err := defaultsConf.LoadFile(ENV.DEFAULTS_PATH, yaml.Parser())

if err != nil {
log.Warn("Could not Load Defaults", ENV.DEFAULTS_PATH)
logger.Warn("Could not Load Defaults", ENV.DEFAULTS_PATH)
}
}

func LoadConfig() {
log.Debug("Loading Config ", ENV.CONFIG_PATH)
logger.Debug("Loading Config ", ENV.CONFIG_PATH)
_, err := userConf.LoadFile(ENV.CONFIG_PATH, yaml.Parser())

if err != nil {
Expand All @@ -166,7 +171,7 @@ func LoadConfig() {
return
}

log.Error("Could not Load Config ", ENV.CONFIG_PATH, ": ", err.Error())
logger.Error("Could not Load Config ", ENV.CONFIG_PATH, ": ", err.Error())
}
}

Expand Down
31 changes: 31 additions & 0 deletions internals/config/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package config

import (
"strings"

"github.com/codeshelldev/gotl/pkg/configutils"
"github.com/codeshelldev/secured-signal-api/utils/deprecation"
)

var transformFuncs = map[string]func(string, any) (string, any) {
Expand All @@ -21,4 +24,32 @@ func lowercaseTransform(key string, value any) (string, any) {

func uppercaseTransform(key string, value any) (string, any) {
return strings.ToUpper(key), value
}

var onUseFuncs = map[string]func(source string, target configutils.TransformTarget) {
"deprecated": func(source string, target configutils.TransformTarget) {
deprecationHandler(source, target)
},
}

func deprecationHandler(source string, target configutils.TransformTarget) {
msgMap := configutils.ParseTag(target.Source.Tag.Get("deprecation"))

message := configutils.GetValueWithSource(source, target.Parent, msgMap)

atRoot := !strings.Contains(source, ".")
usingPrefix := ""
usingSuffix := ""

if atRoot {
usingPrefix = "⇧ "
usingSuffix = " (at root)"
}

deprecation.Warn(source, deprecation.DeprecationMessage{
Using: "{b,fg=bright_white}" + usingPrefix + "{/}{b,i,bg=red}`" + source + "`{/}" + usingSuffix,
Message: message,
Fix: "",
Note: "\n{i}Update your config before the next update,{/}\n{i}where it will be removed for good{/}",
})
}
Loading
Loading