dont export the pending/authz utility models

This commit is contained in:
Roland Shoemaker 2015-05-06 22:22:22 -07:00
parent 651689711f
commit 3041423361
1 changed files with 16 additions and 16 deletions

View File

@ -40,13 +40,13 @@ var dialectMap map[string]interface{} = map[string]interface{}{
} }
// Utility models // Utility models
type PendingAuthzModel struct { type pendingauthzModel struct {
core.Authorization core.Authorization
LockCol int64 LockCol int64
} }
type AuthzModel struct { type authzModel struct {
core.Authorization core.Authorization
Sequence int64 `db:"sequence"` Sequence int64 `db:"sequence"`
@ -141,8 +141,8 @@ func NewSQLStorageAuthority(driver string, name string) (ssa *SQLStorageAuthorit
func (ssa *SQLStorageAuthority) InitTables() (err error) { func (ssa *SQLStorageAuthority) InitTables() (err error) {
ssa.dbMap.AddTableWithName(core.Registration{}, "registrations").SetKeys(false, "ID").SetVersionCol("LockCol") ssa.dbMap.AddTableWithName(core.Registration{}, "registrations").SetKeys(false, "ID").SetVersionCol("LockCol")
ssa.dbMap.AddTableWithName(PendingAuthzModel{}, "pending_authz").SetKeys(false, "ID").SetVersionCol("LockCol") ssa.dbMap.AddTableWithName(pendingauthzModel{}, "pending_authz").SetKeys(false, "ID").SetVersionCol("LockCol")
ssa.dbMap.AddTableWithName(AuthzModel{}, "authz").SetKeys(false, "ID") ssa.dbMap.AddTableWithName(authzModel{}, "authz").SetKeys(false, "ID")
ssa.dbMap.AddTableWithName(core.Certificate{}, "certificates").SetKeys(false, "Serial") ssa.dbMap.AddTableWithName(core.Certificate{}, "certificates").SetKeys(false, "Serial")
ssa.dbMap.AddTableWithName(core.CertificateStatus{}, "certificateStatus").SetKeys(false, "Serial").SetVersionCol("LockCol") ssa.dbMap.AddTableWithName(core.CertificateStatus{}, "certificateStatus").SetKeys(false, "Serial").SetVersionCol("LockCol")
ssa.dbMap.AddTableWithName(core.OcspResponse{}, "ocspResponses").SetKeys(true, "ID") ssa.dbMap.AddTableWithName(core.OcspResponse{}, "ocspResponses").SetKeys(true, "ID")
@ -167,7 +167,7 @@ func (ssa *SQLStorageAuthority) DumpTables() {
} }
fmt.Printf("\n----- pending_authz -----\n") fmt.Printf("\n----- pending_authz -----\n")
var pending_authz []PendingAuthzModel var pending_authz []pendingauthzModel
_, err = ssa.dbMap.Select(&pending_authz, "SELECT * FROM pending_authz") _, err = ssa.dbMap.Select(&pending_authz, "SELECT * FROM pending_authz")
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
@ -178,7 +178,7 @@ func (ssa *SQLStorageAuthority) DumpTables() {
} }
fmt.Printf("\n----- authz -----\n") fmt.Printf("\n----- authz -----\n")
var authz []AuthzModel var authz []authzModel
_, err = ssa.dbMap.Select(&authz, "SELECT * FROM authz") _, err = ssa.dbMap.Select(&authz, "SELECT * FROM authz")
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
@ -269,12 +269,12 @@ func (ssa *SQLStorageAuthority) GetRegistration(id string) (reg core.Registratio
} }
func (ssa *SQLStorageAuthority) GetAuthorization(id string) (authz core.Authorization, err error) { func (ssa *SQLStorageAuthority) GetAuthorization(id string) (authz core.Authorization, err error) {
authObj, err := ssa.dbMap.Get(PendingAuthzModel{}, id) authObj, err := ssa.dbMap.Get(pendingauthzModel{}, id)
if err != nil { if err != nil {
return return
} }
if authObj == nil { if authObj == nil {
authObj, err = ssa.dbMap.Get(AuthzModel{}, id) authObj, err = ssa.dbMap.Get(authzModel{}, id)
if err != nil { if err != nil {
return return
} }
@ -282,11 +282,11 @@ func (ssa *SQLStorageAuthority) GetAuthorization(id string) (authz core.Authoriz
err = fmt.Errorf("No pending_authz or authz with ID %s", id) err = fmt.Errorf("No pending_authz or authz with ID %s", id)
return return
} }
authD := authObj.(*AuthzModel) authD := authObj.(*authzModel)
authz = authD.Authorization authz = authD.Authorization
return return
} }
authD := *authObj.(*PendingAuthzModel) authD := *authObj.(*pendingauthzModel)
authz = authD.Authorization authz = authD.Authorization
return return
} }
@ -437,7 +437,7 @@ func (ssa *SQLStorageAuthority) NewPendingAuthorization() (id string, err error)
} }
// Insert a stub row in pending // Insert a stub row in pending
pending_authz := &PendingAuthzModel{Authorization: core.Authorization{ID: id}} pending_authz := &pendingauthzModel{Authorization: core.Authorization{ID: id}}
err = ssa.dbMap.Insert(pending_authz) err = ssa.dbMap.Insert(pending_authz)
return return
} }
@ -458,11 +458,11 @@ func (ssa *SQLStorageAuthority) UpdatePendingAuthorization(authz core.Authorizat
return return
} }
authObj, err := ssa.dbMap.Get(PendingAuthzModel{}, authz.ID) authObj, err := ssa.dbMap.Get(pendingauthzModel{}, authz.ID)
if err != nil { if err != nil {
return return
} }
auth := authObj.(*PendingAuthzModel) auth := authObj.(*pendingauthzModel)
auth.Authorization = authz auth.Authorization = authz
_, err = ssa.dbMap.Update(auth) _, err = ssa.dbMap.Update(auth)
return return
@ -491,12 +491,12 @@ func (ssa *SQLStorageAuthority) FinalizeAuthorization(authz core.Authorization)
sequence += sequenceObj.Int64 + 1 sequence += sequenceObj.Int64 + 1
} }
auth := &AuthzModel{authz, sequence} auth := &authzModel{authz, sequence}
authObj, err := ssa.dbMap.Get(PendingAuthzModel{}, authz.ID) authObj, err := ssa.dbMap.Get(pendingauthzModel{}, authz.ID)
if err != nil { if err != nil {
return return
} }
oldAuth := authObj.(*PendingAuthzModel) oldAuth := authObj.(*pendingauthzModel)
tx, err := ssa.dbMap.Begin() tx, err := ssa.dbMap.Begin()
if err != nil { if err != nil {