aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/api/docker.go
diff options
context:
space:
mode:
authorJP Appel <jeanpierre.appel01@gmail.com>2024-10-08 13:17:03 -0400
committerJP Appel <jeanpierre.appel01@gmail.com>2024-10-08 13:17:03 -0400
commit13c771c84e6b86cebe6df14d0e92001f940581ba (patch)
tree4b76f90de9c783dc3cb5da633bfc8434964e039d /api/docker.go
parent3b0e5c790ff51756c1317f4af83a2f0b0e66efd9 (diff)
Move ansi stripper to util package
Diffstat (limited to 'api/docker.go')
-rw-r--r--api/docker.go33
1 files changed, 0 insertions, 33 deletions
diff --git a/api/docker.go b/api/docker.go
index c79b76d..551c818 100644
--- a/api/docker.go
+++ b/api/docker.go
@@ -5,7 +5,6 @@ import (
"fmt"
"io"
"log/slog"
- "regexp"
"time"
"github.com/docker/docker/api/types/container"
@@ -14,38 +13,6 @@ import (
const vttContainerId string = "foundry-foundry-1"
-// Strip ansi control characters from source
-//
-// The source reader is automatically closed when stripper reader is
-type ansiStripper struct {
- regex regexp.Regexp
- source io.ReadCloser
-}
-
-func NewAnsiStripper(source io.ReadCloser) *ansiStripper {
- striper := new(ansiStripper)
- striper.regex = *regexp.MustCompile(`\x1b[[0-9;]*m`)
- striper.source = source
-
- return striper
-}
-
-func (rc ansiStripper) Read(p []byte) (int, error) {
- n, err := rc.source.Read(p)
- if err != io.EOF && err != nil {
- return n, err
- }
-
- stripped := rc.regex.ReplaceAll(p[:n], []byte(""))
- n = copy(p, stripped)
-
- return n, err
-}
-
-func (rc ansiStripper) Close() error {
- return rc.source.Close()
-}
-
func stopVtt(ctx context.Context) error {
apiClient, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
if err != nil {