Skip to content

Commit

Permalink
Merge remove packr go generate
Browse files Browse the repository at this point in the history
  • Loading branch information
rekby authored Jun 10, 2022
2 parents 0ba6ce8 + 4155370 commit c97228c
Show file tree
Hide file tree
Showing 65 changed files with 12 additions and 5,729 deletions.
11 changes: 0 additions & 11 deletions cmd/a_main-packr.go

This file was deleted.

29 changes: 11 additions & 18 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,29 @@ package main
import (
"bytes"
"context"
_ "embed"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"runtime"
"strings"

"github.com/rekby/lets-proxy2/internal/docker"

"github.com/BurntSushi/toml"
"github.com/rekby/lets-proxy2/internal/config"

"github.com/gobuffalo/packr"

"github.com/rekby/lets-proxy2/internal/profiler"
"github.com/rekby/lets-proxy2/internal/tlslistener"

"github.com/rekby/lets-proxy2/internal/proxy"

"github.com/rekby/lets-proxy2/internal/docker"
"github.com/rekby/lets-proxy2/internal/domain_checker"

"github.com/rekby/lets-proxy2/internal/log"

"github.com/BurntSushi/toml"
"github.com/rekby/lets-proxy2/internal/profiler"
"github.com/rekby/lets-proxy2/internal/proxy"
"github.com/rekby/lets-proxy2/internal/tlslistener"
zc "github.com/rekby/zapcontext"
"go.uber.org/zap"
)

//go:generate packr
//go:embed static/default-config.toml
var defaultConfigContent []byte

type configType struct {
General configGeneral
Log logConfig
Expand Down Expand Up @@ -122,10 +117,8 @@ func applyMoveConfigDetails(cfg *configType) {
}

func defaultConfig(ctx context.Context) []byte {
box := packr.NewBox("static")
configBytes, err := box.Find("default-config.toml")
configBytes = bytes.Replace(configBytes, []byte("\r\n"), []byte("\n"), -1)
log.DebugFatalCtx(ctx, err, "Got builtin default config")
configBytes := bytes.Replace(defaultConfigContent, []byte("\r\n"), []byte("\n"), -1)
log.DebugCtx(ctx, "Got builtin default config")
return configBytes
}

Expand Down
8 changes: 1 addition & 7 deletions cmd/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import (

"github.com/rekby/lets-proxy2/internal/th"

"github.com/gobuffalo/packr"

"github.com/maxatome/go-testdeep"
)

Expand All @@ -24,17 +22,13 @@ func TestConfigEmbed(t *testing.T) {
td.CmpNoError(err)
defer os.Rename("static/default-config.toml.tmp", "static/default-config.toml")

box := packr.NewBox("static")
boxBytes, err := box.Find("default-config.toml")
td.CmpNoError(err)

toUnixString := func(source []byte) string {
s := string(source)
s = strings.Replace(s, "\r\n", "\n", -1)
return s
}

td.CmpDeeply(toUnixString(boxBytes), toUnixString(sourceConfig))
td.CmpDeeply(toUnixString(defaultConfigContent), toUnixString(sourceConfig))
}

func TestReadConfig(t *testing.T) {
Expand Down
5 changes: 0 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ require (
github.com/BurntSushi/toml v1.1.0
github.com/aws/aws-sdk-go v1.44.32
github.com/docker/docker v20.10.17+incompatible // need old version for compatible with go1.10
github.com/gobuffalo/packr v1.30.1
github.com/gojuno/minimock/v3 v3.0.5
github.com/kardianos/minwinsvc v1.0.0
github.com/maxatome/go-testdeep v1.1.0
Expand Down Expand Up @@ -34,12 +33,9 @@ require (
github.com/docker/distribution v2.8.1+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.4.0 // indirect
github.com/gobuffalo/envy v1.10.1 // indirect
github.com/gobuffalo/packd v1.0.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/joho/godotenv v1.4.0 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
github.com/morikuni/aec v1.0.0 // indirect
Expand All @@ -48,7 +44,6 @@ require (
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/common v0.34.0 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/rogpeppe/go-internal v1.8.1 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
Expand Down
Loading

0 comments on commit c97228c

Please sign in to comment.