Skip to content

Commit d6e7d7a

Browse files
authored
Added additional environment variables (#67)
Upgraded dependencies
1 parent 1661128 commit d6e7d7a

File tree

5 files changed

+100
-40
lines changed

5 files changed

+100
-40
lines changed

README.md

+11-3
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,26 @@ The exception is `generateinvite`, which will generate a new, random invitation
9696
| Flag | Type | Explanation |
9797
|:-:|:-:|--:|
9898
| port | integer | Which port Pønskelisten starts on. |
99+
| externalurl | string | The URL others would use to access Pønskelisten. |
99100
| timezone | string | The timezone Pønskelisten uses. Given in the TZ database name format. List can be found [here](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). |
101+
| environment | string | The environment Pønskelisten is running in. It will behave differently in 'test'. |
102+
| testemail | string | The email all emails are sent to in test mode. |
103+
| name | string | The name of the application. Replaces 'Pønskelisten'. |
100104
| generateinvite | string (true/false) | If Pønskelisten should generate an invitation code on startup. |
101-
| dbip | string | The connection address Pønskelisten uses to reach the database. |
102105
| dbport | integer | The port Pønskelisten can reach the database at. |
103-
| dbname | string | The name of the table within the database. |
106+
| dbtype | string | The type of database running. 'mysql'. |
104107
| dbusername | string | The username used to authenticate with the database. |
105108
| dbpassword | string | The password used to authenticate with the database. |
109+
| dbname | string | The name of the table within the database. |
110+
| dbip | string | The connection address Pønskelisten uses to reach the database. |
111+
| dbssl | string | If the database connection uses SSL. |
112+
| dblocation | string | The database is a local file, what is the system file path. |
106113
| disablesmtp | string (true/false) | Disables SMTP, meaning user verification is disabled. SMTP is enabled by default. |
107114
| smtphost | string | The SMTP server host used. |
108115
| smtpport | integer | The SMTP server host port used. |
109116
| smtpusername | string | The username used to authenticate towards the SMTP server used. |
110-
| smtppassword | string | The username used to authenticate towards the SMTP server used. |
117+
| smtppassword | string | The password used to authenticate towards the SMTP server used. |
118+
| smtpfrom | string | The sender address when sending e-mail from Pønskelisten. |
111119

112120
<br>
113121
<br>

entrypoint.sh

+40-8
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,38 @@
33
# Initialize the command with the binary
44
CMD="/app/poenskelisten"
55

6-
# Add the --port flag if the PORT environment variable is set
6+
# Add the Pønskelisten environment variables if set
77
if [ -n "$port" ]; then
88
CMD="$CMD --port $port"
99
fi
1010

11-
# Add the --timezone flag if the TIMEZONE environment variable is set
11+
if [ -n "$externalurl" ]; then
12+
CMD="$CMD --externalurl $externalurl"
13+
fi
14+
1215
if [ -n "$timezone" ]; then
1316
CMD="$CMD --timezone $timezone"
1417
fi
1518

16-
# Add database-related flags if the corresponding environment variables are set
17-
if [ -n "$dbip" ]; then
18-
CMD="$CMD --dbip $dbip"
19+
if [ -n "$environment" ]; then
20+
CMD="$CMD --environment $environment"
21+
fi
22+
23+
if [ -n "$testemail" ]; then
24+
CMD="$CMD --testemail $testemail"
1925
fi
2026

27+
if [ -n "$name" ]; then
28+
CMD="$CMD --name $name"
29+
fi
30+
31+
# Add database-related flags if the corresponding environment variables are set
2132
if [ -n "$dbport" ]; then
2233
CMD="$CMD --dbport $dbport"
2334
fi
2435

25-
if [ -n "$dbname" ]; then
26-
CMD="$CMD --dbname $dbname"
36+
if [ -n "$dbtype" ]; then
37+
CMD="$CMD --dbtype $dbtype"
2738
fi
2839

2940
if [ -n "$dbusername" ]; then
@@ -34,11 +45,28 @@ if [ -n "$dbpassword" ]; then
3445
CMD="$CMD --dbpassword $dbpassword"
3546
fi
3647

37-
# Add flags for invite generation and SMTP settings if those environment variables are set
48+
if [ -n "$dbname" ]; then
49+
CMD="$CMD --dbname $dbname"
50+
fi
51+
52+
if [ -n "$dbip" ]; then
53+
CMD="$CMD --dbip $dbip"
54+
fi
55+
56+
if [ -n "$dbssl" ]; then
57+
CMD="$CMD --dbssl $dbssl"
58+
fi
59+
60+
if [ -n "$dblocation" ]; then
61+
CMD="$CMD --dblocation $dblocation"
62+
fi
63+
64+
# Add flags for invite generation if those environment variables are set
3865
if [ -n "$generateinvite" ]; then
3966
CMD="$CMD --generateinvite $generateinvite"
4067
fi
4168

69+
# Add flags for SMTP settings if those environment variables are set
4270
if [ -n "$disablesmtp" ]; then
4371
CMD="$CMD --disablesmtp $disablesmtp"
4472
fi
@@ -59,5 +87,9 @@ if [ -n "$smtppassword" ]; then
5987
CMD="$CMD --smtppassword $smtppassword"
6088
fi
6189

90+
if [ -n "$smtpfrom" ]; then
91+
CMD="$CMD --smtpfrom $smtpfrom"
92+
fi
93+
6294
# Execute the final command
6395
exec $CMD

go.mod

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
module aunefyren/poenskelisten
22

3-
go 1.21.0
3+
go 1.23.0
44

5-
toolchain go1.22.0
5+
toolchain go1.24.0
66

77
require (
88
github.com/gin-contrib/cors v1.7.3
@@ -12,7 +12,7 @@ require (
1212
github.com/google/uuid v1.6.0
1313
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
1414
github.com/thanhpk/randstr v1.0.6
15-
golang.org/x/crypto v0.33.0
15+
golang.org/x/crypto v0.36.0
1616
gorm.io/driver/mysql v1.5.7
1717
gorm.io/driver/postgres v1.5.11
1818
gorm.io/driver/sqlite v1.5.7
@@ -21,8 +21,8 @@ require (
2121

2222
require (
2323
filippo.io/edwards25519 v1.1.0 // indirect
24-
github.com/bytedance/sonic v1.12.9 // indirect
25-
github.com/bytedance/sonic/loader v0.2.3 // indirect
24+
github.com/bytedance/sonic v1.13.1 // indirect
25+
github.com/bytedance/sonic/loader v0.2.4 // indirect
2626
github.com/cloudwego/base64x v0.1.5 // indirect
2727
github.com/gabriel-vasile/mimetype v1.4.8 // indirect
2828
github.com/gin-contrib/sse v1.0.0 // indirect
@@ -38,7 +38,7 @@ require (
3838
github.com/jinzhu/inflection v1.0.0 // indirect
3939
github.com/jinzhu/now v1.1.5 // indirect
4040
github.com/json-iterator/go v1.1.12 // indirect
41-
github.com/klauspost/cpuid/v2 v2.2.9 // indirect
41+
github.com/klauspost/cpuid/v2 v2.2.10 // indirect
4242
github.com/kr/text v0.2.0 // indirect
4343
github.com/leodido/go-urn v1.4.0 // indirect
4444
github.com/mattn/go-isatty v0.0.20 // indirect
@@ -48,11 +48,11 @@ require (
4848
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
4949
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
5050
github.com/ugorji/go/codec v1.2.12 // indirect
51-
golang.org/x/arch v0.14.0 // indirect
52-
golang.org/x/net v0.35.0 // indirect
53-
golang.org/x/sync v0.11.0 // indirect
54-
golang.org/x/sys v0.30.0 // indirect
55-
golang.org/x/text v0.22.0 // indirect
51+
golang.org/x/arch v0.15.0 // indirect
52+
golang.org/x/net v0.37.0 // indirect
53+
golang.org/x/sync v0.12.0 // indirect
54+
golang.org/x/sys v0.31.0 // indirect
55+
golang.org/x/text v0.23.0 // indirect
5656
google.golang.org/protobuf v1.36.5 // indirect
5757
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
5858
gopkg.in/mail.v2 v2.3.1 // indirect

go.sum

+18-18
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
22
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
3-
github.com/bytedance/sonic v1.12.9 h1:Od1BvK55NnewtGaJsTDeAOSnLVO2BTSLOe0+ooKokmQ=
4-
github.com/bytedance/sonic v1.12.9/go.mod h1:uVvFidNmlt9+wa31S1urfwwthTWteBgG0hWuoKAXTx8=
3+
github.com/bytedance/sonic v1.13.1 h1:Jyd5CIvdFnkOWuKXr+wm4Nyk2h0yAFsr8ucJgEasO3g=
4+
github.com/bytedance/sonic v1.13.1/go.mod h1:o68xyaF9u2gvVBuGHPlUVCy+ZfmNNO5ETf1+KgkJhz4=
55
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
6-
github.com/bytedance/sonic/loader v0.2.3 h1:yctD0Q3v2NOGfSWPLPvG2ggA2kV6TS6s4wioyEqssH0=
7-
github.com/bytedance/sonic/loader v0.2.3/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI=
6+
github.com/bytedance/sonic/loader v0.2.4 h1:ZWCw4stuXUsn1/+zQDqeE7JKP+QO47tz7QCNan80NzY=
7+
github.com/bytedance/sonic/loader v0.2.4/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI=
88
github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4=
99
github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
1010
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
@@ -57,8 +57,8 @@ github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/
5757
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
5858
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
5959
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
60-
github.com/klauspost/cpuid/v2 v2.2.9 h1:66ze0taIn2H33fBvCkXuv9BmCwDfafmiIVpKV9kKGuY=
61-
github.com/klauspost/cpuid/v2 v2.2.9/go.mod h1:rqkxqrZ1EhYM9G+hXH7YdowN5R5RGN6NK4QwQ3WMXF8=
60+
github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE=
61+
github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
6262
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
6363
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
6464
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
@@ -101,19 +101,19 @@ github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS
101101
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
102102
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
103103
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
104-
golang.org/x/arch v0.14.0 h1:z9JUEZWr8x4rR0OU6c4/4t6E6jOZ8/QBS2bBYBm4tx4=
105-
golang.org/x/arch v0.14.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
106-
golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus=
107-
golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M=
108-
golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8=
109-
golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk=
110-
golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
111-
golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
104+
golang.org/x/arch v0.15.0 h1:QtOrQd0bTUnhNVNndMpLHNWrDmYzZ2KDqSrEymqInZw=
105+
golang.org/x/arch v0.15.0/go.mod h1:JmwW7aLIoRUKgaTzhkiEFxvcEiQGyOg9BMonBJUS7EE=
106+
golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34=
107+
golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc=
108+
golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c=
109+
golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
110+
golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw=
111+
golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
112112
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
113-
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
114-
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
115-
golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
116-
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
113+
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
114+
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
115+
golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
116+
golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
117117
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
118118
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
119119
google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM=

main.go

+20
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,9 @@ func parseFlags(configFile *models.ConfigStruct) (*models.ConfigStruct, bool, er
329329
var port = flag.Int("port", configFile.PoenskelistenPort, "The port Pønskelisten is listening on.")
330330
var externalURL = flag.String("externalurl", configFile.PoenskelistenExternalURL, "The URL others would use to access Pønskelisten.")
331331
var timezone = flag.String("timezone", configFile.Timezone, "The timezone Pønskelisten is running in.")
332+
var environment = flag.String("environment", configFile.PoenskelistenEnvironment, "The environment Pønskelisten is running in. It will behave differently in 'test'.")
333+
var testemail = flag.String("testemail", configFile.PoenskelistenTestEmail, "The email all emails are sent to in test mode.")
334+
var name = flag.String("name", configFile.PoenskelistenName, "The name of the application. Replaces 'Pønskelisten'.")
332335

333336
// DB values
334337
var dbPort = flag.Int("dbport", configFile.DBPort, "The port the database is listening on.")
@@ -347,6 +350,8 @@ func parseFlags(configFile *models.ConfigStruct) (*models.ConfigStruct, bool, er
347350
var smtpUsername = flag.String("smtpusername", configFile.SMTPUsername, "The username used to verify against the SMTP server.")
348351
var smtpPassword = flag.String("smtppassword", configFile.SMTPPassword, "The password used to verify against the SMTP server.")
349352
var smtpFrom = flag.String("smtpfrom", configFile.SMTPFrom, "The sender address when sending e-mail from Pønskelisten.")
353+
354+
// Generate invite
350355
var generateInvite = flag.String("generateinvite", "false", "If an invite code should be automatically generate on startup.")
351356

352357
// Parse flags
@@ -367,6 +372,21 @@ func parseFlags(configFile *models.ConfigStruct) (*models.ConfigStruct, bool, er
367372
configFile.Timezone = *timezone
368373
}
369374

375+
// Respect the flag if provided
376+
if environment != nil {
377+
configFile.PoenskelistenEnvironment = *environment
378+
}
379+
380+
// Respect the flag if provided
381+
if testemail != nil {
382+
configFile.PoenskelistenTestEmail = *testemail
383+
}
384+
385+
// Respect the flag if provided
386+
if name != nil {
387+
configFile.PoenskelistenName = *name
388+
}
389+
370390
// Respect the flag if provided
371391
if dbPort != nil {
372392
configFile.DBPort = *dbPort

0 commit comments

Comments
 (0)