Skip to content

Commit

Permalink
feat: updated dependency config setup
Browse files Browse the repository at this point in the history
  • Loading branch information
tikazyq committed Dec 16, 2024
1 parent c5c08df commit 79c1d5d
Show file tree
Hide file tree
Showing 5 changed files with 187 additions and 62 deletions.
19 changes: 18 additions & 1 deletion core/grpc/server/dependency_service_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,26 @@ func (svr DependencyServiceServer) SyncConfigSetup(_ context.Context, request *g
}
}

// drivers
var drivers []models.DependencyDriver
if request.Drivers != nil && len(request.Drivers) > 0 {
for _, d := range request.Drivers {
drivers = append(drivers, models.DependencyDriver{
Name: d.Name,
Version: d.Version,
})
}
}

if cs == nil {
// Create new config setup
cs = &models.DependencyConfigSetup{
NodeId: n.Id,
DependencyConfigId: cfg.Id,
Status: request.Status,
Error: request.Error,
Version: request.Version,
Drivers: drivers,
}
_, err = service.NewModelService[models.DependencyConfigSetup]().InsertOne(*cs)
if err != nil {
Expand All @@ -220,8 +233,12 @@ func (svr DependencyServiceServer) SyncConfigSetup(_ context.Context, request *g
}
} else {
// Update existing config setup
cs.Status = request.Status
if cs.Status == constants.DependencyStatusUninstalled || request.Status == constants.DependencyStatusInstalled {
cs.Status = request.Status
}
cs.Error = request.Error
cs.Version = request.Version
cs.Drivers = drivers
err = service.NewModelService[models.DependencyConfigSetup]().ReplaceById(cs.Id, *cs)
if err != nil {
log.Errorf("[DependencyService] update dependency config setup error: %v", err)
Expand Down
1 change: 1 addition & 0 deletions core/models/models/dependency_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ type DependencyConfig struct {
ExecCmd string `json:"exec_cmd" bson:"exec_cmd"`
PkgCmd string `json:"pkg_cmd" bson:"pkg_cmd"`
Proxy string `json:"proxy" bson:"proxy"`
Setup bool `json:"setup" bson:"-"`
}
6 changes: 6 additions & 0 deletions core/models/models/dependency_config_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ type DependencyConfigSetup struct {
DependencyConfigId primitive.ObjectID `json:"dependency_config_id" bson:"dependency_config_id"`
NodeId primitive.ObjectID `json:"node_id" bson:"node_id"`
Version string `json:"version" bson:"version"`
Drivers []DependencyDriver `json:"versions,omitempty" bson:"versions,omitempty"`
Status string `json:"status" bson:"status"`
Error string `json:"error,omitempty" bson:"error,omitempty"`
Node *Node `json:"node,omitempty" bson:"-"`
}
type DependencyDriver struct {
Name string `json:"name" bson:"name"`
Version string `json:"version" bson:"version"`
}
212 changes: 153 additions & 59 deletions grpc/dependency_service.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 79c1d5d

Please sign in to comment.