feat(application): add Environment field and inject into Slurm job submission
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"gcy_hpc_server/internal/model"
|
||||
|
||||
@@ -52,6 +53,15 @@ func (s *ApplicationStore) Create(ctx context.Context, req *model.CreateApplicat
|
||||
params = json.RawMessage(`[]`)
|
||||
}
|
||||
|
||||
var envJSON json.RawMessage
|
||||
if len(req.Environment) > 0 {
|
||||
b, err := json.Marshal(req.Environment)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("marshal environment: %w", err)
|
||||
}
|
||||
envJSON = b
|
||||
}
|
||||
|
||||
app := &model.Application{
|
||||
Name: req.Name,
|
||||
Description: req.Description,
|
||||
@@ -59,6 +69,7 @@ func (s *ApplicationStore) Create(ctx context.Context, req *model.CreateApplicat
|
||||
Category: req.Category,
|
||||
ScriptTemplate: req.ScriptTemplate,
|
||||
Parameters: params,
|
||||
Environment: envJSON,
|
||||
Scope: req.Scope,
|
||||
}
|
||||
if err := s.db.WithContext(ctx).Create(app).Error; err != nil {
|
||||
@@ -87,6 +98,9 @@ func (s *ApplicationStore) Update(ctx context.Context, id int64, req *model.Upda
|
||||
if req.Parameters != nil {
|
||||
updates["parameters"] = *req.Parameters
|
||||
}
|
||||
if req.Environment != nil {
|
||||
updates["environment"] = *req.Environment
|
||||
}
|
||||
if req.Scope != nil {
|
||||
updates["scope"] = *req.Scope
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user