Skip to content

Commit 1a6ac70

Browse files
committed
chore: cleanup code
1 parent 56e01ed commit 1a6ac70

File tree

1 file changed

+43
-37
lines changed

1 file changed

+43
-37
lines changed

swiftwave_manager/core/models.go

Lines changed: 43 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -26,86 +26,92 @@ type ImageRegistryCredential struct {
2626
type Domain struct {
2727
ID uint `json:"id" gorm:"primaryKey"`
2828
Name string `json:"name" gorm:"unique"`
29-
SSLStatus DomainSSLStatus `json:"ssl_status"`
30-
SSLPrivateKey string `json:"ssl_private_key"`
31-
SSLFullChain string `json:"ssl_full_chain"`
32-
SSLIssuedAt time.Time `json:"ssl_issued_at"`
33-
SSLIssuer string `json:"ssl_issuer"`
34-
IngressRules []IngressRule `json:"ingress_rules" gorm:"foreignKey:DomainID"`
35-
RedirectRules []RedirectRule `json:"redirect_rules" gorm:"foreignKey:DomainID"`
29+
SSLStatus DomainSSLStatus `json:"SSLStatus"`
30+
SSLPrivateKey string `json:"SSLPrivateKey"`
31+
SSLFullChain string `json:"SSLFullChain"`
32+
SSLIssuedAt time.Time `json:"SSLIssuedAt"`
33+
SSLIssuer string `json:"SSLIssuer"`
34+
IngressRules []IngressRule `json:"ingressRules" gorm:"foreignKey:DomainID"`
35+
RedirectRules []RedirectRule `json:"redirectRules" gorm:"foreignKey:DomainID"`
3636
}
3737

3838
// IngressRule : hold information about Ingress rule for service
3939
type IngressRule struct {
4040
ID uint `json:"id" gorm:"primaryKey"`
41-
DomainID uint `json:"domain_id"`
42-
ApplicationID string `json:"application_id"`
41+
Domain Domain `json:"-"`
42+
DomainID uint `json:"domainID"`
43+
Application Application `json:"-"`
44+
ApplicationID string `json:"applicationID"`
4345
Protocol ProtocolType `json:"protocol"`
4446
Port uint `json:"port"`
45-
TargetPort uint `json:"target_port"`
47+
TargetPort uint `json:"targetPort"`
4648
Status IngressRuleStatus `json:"status"`
47-
CreatedAt time.Time `json:"created_at"`
48-
UpdatedAt time.Time `json:"updated_at"`
49+
CreatedAt time.Time `json:"createdAt"`
50+
UpdatedAt time.Time `json:"updatedAt"`
4951
}
5052

5153
// RedirectRule : hold information about Redirect rules for domain
5254
type RedirectRule struct {
5355
ID uint `json:"id" gorm:"primaryKey"`
54-
DomainID uint `json:"domain_id"`
56+
Domain Domain `json:"-"`
57+
DomainID uint `json:"domainID"`
5558
Port uint `json:"port"`
56-
RedirectURL string `json:"redirect_url"`
59+
RedirectURL string `json:"redirectURL"`
5760
Status RedirectRuleStatus `json:"status"`
58-
CreatedAt time.Time `json:"created_at"`
59-
UpdatedAt time.Time `json:"updated_at"`
61+
CreatedAt time.Time `json:"createdAt"`
62+
UpdatedAt time.Time `json:"updatedAt"`
6063
}
6164

6265
// Application : hold information about application
6366
type Application struct {
6467
ID string `json:"id" gorm:"primaryKey"`
65-
ServiceName string `json:"service_name" gorm:"unique"`
66-
EnvironmentVariables string `json:"environment_variables"` // JSON string
67-
Volumes string `json:"volumes"` // JSON string
68+
ServiceName string `json:"serviceName" gorm:"unique"`
69+
EnvironmentVariables string `json:"environmentVariables"` // JSON string
70+
Volumes string `json:"volumes"` // JSON string
6871
// Deployment
6972
Deployments []Deployment `json:"deployments" gorm:"foreignKey:ApplicationID"`
7073
// Ingress Rules
71-
IngressRules []IngressRule `json:"ingress_rules" gorm:"foreignKey:ApplicationID"`
74+
IngressRules []IngressRule `json:"ingressRules" gorm:"foreignKey:ApplicationID"`
7275
}
7376

7477
// Deployment : hold information about deployment of application
7578
type Deployment struct {
7679
ID string `json:"id" gorm:"primaryKey"`
77-
ApplicationID uint `json:"application_id"`
78-
UpstreamType UpstreamType `json:"upstream_type"`
80+
Application Application `json:"-"`
81+
ApplicationID uint `json:"applicationID"`
82+
UpstreamType UpstreamType `json:"upstreamType"`
7983
// Fields for UpstreamType = Git
80-
GitCredentialID uint `json:"git_credential_id"`
81-
GitProvider GitProvider `json:"git_provider"`
82-
RepositoryOwner string `json:"repository_owner"`
83-
RepositoryName string `json:"repository_name"`
84-
RepositoryBranch string `json:"repository_branch"`
85-
CommitHash string `json:"commit_hash"`
84+
GitCredential GitCredential `json:"-"`
85+
GitCredentialID uint `json:"gitCredentialID"`
86+
GitProvider GitProvider `json:"gitProvider"`
87+
RepositoryOwner string `json:"repositoryOwner"`
88+
RepositoryName string `json:"repositoryName"`
89+
RepositoryBranch string `json:"repositoryBranch"`
90+
CommitHash string `json:"commitHash"`
8691
// Fields for UpstreamType = SourceCode
87-
SourceCodeCompressedFileName string `json:"source_code_compressed_file_name"`
92+
SourceCodeCompressedFileName string `json:"sourceCodeCompressedFileName"`
8893
// Fields for UpstreamType = Image
89-
DockerImage string `json:"docker_image"`
90-
ImageRegistryCredentialID uint `json:"image_registry_credential_id"`
94+
DockerImage string `json:"dockerImage"`
95+
ImageRegistryCredentialID uint `json:"ImageRegistryCredentialID"`
9196
// Common Fields
9297
BuildArgs string `json:"build_args"` // JSON string
9398
Dockerfile string `json:"dockerfile"`
9499
// No of replicas to be deployed
95-
DeploymentMode DeploymentMode `json:"deployment_mode"`
100+
DeploymentMode DeploymentMode `json:"deploymentMode"`
96101
Replicas uint `json:"replicas"`
97102
// Logs
98103
Logs []DeploymentLog `json:"logs" gorm:"foreignKey:DeploymentID"`
99104
// Deployment Status
100105
Status DeploymentStatus `json:"status"`
101106
// Created At
102-
CreatedAt time.Time `json:"created_at"`
107+
CreatedAt time.Time `json:"createdAt"`
103108
}
104109

105110
// DeploymentLog : hold logs of deployment
106111
type DeploymentLog struct {
107-
ID uint `json:"id" gorm:"primaryKey"`
108-
DeploymentID string `json:"deployment_id"`
109-
Content string `json:"content"`
110-
CreatedAt time.Time `json:"created_at"`
112+
ID uint `json:"id" gorm:"primaryKey"`
113+
Deployment Deployment `json:"-"`
114+
DeploymentID string `json:"deploymentID"`
115+
Content string `json:"content"`
116+
CreatedAt time.Time `json:"createdAt"`
111117
}

0 commit comments

Comments
 (0)