chore(tfstated): change database state id and version id formats to uuidv7
This commit is contained in:
parent
169e2d0d9d
commit
6fd1663d8c
9 changed files with 73 additions and 57 deletions
|
@ -3,10 +3,10 @@ package webui
|
|||
import (
|
||||
"html/template"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"git.adyxax.org/adyxax/tfstated/pkg/database"
|
||||
"git.adyxax.org/adyxax/tfstated/pkg/model"
|
||||
"go.n16f.net/uuid"
|
||||
)
|
||||
|
||||
var stateTemplate = template.Must(template.ParseFS(htmlFS, "html/base.html", "html/state.html"))
|
||||
|
@ -19,9 +19,8 @@ func handleStateGET(db *database.DB) http.Handler {
|
|||
Versions []model.Version
|
||||
}
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
stateIdStr := r.PathValue("id")
|
||||
stateId, err := strconv.Atoi(stateIdStr)
|
||||
if err != nil {
|
||||
var stateId uuid.UUID
|
||||
if err := stateId.Parse(r.PathValue("id")); err != nil {
|
||||
errorResponse(w, http.StatusBadRequest, err)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ import (
|
|||
"net/http"
|
||||
"net/url"
|
||||
"path"
|
||||
"strconv"
|
||||
|
||||
"git.adyxax.org/adyxax/tfstated/pkg/database"
|
||||
"git.adyxax.org/adyxax/tfstated/pkg/model"
|
||||
|
@ -87,7 +86,7 @@ func handleStatesPOST(db *database.DB) http.Handler {
|
|||
})
|
||||
return
|
||||
}
|
||||
destination := path.Join("/version", strconv.Itoa(version.Id))
|
||||
destination := path.Join("/version", version.Id.String())
|
||||
http.Redirect(w, r, destination, http.StatusFound)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package webui
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"html/template"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"path"
|
||||
|
||||
"git.adyxax.org/adyxax/tfstated/pkg/database"
|
||||
"git.adyxax.org/adyxax/tfstated/pkg/model"
|
||||
"go.n16f.net/uuid"
|
||||
)
|
||||
|
||||
var versionTemplate = template.Must(template.ParseFS(htmlFS, "html/base.html", "html/version.html"))
|
||||
|
@ -21,9 +21,8 @@ func handleVersionGET(db *database.DB) http.Handler {
|
|||
VersionData string
|
||||
}
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
versionIdStr := r.PathValue("id")
|
||||
versionId, err := strconv.Atoi(versionIdStr)
|
||||
if err != nil {
|
||||
var versionId uuid.UUID
|
||||
if err := versionId.Parse(r.PathValue("id")); err != nil {
|
||||
errorResponse(w, http.StatusBadRequest, err)
|
||||
return
|
||||
}
|
||||
|
@ -49,7 +48,7 @@ func handleVersionGET(db *database.DB) http.Handler {
|
|||
versionData := string(version.Data[:])
|
||||
render(w, versionTemplate, http.StatusOK, VersionsData{
|
||||
Page: makePage(r, &Page{
|
||||
Precedent: fmt.Sprintf("/state/%d", state.Id),
|
||||
Precedent: path.Join("/state/", state.Id.String()),
|
||||
Section: "states",
|
||||
Title: state.Path,
|
||||
}),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue