Passed
Pull Request — main (#166)
by Yume
01:53
created

config.GetConfigPath   A

Complexity

Conditions 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
dl 0
loc 6
rs 10
c 0
b 0
f 0
nop 0
1
package config
2
3
import (
4
	"os"
5
	"time"
6
)
7
8
const (
9
	GCThresholdPercent = 0.7 // GCThresholdPercent is the threshold for garbage collection
10
11
	GCLimit = 1024 * 1024 * 1024 // GCLimit is the limit for garbage collection
12
13
	MB = 1024 * 1024 // MB is the number of bytes in a megabyte
14
15
	SentryFlushTimeout = 2 * time.Second // SentryFlushTimeout is the timeout for flushing sentry
16
)
17
18
// PasswordConfigStruct is the struct for the password config.
19
type PasswordConfigStruct struct {
20
	Iterations uint32 // Iterations to use for Argon2ID
21
	Memory     uint32 // Memory to use for Argon2ID
22
	Threads    uint8  // Threads to use for Argon2ID
23
	KeyLen     uint32 // KeyLen to use for Argon2ID
24
	SaltLen    uint32 // SaltLen to use for Argon2ID
25
}
26
27
func GetConfigPath() string {
28
	if IsDevelopment() {
29
		return "./cmd/v2/config/config-local"
30
	}
31
32
	return "./cmd/v2/config/config-prod"
33
}
34
35
func IsProduction() bool {
36
	return os.Getenv("APP_ENV") != "dev"
37
}
38
39
func IsDevelopment() bool {
40
	return os.Getenv("APP_ENV") == "dev"
41
}
42
43
func GetCallbackURL() string {
44
	return os.Getenv("CALLBACK_URL")
45
}
46