func (r *Role) fillRoleFromSQL(row datastore.ResRow) error { var ( rl []byte er []byte da []byte oa []byte ) err := row.Scan(&r.Name, &r.Description, &rl, &er, &da, &oa) if err != nil { return err } r.ChefType = "role" r.JSONClass = "Chef::Role" err = datastore.DecodeBlob(rl, &r.RunList) if err != nil { return err } err = datastore.DecodeBlob(er, &r.EnvRunLists) if err != nil { return err } err = datastore.DecodeBlob(da, &r.Default) if err != nil { return err } err = datastore.DecodeBlob(oa, &r.Override) if err != nil { return err } datastore.ChkNilArray(r) return nil }
func (le *LogInfo) fillLogEventFromPostgreSQL(row datastore.ResRow) error { err := row.Scan(&le.ID, &le.ActorType, &le.ActorInfo, &le.Time, &le.Action, &le.ObjectType, &le.ObjectName, &le.ExtendedInfo) if err != nil { return err } return nil }
// Fill an environment in from a row returned from the SQL server. See the // equivalent function in node/node.go for more details. // // As there, the SQL query that made the row needs to have the same number & // order of columns as the one in Get(), even if the WHERE clause is different // or omitted. func (e *ChefEnvironment) fillEnvFromSQL(row datastore.ResRow) error { var ( da []byte oa []byte cv []byte ) err := row.Scan(&e.Name, &e.Description, &da, &oa, &cv) if err != nil { return err } e.ChefType = "environment" e.JSONClass = "Chef::Environment" err = datastore.DecodeBlob(da, &e.Default) if err != nil { return err } err = datastore.DecodeBlob(oa, &e.Override) if err != nil { return err } err = datastore.DecodeBlob(cv, &e.CookbookVersions) if err != nil { return err } datastore.ChkNilArray(e) return nil }
func (c *Cookbook) fillCookbookFromSQL(row datastore.ResRow) error { err := row.Scan(&c.id, &c.Name) if err != nil { return err } return nil }
func (c *Client) fillClientFromSQL(row datastore.ResRow) error { err := row.Scan(&c.Name, &c.NodeName, &c.Validator, &c.Admin, &c.Orgname, &c.pubKey, &c.Certificate) if err != nil { return err } c.ChefType = "client" c.JSONClass = "Chef::ApiClient" return nil }
func (srs *ShoveyRunStream) fillShoveyRunStreamFromMySQL(row datastore.ResRow) error { var ca mysql.NullTime err := row.Scan(&srs.ShoveyUUID, &srs.NodeName, &srs.Seq, &srs.OutputType, &srs.Output, &srs.IsLast, &ca) if err != nil { return err } if ca.Valid { srs.CreatedAt = ca.Time } return nil }
func (ns *NodeStatus) fillNodeStatusFromMySQL(row datastore.ResRow) error { var ua mysql.NullTime err := row.Scan(&ns.Status, &ua) if err != nil { return nil } if ua.Valid { ns.UpdatedAt = ua.Time } return nil }
func (s *Sandbox) fillSandboxFromPostgreSQL(row datastore.ResRow) error { var csb []byte err := row.Scan(&s.ID, &s.CreationTime, &csb, &s.Completed) if err != nil { return err } err = datastore.DecodeBlob(csb, &s.Checksums) if err != nil { return err } return nil }
func (le *LogInfo) fillLogEventFromMySQL(row datastore.ResRow) error { var tb []byte err := row.Scan(&le.ID, &le.ActorType, &le.ActorInfo, &tb, &le.Action, &le.ObjectType, &le.ObjectName, &le.ExtendedInfo) if err != nil { return err } le.Time, err = time.Parse(datastore.MySQLTimeFormat, string(tb)) if err != nil { return err } return nil }
func (u *User) fillUserFromSQL(row datastore.ResRow) error { var email sql.NullString err := row.Scan(&u.Username, &u.Name, &u.Admin, &u.pubKey, &email, &u.passwd, &u.salt) if err != nil { return err } if !email.Valid { u.Email = "" } else { u.Email = email.String } return nil }
func (sr *ShoveyRun) fillShoveyRunFromMySQL(row datastore.ResRow) error { var at, et mysql.NullTime err := row.Scan(&sr.ID, &sr.ShoveyUUID, &sr.NodeName, &sr.Status, &at, &et, &sr.Error, &sr.ExitStatus) if err != nil { return err } if at.Valid { sr.AckTime = at.Time } if et.Valid { sr.EndTime = et.Time } return nil }
func (dbi *DataBagItem) fillDBItemFromMySQL(row datastore.ResRow) error { var rawb []byte err := row.Scan(&dbi.id, &dbi.dataBagID, &dbi.Name, &dbi.origName, &dbi.DataBagName, &rawb) if err != nil { return err } dbi.ChefType = "data_bag_item" dbi.JSONClass = "Chef::DataBagItem" err = datastore.DecodeBlob(rawb, &dbi.RawData) if err != nil { return err } datastore.ChkNilArray(dbi) return nil }
func (s *Shovey) fillShoveyFromMySQL(row datastore.ResRow) error { var ca, ua mysql.NullTime var tm int64 err := row.Scan(&s.RunID, &s.Command, &ca, &ua, &s.Status, &tm, &s.Quorum) if err != nil { return err } if ca.Valid { s.CreatedAt = ca.Time } if ua.Valid { s.UpdatedAt = ua.Time } s.Timeout = time.Duration(tm) return nil }
func (s *Shovey) fillShoveyFromPostgreSQL(row datastore.ResRow) error { var ca, ua pq.NullTime var nn util.StringSlice var tm int64 err := row.Scan(&s.RunID, &nn, &s.Command, &ca, &ua, &s.Status, &tm, &s.Quorum) if err != nil { return err } if ca.Valid { s.CreatedAt = ca.Time } if ua.Valid { s.UpdatedAt = ua.Time } s.Timeout = time.Duration(tm) s.NodeNames = nn return nil }
func (r *Report) fillReportFromMySQL(row datastore.ResRow) error { var res, dat []byte var st, et mysql.NullTime err := row.Scan(&r.RunID, &st, &et, &r.TotalResCount, &r.Status, &r.RunList, &res, &dat, &r.NodeName) if err != nil { return err } if err = datastore.DecodeBlob(res, &r.Resources); err != nil { return err } if err = datastore.DecodeBlob(dat, &r.Data); err != nil { return err } if st.Valid { r.StartTime = st.Time } if et.Valid { r.EndTime = et.Time } return nil }
// Fill in a node from a row returned from the SQL server. Useful for the case // down the road where an array of objects is needed, but building it with // a call to GetList(), then repeated calls to Get() sucks with a real db even // if it's marginally acceptable in in-memory mode. // // NB: This does require the query to look like the one in Get(). func (n *Node) fillNodeFromSQL(row datastore.ResRow) error { var ( rl []byte aa []byte na []byte da []byte oa []byte ) err := row.Scan(&n.Name, &n.ChefEnvironment, &rl, &aa, &na, &da, &oa) if err != nil { return err } n.ChefType = "node" n.JSONClass = "Chef::Node" err = datastore.DecodeBlob(rl, &n.RunList) if err != nil { return err } err = datastore.DecodeBlob(aa, &n.Automatic) if err != nil { return err } err = datastore.DecodeBlob(na, &n.Normal) if err != nil { return err } err = datastore.DecodeBlob(da, &n.Default) if err != nil { return err } err = datastore.DecodeBlob(oa, &n.Override) if err != nil { return err } datastore.ChkNilArray(n) return nil }
func (cbv *CookbookVersion) fillCookbookVersionFromSQL(row datastore.ResRow) error { var ( defb []byte libb []byte attb []byte recb []byte prob []byte resb []byte temb []byte roob []byte filb []byte metb []byte major int64 minor int64 patch int64 ) err := row.Scan(&cbv.id, &cbv.cookbookID, &defb, &libb, &attb, &recb, &prob, &resb, &temb, &roob, &filb, &metb, &major, &minor, &patch, &cbv.IsFrozen, &cbv.CookbookName) if err != nil { return err } /* Now... populate it. :-/ */ // These may need to accept x.y versions with only two elements // instead of x.y.0 with the added default 0 patch number. cbv.Version = fmt.Sprintf("%d.%d.%d", major, minor, patch) cbv.Name = fmt.Sprintf("%s-%s", cbv.CookbookName, cbv.Version) cbv.ChefType = "cookbook_version" cbv.JSONClass = "Chef::CookbookVersion" /* TODO: experiment some more with getting this done with * pointers. */ err = datastore.DecodeBlob(metb, &cbv.Metadata) if err != nil { return err } err = datastore.DecodeBlob(defb, &cbv.Definitions) if err != nil { return err } err = datastore.DecodeBlob(libb, &cbv.Libraries) if err != nil { return err } err = datastore.DecodeBlob(attb, &cbv.Attributes) if err != nil { return err } err = datastore.DecodeBlob(recb, &cbv.Recipes) if err != nil { return err } err = datastore.DecodeBlob(prob, &cbv.Providers) if err != nil { return err } err = datastore.DecodeBlob(temb, &cbv.Templates) if err != nil { return err } err = datastore.DecodeBlob(resb, &cbv.Resources) if err != nil { return err } err = datastore.DecodeBlob(roob, &cbv.RootFiles) if err != nil { return err } err = datastore.DecodeBlob(filb, &cbv.Files) if err != nil { return err } datastore.ChkNilArray(cbv) return nil }