Skip to content

Commit 0357420

Browse files
authored
feat: added support to provide docker command (#313)
1 parent 364d396 commit 0357420

File tree

6 files changed

+98
-1
lines changed

6 files changed

+98
-1
lines changed

swiftwave_service/core/application.operations.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ func (application *Application) Create(ctx context.Context, db gorm.DB, dockerMa
104104
DeploymentMode: application.DeploymentMode,
105105
Replicas: application.Replicas,
106106
WebhookToken: uuid.NewString(),
107+
Command: application.Command,
107108
Capabilities: application.Capabilities,
108109
Sysctls: application.Sysctls,
109110
}
@@ -237,6 +238,16 @@ func (application *Application) Update(ctx context.Context, db gorm.DB, dockerMa
237238
// reload application
238239
isReloadRequired = true
239240
}
241+
// check if Command is changed
242+
if applicationExistingFull.Command != application.Command {
243+
// update command
244+
err = db.Model(&applicationExistingFull).Update("command", application.Command).Error
245+
if err != nil {
246+
return nil, err
247+
}
248+
// reload application
249+
isReloadRequired = true
250+
}
240251
// if replicated deployment, check if Replicas is changed
241252
if application.DeploymentMode == DeploymentModeReplicated && applicationExistingFull.Replicas != application.Replicas {
242253
// update replicas

swiftwave_service/core/models.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ type Application struct {
145145
LatestDeployment Deployment `json:"-"`
146146
// Ingress Rules
147147
IngressRules []IngressRule `json:"ingressRules" gorm:"foreignKey:ApplicationID"`
148+
// Command
149+
Command string `json:"command"`
148150
// Capabilities
149151
Capabilities pq.StringArray `json:"capabilities" gorm:"type:text[]"`
150152
// Sysctls

swiftwave_service/graphql/generated.go

Lines changed: 79 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

swiftwave_service/graphql/graphql_object_mapper.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ func applicationInputToDatabaseObject(record *model.ApplicationInput) *core.Appl
222222
LatestDeployment: *applicationInputToDeploymentDatabaseObject(record),
223223
Deployments: make([]core.Deployment, 0),
224224
IngressRules: make([]core.IngressRule, 0),
225+
Command: record.Command,
225226
Capabilities: record.Capabilities,
226227
Sysctls: record.Sysctls,
227228
IsSleeping: false,
@@ -240,6 +241,7 @@ func applicationToGraphqlObject(record *core.Application) *model.Application {
240241
Capabilities: record.Capabilities,
241242
Sysctls: record.Sysctls,
242243
IsSleeping: record.IsSleeping,
244+
Command: record.Command,
243245
}
244246
}
245247

swiftwave_service/graphql/model/models_gen.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

swiftwave_service/graphql/schema/application.graphqls

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ type Application {
2626
isDeleted: Boolean!
2727
webhookToken: String!
2828
isSleeping: Boolean!
29+
command: String!
2930
}
3031

3132
input ApplicationInput {
@@ -39,6 +40,7 @@ input ApplicationInput {
3940
deploymentMode: DeploymentMode! # dont change with each deployment
4041
replicas: Uint # dont change with each deployment
4142
upstreamType: UpstreamType!
43+
command: String! # docker run command (can be blank)
4244
# required for upstreamType = "git"
4345
gitCredentialID: Uint
4446
gitProvider: GitProvider

0 commit comments

Comments
 (0)