Skip to content

Commit

Permalink
rest: Use gocleanup
Browse files Browse the repository at this point in the history
When using the REST API over a unix socket, this ensures the unix socket
is removed from the filesystem when vfkit exits.
  • Loading branch information
cfergeau committed Mar 27, 2024
1 parent 4bb5541 commit 4419006
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/rest/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import (
"errors"
"fmt"
"net/url"
"os"
"strings"
"syscall"

"github.com/crc-org/vfkit/pkg/cmdline"
"github.com/gin-gonic/gin"
"github.com/onsi/gocleanup"
"github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -73,6 +75,7 @@ func (v *VFKitService) Start() {
case TCP:
err = v.router.Run(v.Host)
case Unix:
gocleanup.Register(func() { os.Remove(v.Path) })
err = v.router.RunUnix(v.Path)
}
logrus.Fatal(err)
Expand Down

0 comments on commit 4419006

Please sign in to comment.