mirror of
https://github.com/Dvorinka/Containr.git
synced 2026-10-28 15:51:26 +00:00
refactor(db): port service clone/move ops to sqlc
Tranche 2: cloneServiceRow's INSERT...SELECT (volumes and traefik_labels now read straight from the source row — traefik_labels was silently dropped before, and the jsonb param round-trip goes away), domain and variable copies, name-conflict counts, move UPDATE, project owner check. Also fixes serviceWriteAccess: user_id is a context string, not a uuid.UUID — the tranche-1 cast silently failed owner checks for non-admins. Live tests cover the domain invariants and a full clone round-trip (config, domains, variables). Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
302c595380
commit
25a8443548
6 files changed
+328
-61
No files matched your search
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"regexp"
|
||||
@@ -210,7 +211,7 @@ func basicAuthUsernames(encoded string) []string {
|
||||
// serviceWriteAccess mirrors the service update handler's access check.
|
||||
func serviceWriteAccess(c *gin.Context, db *database.DB, serviceID uuid.UUID) bool {
|
||||
userID, _ := c.Get("user_id")
|
||||
uid, _ := userID.(uuid.UUID)
|
||||
uid, _ := uuid.Parse(fmt.Sprint(userID))
|
||||
ok, err := sqlcdb.New(db.DB).ServiceWriteAccess(context.Background(), sqlcdb.ServiceWriteAccessParams{
|
||||
ID: serviceID,
|
||||
OwnerID: uid,
|
||||
|
||||
Reference in new issue
Block a user