func AddContainerUser(dbConn *sql.DB, s ContainerUser) (int, error) { //logit.Info.Println("AddContainerUser called") //encrypt the password...passwords at rest are encrypted encrypted, err := sec.EncryptPassword(s.Passwd) queryStr := fmt.Sprintf("insert into containeruser ( containername, usename, passwd, updatedt) values ( '%s', '%s', '%s', now()) returning id", s.Containername, s.Rolname, encrypted) logit.Info.Println("AddContainerUser:"******"error in AddContainerUser query " + err.Error()) return theID, err } switch { case err != nil: logit.Error.Println("AddContainerUser: error " + err.Error()) return theID, err default: } return theID, nil }
func UpdateContainerUser(dbConn *sql.DB, user ContainerUser) error { logit.Info.Println("admindb:UpdateContainerUser encrypting password of " + user.Passwd) encrypted, err := sec.EncryptPassword(user.Passwd) queryStr := fmt.Sprintf("update containeruser set ( passwd, updatedt) = ('%s', now()) where usename = '%s' returning id", encrypted, user.Rolname) logit.Info.Println("[" + queryStr + "]") var userid int err = dbConn.QueryRow(queryStr).Scan(&userid) switch { case err != nil: return err default: logit.Info.Println("admindb:UpdateContainerUser:updated " + user.ID) } return nil }