Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 5 additions & 5 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test")
load("@bazel_gazelle//:def.bzl", "gazelle")
load("//:version.bzl", "VERSION")
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test")
load("@rules_oci//oci:defs.bzl", "oci_image", "oci_push", "oci_tarball")
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
load("//:version.bzl", "VERSION")

package(default_visibility = ["//visibility:public"])

Expand Down Expand Up @@ -89,17 +89,17 @@ pkg_tar(
oci_image(
name = "vbs_image",
base = "@distroless_static",
tars = [":vbs_tar"],
entrypoint = ["/usr/bin/vbs-linux"],
cmd = [
"serve",
"--http=0.0.0.0:8080",
],
entrypoint = ["/usr/bin/vbs-linux"],
exposed_ports = ["8080"],
labels = {
"org.opencontainers.image.source": "https://github.com/kindlyops/vbs",
"org.opencontainers.image.description": "Tools for video broadcast production",
},
tars = [":vbs_tar"],
)

# Generate tag file with IMAGE_TAG variable
Expand All @@ -115,8 +115,8 @@ genrule(
oci_push(
name = "push_image",
image = ":vbs_image",
repository = "ghcr.io/kindlyops/vbs",
remote_tags = ":image_tags",
repository = "ghcr.io/kindlyops/vbs",
tags = ["manual"],
)

Expand Down
3 changes: 0 additions & 3 deletions cmd/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,10 @@ go_library(
"//vendor/github.com/charmbracelet/lipgloss:go_default_library",
"//vendor/github.com/hypebeast/go-osc/osc:go_default_library",
"//vendor/github.com/kennygrant/sanitize:go_default_library",
"//vendor/github.com/labstack/echo/v5:go_default_library",
"//vendor/github.com/mattn/go-isatty:go_default_library",
"//vendor/github.com/muesli/coral:go_default_library",
"//vendor/github.com/pocketbase/pocketbase:go_default_library",
"//vendor/github.com/pocketbase/pocketbase/apis:go_default_library",
"//vendor/github.com/pocketbase/pocketbase/core:go_default_library",
"//vendor/github.com/pocketbase/pocketbase/plugins/migratecmd:go_default_library",
"//vendor/github.com/rs/zerolog:go_default_library",
"//vendor/github.com/rs/zerolog/log:go_default_library",
"//vendor/github.com/spf13/viper:go_default_library",
Expand Down
66 changes: 20 additions & 46 deletions cmd/fly.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,9 @@ import (
"path/filepath"

"github.com/kindlyops/vbs/embeddy"
"github.com/labstack/echo/v5"
"github.com/muesli/coral"
"github.com/pocketbase/pocketbase"
"github.com/pocketbase/pocketbase/apis"
"github.com/pocketbase/pocketbase/core"
"github.com/pocketbase/pocketbase/plugins/migratecmd"
"github.com/rs/zerolog/log"
)

Expand All @@ -49,48 +46,35 @@ func flyServer(cmd *coral.Command, args []string) {
os.MkdirAll(configDir, os.ModePerm)

log.Debug().Msgf("running pocketbase with data dir %s\n", configDir)
app := pocketbase.NewWithConfig(&pocketbase.Config{
app := pocketbase.NewWithConfig(pocketbase.Config{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [golangci] reported by reviewdog 🐶
pocketbase.Config is missing fields HideStartBanner, DefaultDev, DefaultEncryptionEnv, DefaultQueryTimeout, DataMaxOpenConns, DataMaxIdleConns, AuxMaxOpenConns, AuxMaxIdleConns, DBConnect (exhaustruct)

DefaultDataDir: configDir,
})

migrationsDir := "" // default to "pb_migrations" (for js) and "migrations" (for go)

// register the `migrate` command
migratecmd.MustRegister(app, app.RootCmd, &migratecmd.Options{
TemplateLang: migratecmd.TemplateLangGo, // or migratecmd.TemplateLangJS
Dir: migrationsDir,
Automigrate: true,
})

app.OnBeforeServe().Add(func(e *core.ServeEvent) error {
app.OnServe().BindFunc(func(serveEvent *core.ServeEvent) error {
public, _ := fs.Sub(embeddy.GetNextFS(), "public")
assetHandler := http.FileServer(http.FS(public))
e.Router.AddRoute(echo.Route{
Method: http.MethodGet,
Path: "/*",
Handler: echo.WrapHandler(assetHandler),
Middlewares: []echo.MiddlewareFunc{
apis.ActivityLogger(app),
//apis.RequireAdminAuth(),
},

// Serve static files
serveEvent.Router.GET("/*", func(re *core.RequestEvent) error {
assetHandler.ServeHTTP(re.Response, re.Request)

return nil
})

e.Router.AddRoute(echo.Route{
Method: http.MethodPost,
Path: "/api/switcher/*",
Middlewares: []echo.MiddlewareFunc{
apis.ActivityLogger(app),
},
Handler: echo.WrapHandler(&Switcher{}),
// Switcher API endpoint
serveEvent.Router.POST("/api/switcher/*", func(re *core.RequestEvent) error {
switcher := &Switcher{}
switcher.ServeHTTP(re.Response, re.Request)

return nil
})

e.Router.AddRoute(echo.Route{
Method: http.MethodPost,
Path: "/api/light/*",
Middlewares: []echo.MiddlewareFunc{
apis.ActivityLogger(app),
},
Handler: echo.WrapHandler(&Lighting{}),
// Lighting API endpoint
serveEvent.Router.POST("/api/light/*", func(re *core.RequestEvent) error {
lighting := &Lighting{}
lighting.ServeHTTP(re.Response, re.Request)

return nil
})

return nil
Expand All @@ -99,16 +83,6 @@ func flyServer(cmd *coral.Command, args []string) {
if err := app.Start(); err != nil {
log.Fatal().Err(err).Msg("error starting pocketbase")
}

// app.RootCmd.AddCommand(&cobra.Command{
// Use: "fly",
// Run: func(command *cobra.Command, args []string) {
// log.Debug().Msgf("Pocketbase interceptor no-op")
// if err := app.Execute(); err != nil {
// log.Fatal().Err(err).Msg("error starting pocketbase")
// }
// },
// })
}

// Port to listen for HTTP requests.
Expand Down
42 changes: 35 additions & 7 deletions cmd/lighting.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ import (

"github.com/hypebeast/go-osc/osc"
"github.com/kindlyops/vbs/embeddy"
"github.com/labstack/echo/v5"
"github.com/muesli/coral"
"github.com/pocketbase/pocketbase"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [golangci] reported by reviewdog 🐶
import 'github.com/pocketbase/pocketbase' is not allowed from list 'Main' (depguard)

"github.com/pocketbase/pocketbase/core"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [golangci] reported by reviewdog 🐶
import 'github.com/pocketbase/pocketbase/core' is not allowed from list 'Main' (depguard)

"github.com/rs/zerolog/log"
"github.com/spf13/viper"
)
Expand Down Expand Up @@ -50,14 +51,41 @@ func lightingBridge(cmd *coral.Command, args []string) {
assetHandler := http.FileServer(http.FS(public))

log.Debug().Msgf("Starting HTTP server at: http://%s\n", listenAddr)
e := echo.New()
e.GET("/*", echo.WrapHandler(assetHandler))
e.POST("/api/switcher/*", echo.WrapHandler(&Switcher{}))
e.POST("/api/light/*", echo.WrapHandler(&Lighting{}))
err := e.Start(listenAddr)
app := pocketbase.New()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [golangci] reported by reviewdog 🐶
assignments should only be cuddled with other assignments (wsl)


app.OnServe().BindFunc(func(serveEvent *core.ServeEvent) error {
// Serve static files
serveEvent.Router.GET("/*", func(re *core.RequestEvent) error {
assetHandler.ServeHTTP(re.Response, re.Request)

return nil
})

// Switcher API endpoint
serveEvent.Router.POST("/api/switcher/*", func(re *core.RequestEvent) error {
switcher := &Switcher{}
switcher.ServeHTTP(re.Response, re.Request)

return nil
})

// Lighting API endpoint
serveEvent.Router.POST("/api/light/*", func(re *core.RequestEvent) error {
lighting := &Lighting{}
lighting.ServeHTTP(re.Response, re.Request)

return nil
})

// Override the server address
serveEvent.Server.Addr = listenAddr

return nil
})

err := app.Start()
if err != nil {
log.Error().Err(err).Msg("error from echo.Start")
log.Error().Err(err).Msg("error from app.Start")
}
}

Expand Down
103 changes: 30 additions & 73 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/kindlyops/vbs

go 1.21
go 1.25.0

require (
github.com/aws/aws-sdk-go v1.55.8
Expand All @@ -16,108 +16,65 @@ require (
github.com/charmbracelet/bubbles v0.16.1
github.com/charmbracelet/bubbletea v0.24.2
github.com/charmbracelet/lipgloss v0.13.1
github.com/labstack/echo/v5 v5.0.0-20220201181537-ed2888cfa198
github.com/labstack/echo/v5 v5.0.1
github.com/muesli/coral v1.0.0
github.com/pocketbase/pocketbase v0.16.5
github.com/pocketbase/pocketbase v0.30.4
)

require (
github.com/AlecAivazis/survey/v2 v2.3.6 // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/aws/aws-sdk-go-v2 v1.18.0 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.10 // indirect
github.com/aws/aws-sdk-go-v2/config v1.18.25 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.13.24 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.3 // indirect
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.67 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.33 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.27 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.34 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.25 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.11 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.28 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.27 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.14.2 // indirect
github.com/aws/aws-sdk-go-v2/service/s3 v1.33.1 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.12.10 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.10 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.19.0 // indirect
github.com/aws/smithy-go v1.13.5 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/charmbracelet/harmonica v0.2.0 // indirect
github.com/charmbracelet/x/ansi v0.3.2 // indirect
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect
github.com/disintegration/imaging v1.6.2 // indirect
github.com/domodwyer/mailyak/v3 v3.6.0 // indirect
github.com/domodwyer/mailyak/v3 v3.6.2 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/ganigeorgiev/fexpr v0.3.0 // indirect
github.com/fatih/color v1.18.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.10 // indirect
github.com/ganigeorgiev/fexpr v0.5.0 // indirect
github.com/go-ozzo/ozzo-validation/v4 v4.3.0 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/google/wire v0.5.0 // indirect
github.com/googleapis/gax-go/v2 v2.10.0 // indirect
github.com/go-sql-driver/mysql v1.8.1 // indirect
github.com/golang-jwt/jwt/v5 v5.3.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-localereader v0.0.1 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/mattn/go-sqlite3 v1.14.17 // indirect
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/muesli/reflow v0.3.0 // indirect
github.com/muesli/termenv v0.15.2 // indirect
github.com/ncruces/go-strftime v1.0.0 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/pocketbase/dbx v1.10.0 // indirect
github.com/pocketbase/dbx v1.11.0 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/spf13/afero v1.9.5 // indirect
github.com/spf13/cast v1.5.1 // indirect
github.com/spf13/cobra v1.7.0 // indirect
github.com/spf13/cast v1.10.0 // indirect
github.com/spf13/cobra v1.10.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/pflag v1.0.10 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
go.opencensus.io v0.24.0 // indirect
gocloud.dev v0.29.0 // indirect
golang.org/x/crypto v0.11.0 // indirect
golang.org/x/image v0.7.0 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/net v0.12.0 // indirect
golang.org/x/oauth2 v0.8.0 // indirect
golang.org/x/sync v0.3.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/term v0.10.0 // indirect
golang.org/x/text v0.11.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.11.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/api v0.125.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect
google.golang.org/grpc v1.55.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect
golang.org/x/crypto v0.47.0 // indirect
golang.org/x/exp v0.0.0-20251009144603-d2f985daa21b // indirect
golang.org/x/image v0.32.0 // indirect
golang.org/x/net v0.49.0 // indirect
golang.org/x/oauth2 v0.32.0 // indirect
golang.org/x/sync v0.19.0 // indirect
golang.org/x/sys v0.40.0 // indirect
golang.org/x/term v0.39.0 // indirect
golang.org/x/text v0.33.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
lukechampine.com/uint128 v1.3.0 // indirect
modernc.org/cc/v3 v3.40.0 // indirect
modernc.org/ccgo/v3 v3.16.13 // indirect
modernc.org/libc v1.22.6 // indirect
modernc.org/mathutil v1.5.0 // indirect
modernc.org/memory v1.5.0 // indirect
modernc.org/opt v0.1.3 // indirect
modernc.org/sqlite v1.22.1 // indirect
modernc.org/strutil v1.1.3 // indirect
modernc.org/token v1.1.0 // indirect
modernc.org/libc v1.66.10 // indirect
modernc.org/mathutil v1.7.1 // indirect
modernc.org/memory v1.11.0 // indirect
modernc.org/sqlite v1.39.1 // indirect
)
Loading
Loading