/
configdecoder.go
66 lines (64 loc) · 2.41 KB
/
configdecoder.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Code generated by github.com/gokultp/go-envparser. DO NOT EDIT.
package configs
import (
commonconfigs "github.com/firstcontributions/backend/internal/configs"
"github.com/gokultp/go-envparser/pkg/envdecoder"
"os"
"strconv"
"fmt"
)
func (t *Config) DecodeEnv() error {
_recLog := commonconfigs.LogConfig{}
if err := envdecoder.Decode(&_recLog); err != nil {
return fmt.Errorf("type commonconfigs.LogConfignot implemts env Decoder interface, %w", envdecoder.ErrDecoderNotImplemented)
}
t.Log = &_recLog
_recRedisconfig := RedisConfig{}
if err := envdecoder.Decode(&_recRedisconfig); err != nil {
return fmt.Errorf("type RedisConfignot implemts env Decoder interface, %w", envdecoder.ErrDecoderNotImplemented)
}
t.RedisConfig = &_recRedisconfig
if _recPortStr := os.Getenv("GATEWAY_PORT"); _recPortStr != "" {
_recPort := _recPortStr
t.Port = &_recPort
}
if _recSessionttldaysStr := os.Getenv("SESSION_TTL_DAYS"); _recSessionttldaysStr != "" {
_recSessionttldays64, err := strconv.ParseInt(_recSessionttldaysStr, 10, 32)
if err != nil {
return err
}
_recSessionttldays := int(_recSessionttldays64)
t.SessionTTLDays = &_recSessionttldays
}
if _recCsrfttlsecondsStr := os.Getenv("CSRF_TTL_SECONDS"); _recCsrfttlsecondsStr != "" {
_recCsrfttlseconds64, err := strconv.ParseInt(_recCsrfttlsecondsStr, 10, 32)
if err != nil {
return err
}
_recCsrfttlseconds := int(_recCsrfttlseconds64)
t.CSRFTTLSeconds = &_recCsrfttlseconds
}
if _recHashkeyStr := os.Getenv("HASH_KEY"); _recHashkeyStr != "" {
_recHashkey := _recHashkeyStr
t.HashKey = &_recHashkey
}
if _recBlockkeyStr := os.Getenv("BLOCK_KEY"); _recBlockkeyStr != "" {
_recBlockkey := _recBlockkeyStr
t.BlockKey = &_recBlockkey
}
_recGithubconfig := commonconfigs.GithubConfig{}
if err := envdecoder.Decode(&_recGithubconfig); err != nil {
return fmt.Errorf("type commonconfigs.GithubConfignot implemts env Decoder interface, %w", envdecoder.ErrDecoderNotImplemented)
}
t.GithubConfig = &_recGithubconfig
if _recMongourlStr := os.Getenv("MONGO_URL"); _recMongourlStr != "" {
_recMongourl := _recMongourlStr
t.MongoURL = &_recMongourl
}
_recUsersserviceconfig := UsersServiceConfig{}
if err := envdecoder.Decode(&_recUsersserviceconfig); err != nil {
return fmt.Errorf("type UsersServiceConfignot implemts env Decoder interface, %w", envdecoder.ErrDecoderNotImplemented)
}
t.UsersServiceConfig = &_recUsersserviceconfig
return nil
}