Switch to using latest mediocre-go-lib

This commit is contained in:
Brian Picciano 2024-06-22 17:49:56 +02:00
parent 4664ec4a70
commit 47e53dffb7
19 changed files with 96 additions and 35 deletions

View File

@ -69,7 +69,7 @@ in rec {
''; '';
}; };
vendorHash = "sha256-33gwBj+6x9I/yz0Qf4G8YXRgC/HfwHCedqzrCE4FHHk="; vendorHash = "sha256-heXFvEea3u3zvdUvVxlI+FTxqEeImoXd1sqdJJTASoc=";
subPackages = [ subPackages = [
"./cmd/entrypoint" "./cmd/entrypoint"

View File

@ -7,8 +7,8 @@ import (
"isle/garage" "isle/garage"
"path/filepath" "path/filepath"
"github.com/mediocregopher/mediocre-go-lib/v2/mctx" "dev.mediocregopher.com/mediocre-go-lib.git/mctx"
"github.com/mediocregopher/mediocre-go-lib/v2/mlog" "dev.mediocregopher.com/mediocre-go-lib.git/mlog"
"github.com/minio/minio-go/v7" "github.com/minio/minio-go/v7"
) )

View File

@ -14,7 +14,7 @@ import (
"os" "os"
"strings" "strings"
"github.com/mediocregopher/mediocre-go-lib/v2/mlog" "dev.mediocregopher.com/mediocre-go-lib.git/mlog"
) )
func randStr(l int) string { func randStr(l int) string {

View File

@ -12,8 +12,8 @@ import (
"isle/bootstrap" "isle/bootstrap"
"isle/daemon" "isle/daemon"
"github.com/mediocregopher/mediocre-go-lib/v2/mctx" "dev.mediocregopher.com/mediocre-go-lib.git/mctx"
"github.com/mediocregopher/mediocre-go-lib/v2/mlog" "dev.mediocregopher.com/mediocre-go-lib.git/mlog"
) )
// The daemon sub-command deals with starting an actual isle daemon // The daemon sub-command deals with starting an actual isle daemon

View File

@ -7,7 +7,7 @@ import (
"isle/daemon" "isle/daemon"
"isle/garage" "isle/garage"
"github.com/mediocregopher/mediocre-go-lib/v2/mlog" "dev.mediocregopher.com/mediocre-go-lib.git/mlog"
) )
func garageInitializeGlobalBucket( func garageInitializeGlobalBucket(

View File

@ -9,7 +9,7 @@ import (
"regexp" "regexp"
"sort" "sort"
"github.com/mediocregopher/mediocre-go-lib/v2/mlog" "dev.mediocregopher.com/mediocre-go-lib.git/mlog"
) )
var hostNameRegexp = regexp.MustCompile(`^[a-z][a-z0-9\-]*$`) var hostNameRegexp = regexp.MustCompile(`^[a-z][a-z0-9\-]*$`)

47
go/cmd/entrypoint/jigs.go Normal file
View File

@ -0,0 +1,47 @@
package main
import (
"errors"
"fmt"
"io/fs"
"os"
"slices"
"strings"
)
func envOr(name string, fallback func() string) string {
if v := os.Getenv(name); v != "" {
return v
}
return fallback()
}
func firstExistingDir(paths ...string) (string, error) {
var errs []error
for _, path := range paths {
stat, err := os.Stat(path)
switch {
case errors.Is(err, fs.ErrExist):
continue
case err != nil:
errs = append(
errs, fmt.Errorf("checking if path %q exists: %w", path, err),
)
case !stat.IsDir():
errs = append(
errs, fmt.Errorf("path %q exists but is not a directory", path),
)
default:
return path, nil
}
}
err := fmt.Errorf(
"no directory found at any of the following paths: %s",
strings.Join(paths, ", "),
)
if len(errs) > 0 {
err = errors.Join(slices.Insert(errs, 0, err)...)
}
return "", err
}

View File

@ -6,8 +6,8 @@ import (
"path" "path"
"sync" "sync"
"github.com/mediocregopher/mediocre-go-lib/v2/mctx" "dev.mediocregopher.com/mediocre-go-lib.git/mctx"
"github.com/mediocregopher/mediocre-go-lib/v2/mlog" "dev.mediocregopher.com/mediocre-go-lib.git/mlog"
) )
type logMsgHandler struct { type logMsgHandler struct {

View File

@ -2,14 +2,15 @@ package main
import ( import (
"context" "context"
"fmt"
"os" "os"
"os/signal" "os/signal"
"path/filepath" "path/filepath"
"syscall" "syscall"
"github.com/adrg/xdg" "github.com/adrg/xdg"
"github.com/mediocregopher/mediocre-go-lib/v2/mctx" "dev.mediocregopher.com/mediocre-go-lib.git/mctx"
"github.com/mediocregopher/mediocre-go-lib/v2/mlog" "dev.mediocregopher.com/mediocre-go-lib.git/mlog"
) )
// The purpose of this binary is to act as the entrypoint of the isle // The purpose of this binary is to act as the entrypoint of the isle
@ -25,11 +26,18 @@ func getAppDirPath() string {
return appDirPath return appDirPath
} }
func envOr(name, fallback string) string { func getRPCSocketDirPath() string {
if v := os.Getenv(name); v != "" { path, err := firstExistingDir(
return v "/run",
"/var/run",
"/tmp",
"/dev/shm",
)
if err != nil {
panic(fmt.Sprintf("Failed to find directory for RPC socket: %v", err))
} }
return fallback
return path
} }
// RUNTIME_DIRECTORY/STATE_DIRECTORY are used by the systemd service in // RUNTIME_DIRECTORY/STATE_DIRECTORY are used by the systemd service in
@ -38,13 +46,19 @@ var (
envAppDirPath = getAppDirPath() envAppDirPath = getAppDirPath()
envRuntimeDirPath = envOr( envRuntimeDirPath = envOr(
"RUNTIME_DIRECTORY", "RUNTIME_DIRECTORY",
filepath.Join(xdg.RuntimeDir, "isle"), func() string { return filepath.Join(xdg.RuntimeDir, "isle") },
) )
envStateDirPath = envOr( envStateDirPath = envOr(
"STATE_DIRECTORY", "STATE_DIRECTORY",
filepath.Join(xdg.StateHome, "isle"), func() string { return filepath.Join(xdg.StateHome, "isle") },
) )
envBinDirPath = filepath.Join(envAppDirPath, "bin") envBinDirPath = filepath.Join(envAppDirPath, "bin")
envSocketPath = envOr(
"ISLE_SOCKET_PATH",
func() string {
return filepath.Join(getRPCSocketDirPath(), "isle-daemon.sock")
},
)
) )
func binPath(name string) string { func binPath(name string) string {

View File

@ -8,8 +8,8 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"github.com/mediocregopher/mediocre-go-lib/v2/mctx" "dev.mediocregopher.com/mediocre-go-lib.git/mctx"
"github.com/mediocregopher/mediocre-go-lib/v2/mlog" "dev.mediocregopher.com/mediocre-go-lib.git/mlog"
"github.com/shirou/gopsutil/process" "github.com/shirou/gopsutil/process"
) )

View File

@ -6,7 +6,7 @@ import (
"os" "os"
"strings" "strings"
"github.com/mediocregopher/mediocre-go-lib/v2/mlog" "dev.mediocregopher.com/mediocre-go-lib.git/mlog"
"github.com/spf13/pflag" "github.com/spf13/pflag"
) )

View File

@ -11,8 +11,8 @@ import (
"strconv" "strconv"
"code.betamike.com/micropelago/pmux/pmuxlib" "code.betamike.com/micropelago/pmux/pmuxlib"
"github.com/mediocregopher/mediocre-go-lib/v2/mctx" "dev.mediocregopher.com/mediocre-go-lib.git/mctx"
"github.com/mediocregopher/mediocre-go-lib/v2/mlog" "dev.mediocregopher.com/mediocre-go-lib.git/mlog"
) )
func garageAdminClientLogger(logger *mlog.Logger) *mlog.Logger { func garageAdminClientLogger(logger *mlog.Logger) *mlog.Logger {

View File

@ -11,7 +11,7 @@ import (
"time" "time"
"code.betamike.com/micropelago/pmux/pmuxlib" "code.betamike.com/micropelago/pmux/pmuxlib"
"github.com/mediocregopher/mediocre-go-lib/v2/mlog" "dev.mediocregopher.com/mediocre-go-lib.git/mlog"
) )
type daemon struct { type daemon struct {

View File

@ -10,7 +10,7 @@ import (
"isle/nebula" "isle/nebula"
"path/filepath" "path/filepath"
"github.com/mediocregopher/mediocre-go-lib/v2/mctx" "dev.mediocregopher.com/mediocre-go-lib.git/mctx"
"github.com/minio/minio-go/v7" "github.com/minio/minio-go/v7"
) )

View File

@ -4,8 +4,8 @@ import (
"context" "context"
"errors" "errors"
"github.com/mediocregopher/mediocre-go-lib/v2/mctx" "dev.mediocregopher.com/mediocre-go-lib.git/mctx"
"github.com/mediocregopher/mediocre-go-lib/v2/mlog" "dev.mediocregopher.com/mediocre-go-lib.git/mlog"
) )
// Handler is any type which is capable of handling arbitrary RPC calls. The // Handler is any type which is capable of handling arbitrary RPC calls. The

View File

@ -10,7 +10,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/mediocregopher/mediocre-go-lib/v2/mlog" "dev.mediocregopher.com/mediocre-go-lib.git/mlog"
) )
type DivideParams struct { type DivideParams struct {

View File

@ -10,8 +10,8 @@ import (
"net/http/httputil" "net/http/httputil"
"time" "time"
"github.com/mediocregopher/mediocre-go-lib/v2/mctx" "dev.mediocregopher.com/mediocre-go-lib.git/mctx"
"github.com/mediocregopher/mediocre-go-lib/v2/mlog" "dev.mediocregopher.com/mediocre-go-lib.git/mlog"
) )
// BucketID is a unique identifier for a bucket in garage. It is different than // BucketID is a unique identifier for a bucket in garage. It is different than

View File

@ -4,14 +4,14 @@ go 1.22
require ( require (
code.betamike.com/micropelago/pmux v0.0.0-20230706154656-fde8c2be7540 code.betamike.com/micropelago/pmux v0.0.0-20230706154656-fde8c2be7540
dev.mediocregopher.com/mediocre-go-lib.git v0.0.0-20240511135822-4ab1176672d7
github.com/adrg/xdg v0.4.0 github.com/adrg/xdg v0.4.0
github.com/imdario/mergo v0.3.12 github.com/imdario/mergo v0.3.12
github.com/mediocregopher/mediocre-go-lib/v2 v2.0.0-beta.1.0.20221113151154-07f3889a705b github.com/jxskiss/base62 v1.1.0
github.com/minio/minio-go/v7 v7.0.28 github.com/minio/minio-go/v7 v7.0.28
github.com/shirou/gopsutil v3.21.11+incompatible github.com/shirou/gopsutil v3.21.11+incompatible
github.com/slackhq/nebula v1.6.1 github.com/slackhq/nebula v1.6.1
github.com/spf13/pflag v1.0.5 github.com/spf13/pflag v1.0.5
golang.org/x/crypto v0.0.0-20220331220935-ae2d96664a29
gopkg.in/yaml.v3 v3.0.1 gopkg.in/yaml.v3 v3.0.1
) )
@ -23,7 +23,6 @@ require (
github.com/gopherjs/gopherjs v1.17.2 // indirect github.com/gopherjs/gopherjs v1.17.2 // indirect
github.com/json-iterator/go v1.1.12 // indirect github.com/json-iterator/go v1.1.12 // indirect
github.com/jtolds/gls v4.20.0+incompatible // indirect github.com/jtolds/gls v4.20.0+incompatible // indirect
github.com/jxskiss/base62 v1.1.0 // indirect
github.com/klauspost/compress v1.13.5 // indirect github.com/klauspost/compress v1.13.5 // indirect
github.com/klauspost/cpuid v1.3.1 // indirect github.com/klauspost/cpuid v1.3.1 // indirect
github.com/minio/md5-simd v1.1.0 // indirect github.com/minio/md5-simd v1.1.0 // indirect
@ -37,6 +36,7 @@ require (
github.com/tklauser/go-sysconf v0.3.10 // indirect github.com/tklauser/go-sysconf v0.3.10 // indirect
github.com/tklauser/numcpus v0.4.0 // indirect github.com/tklauser/numcpus v0.4.0 // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect github.com/yusufpapurcu/wmi v1.2.2 // indirect
golang.org/x/crypto v0.0.0-20220331220935-ae2d96664a29 // indirect
golang.org/x/net v0.0.0-20220403103023-749bd193bc2b // indirect golang.org/x/net v0.0.0-20220403103023-749bd193bc2b // indirect
golang.org/x/sys v0.0.0-20220406155245-289d7a0edf71 // indirect golang.org/x/sys v0.0.0-20220406155245-289d7a0edf71 // indirect
golang.org/x/text v0.3.8-0.20211105212822-18b340fc7af2 // indirect golang.org/x/text v0.3.8-0.20211105212822-18b340fc7af2 // indirect

View File

@ -1,5 +1,7 @@
code.betamike.com/micropelago/pmux v0.0.0-20230706154656-fde8c2be7540 h1:ycD1mEkCbrx3Apr71Q2PKgyycRu8wvwX9J4ZSvjyTtQ= code.betamike.com/micropelago/pmux v0.0.0-20230706154656-fde8c2be7540 h1:ycD1mEkCbrx3Apr71Q2PKgyycRu8wvwX9J4ZSvjyTtQ=
code.betamike.com/micropelago/pmux v0.0.0-20230706154656-fde8c2be7540/go.mod h1:WlEWacLREVfIQl1IlBjKzuDgL56DFRvyl7YiL5gGP4w= code.betamike.com/micropelago/pmux v0.0.0-20230706154656-fde8c2be7540/go.mod h1:WlEWacLREVfIQl1IlBjKzuDgL56DFRvyl7YiL5gGP4w=
dev.mediocregopher.com/mediocre-go-lib.git v0.0.0-20240511135822-4ab1176672d7 h1:wKQ3bXzG+KQDtRAN/xaRZ4aQtJe1pccleG6V43MvFxw=
dev.mediocregopher.com/mediocre-go-lib.git v0.0.0-20240511135822-4ab1176672d7/go.mod h1:nP+AtQWrc3k5qq5y3ABiBLkOfUPlk/FO9fpTFpF+jgs=
github.com/adrg/xdg v0.4.0 h1:RzRqFcjH4nE5C6oTAxhBtoE2IRyjBSa62SCbyPidvls= github.com/adrg/xdg v0.4.0 h1:RzRqFcjH4nE5C6oTAxhBtoE2IRyjBSa62SCbyPidvls=
github.com/adrg/xdg v0.4.0/go.mod h1:N6ag73EX4wyxeaoeHctc1mas01KZgsj5tYiAIwqJE/E= github.com/adrg/xdg v0.4.0/go.mod h1:N6ag73EX4wyxeaoeHctc1mas01KZgsj5tYiAIwqJE/E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@ -36,8 +38,6 @@ github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfn
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/mediocregopher/mediocre-go-lib/v2 v2.0.0-beta.1.0.20221113151154-07f3889a705b h1:A+IqPY72GXChyCje7YqnZrb8Q4ajUqft/etsmIOobu4=
github.com/mediocregopher/mediocre-go-lib/v2 v2.0.0-beta.1.0.20221113151154-07f3889a705b/go.mod h1:wOZVlnKYvIbkzyCJ3dxy1k40XkirvCd1pisX2O91qoQ=
github.com/minio/md5-simd v1.1.0 h1:QPfiOqlZH+Cj9teu0t9b1nTBfPbyTl16Of5MeuShdK4= github.com/minio/md5-simd v1.1.0 h1:QPfiOqlZH+Cj9teu0t9b1nTBfPbyTl16Of5MeuShdK4=
github.com/minio/md5-simd v1.1.0/go.mod h1:XpBqgZULrMYD3R+M28PcmP0CkI7PEMzB3U77ZrKZ0Gw= github.com/minio/md5-simd v1.1.0/go.mod h1:XpBqgZULrMYD3R+M28PcmP0CkI7PEMzB3U77ZrKZ0Gw=
github.com/minio/minio-go/v7 v7.0.28 h1:VMr3K5qGIEt+/KW3poopRh8mzi5RwuCjmrmstK196Fg= github.com/minio/minio-go/v7 v7.0.28 h1:VMr3K5qGIEt+/KW3poopRh8mzi5RwuCjmrmstK196Fg=