Skip to content

Commit f95a2d1

Browse files
committed
refactor(healthcheck): change HealthCheck type from struct to string and update related references
1 parent 8fcf0c2 commit f95a2d1

4 files changed

Lines changed: 23 additions & 30 deletions

File tree

internal/system/syncer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ func (s *Syncer) Start(ctx context.Context) {
186186
targets := make([]WatchTarget, 0, len(svcs))
187187
for _, svc := range svcs {
188188
var healthPath string
189-
if svc.Blueprint != nil && svc.Blueprint.HealthCheck != nil {
190-
healthPath = svc.Blueprint.HealthCheck.Path
189+
if svc.Blueprint != nil && svc.Blueprint.HealthCheck != "" {
190+
healthPath = svc.Blueprint.HealthCheck
191191
}
192192

193193
targets = append(targets, WatchTarget{

pkg/core/deploy/deployer.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,24 @@ func NewDeployer(c *shared.Config, l *shared.Logger, s store.DeploymentStore, a
2828
}
2929

3030
type DeployRequest struct {
31-
Name string `json:"name" validate:"required"`
32-
Description string `json:"description,omitempty"`
33-
UserId string `json:"user_id" validate:"required"`
34-
Type string `json:"type" validate:"required,oneof= static web worker job"`
35-
Source string `json:"source" validate:"required,oneof=remote image"`
36-
Runtime string `json:"runtime" validate:"required,oneof=static golang php python nodejs ruby dotnet java"`
37-
Version string `json:"version,omitempty"`
38-
RunCmd string `json:"run_cmd,omitempty"`
39-
BuildCmd string `json:"build_cmd,omitempty"`
40-
Port int `json:"port,omitempty"`
41-
WorkingDir string `json:"working_dir,omitempty"`
42-
StaticDir string `json:"static_dir,omitempty"`
43-
Image string `json:"image,omitempty"`
44-
EnvVars map[string]any `json:"env_vars,omitempty"`
45-
Secrets map[string]any `json:"secrets,omitempty"`
46-
Remote store.RemoteObj `json:"remote,omitempty"`
47-
Domain string `json:"domain,omitempty"`
48-
HealthCheck *store.HealthCheck `json:"health_check,omitempty"`
31+
Name string `json:"name" validate:"required"`
32+
Description string `json:"description,omitempty"`
33+
UserId string `json:"user_id" validate:"required"`
34+
Type string `json:"type" validate:"required,oneof= static web worker job"`
35+
Source string `json:"source" validate:"required,oneof=remote image"`
36+
Runtime string `json:"runtime" validate:"required,oneof=static golang php python nodejs ruby dotnet java"`
37+
Version string `json:"version,omitempty"`
38+
RunCmd string `json:"run_cmd,omitempty"`
39+
BuildCmd string `json:"build_cmd,omitempty"`
40+
Port int `json:"port,omitempty"`
41+
WorkingDir string `json:"working_dir,omitempty"`
42+
StaticDir string `json:"static_dir,omitempty"`
43+
Image string `json:"image,omitempty"`
44+
EnvVars map[string]any `json:"env_vars,omitempty"`
45+
Secrets map[string]any `json:"secrets,omitempty"`
46+
Remote store.RemoteObj `json:"remote,omitempty"`
47+
Domain string `json:"domain,omitempty"`
48+
HealthCheck string `json:"health_check,omitempty"`
4949
}
5050

5151
func (dr *DeployRequest) GetRuntimeObj() store.RuntimeObj {

pkg/core/system/converters_v1_1.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ func FromStoreService(s *store.Service) ServiceV1_1 {
135135
if s.DeploymentId != "" {
136136
svc.DeploymentID = &s.DeploymentId
137137
}
138-
if s.Blueprint != nil && s.Blueprint.HealthCheck != nil && s.Blueprint.HealthCheck.Path != "" {
139-
svc.HealthCheck = s.Blueprint.HealthCheck.Path
138+
if s.Blueprint != nil && s.Blueprint.HealthCheck != "" {
139+
svc.HealthCheck = s.Blueprint.HealthCheck
140140
}
141141

142142
if len(s.EnvVars) > 0 {

pkg/store/deployments.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,6 @@ type RemoteObj struct {
3636
Token string `json:"token,omitempty" db:"-"`
3737
}
3838

39-
type HealthCheck struct {
40-
Path string `json:"path"`
41-
Interval int `json:"interval,omitempty"`
42-
Timeout int `json:"timeout,omitempty"`
43-
Retries int `json:"retries,omitempty"`
44-
}
45-
4639
type Blueprint struct {
4740
Name string `json:"name" db:"name"`
4841
Desc string `json:"description" db:"description"`
@@ -60,7 +53,7 @@ type Blueprint struct {
6053
Secrets map[string]string `json:"secrets,omitempty" db:"secrets"`
6154
Status string `json:"status" db:"status"`
6255
ProjectID *string `json:"project_id,omitempty" db:"project_id"`
63-
HealthCheck *HealthCheck `json:"health_check,omitempty" db:"health_check"`
56+
HealthCheck string `json:"health_check,omitempty" db:"health_check"`
6457
}
6558

6659
type Deployment struct {

0 commit comments

Comments
 (0)