Skip to content

Commit 126a3ca

Browse files
authored
Merge branch 'main' into bk1031/db-table-prefix
2 parents 30e3340 + 5cd1661 commit 126a3ca

20 files changed

+595
-110
lines changed

.gitignore

+1-5
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,7 @@ go.work
4242
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
4343

4444
# User-specific stuff
45-
.idea/**/workspace.xml
46-
.idea/**/tasks.xml
47-
.idea/**/usage.statistics.xml
48-
.idea/**/dictionaries
49-
.idea/**/shelf
45+
.idea/
5046

5147
# AWS User-specific
5248
.idea/**/aws.xml

.idea/.gitignore

-8
This file was deleted.

.idea/discord.xml

-7
This file was deleted.

.idea/misc.xml

-6
This file was deleted.

.idea/modules.xml

-8
This file was deleted.

.idea/vcs.xml

-6
This file was deleted.

Dockerfile

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
FROM golang:1.22-alpine3.19 as builder
2-
3-
ENV GOOS=linux
1+
FROM --platform=$BUILDPLATFORM golang:1.22-alpine3.19 as builder
42

53
RUN apk --no-cache add ca-certificates
64
RUN apk add --no-cache tzdata
@@ -9,12 +7,12 @@ WORKDIR /app
97

108
COPY go.mod ./
119
COPY go.sum ./
12-
1310
RUN go mod download
1411

1512
COPY . ./
16-
17-
RUN go build -o /rincon
13+
ARG TARGETOS
14+
ARG TARGETARCH
15+
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o /rincon
1816

1917
##
2018
## Deploy

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Bharat Kathi
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

api/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func AuthMiddleware() gin.HandlerFunc {
5050
payload, _ := base64.StdEncoding.DecodeString(auth[1])
5151
pair := strings.SplitN(string(payload), ":", 2)
5252
if len(pair) != 2 || pair[0] != config.AuthUser || pair[1] != config.AuthPassword {
53-
c.AbortWithStatusJSON(401, gin.H{"message": "Request not authorized"})
53+
c.AbortWithStatusJSON(401, gin.H{"message": "Invalid credentials"})
5454
return
5555
}
5656
}

config/config.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"os"
55
)
66

7-
var Version = "1.0.0"
7+
var Version = "1.0.3"
88
var Env = os.Getenv("ENV")
99
var Port = os.Getenv("PORT")
1010

database/db.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,21 @@ func InitializeDB() {
2222
return
2323
}
2424
if err != nil {
25-
if dbRetries < 10 {
25+
if dbRetries < 5 {
2626
dbRetries++
2727
utils.SugarLogger.Errorln("Failed to connect database, retrying in 5s... ")
2828
time.Sleep(time.Second * 5)
2929
InitializeDB()
3030
} else {
31-
utils.SugarLogger.Fatalln("Failed to connect database after 10 attempts, terminating program...")
31+
utils.SugarLogger.Errorln("Failed to connect database after 5 attempts, defaulting to local storage")
32+
config.StorageMode = "local"
33+
return
3234
}
3335
} else {
3436
utils.SugarLogger.Infoln("Connected to database")
35-
err := db.AutoMigrate(&model.Service{}, &model.ServiceDependency{}, &model.Route{})
37+
err = db.AutoMigrate(&model.Service{}, &model.ServiceDependency{}, &model.Route{})
3638
if err != nil {
37-
utils.SugarLogger.Fatalln("AutoMigration failed", err)
39+
utils.SugarLogger.Errorln("AutoMigration failed", err)
3840
}
3941
utils.SugarLogger.Infoln("AutoMigration complete")
4042
DB = db

docker-compose.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: "3.9"
22

33
services:
44
postgres:
5-
image: postgres:14.1-alpine
5+
image: postgres:16-alpine
66
restart: unless-stopped
77
environment:
88
POSTGRES_DB: rincon

go.mod

+44-2
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,44 @@ require (
88
)
99

1010
require (
11+
dario.cat/mergo v1.0.0 // indirect
1112
filippo.io/edwards25519 v1.1.0 // indirect
13+
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
14+
github.com/Microsoft/go-winio v0.6.1 // indirect
15+
github.com/Microsoft/hcsshim v0.11.4 // indirect
1216
github.com/bytedance/sonic v1.11.6 // indirect
1317
github.com/bytedance/sonic/loader v0.1.1 // indirect
18+
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
1419
github.com/cloudwego/base64x v0.1.4 // indirect
1520
github.com/cloudwego/iasm v0.2.0 // indirect
21+
github.com/containerd/containerd v1.7.15 // indirect
22+
github.com/containerd/log v0.1.0 // indirect
1623
github.com/coreos/go-semver v0.3.0 // indirect
17-
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
24+
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
25+
github.com/cpuguy83/dockercfg v0.3.1 // indirect
26+
github.com/distribution/reference v0.5.0 // indirect
27+
github.com/docker/docker v25.0.5+incompatible // indirect
28+
github.com/docker/go-connections v0.5.0 // indirect
29+
github.com/docker/go-units v0.5.0 // indirect
30+
github.com/felixge/httpsnoop v1.0.4 // indirect
1831
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
1932
github.com/gin-contrib/cors v1.7.2 // indirect
2033
github.com/gin-contrib/sse v0.1.0 // indirect
2134
github.com/gin-gonic/gin v1.10.0 // indirect
2235
github.com/go-co-op/gocron v1.37.0 // indirect
2336
github.com/go-co-op/gocron-etcd-elector v0.0.0-20240205030445-720b1270dfa2 // indirect
2437
github.com/go-co-op/gocron/v2 v2.5.0 // indirect
38+
github.com/go-logr/logr v1.4.1 // indirect
39+
github.com/go-logr/stdr v1.2.2 // indirect
40+
github.com/go-ole/go-ole v1.2.6 // indirect
2541
github.com/go-playground/locales v0.14.1 // indirect
2642
github.com/go-playground/universal-translator v0.18.1 // indirect
2743
github.com/go-playground/validator/v10 v10.20.0 // indirect
2844
github.com/go-resty/resty/v2 v2.13.1 // indirect
2945
github.com/go-sql-driver/mysql v1.8.1 // indirect
3046
github.com/goccy/go-json v0.10.2 // indirect
3147
github.com/gogo/protobuf v1.3.2 // indirect
32-
github.com/golang/protobuf v1.5.3 // indirect
48+
github.com/golang/protobuf v1.5.4 // indirect
3349
github.com/google/uuid v1.6.0 // indirect
3450
github.com/jackc/pgpassfile v1.0.0 // indirect
3551
github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9 // indirect
@@ -39,29 +55,55 @@ require (
3955
github.com/jinzhu/now v1.1.5 // indirect
4056
github.com/jonboulle/clockwork v0.4.0 // indirect
4157
github.com/json-iterator/go v1.1.12 // indirect
58+
github.com/klauspost/compress v1.16.0 // indirect
4259
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
4360
github.com/leodido/go-urn v1.4.0 // indirect
61+
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
62+
github.com/magiconair/properties v1.8.7 // indirect
4463
github.com/mattn/go-colorable v0.1.13 // indirect
4564
github.com/mattn/go-isatty v0.0.20 // indirect
65+
github.com/moby/patternmatcher v0.6.0 // indirect
66+
github.com/moby/sys/sequential v0.5.0 // indirect
67+
github.com/moby/sys/user v0.1.0 // indirect
68+
github.com/moby/term v0.5.0 // indirect
4669
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
4770
github.com/modern-go/reflect2 v1.0.2 // indirect
71+
github.com/morikuni/aec v1.0.0 // indirect
72+
github.com/opencontainers/go-digest v1.0.0 // indirect
73+
github.com/opencontainers/image-spec v1.1.0 // indirect
4874
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
4975
github.com/pkg/errors v0.9.1 // indirect
76+
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
5077
github.com/robfig/cron/v3 v3.0.1 // indirect
78+
github.com/shirou/gopsutil/v3 v3.23.12 // indirect
79+
github.com/shoenig/go-m1cpu v0.1.6 // indirect
80+
github.com/sirupsen/logrus v1.9.3 // indirect
81+
github.com/testcontainers/testcontainers-go v0.31.0 // indirect
82+
github.com/testcontainers/testcontainers-go/modules/mysql v0.31.0 // indirect
83+
github.com/testcontainers/testcontainers-go/modules/postgres v0.31.0 // indirect
84+
github.com/tklauser/go-sysconf v0.3.12 // indirect
85+
github.com/tklauser/numcpus v0.6.1 // indirect
5186
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
5287
github.com/ugorji/go/codec v1.2.12 // indirect
88+
github.com/yusufpapurcu/wmi v1.2.3 // indirect
5389
go.etcd.io/etcd/api/v3 v3.5.12 // indirect
5490
go.etcd.io/etcd/client/pkg/v3 v3.5.12 // indirect
5591
go.etcd.io/etcd/client/v3 v3.5.12 // indirect
92+
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
93+
go.opentelemetry.io/otel v1.24.0 // indirect
94+
go.opentelemetry.io/otel/metric v1.24.0 // indirect
95+
go.opentelemetry.io/otel/trace v1.24.0 // indirect
5696
go.uber.org/atomic v1.9.0 // indirect
5797
go.uber.org/multierr v1.11.0 // indirect
5898
golang.org/x/arch v0.8.0 // indirect
5999
golang.org/x/crypto v0.23.0 // indirect
60100
golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f // indirect
101+
golang.org/x/mod v0.17.0 // indirect
61102
golang.org/x/net v0.25.0 // indirect
62103
golang.org/x/sync v0.7.0 // indirect
63104
golang.org/x/sys v0.20.0 // indirect
64105
golang.org/x/text v0.15.0 // indirect
106+
golang.org/x/tools v0.20.0 // indirect
65107
google.golang.org/genproto v0.0.0-20230822172742-b8732ec3820d // indirect
66108
google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d // indirect
67109
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect

0 commit comments

Comments
 (0)