MCPcopy Create free account
hub / github.com/cloudwan/gohan / decodeState

Function decodeState

db/sql/sql.go:822–848  ·  view source on GitHub ↗
(data map[string]interface{}, state *transaction.ResourceState)

Source from the content-addressed store, hash-verified

820}
821
822func decodeState(data map[string]interface{}, state *transaction.ResourceState) error {
823 var ok bool
824 state.ConfigVersion, ok = data[configVersionColumnName].(int64)
825 if !ok {
826 return fmt.Errorf("Wrong state column %s returned from query", configVersionColumnName)
827 }
828 state.StateVersion, ok = data[stateVersionColumnName].(int64)
829 if !ok {
830 return fmt.Errorf("Wrong state column %s returned from query", stateVersionColumnName)
831 }
832 stateError, ok := data[stateErrorColumnName].([]byte)
833 if !ok {
834 return fmt.Errorf("Wrong state column %s returned from query", stateErrorColumnName)
835 }
836 state.Error = string(stateError)
837 stateState, ok := data[stateColumnName].([]byte)
838 if !ok {
839 return fmt.Errorf("Wrong state column %s returned from query", stateColumnName)
840 }
841 state.State = string(stateState)
842 stateMonitoring, ok := data[stateMonitoringColumnName].([]byte)
843 if !ok {
844 return fmt.Errorf("Wrong state column %s returned from query", stateMonitoringColumnName)
845 }
846 state.Monitoring = string(stateMonitoring)
847 return nil
848}
849
850//normFields runs normFields on all the fields.
851func normFields(fields []string, s *schema.Schema) []string {

Callers 1

StateFetchContextMethod · 0.85

Calls 1

ErrorfMethod · 0.65

Tested by

no test coverage detected