Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.buildx-cache/
vendor
12 changes: 5 additions & 7 deletions poc/device/agent/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,24 +297,22 @@ func (db *Database) notify(

func (db *Database) SetDesiredState(deploymentId string, state AppDeploymentState) error {
db.mu.Lock()

defer db.TriggerDataPersist()
defer db.mu.Unlock()

record, exists := db.deployments[deploymentId]
if !exists {
// initialise a record object
record = &DeploymentRecord{
AppID: deploymentId,
DeploymentID: deploymentId,
ComponentViseStatus: make(map[string]sbi.ComponentStatus),
Phase: "pending",
LastUpdated: time.Now(),
}
db.deployments[deploymentId] = record
db.notify(deploymentId, record, DeploymentChangeTypeDesiredStateAdded)
}

// Only update if actually different
// if record.DesiredState == nil || record.DesiredState.AppDeploymentYAMLHash !=
// state.AppDeploymentYAMLHash {
record.DesiredState = &state
record.LastUpdated = time.Now()
// Store the digest and URL from the state
Expand All @@ -324,11 +322,11 @@ func (db *Database) SetDesiredState(deploymentId string, state AppDeploymentStat
if state.URL != nil {
record.URL = *state.URL
}
// record should be updated in db after assigning all fields in record
db.deployments[deploymentId] = record

db.notify(deploymentId, record, DeploymentChangeTypeDesiredStateAdded)

db.TriggerDataPersist()

return nil
}

Expand Down
Loading