diff --git a/api/datastore/migrator/migrate_dbversion100.go b/api/datastore/migrator/migrate_dbversion100.go index 458c10c95..59b15b08d 100644 --- a/api/datastore/migrator/migrate_dbversion100.go +++ b/api/datastore/migrator/migrate_dbversion100.go @@ -94,6 +94,10 @@ func (m *Migrator) updateEdgeStackStatusForDB100() error { continue } + if environmentStatus.Details == nil { + continue + } + statusArray := []portainer.EdgeStackDeploymentStatus{} if environmentStatus.Details.Pending { statusArray = append(statusArray, portainer.EdgeStackDeploymentStatus{ diff --git a/api/datastore/migrator/migrate_dbversion80.go b/api/datastore/migrator/migrate_dbversion80.go index 77671745e..a738e5177 100644 --- a/api/datastore/migrator/migrate_dbversion80.go +++ b/api/datastore/migrator/migrate_dbversion80.go @@ -75,6 +75,10 @@ func (m *Migrator) updateEdgeStackStatusForDB80() error { for _, edgeStack := range edgeStacks { for endpointId, status := range edgeStack.Status { + if status.Details == nil { + status.Details = &portainer.EdgeStackStatusDetails{} + } + switch status.Type { case portainer.EdgeStackStatusPending: status.Details.Pending = true @@ -93,10 +97,10 @@ func (m *Migrator) updateEdgeStackStatusForDB80() error { edgeStack.Status[endpointId] = status } - err = m.edgeStackService.UpdateEdgeStack(edgeStack.ID, &edgeStack) - if err != nil { + if err := m.edgeStackService.UpdateEdgeStack(edgeStack.ID, &edgeStack); err != nil { return err } } + return nil } diff --git a/api/portainer.go b/api/portainer.go index 5b7d177da..60d09a993 100644 --- a/api/portainer.go +++ b/api/portainer.go @@ -309,7 +309,7 @@ type ( // FileVersion is the version of the stack file, used to detect changes FileVersion int `json:"FileVersion"` // ConfigHash is the commit hash of the git repository used for deploying the stack - ConfigHash string `json:"ConfigHash"` + ConfigHash string `json:"ConfigHash,omitempty"` } // EdgeStack represents an edge stack @@ -353,24 +353,24 @@ type ( // EE only feature DeploymentInfo StackDeploymentInfo // ReadyRePullImage is a flag to indicate whether the auto update is trigger to re-pull image - ReadyRePullImage bool + ReadyRePullImage bool `json:"ReadyRePullImage,omitempty"` // Deprecated - Details EdgeStackStatusDetails + Details *EdgeStackStatusDetails `json:"Details,omitempty"` // Deprecated - Error string + Error string `json:"Error,omitempty"` // Deprecated - Type EdgeStackStatusType `json:"Type"` + Type EdgeStackStatusType `json:"Type,omitempty"` } // EdgeStackDeploymentStatus represents an edge stack deployment status EdgeStackDeploymentStatus struct { Time int64 Type EdgeStackStatusType - Error string + Error string `json:"Error,omitempty"` // EE only feature - RollbackTo *int - Version int `json:"Version,omitempty"` + RollbackTo *int `json:"RollbackTo,omitempty"` + Version int `json:"Version,omitempty"` } // EdgeStackStatusType represents an edge stack status type