Skip to content

Commit 55ee356

Browse files
Seperated out all the structures and migrated them from models to config
1 parent 78cd820 commit 55ee356

File tree

8 files changed

+75
-72
lines changed

8 files changed

+75
-72
lines changed

config/app.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package config
2+
3+
/* app parameters */
4+
type App struct {
5+
Name string `yaml:"name"`
6+
Version string `yaml:"version"`
7+
Environment string `yaml:"environment"`
8+
}

config/backend_security.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package config
2+
3+
/* backend security configs */
4+
type BackendSecurity struct {
5+
JWTExpiry int `yaml:"jwt_expiry"`
6+
}

config/config.go

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
package config
22

3-
import (
4-
"github.com/PythonHacker24/linux-acl-management-backend/internal/models"
5-
)
6-
73
/* globally accessible yaml config */
8-
var BackendConfig models.Config
4+
var BackendConfig Config
95

106
/* globally accessible environment variables */
11-
var EnvConfig models.EnvConfig
7+
var EnvConfig EnvironmentConfig
8+
9+
/* complete yaml config for global usage */
10+
type Config struct {
11+
AppInfo App `yaml:"app"`
12+
Server Server `yaml:"server"`
13+
Database Database `yaml:"database"`
14+
Logging Logging `yaml:"logging"`
15+
FileSystemServers []FileSystemServers `yaml:"filesystem_servers"`
16+
BackendSecurity BackendSecurity `yaml:"backend_security"`
17+
}
18+
19+
/* complete environment variables configs for global usage */
20+
type EnvironmentConfig struct {
21+
JWTSecret string
22+
}

config/database.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package config
2+
3+
/* database parameters */
4+
type Database struct {
5+
TransactionLogRedis TransactionLogRedis `yaml:"transaction_log_redis"`
6+
}
7+
8+
/* transaction log redis parameters */
9+
type TransactionLogRedis struct {
10+
Address string `yaml:"address"`
11+
Password string `yaml:"password"`
12+
DB string `yaml:"db"`
13+
}

config/filesystem.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package config
2+
3+
/* file system server parameters */
4+
type FileSystemServers struct {
5+
Remote *Remote `yaml:"remote,omitempty"`
6+
Path string `yaml:"path"`
7+
Method string `yaml:"method"`
8+
}
9+
10+
/* remote parameters for file system server with laclm daemons installed */
11+
type Remote struct {
12+
Host string `yaml:"host"`
13+
Port int `yaml:"port"`
14+
}

config/logging.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package config
2+
3+
/* logging parameters */
4+
type Logging struct {
5+
File string `yaml:"file"`
6+
MaxSize int `yaml:"max_size"`
7+
MaxBackups int `yaml:"max_backups"`
8+
MaxAge int `yaml:"max_age"`
9+
Compress bool `yaml:"compress"`
10+
}

config/server.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package config
2+
3+
/* server deployment parameters */
4+
type Server struct {
5+
Host string `yaml:"host"`
6+
Port int `yaml:"port"`
7+
}

internal/models/models.go

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,5 @@
11
package models
22

3-
/* app parameters */
4-
type App struct {
5-
Name string `yaml:"name"`
6-
Version string `yaml:"version"`
7-
Environment string `yaml:"environment"`
8-
}
9-
10-
/* server deployment parameters */
11-
type Server struct {
12-
Host string `yaml:"host"`
13-
Port int `yaml:"port"`
14-
}
15-
16-
/* database parameters */
17-
type Database struct {
18-
TransactionLogRedis TransactionLogRedis `yaml:"transaction_log_redis"`
19-
}
20-
21-
/* transaction log redis parameters */
22-
type TransactionLogRedis struct {
23-
Address string `yaml:"address"`
24-
Password string `yaml:"password"`
25-
DB string `yaml:"db"`
26-
}
27-
28-
/* logging parameters */
29-
type Logging struct {
30-
File string `yaml:"file"`
31-
MaxSize int `yaml:"max_size"`
32-
MaxBackups int `yaml:"max_backups"`
33-
MaxAge int `yaml:"max_age"`
34-
Compress bool `yaml:"compress"`
35-
}
36-
37-
/* file system server parameters */
38-
type FileSystemServers struct {
39-
Remote *Remote `yaml:"remote,omitempty"`
40-
Path string `yaml:"path"`
41-
Method string `yaml:"method"`
42-
}
43-
44-
/* remote parameters for file system server with laclm daemons installed */
45-
type Remote struct {
46-
Host string `yaml:"host"`
47-
Port int `yaml:"port"`
48-
}
49-
50-
/* backend security configs */
51-
type BackendSecurity struct {
52-
JWTExpiry int `yaml:"jwt_expiry"`
53-
}
54-
55-
/* complete yaml config for global usage */
56-
type Config struct {
57-
AppInfo App `yaml:"app"`
58-
Server Server `yaml:"server"`
59-
Database Database `yaml:"database"`
60-
Logging Logging `yaml:"logging"`
61-
FileSystemServers []FileSystemServers `yaml:"filesystem_servers"`
62-
BackendSecurity BackendSecurity `yaml:"backend_security"`
63-
}
64-
65-
/* complete environment variables configs for global usage */
66-
type EnvConfig struct {
67-
JWTSecret string
68-
}
693

704
/* health response */
715
type HealthResponse struct {

0 commit comments

Comments
 (0)