forked from wrenn/wrenn
Moves 12 packages from internal/ to pkg/ (config, id, validate, events, db, auth, lifecycle, scheduler, channels, audit, service) so they can be imported by the enterprise repo as a Go module dependency. Introduces pkg/cpextension (shared Extension interface + ServerContext) and pkg/cpserver (Run() entrypoint with functional options) so the enterprise main.go can call cpserver.Run(cpserver.WithExtensions(...)) without duplicating the 20-step server bootstrap. Adds db/migrations/embed.go for go:embed access to OSS SQL migrations from the enterprise module. cmd/control-plane/main.go is reduced to a 10-line wrapper around cpserver.Run.
28 lines
743 B
Go
28 lines
743 B
Go
package service
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
|
|
"git.omukk.dev/wrenn/wrenn/pkg/db"
|
|
)
|
|
|
|
// TemplateService provides template/snapshot operations shared between the
|
|
// REST API and the dashboard.
|
|
type TemplateService struct {
|
|
DB *db.Queries
|
|
}
|
|
|
|
// List returns all templates belonging to the given team. If typeFilter is
|
|
// non-empty, only templates of that type ("base" or "snapshot") are returned.
|
|
func (s *TemplateService) List(ctx context.Context, teamID pgtype.UUID, typeFilter string) ([]db.Template, error) {
|
|
if typeFilter != "" {
|
|
return s.DB.ListTemplatesByTeamAndType(ctx, db.ListTemplatesByTeamAndTypeParams{
|
|
TeamID: teamID,
|
|
Type: typeFilter,
|
|
})
|
|
}
|
|
return s.DB.ListTemplatesByTeam(ctx, teamID)
|
|
}
|