diff --git a/README.md b/README.md index 8b48df2..e8015dd 100644 --- a/README.md +++ b/README.md @@ -176,7 +176,7 @@ e46bfc69b893b659c4db713ba2cc84f1 GET /some/other/api ### Different output formats -By default Replay Zero generates Karate `*.feature` files and outputs them to the directory Replay Zero was started in. But the `--output` flag allows you to specify the format you'd like your tests to be generated in. The created files will always following the naming format `replay_scenarios_{N}.{extension}`. Currently the supported test formats are +By default Replay Zero generates Karate `*.feature` files and outputs them to the directory Replay Zero was started in. But the `--template` or `-t` flag allows you to specify the format you'd like your tests to be generated in. The created files will always following the naming format `replay_scenarios_{N}.{extension}`. Out of the box we support below test formats * Karate (`*.feature`) * Gatling (`*.scala`) @@ -184,9 +184,22 @@ By default Replay Zero generates Karate `*.feature` files and outputs them to th Specify the output as a lowercase input to the flag: ```sh -replay-zero --output=gatling +replay-zero --template=gatling ``` +#### Custom templates + +You can also pass path to your own custom template (in case you dont want to use karate or gatling) to the same paramater and `--extension` or `-e` to pass extentsion of the output. + +E.g. + +```sh +replay-zero --template=/path/to/your/custom-template --extension=java +``` + +Templates are following the format from the [text/template](https://golang.org/pkg/text/template/) package. And it also support all template functions provided by [Sprig](http://masterminds.github.io/sprig/). You can even extend your template's functionality with string manipulation, math operators, and more from the Sprig library + + ## Roadmap Replay Zero has many plans for improvement which you can find in the Issues tab of this repo. Now that you've read the entire README up until this point (right?) and know of all the features Replay Zero offers, here is a visual recap of both some of the features currently provided (multiple target proxying, output templating) as well as some planned roadmap items (remote proxyingm, custom template sourcing) and how they may fit in alongside existing features. diff --git a/go.mod b/go.mod index 66ac1ef..94d6445 100644 --- a/go.mod +++ b/go.mod @@ -8,11 +8,13 @@ require ( github.com/Masterminds/sprig v2.22.0+incompatible github.com/aws/aws-sdk-go v1.29.25 github.com/go-test/deep v1.0.5 + github.com/gobuffalo/here v0.6.2 // indirect github.com/google/uuid v1.1.1 // indirect github.com/huandu/xstrings v1.3.2 // indirect github.com/imdario/mergo v0.3.11 // indirect github.com/jmespath/go-jmespath v0.3.0 // indirect github.com/kylelemons/godebug v1.1.0 + github.com/markbates/pkger v0.17.1 github.com/mitchellh/copystructure v1.0.0 // indirect github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d github.com/spf13/pflag v1.0.5 diff --git a/go.sum b/go.sum index 5a03443..d870c5d 100644 --- a/go.sum +++ b/go.sum @@ -8,9 +8,15 @@ github.com/aws/aws-sdk-go v1.29.25 h1:03yt6K6vCxfxFHT7mXGqFeISsNDE27LO2u+5AQBnTz github.com/aws/aws-sdk-go v1.29.25/go.mod h1:1KvfttTE3SPKMpo8g2c6jL3ZKfXtFvKscTgahTma5Xg= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-test/deep v1.0.5 h1:AKODKU3pDH1RzZzm6YZu77YWtEAq6uh1rLIAQlay2qc= github.com/go-test/deep v1.0.5/go.mod h1:QV8Hv/iy04NyLBxAdO9njL0iVPN1S4d/A3NVv1V36o8= +github.com/gobuffalo/here v0.6.0 h1:hYrd0a6gDmWxBM4TnrGw8mQg24iSVoIkHEk7FodQcBI= +github.com/gobuffalo/here v0.6.0/go.mod h1:wAG085dHOYqUpf+Ap+WOdrPTp5IYcDAs/x7PLa8Y5fM= +github.com/gobuffalo/here v0.6.2 h1:ZtCqC7F9ou3moLbYfHM1Tj+gwHGgWhjyRjVjsir9BE0= +github.com/gobuffalo/here v0.6.2/go.mod h1:D75Sq0p2BVHdgQu3vCRsXbg85rx943V19urJpqAVWjI= github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/huandu/xstrings v1.3.2 h1:L18LIDzqlW6xN2rEkpdV8+oL/IXWJ1APd+vsdYy4Wdw= @@ -21,8 +27,16 @@ github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5i github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmespath/go-jmespath v0.3.0 h1:OS12ieG61fsCg5+qLJ+SsW9NicxNkg3b25OyT2yCeUc= github.com/jmespath/go-jmespath v0.3.0/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeYCZ7fLUTSywik= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs= +github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +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/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/markbates/pkger v0.17.1 h1:/MKEtWqtc0mZvu9OinB9UzVN9iYCwLWuyUv4Bw+PCno= +github.com/markbates/pkger v0.17.1/go.mod h1:0JoVlrol20BSywW79rN3kdFFsE5xYM+rSCQDXbLhiuI= github.com/mitchellh/copystructure v1.0.0 h1:Laisrj+bAB6b/yJwB5Bt3ITZhGJdqmxquMKeZ+mmkFQ= github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= github.com/mitchellh/reflectwalk v1.0.0 h1:9D+8oIskB4VJBN5SFlmc27fSlIBZaov1Wpk/IfikLNY= @@ -51,7 +65,12 @@ golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/main.go b/main.go index 87c31b7..0e534bc 100644 --- a/main.go +++ b/main.go @@ -11,9 +11,9 @@ import ( "strings" "syscall" + "github.com/markbates/pkger" flag "github.com/spf13/pflag" - "github.com/intuit/replay-zero/templates" "github.com/ztrue/shutdown" ) @@ -31,7 +31,8 @@ var ( listenPort int defaultTargetPort int batchSize int - output string + template string + extension string debug bool streamRoleArn string streamName string @@ -81,10 +82,11 @@ func readFlags() { } flag.BoolVarP(&flags.version, "version", "V", false, "Print version info and exit") flag.IntVarP(&flags.listenPort, "listen-port", "l", 9000, "The port the Replay Zero proxy will listen on") - flag.IntVarP(&flags.defaultTargetPort, "target-port", "t", 8080, "The port the Replay Zero proxy will forward to on localhost") + flag.IntVarP(&flags.defaultTargetPort, "target-port", "p", 8080, "The port the Replay Zero proxy will forward to on localhost") flag.BoolVar(&flags.debug, "debug", false, "Set logging to also print debug messages") flag.IntVarP(&flags.batchSize, "batch-size", "b", 1, "Buffer events before writing out to a file") - flag.StringVarP(&flags.output, "output", "o", "karate", "Either [karate] or [gatling]") + flag.StringVarP(&flags.template, "template", "t", "karate", "Either [karate] or [gatling] or [path/to/custom/template]") + flag.StringVarP(&flags.extension, "extension", "e", "", "For custom output template") flag.StringVarP(&flags.streamName, "stream-name", "s", "", "AWS Kinesis Stream name (streaming mode only)") flag.StringVarP(&flags.streamRoleArn, "stream-role-arn", "r", "", "AWS Kinesis Stream ARN (streaming mode only)") flag.Parse() @@ -100,25 +102,61 @@ func readFlags() { } else if flags.batchSize > 1 { log.Printf("Using fixed batch size of %d\n", flags.batchSize) } + + // check if template exist at the provided path + // TODO: add validation for correctness of template + if !(flags.template == "karate" || flags.template == "gatling") { + _, err := ioutil.ReadFile(flags.template) + if err != nil { + log.Printf("Failed to load template") + panic(err) + } + if flags.extension == "" { + log.Fatal("For custom template, output extension is expected to be passed using --extension or -e flag.") + os.Exit(0) + } + } +} + +// get embeded template file content +func getPkgTemplate(filePath string) string { + f, err := pkger.Open(filePath) + if err != nil { + panic(err) + } + defer f.Close() + info, err := f.Stat() + if err != nil { + panic(err) + } + b := make([]byte, info.Size()) + content, err := f.Read(b) + if err != nil { + panic(err) + } + return string(b[:content]) } -func getFormat(output string) outputFormat { - switch output { +func getFormat(template string, extension string) outputFormat { + switch template { case "karate": return outputFormat{ - template: templates.KarateBase, + template: getPkgTemplate("/templates/karate_default.template"), extension: "feature", } case "gatling": return outputFormat{ - template: templates.GatlingBase, + template: getPkgTemplate("/templates/gatling_default.template"), extension: "scala", } default: - log.Printf("Unknown output '%s', defaulting to karate", output) + dat, err := ioutil.ReadFile(template) + if err != nil { + panic(err) + } return outputFormat{ - template: templates.KarateBase, - extension: "feature", + template: string(dat), + extension: extension, } } } @@ -207,8 +245,8 @@ func main() { log.Println("Running ONLINE, sending recorded events to Kinesis") h = getOnlineHandler(flags.streamName, flags.streamRoleArn) } else { - log.Printf("Running OFFLINE, writing out events to %s files\n", flags.output) - h = getOfflineHandler(flags.output) + log.Printf("Running OFFLINE, writing out events to %s files\n", flags.template) + h = getOfflineHandler(flags.template, flags.extension) } shutdown.Add(func() { diff --git a/offline.go b/offline.go index a428dac..88b9cdd 100644 --- a/offline.go +++ b/offline.go @@ -34,9 +34,9 @@ type offlineHandler struct { templateFuncMap template.FuncMap } -func getOfflineHandler(output string) eventHandler { +func getOfflineHandler(template string, extension string) eventHandler { return &offlineHandler{ - format: getFormat(output), + format: getFormat(template, extension), defaultBatchSize: flags.batchSize, currentBatchSize: flags.batchSize, writerFactory: getFileWriter, diff --git a/templates/gatling_default.template b/templates/gatling_default.template new file mode 100644 index 0000000..7187a19 --- /dev/null +++ b/templates/gatling_default.template @@ -0,0 +1,66 @@ +package com.yourcompany.perf.yourservice + +// Generated by Replay Zero at {{ now }} + +import io.gatling.core.Predef._ +import io.gatling.core.structure.ScenarioBuilder +import io.gatling.http.Predef._ +import io.gatling.http.protocol.HttpProtocolBuilder + +class YourServiceBaseline extends Simulation { + +val TP99_RESPONSE_TIME = 1600 +val TP90_RESPONSE_TIME = 800 +val TP50_RESPONSE_TIME = 600 +val AVAILABILITY_RATE = 99 + +val testDuration: Integer = java.lang.Integer.getInteger("duration", 10) +val rampDuration: Integer = java.lang.Integer.getInteger("ramp", 2) +require(rampDuration > 0, "Ramp duration must be a natural number!") + +val steadyStateDuration: Integer = testDuration.intValue() - rampDuration.intValue() +require(steadyStateDuration > 0, "Total test duration must be greater than ramp duration!") + +val initialTps: Int = java.lang.Integer.getInteger("initial", 5) +val steadyStateTps: Int = java.lang.Integer.getInteger("steady", 100) +val host: String = System.getProperty("host", "TODO: put your service's base URL here") +val httpProtocol: HttpProtocolBuilder = http.baseURL(host) + +{{ range $index, $event := . -}} +val scenario_{{$index}}: ScenarioBuilder = scenario("scenario_{{$index}}") + .exec(http("http_{{$index}}")) + .{{lower $event.HTTPMethod}}("{{$event.Endpoint}}") + {{- if gt (len $event.ReqHeaders) 0}} + .headers( + {{- range $h_index, $header := $event.ReqHeaders}} + {{- if $h_index -}},{{end}} + "{{$header.Name}}" = "{{$header.Value}}" + {{- end}} + ) + {{- end}} + {{- if $event.ReqBody}} + .body(StringBody( + """ + {{ $event.ReqBody }} + """ + )){{- end }} + +{{ end -}} +{{- println -}} +setUp( + {{- $toSkip := sub (len .) 1}} + {{- range $index, $event := . }} + scenario_{{$index}}.inject(rampUsersPerSec(initialTps) to steadyStateTps during (rampDuration minutes), + constantUsersPerSec(steadyStateTps) during (steadyStateDuration minutes)){{if ne $index $toSkip }},{{end}} + {{- end }} +) + .protocols(httpProtocol) + .assertions( + {{- range $index, $event := . -}} + {{- range $k, $v := dict "1" "99" "2" "90" "3" "50"}} + details("http_{{$index}}").responseTime.percentile{{$k}}.lessThan(TP{{$v}}_RESPONSE_TIME), + {{- end}} + {{- end}} + global.failedRequests.percent.lessThan(100 - AVAILABILITY_RATE) + ) +} \ No newline at end of file diff --git a/templates/karate_default.template b/templates/karate_default.template new file mode 100644 index 0000000..decd829 --- /dev/null +++ b/templates/karate_default.template @@ -0,0 +1,34 @@ +# Generated by Replay Zero at {{ now }} +Feature: + + Background: + * url 'http://localhost:8080' +{{ range $index, $event := . }} + Scenario: test scenario {{.PairID}} + Given path '{{ $event.Endpoint }}' + {{/* add request headers if present */ -}} + {{ range $header := $event.ReqHeaders -}} + And header {{$header.Name}} = '{{$header.Value}}' + {{end }} + {{- /* add request body if present */ -}} + {{ if $event.ReqBody -}} + And request + """ + {{ $event.ReqBody }} + """ + {{- end }} + + When method {{ $event.HTTPMethod }} + Then status {{ $event.ResponseCode }} + {{/* assert on response headers if present */ -}} + {{ range $header := $event.RespHeaders -}} + And match header {{$header.Name}} == '{{$header.Value}}' + {{end }} + {{- /* assert on response body if present */ -}} + {{ if $event.RespBody -}} + And match response == + """ + {{ $event.RespBody }} + """ + {{- end }} +{{ end }} \ No newline at end of file diff --git a/vendor/github.com/gobuffalo/here/.gitignore b/vendor/github.com/gobuffalo/here/.gitignore new file mode 100644 index 0000000..d188dc0 --- /dev/null +++ b/vendor/github.com/gobuffalo/here/.gitignore @@ -0,0 +1,28 @@ +*.log +.DS_Store +doc +tmp +pkg +*.pid +coverage +coverage.data +build/* +*.pbxuser +*.mode1v3 +.svn +profile +.console_history +.sass-cache/* +solr/ +.jhw-cache/ +jhw.* +*.sublime* +node_modules/ +dist/ +generated/ +.vendor/ +bin/* +gin-bin +.idea/ +.vscode +cover.out diff --git a/vendor/github.com/gobuffalo/here/.goreleaser.yml b/vendor/github.com/gobuffalo/here/.goreleaser.yml new file mode 100644 index 0000000..0ea9d65 --- /dev/null +++ b/vendor/github.com/gobuffalo/here/.goreleaser.yml @@ -0,0 +1,45 @@ +builds: + - + main: ./cmd/here/main.go + env: + - CGO_ENABLED=0 + ldflags: + - -s -w -X "github.com/gobuffalo/here.Version={{.Tag}}" + goos: + - darwin + - linux + - windows + goarch: + - amd64 + - 386 + - arm + - arm64 + goarm: + - 6 + - 7 +archives: + - + replacements: + '386': i386 + darwin: Darwin + linux: Linux + windows: Windows + amd64: x86_64 +checksum: + name_template: checksums.txt +snapshot: + name_template: '{{ .Tag }}-next' +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' +brews: + - + name: 'here' + github: + owner: 'gobuffalo' + name: 'homebrew-tap' + install: | + bin.install "here" diff --git a/vendor/github.com/gobuffalo/here/LICENSE b/vendor/github.com/gobuffalo/here/LICENSE new file mode 100644 index 0000000..649efd4 --- /dev/null +++ b/vendor/github.com/gobuffalo/here/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2019 Mark Bates + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/vendor/github.com/gobuffalo/here/Makefile b/vendor/github.com/gobuffalo/here/Makefile new file mode 100644 index 0000000..3be6fb1 --- /dev/null +++ b/vendor/github.com/gobuffalo/here/Makefile @@ -0,0 +1,50 @@ +TAGS ?= "" +GO_BIN ?= "go" + + +install: tidy + cd ./cmd/here && $(GO_BIN) install -tags ${TAGS} -v . + make tidy + +tidy: + $(GO_BIN) mod tidy -v + +build: tidy + $(GO_BIN) build -v . + make tidy + +test: tidy + $(GO_BIN) test -count 1 -cover -tags ${TAGS} -timeout 10s ./... + make tidy + +cov: + $(GO_BIN) test -coverprofile cover.out -count 1 -tags ${TAGS} ./... + go tool cover -html cover.out + make tidy + +ci-test: + $(GO_BIN) test -tags ${TAGS} -race ./... + +lint: + go get github.com/golangci/golangci-lint/cmd/golangci-lint + golangci-lint run --enable-all + make tidy + +update: + rm go.* + $(GO_BIN) mod init + $(GO_BIN) mod tidy + make test + make install + make tidy + +release-test: + $(GO_BIN) test -tags ${TAGS} -race ./... + make tidy + +release: + make tidy + release -y -f version.go --skip-packr + make tidy + + diff --git a/vendor/github.com/gobuffalo/here/README.md b/vendor/github.com/gobuffalo/here/README.md new file mode 100644 index 0000000..79bc3d8 --- /dev/null +++ b/vendor/github.com/gobuffalo/here/README.md @@ -0,0 +1,277 @@ +# Here + +[![](https://github.com/gobuffalo/here/workflows/Tests/badge.svg)](https://github.com/gobuffalo/here/actions) +[![GoDoc](https://godoc.org/github.com/gobuffalo/here?status.svg)](https://godoc.org/github.com/gobuffalo/here) + +Here will get you **accurate** Go information about the directory of package requested. + +### Requirements + +* Go 1.13+ +* Go Modules + +## CLI + +While you can use the tool via its API, you can also use the CLI to get a JSON version of the data. + +### Installation + +```bash +$ go get github.com/gobuffalo/here/cmd/here +``` + +### Usage + +#### Default + +```bash +$ here + +{ + "Dir": "$GOPATH/src/github.com/gobuffalo/here", + "ImportPath": "github.com/gobuffalo/here", + "Name": "here", + "Doc": "", + "Target": "$GOPATH/pkg/darwin_amd64/github.com/gobuffalo/here.a", + "Root": "$GOPATH", + "Match": [ + "." + ], + "Stale": true, + "StaleReason": "not installed but available in build cache", + "GoFiles": [ + "current.go", + "dir.go", + "here.go", + "info.go", + "info_map.go", + "module.go", + "pkg.go", + "version.go" + ], + "Imports": [ + "bytes", + "encoding/json", + "fmt", + "os", + "os/exec", + "path/filepath", + "regexp", + "sync" + ], + "Deps": [ + "bytes", + "context", + "encoding", + "encoding/base64", + "encoding/binary", + "encoding/json", + "errors", + "fmt", + "internal/bytealg", + "internal/cpu", + "internal/fmtsort", + "internal/oserror", + "internal/poll", + "internal/race", + "internal/reflectlite", + "internal/syscall/unix", + "internal/testlog", + "io", + "math", + "math/bits", + "os", + "os/exec", + "path/filepath", + "reflect", + "regexp", + "regexp/syntax", + "runtime", + "runtime/internal/atomic", + "runtime/internal/math", + "runtime/internal/sys", + "sort", + "strconv", + "strings", + "sync", + "sync/atomic", + "syscall", + "time", + "unicode", + "unicode/utf16", + "unicode/utf8", + "unsafe" + ], + "TestGoFiles": [ + "current_test.go", + "dir_test.go", + "here_test.go", + "info_test.go", + "module_test.go", + "pkg_test.go" + ], + "TestImports": [ + "github.com/stretchr/testify/require", + "os", + "path/filepath", + "testing" + ], + "Module": { + "Path": "github.com/gobuffalo/here", + "Main": true, + "Dir": "$GOPATH/src/github.com/gobuffalo/here", + "GoMod": "$GOPATH/src/github.com/gobuffalo/here/go.mod", + "GoVersion": "1.13" + } +} +``` + +#### By Directory + +```bash +$ here cmd/here + +{ + "Dir": "$GOPATH/src/github.com/gobuffalo/here/cmd/here", + "ImportPath": "github.com/gobuffalo/here/cmd/here", + "Name": "main", + "Doc": "", + "Target": "$GOPATH/bin/here", + "Root": "$GOPATH", + "Match": [ + "." + ], + "Stale": false, + "StaleReason": "", + "GoFiles": [ + "main.go" + ], + "Imports": [ + "fmt", + "github.com/gobuffalo/here", + "log", + "os", + "os/exec" + ], + "Deps": [ + "bytes", + "context", + "encoding", + "encoding/base64", + "encoding/binary", + "encoding/json", + "errors", + "fmt", + "github.com/gobuffalo/here", + "internal/bytealg", + "internal/cpu", + "internal/fmtsort", + "internal/oserror", + "internal/poll", + "internal/race", + "internal/reflectlite", + "internal/syscall/unix", + "internal/testlog", + "io", + "log", + "math", + "math/bits", + "os", + "os/exec", + "path/filepath", + "reflect", + "regexp", + "regexp/syntax", + "runtime", + "runtime/internal/atomic", + "runtime/internal/math", + "runtime/internal/sys", + "sort", + "strconv", + "strings", + "sync", + "sync/atomic", + "syscall", + "time", + "unicode", + "unicode/utf16", + "unicode/utf8", + "unsafe" + ], + "TestGoFiles": null, + "TestImports": null, + "Module": { + "Path": "github.com/gobuffalo/here", + "Main": true, + "Dir": "$GOPATH/src/github.com/gobuffalo/here", + "GoMod": "$GOPATH/src/github.com/gobuffalo/here/go.mod", + "GoVersion": "1.13" + } +} +``` + +#### By Package + +```bash +$ here pkg github.com/gobuffalo/genny + +{ + "Dir": "$GOPATH/pkg/mod/github.com/gobuffalo/genny@v0.4.1", + "ImportPath": "github.com/gobuffalo/genny", + "Name": "genny", + "Doc": "Package genny is a _framework_ for writing modular generators, it however, doesn't actually generate anything.", + "Target": "", + "Root": "$GOPATH/pkg/mod/github.com/gobuffalo/genny@v0.4.1", + "Match": [ + "github.com/gobuffalo/genny" + ], + "Stale": true, + "StaleReason": "build ID mismatch", + "GoFiles": [ + "confirm.go", + "dir.go", + "disk.go", + "dry_runner.go", + "events.go", + "file.go", + "force.go", + "generator.go", + "genny.go", + "group.go", + "helpers.go", + "logger.go", + "replacer.go", + "results.go", + "runner.go", + "step.go", + "transformer.go", + "version.go", + "wet_runner.go" + ], + "Imports": null, + "Deps": null, + "TestGoFiles": [ + "dry_runner_test.go", + "file_test.go", + "force_test.go", + "generator_test.go", + "genny_test.go", + "group_test.go", + "helpers_test.go", + "replacer_test.go", + "results_test.go", + "runner_test.go", + "step_test.go", + "transformer_test.go", + "wet_runner_test.go" + ], + "TestImports": null, + "Module": { + "Path": "github.com/gobuffalo/genny", + "Main": false, + "Dir": "$GOPATH/pkg/mod/github.com/gobuffalo/genny@v0.4.1", + "GoMod": "$GOPATH/pkg/mod/cache/download/github.com/gobuffalo/genny/@v/v0.4.1.mod", + "GoVersion": "1.13" + } +} +``` diff --git a/vendor/github.com/gobuffalo/here/SHOULDERS.md b/vendor/github.com/gobuffalo/here/SHOULDERS.md new file mode 100644 index 0000000..ae560b7 --- /dev/null +++ b/vendor/github.com/gobuffalo/here/SHOULDERS.md @@ -0,0 +1,24 @@ +# github.com/gobuffalo/here Stands on the Shoulders of Giants + +github.com/gobuffalo/here does not try to reinvent the wheel! Instead, it uses the already great wheels developed by the Go community and puts them all together in the best way possible. Without these giants, this project would not be possible. Please make sure to check them out and thank them for all of their hard work. + +Thank you to the following **GIANTS**: + + +* [github.com/davecgh/go-spew](https://godoc.org/github.com/davecgh/go-spew) + +* [github.com/kr/pretty](https://godoc.org/github.com/kr/pretty) + +* [github.com/kr/pty](https://godoc.org/github.com/kr/pty) + +* [github.com/kr/text](https://godoc.org/github.com/kr/text) + +* [github.com/pmezard/go-difflib](https://godoc.org/github.com/pmezard/go-difflib) + +* [github.com/stretchr/objx](https://godoc.org/github.com/stretchr/objx) + +* [github.com/stretchr/testify](https://godoc.org/github.com/stretchr/testify) + +* [gopkg.in/check.v1](https://godoc.org/gopkg.in/check.v1) + +* [gopkg.in/yaml.v2](https://godoc.org/gopkg.in/yaml.v2) diff --git a/vendor/github.com/gobuffalo/here/current.go b/vendor/github.com/gobuffalo/here/current.go new file mode 100644 index 0000000..fb5b3e8 --- /dev/null +++ b/vendor/github.com/gobuffalo/here/current.go @@ -0,0 +1,31 @@ +package here + +import ( + "path/filepath" +) + +// Current returns the Info representing the current Go module +func (h Here) Current() (Info, error) { + hp := &h + (&hp.curOnce).Do(func() { + b, err := run("go", "env", "GOMOD") + if err != nil { + hp.curErr = err + return + } + root := filepath.Dir(string(b)) + i, err := h.Dir(root) + if err != nil { + hp.curErr = err + return + } + hp.current = i + }) + + return h.current, h.curErr +} + +// Current returns the Info representing the current Go module +func Current() (Info, error) { + return New().Current() +} diff --git a/vendor/github.com/gobuffalo/here/dir.go b/vendor/github.com/gobuffalo/here/dir.go new file mode 100644 index 0000000..95be28d --- /dev/null +++ b/vendor/github.com/gobuffalo/here/dir.go @@ -0,0 +1,84 @@ +package here + +import ( + "encoding/json" + "fmt" + "os" + "path/filepath" +) + +// Dir attempts to gather info for the requested directory. +func (h Here) Dir(p string) (Info, error) { + i, err := h.cache(p, func(p string) (Info, error) { + var i Info + + fi, err := os.Stat(p) + if err != nil { + return i, err + } + + if !fi.IsDir() { + p = filepath.Dir(p) + } + + pwd, err := os.Getwd() + if err != nil { + return i, err + } + + defer os.Chdir(pwd) + + os.Chdir(p) + + b, err := run("go", "list", "-json") + // go: cannot find main module; see 'go help modules' + // build .: cannot find module for path . + // no Go files in + if err != nil { + if nonGoDirRx.MatchString(err.Error()) { + return fromNonGoDir(p) + } + return i, err + } + + if err := json.Unmarshal(b, &i); err != nil { + return i, err + } + + return i, nil + }) + + if err != nil { + return i, fmt.Errorf("here.Dir: %s: %w", p, err) + } + + return h.cache(i.ImportPath, func(p string) (Info, error) { + return i, nil + }) +} + +// Dir attempts to gather info for the requested directory. +func Dir(p string) (Info, error) { + return New().Dir(p) +} + +func fromNonGoDir(dir string) (Info, error) { + i := Info{ + Dir: dir, + Name: filepath.Base(dir), + } + + b, err := run("go", "list", "-json", "-m") + if err != nil { + if nonGoDirRx.MatchString(err.Error()) { + return i, nil + } + return i, fmt.Errorf("here.nonGoDir: %s: %w", dir, err) + } + + if err := json.Unmarshal(b, &i.Module); err != nil { + return i, fmt.Errorf("here.nonGoDir: %s: %w", dir, err) + } + + return i, nil +} diff --git a/vendor/github.com/gobuffalo/here/go.mod b/vendor/github.com/gobuffalo/here/go.mod new file mode 100644 index 0000000..26c922f --- /dev/null +++ b/vendor/github.com/gobuffalo/here/go.mod @@ -0,0 +1,11 @@ +module github.com/gobuffalo/here + +go 1.13 + +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/kr/pretty v0.2.0 // indirect + github.com/stretchr/testify v1.5.1 + gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect + gopkg.in/yaml.v2 v2.2.8 // indirect +) diff --git a/vendor/github.com/gobuffalo/here/go.sum b/vendor/github.com/gobuffalo/here/go.sum new file mode 100644 index 0000000..e4630f1 --- /dev/null +++ b/vendor/github.com/gobuffalo/here/go.sum @@ -0,0 +1,22 @@ +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs= +github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +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/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/vendor/github.com/gobuffalo/here/here.go b/vendor/github.com/gobuffalo/here/here.go new file mode 100644 index 0000000..69966a7 --- /dev/null +++ b/vendor/github.com/gobuffalo/here/here.go @@ -0,0 +1,57 @@ +package here + +import ( + "bytes" + "fmt" + "os/exec" + "regexp" + "sync" +) + +type Here struct { + infos *infoMap + curOnce sync.Once + curErr error + current Info +} + +// New returns a Here type that will cache +// all results. This speeds up repeated calls, +// and can be useful for testing. +func New() Here { + return Here{ + infos: &infoMap{ + data: &sync.Map{}, + }, + } +} + +func run(n string, args ...string) ([]byte, error) { + c := exec.Command(n, args...) + + bb := &bytes.Buffer{} + ebb := &bytes.Buffer{} + c.Stdout = bb + c.Stderr = ebb + err := c.Run() + if err != nil { + return nil, fmt.Errorf("%v %w: %s", c.Args, err, ebb) + } + + return bb.Bytes(), nil +} + +func (h Here) cache(p string, fn func(string) (Info, error)) (Info, error) { + i, ok := h.infos.Load(p) + if ok { + return i, nil + } + i, err := fn(p) + if err != nil { + return i, fmt.Errorf("here.cache: %s: %w", p, err) + } + h.infos.Store(p, i) + return i, nil +} + +var nonGoDirRx = regexp.MustCompile(`cannot find main|go help modules|go: |build .:|no Go files|can't load package|not using modules`) diff --git a/vendor/github.com/gobuffalo/here/info.go b/vendor/github.com/gobuffalo/here/info.go new file mode 100644 index 0000000..a6101cf --- /dev/null +++ b/vendor/github.com/gobuffalo/here/info.go @@ -0,0 +1,39 @@ +package here + +import ( + "encoding/json" +) + +// Info represents details about the directory/package +type Info struct { + Dir string + ImportPath string + Name string + Doc string + Target string + Root string + Match []string + Stale bool + StaleReason string + GoFiles []string + Imports []string + Deps []string + TestGoFiles []string + TestImports []string + Module Module +} + +// IsZero checks if the type has been filled +// with rich chocolately data goodness +func (i Info) IsZero() bool { + return i.String() == Info{}.String() +} + +func (i Info) String() string { + b, err := json.MarshalIndent(i, "", " ") + if err != nil { + return err.Error() + } + s := string(b) + return s +} diff --git a/vendor/github.com/gobuffalo/here/info_map.go b/vendor/github.com/gobuffalo/here/info_map.go new file mode 100644 index 0000000..b3212a5 --- /dev/null +++ b/vendor/github.com/gobuffalo/here/info_map.go @@ -0,0 +1,32 @@ +// Code generated by github.com/gobuffalo/mapgen. DO NOT EDIT. + +package here + +import ( + "sync" +) + +// infoMap wraps sync.Map and uses the following types: +// key: string +// value: Info +type infoMap struct { + data *sync.Map +} + +// Load the key from the map. +// Returns Info or bool. +// A false return indicates either the key was not found +// or the value is not of type Info +func (m *infoMap) Load(key string) (Info, bool) { + i, ok := m.data.Load(key) + if !ok { + return Info{}, false + } + s, ok := i.(Info) + return s, ok +} + +// Store a Info in the map +func (m *infoMap) Store(key string, value Info) { + m.data.Store(key, value) +} diff --git a/vendor/github.com/gobuffalo/here/module.go b/vendor/github.com/gobuffalo/here/module.go new file mode 100644 index 0000000..c9cd60d --- /dev/null +++ b/vendor/github.com/gobuffalo/here/module.go @@ -0,0 +1,29 @@ +package here + +import ( + "encoding/json" +) + +type Module struct { + Path string + Main bool + Dir string + GoMod string + GoVersion string +} + +func (i Module) String() string { + b, err := json.MarshalIndent(i, "", " ") + if err != nil { + return err.Error() + } + return string(b) +} + +func (i Module) IsZero() bool { + const cla = "command-line-arguments" + if i.Path == cla { + i.Path = "" + } + return i.String() == Module{}.String() +} diff --git a/vendor/github.com/gobuffalo/here/parse.go b/vendor/github.com/gobuffalo/here/parse.go new file mode 100644 index 0000000..9b6abcd --- /dev/null +++ b/vendor/github.com/gobuffalo/here/parse.go @@ -0,0 +1,64 @@ +package here + +import ( + "fmt" + "path/filepath" + "regexp" + "strings" +) + +func (i Info) Parse(p string) (Path, error) { + p = strings.TrimSpace(p) + p = filepath.Clean(p) + p = strings.TrimPrefix(p, i.Dir) + + p = strings.Replace(p, "\\", "/", -1) + p = strings.TrimSpace(p) + + if len(p) == 0 || p == ":" || p == "." { + return i.build("", "", "") + } + + res := pathrx.FindAllStringSubmatch(p, -1) + if len(res) == 0 { + return Path{}, fmt.Errorf("could not parse %q", p) + } + + matches := res[0] + + if len(matches) != 4 { + return Path{}, fmt.Errorf("could not parse %q", p) + } + + return i.build(p, matches[1], matches[3]) +} + +func (i Info) build(p, pkg, name string) (Path, error) { + pt := Path{ + Pkg: pkg, + Name: name, + } + + if strings.HasPrefix(pt.Pkg, "/") || len(pt.Pkg) == 0 { + pt.Name = pt.Pkg + pt.Pkg = i.Module.Path + } + + if len(pt.Name) == 0 { + pt.Name = "/" + } + + if pt.Pkg == pt.Name { + pt.Pkg = i.Module.Path + pt.Name = "/" + } + + if !strings.HasPrefix(pt.Name, "/") { + pt.Name = "/" + pt.Name + } + pt.Name = strings.TrimPrefix(pt.Name, i.Dir) + + return pt, nil +} + +var pathrx = regexp.MustCompile("([^:]+)(:(/.+))?") diff --git a/vendor/github.com/gobuffalo/here/path.go b/vendor/github.com/gobuffalo/here/path.go new file mode 100644 index 0000000..b3b3ad0 --- /dev/null +++ b/vendor/github.com/gobuffalo/here/path.go @@ -0,0 +1,20 @@ +package here + +import ( + "fmt" +) + +type Path struct { + Pkg string + Name string +} + +func (p Path) String() string { + if p.Name == "" { + p.Name = "/" + } + if p.Pkg == "" { + return p.Name + } + return fmt.Sprintf("%s:%s", p.Pkg, p.Name) +} diff --git a/vendor/github.com/gobuffalo/here/pkg.go b/vendor/github.com/gobuffalo/here/pkg.go new file mode 100644 index 0000000..d79b58a --- /dev/null +++ b/vendor/github.com/gobuffalo/here/pkg.go @@ -0,0 +1,57 @@ +package here + +import ( + "encoding/json" + "fmt" +) + +// Package attempts to gather info for the requested package. +// +// From the `go help list` docs: +// The -find flag causes list to identify the named packages but not +// resolve their dependencies: the Imports and Deps lists will be empty. +// +// A workaround for this issue is to use the `Dir` field in the +// returned `Info` value and pass it to the `Dir(string) (Info, error)` +// function to return the complete data. +func (h Here) Package(p string) (Info, error) { + i, err := h.cache(p, func(p string) (Info, error) { + var i Info + if len(p) == 0 || p == "." { + return i, fmt.Errorf("missing package name") + } + b, err := run("go", "list", "-json", "-find", p) + if err != nil { + return i, err + } + if err := json.Unmarshal(b, &i); err != nil { + return i, err + } + + return i, nil + }) + + if err != nil { + return i, fmt.Errorf("here.Package: %s: %w", p, err) + } + + h.cache(i.Dir, func(p string) (Info, error) { + return i, nil + }) + + return i, nil + +} + +// Package attempts to gather info for the requested package. +// +// From the `go help list` docs: +// The -find flag causes list to identify the named packages but not +// resolve their dependencies: the Imports and Deps lists will be empty. +// +// A workaround for this issue is to use the `Dir` field in the +// returned `Info` value and pass it to the `Dir(string) (Info, error)` +// function to return the complete data. +func Package(p string) (Info, error) { + return New().Package(p) +} diff --git a/vendor/github.com/gobuffalo/here/version.go b/vendor/github.com/gobuffalo/here/version.go new file mode 100644 index 0000000..97fdbe8 --- /dev/null +++ b/vendor/github.com/gobuffalo/here/version.go @@ -0,0 +1,4 @@ +package here + +// Version of here +var Version = "development" diff --git a/vendor/github.com/markbates/pkger/.gitignore b/vendor/github.com/markbates/pkger/.gitignore new file mode 100644 index 0000000..5d3a9cc --- /dev/null +++ b/vendor/github.com/markbates/pkger/.gitignore @@ -0,0 +1,35 @@ +.fstest +*.log +.DS_Store +doc +tmp +pkg +*.gem +*.pid +coverage +coverage.data +build/* +*.pbxuser +*.mode1v3 +.svn +profile +.console_history +.sass-cache/* +.rake_tasks~ +*.log.lck +solr/ +.jhw-cache/ +jhw.* +*.sublime* +node_modules/ +dist/ +generated/ +.vendor/ +bin/* +gin-bin +.idea/ +pkged.go +cover.out +.pkgtest +example +app diff --git a/vendor/github.com/markbates/pkger/.goreleaser.yml b/vendor/github.com/markbates/pkger/.goreleaser.yml new file mode 100644 index 0000000..567628b --- /dev/null +++ b/vendor/github.com/markbates/pkger/.goreleaser.yml @@ -0,0 +1,45 @@ +builds: + - + main: ./cmd/pkger/main.go + env: + - CGO_ENABLED=0 + ldflags: + - -s -w -X "github.com/markbates/pkger.Version={{.Tag}}" + goos: + - darwin + - linux + - windows + goarch: + - amd64 + - 386 + - arm + - arm64 + goarm: + - 6 + - 7 +archives: + - + replacements: + '386': i386 + darwin: Darwin + linux: Linux + windows: Windows + amd64: x86_64 +checksum: + name_template: checksums.txt +snapshot: + name_template: '{{ .Tag }}-next' +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' +brews: + - + name: 'pkger' + github: + owner: 'markbates' + name: 'homebrew-tap' + install: | + bin.install "pkger" diff --git a/vendor/github.com/markbates/pkger/LICENSE b/vendor/github.com/markbates/pkger/LICENSE new file mode 100644 index 0000000..649efd4 --- /dev/null +++ b/vendor/github.com/markbates/pkger/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2019 Mark Bates + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/vendor/github.com/markbates/pkger/Makefile b/vendor/github.com/markbates/pkger/Makefile new file mode 100644 index 0000000..380c6d7 --- /dev/null +++ b/vendor/github.com/markbates/pkger/Makefile @@ -0,0 +1,54 @@ +TAGS ?= "" +GO_BIN ?= "go" + + +install: tidy + cd ./cmd/pkger && $(GO_BIN) install -tags ${TAGS} -v . + make tidy + +run: install + cd ./examples/app; pkger + +tidy: + $(GO_BIN) mod tidy -v + +build: tidy + $(GO_BIN) build -v . + make tidy + +test: tidy + $(GO_BIN) test -count 1 -cover -tags ${TAGS} -timeout 1m ./... + make tidy + +cov: + $(GO_BIN) test -coverprofile cover.out -tags ${TAGS} ./... + go tool cover -html cover.out + make tidy + +ci-test: + $(GO_BIN) test -tags ${TAGS} -race ./... + +lint: + go get github.com/golangci/golangci-lint/cmd/golangci-lint + golangci-lint run --enable-all + make tidy + +update: + rm go.* + $(GO_BIN) mod init + $(GO_BIN) mod tidy + make test + make install + make tidy + +release-test: + $(GO_BIN) test -tags ${TAGS} -race ./... + make tidy + +release: + $(GO_BIN) get github.com/gobuffalo/release + make tidy + release -y -f version.go --skip-packr + make tidy + + diff --git a/vendor/github.com/markbates/pkger/README.md b/vendor/github.com/markbates/pkger/README.md new file mode 100644 index 0000000..32215ea --- /dev/null +++ b/vendor/github.com/markbates/pkger/README.md @@ -0,0 +1,432 @@ +# Pkger + +[`github.com/markbates/pkger`](https://godoc.org/github.com/markbates/pkger) is a tool for embedding static files into Go binaries. It will, hopefully, be a replacement for [`github.com/gobuffalo/packr/v2`](https://godoc.org/github.com/gobuffalo/packr/v2). + +### Requirements + +* Go 1.13+ +* Go Modules + +## How it Works (Module Aware Pathing) + +Pkger is powered by the dark magic of Go Modules, so they're like, totally required. + +With Go Modules pkger can resolve packages with accuracy. No more guessing and trying to +figure out build paths, GOPATHS, etc... for this tired old lad. + +With the module's path correctly resolved, it can serve as the "root" directory for that +module, and all files in that module's directory are available. + +Paths: +* Paths should use UNIX style paths: + `/cmd/pkger/main.go` +* If unspecified the path's package is assumed to be the current module. +* Packages can specified in at the beginning of a path with a `:` seperator. +github.com/markbates/pkger:/cmd/pkger/main.go +* There are no relative paths. All paths are absolute to the modules root. +* Fully-qualified paths are embedded into the metadata of your static assets. If this behavior is undesirable, a preference is to build in a containerized environ, like docker, where the path strings are not ex-filtrating data about your development environment. + +``` +"github.com/gobuffalo/buffalo:/go.mod" => /go/pkg/mod/github.com/gobuffalo/buffalo@v0.14.7/go.mod +``` + +## CLI + +### Installation + +```bash +$ go get github.com/markbates/pkger/cmd/pkger +$ pkger -h +``` + +### Usage + +```bash +$ pkger +``` + +The result will be a `pkged.go` file in the **root** of the module with the embedded information and the package name of the module. + +```go +// ./pkged.go +package <.> + +// Pkger stuff here +``` + +The `-o` flag can be used to specify the directory of the `pkged.go` file. + +```bash +$ pkger -o cmd/reader +``` + +The result will be a `pkged.go` file in the **cmd/reader** folder with the embedded information and the package name of that folder. + +```go +// cmd/reader/pkged.go +package + +// Pkger stuff here +``` + +### Including Files at Package Time + +There may be reasons where you don't reference a particular file, or folder, that you want embedded in your application, such as a build artifact. + +To do this you may use either the [`github.com/markbates/pkger#Include`](https://godoc.org/github.com/markbates/pkger#Include) function to set a no-op parser directive to include the specified path. + +Alternatively, you may use the `-include` flag with the `pkger` and `pkger list` commands. + +```bash +$ pkger list -include /actions -include github.com/gobuffalo/buffalo:/app.go + +app + > app:/actions + > app:/actions/actions.go + > app:/assets + > app:/assets/css + > app:/assets/css/_buffalo.scss + > app:/assets/css/application.scss + > app:/assets/images + > app:/assets/images/favicon.ico + > app:/assets/images/logo.svg + > app:/assets/js + > app:/assets/js/application.js + > app:/go.mod + > app:/locales/all.en-us.yaml + > app:/public + > app:/public/assets + > app:/public/assets/.keep + > app:/public/assets/app.css + > app:/public/images + > app:/public/images/img1.png + > app:/public/index.html + > app:/public/robots.txt + > app:/templates + > app:/templates/_flash.plush.html + > app:/templates/application.plush.html + > app:/templates/index.plush.html + > app:/web + > app:/web/web.go + > github.com/gobuffalo/buffalo:/app.go + > github.com/gobuffalo/buffalo:/logo.svg +``` + +## Reference Application + +The reference application for the `README` examples, as well as all testing, can be found at [https://github.com/markbates/pkger/tree/master/pkging/pkgtest/testdata/ref](https://github.com/markbates/pkger/tree/master/pkging/pkgtest/testdata/ref). + +``` +├── actions +│   └── actions.go +├── assets +│   ├── css +│   │   ├── _buffalo.scss +│   │   └── application.scss +│   ├── images +│   │   ├── favicon.ico +│   │   └── logo.svg +│   └── js +│   └── application.js +├── go.mod +├── go.sum +├── locales +│   └── all.en-us.yaml +├── main.go +├── mod +│   └── mod.go +├── models +│   └── models.go +├── public +│   ├── assets +│   │   └── app.css +│   ├── images +│   │   └── img1.png +│   ├── index.html +│   └── robots.txt +├── templates +│   ├── _flash.plush.html +│   ├── application.plush.html +│   └── index.plush.html +└── web + └── web.go + +13 directories, 20 files +``` + + +## API Usage + +Pkger's API is modeled on that of the [`os`](https://godoc.org/os) package in Go's standard library. This makes Pkger usage familiar to Go developers. + +The two most important interfaces are [`github.com/markbates/pkger/pkging#Pkger`](https://godoc.org/github.com/markbates/pkger/pkging#Pkger) and [`github.com/markbates/pkger/pkging#File`](https://godoc.org/github.com/markbates/pkger/pkging#File). + +```go +type Pkger interface { + Parse(p string) (Path, error) + Current() (here.Info, error) + Info(p string) (here.Info, error) + Create(name string) (File, error) + MkdirAll(p string, perm os.FileMode) error + Open(name string) (File, error) + Stat(name string) (os.FileInfo, error) + Walk(p string, wf filepath.WalkFunc) error + Remove(name string) error + RemoveAll(path string) error +} + +type File interface { + Close() error + Info() here.Info + Name() string + Open(name string) (http.File, error) + Path() Path + Read(p []byte) (int, error) + Readdir(count int) ([]os.FileInfo, error) + Seek(offset int64, whence int) (int64, error) + Stat() (os.FileInfo, error) + Write(b []byte) (int, error) +} +``` + +These two interfaces, along with the [`os#FileInfo`](https://godoc.org/os#FileInfo), provide the bulk of the API surface area. + +### Open + +```go +func run() error { + f, err := pkger.Open("/public/index.html") + if err != nil { + return err + } + defer f.Close() + + info, err := f.Stat() + if err != nil { + return err + } + + fmt.Println("Name: ", info.Name()) + fmt.Println("Size: ", info.Size()) + fmt.Println("Mode: ", info.Mode()) + fmt.Println("ModTime: ", info.ModTime()) + + if _, err := io.Copy(os.Stdout, f); err != nil { + return err + } + return nil +} +``` + +### Stat + +```go +func run() error { + info, err := pkger.Stat("/public/index.html") + if err != nil { + return err + } + + fmt.Println("Name: ", info.Name()) + fmt.Println("Size: ", info.Size()) + fmt.Println("Mode: ", info.Mode()) + fmt.Println("ModTime: ", info.ModTime()) + + return nil +} +``` + +### Walk + +```go +func run() error { + w := tabwriter.NewWriter(os.Stdout, 0, 0, 0, ' ', tabwriter.Debug) + defer w.Flush() + + return pkger.Walk("/public", func(path string, info os.FileInfo, err error) error { + if err != nil { + return err + } + + fmt.Fprintf(w, + "%s \t %d \t %s \t %s \t\n", + info.Name(), + info.Size(), + info.Mode(), + info.ModTime().Format(time.RFC3339), + ) + + return nil + }) + +} +``` + +## Understanding the Parser + +The [`github.com/markbates/pkger/parser#Parser`](https://godoc.org/github.com/markbates/pkger/parser#Parser) works by statically analyzing the source code of your module using the [`go/parser`](https://godoc.org/go/parser) to find a selection of declarations. + +The following declarations in your source code will tell the parser to embed files or folders. + +* `pkger.Dir("")` - Embeds all files under the specified path. +* `pkger.Open("")` - Embeds the file, or folder, of the specified path. +* `pkger.Stat("")` - Embeds the file, or folder, of the specified path. +* `pkger.Walk("", filepath.WalkFunc)` - Embeds all files under the specified path. +* `pkger.Include("")` - `Include` is a no-op that directs the pkger tool to include the desired file or folder. + +### CLI Usage + +To see what declarations the parser has found, you can use the `pkger parse` command to get a `JSON` list of the declarations. + +```bash +$ pkger parse + +{ + ".": [ + { + "file": { + "Abs": "/go/src/github.com/markbates/pkger/pkging/pkgtest/testdata/ref/foo/bar/baz", + "Path": { + "Pkg": "app", + "Name": "/foo/bar/baz" + }, + "Here": { + "Dir": "/go/src/github.com/markbates/pkger/pkging/pkgtest/testdata/ref", + "ImportPath": "app", + "Module": { + "Path": "app", + "Main": true, + "Dir": "/go/src/github.com/markbates/pkger/pkging/pkgtest/testdata/ref", + "GoMod": "/go/src/github.com/markbates/pkger/pkging/pkgtest/testdata/ref/go.mod", + "GoVersion": "1.13" + }, + "Name": "main" + } + }, + "pos": { + "Filename": "/go/src/github.com/markbates/pkger/pkging/pkgtest/testdata/ref/main.go", + "Offset": 629, + "Line": 47, + "Column": 27 + }, + "type": "pkger.MkdirAll", + "value": "/foo/bar/baz" + }, + { + "file": { + "Abs": "/go/src/github.com/markbates/pkger/pkging/pkgtest/testdata/ref/foo/bar/baz/biz.txt", + "Path": { + "Pkg": "app", + "Name": "/foo/bar/baz/biz.txt" + }, + "Here": { + "Dir": "/go/src/github.com/markbates/pkger/pkging/pkgtest/testdata/ref", + "ImportPath": "app", + "Module": { + "Path": "app", + "Main": true, + "Dir": "/go/src/github.com/markbates/pkger/pkging/pkgtest/testdata/ref", + "GoMod": "/go/src/github.com/markbates/pkger/pkging/pkgtest/testdata/ref/go.mod", + "GoVersion": "1.13" + }, + "Name": "main" + } + }, + "pos": { + "Filename": "/go/src/github.com/markbates/pkger/pkging/pkgtest/testdata/ref/main.go", + "Offset": 706, + "Line": 51, + "Column": 25 + }, + "type": "pkger.Create", + "value": "/foo/bar/baz/biz.txt" + }, + ... + ] +} +``` + +For a module aware list use the `pkger list` command. + +```bash +$ pkger list + +app + > app:/assets + > app:/assets/css + > app:/assets/css/_buffalo.scss + > app:/assets/css/application.scss + > app:/assets/images + > app:/assets/images/favicon.ico + > app:/assets/images/logo.svg + > app:/assets/js + > app:/assets/js/application.js + > app:/go.mod + > app:/locales/all.en-us.yaml + > app:/public + > app:/public/assets + > app:/public/assets/.keep + > app:/public/assets/app.css + > app:/public/images + > app:/public/images/img1.png + > app:/public/index.html + > app:/public/robots.txt + > app:/templates + > app:/templates/_flash.plush.html + > app:/templates/application.plush.html + > app:/templates/index.plush.html + > app:/web + > app:/web/web.go + > github.com/gobuffalo/buffalo:/logo.svg +``` + +The `-json` flag can be used to get a more detailed list in JSON. + +```bash +$ pkger list -json + +{ + "ImportPath": "app", + "Files": [ + { + "Abs": "/go/src/github.com/markbates/pkger/pkging/pkgtest/testdata/ref/assets", + "Path": { + "Pkg": "app", + "Name": "/assets" + }, + "Here": { + "Dir": "/go/src/github.com/markbates/pkger/pkging/pkgtest/testdata/ref/assets", + "ImportPath": "", + "Module": { + "Path": "app", + "Main": true, + "Dir": "/go/src/github.com/markbates/pkger/pkging/pkgtest/testdata/ref", + "GoMod": "/go/src/github.com/markbates/pkger/pkging/pkgtest/testdata/ref/go.mod", + "GoVersion": "1.13" + }, + "Name": "assets" + } + }, + { + "Abs": "/go/src/github.com/markbates/pkger/pkging/pkgtest/testdata/ref/assets/css", + "Path": { + "Pkg": "app", + "Name": "/assets/css" + }, + "Here": { + "Dir": "/go/src/github.com/markbates/pkger/pkging/pkgtest/testdata/ref/assets", + "ImportPath": "", + "Module": { + "Path": "app", + "Main": true, + "Dir": "/go/src/github.com/markbates/pkger/pkging/pkgtest/testdata/ref", + "GoMod": "/go/src/github.com/markbates/pkger/pkging/pkgtest/testdata/ref/go.mod", + "GoVersion": "1.13" + }, + "Name": "assets" + } + }, + ... +} +``` + diff --git a/vendor/github.com/markbates/pkger/SHOULDERS.md b/vendor/github.com/markbates/pkger/SHOULDERS.md new file mode 100644 index 0000000..241d69c --- /dev/null +++ b/vendor/github.com/markbates/pkger/SHOULDERS.md @@ -0,0 +1,24 @@ +# github.com/markbates/pkger Stands on the Shoulders of Giants + +github.com/markbates/pkger does not try to reinvent the wheel! Instead, it uses the already great wheels developed by the Go community and puts them all together in the best way possible. Without these giants, this project would not be possible. Please make sure to check them out and thank them for all of their hard work. + +Thank you to the following **GIANTS**: + + +* [github.com/davecgh/go-spew](https://godoc.org/github.com/davecgh/go-spew) + +* [github.com/kr/pretty](https://godoc.org/github.com/kr/pretty) + +* [github.com/kr/pty](https://godoc.org/github.com/kr/pty) + +* [github.com/kr/text](https://godoc.org/github.com/kr/text) + +* [github.com/pmezard/go-difflib](https://godoc.org/github.com/pmezard/go-difflib) + +* [github.com/stretchr/objx](https://godoc.org/github.com/stretchr/objx) + +* [github.com/stretchr/testify](https://godoc.org/github.com/stretchr/testify) + +* [gopkg.in/check.v1](https://godoc.org/gopkg.in/check.v1) + +* [gopkg.in/yaml.v2](https://godoc.org/gopkg.in/yaml.v2) diff --git a/vendor/github.com/markbates/pkger/apply.go b/vendor/github.com/markbates/pkger/apply.go new file mode 100644 index 0000000..e59b19c --- /dev/null +++ b/vendor/github.com/markbates/pkger/apply.go @@ -0,0 +1,19 @@ +package pkger + +import ( + "github.com/markbates/pkger/pkging" +) + +// Apply will wrap the current implementation +// of pkger.Pkger with the new pkg. This allows +// for layering of pkging.Pkger implementations. +func Apply(pkg pkging.Pkger, err error) error { + if err != nil { + panic(err) + return err + } + gil.Lock() + defer gil.Unlock() + current = pkging.Wrap(current, pkg) + return nil +} diff --git a/vendor/github.com/markbates/pkger/go.mod b/vendor/github.com/markbates/pkger/go.mod new file mode 100644 index 0000000..b6a7e50 --- /dev/null +++ b/vendor/github.com/markbates/pkger/go.mod @@ -0,0 +1,8 @@ +module github.com/markbates/pkger + +go 1.13 + +require ( + github.com/gobuffalo/here v0.6.0 + github.com/stretchr/testify v1.4.0 +) diff --git a/vendor/github.com/markbates/pkger/go.sum b/vendor/github.com/markbates/pkger/go.sum new file mode 100644 index 0000000..77e25e1 --- /dev/null +++ b/vendor/github.com/markbates/pkger/go.sum @@ -0,0 +1,22 @@ +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/gobuffalo/here v0.6.0 h1:hYrd0a6gDmWxBM4TnrGw8mQg24iSVoIkHEk7FodQcBI= +github.com/gobuffalo/here v0.6.0/go.mod h1:wAG085dHOYqUpf+Ap+WOdrPTp5IYcDAs/x7PLa8Y5fM= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +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/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.7 h1:VUgggvou5XRW9mHwD/yXxIYSMtY0zoKQf/v226p2nyo= +gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/vendor/github.com/markbates/pkger/here/here.go b/vendor/github.com/markbates/pkger/here/here.go new file mode 100644 index 0000000..f87a061 --- /dev/null +++ b/vendor/github.com/markbates/pkger/here/here.go @@ -0,0 +1,14 @@ +package here + +import ( + "github.com/gobuffalo/here" +) + +type Info = here.Info +type Module = here.Module +type Path = here.Path + +var Here = here.New() +var Dir = Here.Dir +var Package = Here.Package +var Current = Here.Current diff --git a/vendor/github.com/markbates/pkger/internal/maps/files.go b/vendor/github.com/markbates/pkger/internal/maps/files.go new file mode 100644 index 0000000..3b3b6ac --- /dev/null +++ b/vendor/github.com/markbates/pkger/internal/maps/files.go @@ -0,0 +1,124 @@ +// Code generated by github.com/gobuffalo/mapgen. DO NOT EDIT. + +package maps + +import ( + "encoding/json" + "fmt" + "sort" + "sync" + + "github.com/markbates/pkger/here" + "github.com/markbates/pkger/pkging" +) + +// Files wraps sync.Map and uses the following types: +// key: here.Path +// value: pkging.File +type Files struct { + data *sync.Map + once *sync.Once +} + +func (m *Files) Data() *sync.Map { + if m.once == nil { + m.once = &sync.Once{} + } + m.once.Do(func() { + if m.data == nil { + m.data = &sync.Map{} + } + }) + return m.data +} + +func (m *Files) MarshalJSON() ([]byte, error) { + var err error + mm := map[string]interface{}{} + m.Data().Range(func(key, value interface{}) bool { + var b []byte + b, err = json.Marshal(key) + if err != nil { + return false + } + mm[string(b)] = value + return true + }) + + if err != nil { + return nil, err + } + + return json.Marshal(mm) +} + +func (m *Files) UnmarshalJSON(b []byte) error { + mm := map[string]pkging.File{} + + if err := json.Unmarshal(b, &mm); err != nil { + return err + } + for k, v := range mm { + var pt here.Path + if err := json.Unmarshal([]byte(k), &pt); err != nil { + return err + } + m.Store(pt, v) + } + return nil +} + +// Delete the key from the map +func (m *Files) Delete(key here.Path) { + m.Data().Delete(key) +} + +// Load the key from the map. +// Returns pkging.File or bool. +// A false return indicates either the key was not found +// or the value is not of type pkging.File +func (m *Files) Load(key here.Path) (pkging.File, bool) { + i, ok := m.Data().Load(key) + if !ok { + return nil, false + } + s, ok := i.(pkging.File) + return s, ok +} + +// Range over the pkging.File values in the map +func (m *Files) Range(f func(key here.Path, value pkging.File) bool) { + m.Data().Range(func(k, v interface{}) bool { + key, ok := k.(here.Path) + if !ok { + return false + } + value, ok := v.(pkging.File) + if !ok { + return false + } + return f(key, value) + }) +} + +// Store a pkging.File in the map +func (m *Files) Store(key here.Path, value pkging.File) { + m.Data().Store(key, value) +} + +// Keys returns a list of keys in the map +func (m *Files) Keys() []here.Path { + var keys []here.Path + m.Range(func(key here.Path, value pkging.File) bool { + keys = append(keys, key) + return true + }) + sort.Slice(keys, func(a, b int) bool { + return keys[a].String() <= keys[b].String() + }) + return keys +} + +func (m *Files) String() string { + return fmt.Sprintf("%v", m.Keys()) +} diff --git a/vendor/github.com/markbates/pkger/internal/maps/infos.go b/vendor/github.com/markbates/pkger/internal/maps/infos.go new file mode 100644 index 0000000..0eed02f --- /dev/null +++ b/vendor/github.com/markbates/pkger/internal/maps/infos.go @@ -0,0 +1,103 @@ +// Code generated by github.com/markbates/pkger/mapgen. DO NOT EDIT. + +package maps + +import ( + "encoding/json" + "fmt" + "sort" + "sync" + + "github.com/markbates/pkger/here" +) + +// Infos wraps sync.Map and uses the following types: +// key: string +// value: here.Info +type Infos struct { + data *sync.Map + once *sync.Once +} + +func (m *Infos) Data() *sync.Map { + if m.once == nil { + m.once = &sync.Once{} + } + m.once.Do(func() { + if m.data == nil { + m.data = &sync.Map{} + } + }) + return m.data +} + +func (m *Infos) MarshalJSON() ([]byte, error) { + mm := map[string]interface{}{} + m.data.Range(func(key, value interface{}) bool { + mm[fmt.Sprintf("%s", key)] = value + return true + }) + return json.Marshal(mm) +} + +func (m *Infos) UnmarshalJSON(b []byte) error { + mm := map[string]here.Info{} + + if err := json.Unmarshal(b, &mm); err != nil { + return err + } + for k, v := range mm { + m.Store(k, v) + } + return nil +} + +// Delete the key from the map +func (m *Infos) Delete(key string) { + m.Data().Delete(key) +} + +// Load the key from the map. +// Returns here.Info or bool. +// A false return indicates either the key was not found +// or the value is not of type here.Info +func (m *Infos) Load(key string) (here.Info, bool) { + m.Data() + i, ok := m.data.Load(key) + if !ok { + return here.Info{}, false + } + s, ok := i.(here.Info) + return s, ok +} + +// Range over the here.Info values in the map +func (m *Infos) Range(f func(key string, value here.Info) bool) { + m.Data().Range(func(k, v interface{}) bool { + key, ok := k.(string) + if !ok { + return false + } + value, ok := v.(here.Info) + if !ok { + return false + } + return f(key, value) + }) +} + +// Store a here.Info in the map +func (m *Infos) Store(key string, value here.Info) { + m.Data().Store(key, value) +} + +// Keys returns a list of keys in the map +func (m *Infos) Keys() []string { + var keys []string + m.Range(func(key string, value here.Info) bool { + keys = append(keys, key) + return true + }) + sort.Strings(keys) + return keys +} diff --git a/vendor/github.com/markbates/pkger/pkger.go b/vendor/github.com/markbates/pkger/pkger.go new file mode 100644 index 0000000..5f56a51 --- /dev/null +++ b/vendor/github.com/markbates/pkger/pkger.go @@ -0,0 +1,95 @@ +package pkger + +import ( + "net/http" + "os" + "path/filepath" + "sync" + + "github.com/markbates/pkger/here" + "github.com/markbates/pkger/pkging" + "github.com/markbates/pkger/pkging/stdos" +) + +var current pkging.Pkger +var gil = &sync.RWMutex{} + +var disk = func() pkging.Pkger { + her, _ := here.Current() + n, _ := stdos.New(her) + return n +}() + +func impl() pkging.Pkger { + gil.RLock() + defer gil.RUnlock() + if current == nil { + return disk + } + return current +} + +type Dir string + +func (d Dir) Open(name string) (http.File, error) { + f, err := impl().Open(string(d)) + if err != nil { + return nil, err + } + return f.Open(name) +} + +// Parse the string in here.Path format. +func Parse(p string) (here.Path, error) { + return impl().Parse(p) +} + +// Current returns the here.Info representing the current Pkger implementation. +func Current() (here.Info, error) { + return impl().Current() +} + +// Info returns the here.Info of the here.Path +func Info(p string) (here.Info, error) { + return impl().Info(p) +} + +// Create creates the named file with mode 0666 (before umask) - It's actually 0644, truncating it if it already exists. If successful, methods on the returned File can be used for I/O; the associated file descriptor has mode O_RDWR. +func Create(p string) (pkging.File, error) { + return impl().Create(p) +} + +// MkdirAll creates a directory named path, along with any necessary parents, and returns nil, or else returns an error. The permission bits perm (before umask) are used for all directories that MkdirAll creates. If path is already a directory, MkdirAll does nothing and returns nil. +func MkdirAll(p string, perm os.FileMode) error { + return impl().MkdirAll(p, perm) +} + +// Open opens the named file for reading. If successful, methods on the returned file can be used for reading; the associated file descriptor has mode O_RDONLY. +func Open(p string) (pkging.File, error) { + return impl().Open(p) +} + +// Stat returns a FileInfo describing the named file. +func Stat(name string) (os.FileInfo, error) { + return impl().Stat(name) +} + +// Walk walks the file tree rooted at root, calling walkFn for each file or directory in the tree, including root. All errors that arise visiting files and directories are filtered by walkFn. The files are walked in lexical order, which makes the output deterministic but means that for very large directories Walk can be inefficient. Walk does not follow symbolic links. - That is from the standard library. I know. Their grammar teachers can not be happy with them right now. +func Walk(p string, wf filepath.WalkFunc) error { + return impl().Walk(p, wf) +} + +// Remove removes the named file or (empty) directory. +func Remove(name string) error { + return impl().Remove(name) +} + +// RemoveAll removes path and any children it contains. It removes everything it can but returns the first error it encounters. If the path does not exist, RemoveAll returns nil (no error). +func RemoveAll(name string) error { + return impl().RemoveAll(name) +} + +// Include is a no-op that directs the pkger tool to include the desired file or folder. +func Include(name string) string { + return name +} diff --git a/vendor/github.com/markbates/pkger/pkging/faces.go b/vendor/github.com/markbates/pkger/pkging/faces.go new file mode 100644 index 0000000..5a8efcd --- /dev/null +++ b/vendor/github.com/markbates/pkger/pkging/faces.go @@ -0,0 +1,7 @@ +package pkging + +import "os" + +type Adder interface { + Add(files ...*os.File) error +} diff --git a/vendor/github.com/markbates/pkger/pkging/file.go b/vendor/github.com/markbates/pkger/pkging/file.go new file mode 100644 index 0000000..c7d12a1 --- /dev/null +++ b/vendor/github.com/markbates/pkger/pkging/file.go @@ -0,0 +1,44 @@ +package pkging + +import ( + "net/http" + "os" + + "github.com/markbates/pkger/here" +) + +type File interface { + // Close closes the File, rendering it unusable for I/O. + Close() error + + // Info returns the here.Info of the file + Info() here.Info + + // Name retuns the name of the file + Name() string + + // Open implements the http.FileSystem interface. A FileSystem implements access to a collection of named files. The elements in a file path are separated by slash ('/', U+002F) characters, regardless of host operating system convention. + Open(name string) (http.File, error) + + // Path returns the here.Path of the file + Path() here.Path + + // Read reads up to len(b) bytes from the File. It returns the number of bytes read and any error encountered. At end of file, Read returns 0, io.EOF. + Read(p []byte) (int, error) + + // Readdir reads the contents of the directory associated with file and returns a slice of up to n FileInfo values, as would be returned by Lstat, in directory order. Subsequent calls on the same file will yield further FileInfos. + // + // If n > 0, Readdir returns at most n FileInfo structures. In this case, if Readdir returns an empty slice, it will return a non-nil error explaining why. At the end of a directory, the error is io.EOF. + // + // If n <= 0, Readdir returns all the FileInfo from the directory in a single slice. In this case, if Readdir succeeds (reads all the way to the end of the directory), it returns the slice and a nil error. If it encounters an error before the end of the directory, Readdir returns the FileInfo read until that point and a non-nil error. + Readdir(count int) ([]os.FileInfo, error) + + // Seek sets the offset for the next Read or Write on file to offset, interpreted according to whence: 0 means relative to the origin of the file, 1 means relative to the current offset, and 2 means relative to the end. It returns the new offset and an error, if any. + Seek(offset int64, whence int) (int64, error) + + // Stat returns the FileInfo structure describing file. If there is an error, it will be of type *PathError. + Stat() (os.FileInfo, error) + + // Write writes len(b) bytes to the File. It returns the number of bytes written and an error, if any. Write returns a non-nil error when n != len(b). + Write(b []byte) (int, error) +} diff --git a/vendor/github.com/markbates/pkger/pkging/file_info.go b/vendor/github.com/markbates/pkger/pkging/file_info.go new file mode 100644 index 0000000..dd194c8 --- /dev/null +++ b/vendor/github.com/markbates/pkger/pkging/file_info.go @@ -0,0 +1,65 @@ +package pkging + +import ( + "encoding/json" + "os" + "time" +) + +type Details struct { + Name string `json:"name"` + Size int64 `json:"size"` + Mode os.FileMode `json:"mode"` + ModTime ModTime `json:"mod_time"` + IsDir bool `json:"is_dir"` + Sys interface{} `json:"sys"` +} + +type FileInfo struct { + Details `json:"details"` +} + +func (f *FileInfo) String() string { + b, _ := json.MarshalIndent(f, "", " ") + return string(b) +} + +func (f *FileInfo) Name() string { + return f.Details.Name +} + +func (f *FileInfo) Size() int64 { + return f.Details.Size +} + +func (f *FileInfo) Mode() os.FileMode { + return f.Details.Mode +} + +func (f *FileInfo) ModTime() time.Time { + return time.Time(f.Details.ModTime) +} + +func (f *FileInfo) IsDir() bool { + return f.Details.IsDir +} + +func (f *FileInfo) Sys() interface{} { + return f.Details.Sys +} + +var _ os.FileInfo = &FileInfo{} + +func NewFileInfo(info os.FileInfo) *FileInfo { + fi := &FileInfo{ + Details: Details{ + Name: info.Name(), + Size: info.Size(), + Mode: info.Mode(), + ModTime: ModTime(info.ModTime()), + IsDir: info.IsDir(), + Sys: info.Sys(), + }, + } + return fi +} diff --git a/vendor/github.com/markbates/pkger/pkging/mod_time.go b/vendor/github.com/markbates/pkger/pkging/mod_time.go new file mode 100644 index 0000000..d81a32c --- /dev/null +++ b/vendor/github.com/markbates/pkger/pkging/mod_time.go @@ -0,0 +1,24 @@ +package pkging + +import ( + "encoding/json" + "time" +) + +const timeFmt = time.RFC3339Nano + +type ModTime time.Time + +func (m ModTime) MarshalJSON() ([]byte, error) { + t := time.Time(m) + return json.Marshal(t.Format(timeFmt)) +} + +func (m *ModTime) UnmarshalJSON(b []byte) error { + t := time.Time{} + if err := json.Unmarshal(b, &t); err != nil { + return err + } + (*m) = ModTime(t) + return nil +} diff --git a/vendor/github.com/markbates/pkger/pkging/pkger.go b/vendor/github.com/markbates/pkger/pkging/pkger.go new file mode 100644 index 0000000..b2076f6 --- /dev/null +++ b/vendor/github.com/markbates/pkger/pkging/pkger.go @@ -0,0 +1,43 @@ +package pkging + +import ( + "os" + "path/filepath" + + "github.com/markbates/pkger/here" +) + +type Pkger interface { + // Parse the string in here.Path format. + Parse(p string) (here.Path, error) + + // Current returns the here.Info representing the current Pkger implementation. + Current() (here.Info, error) + + // Info returns the here.Info of the here.Path + Info(p string) (here.Info, error) + + // Create creates the named file with mode 0666 (before umask) - It's actually 0644, truncating it if it already exists. If successful, methods on the returned File can be used for I/O; the associated file descriptor has mode O_RDWR. + Create(name string) (File, error) + + // MkdirAll creates a directory named path, along with any necessary parents, and returns nil, or else returns an error. The permission bits perm (before umask) are used for all directories that MkdirAll creates. If path is already a directory, MkdirAll does nothing and returns nil. + MkdirAll(p string, perm os.FileMode) error + + // Open opens the named file for reading. If successful, methods on the returned file can be used for reading; the associated file descriptor has mode O_RDONLY. + // @Parser Directive + Open(name string) (File, error) + + // Stat returns a FileInfo describing the named file. + // @Parser Directive + Stat(name string) (os.FileInfo, error) + + // Walk walks the file tree rooted at root, calling walkFn for each file or directory in the tree, including root. All errors that arise visiting files and directories are filtered by walkFn. The files are walked in lexical order, which makes the output deterministic but means that for very large directories Walk can be inefficient. Walk does not follow symbolic links. - That is from the standard library. I know. Their grammar teachers can not be happy with them right now. + // @Parser Directive + Walk(p string, wf filepath.WalkFunc) error + + // Remove removes the named file or (empty) directory. + Remove(name string) error + + // RemoveAll removes path and any children it contains. It removes everything it can but returns the first error it encounters. If the path does not exist, RemoveAll returns nil (no error). + RemoveAll(path string) error +} diff --git a/vendor/github.com/markbates/pkger/pkging/stdos/file.go b/vendor/github.com/markbates/pkger/pkging/stdos/file.go new file mode 100644 index 0000000..35845cf --- /dev/null +++ b/vendor/github.com/markbates/pkger/pkging/stdos/file.go @@ -0,0 +1,73 @@ +package stdos + +import ( + "net/http" + "os" + "path" + + "github.com/markbates/pkger/here" + "github.com/markbates/pkger/pkging" +) + +var _ pkging.File = &File{} + +type File struct { + *os.File + info *pkging.FileInfo + her here.Info + path here.Path + pkging pkging.Pkger +} + +// Close closes the File, rendering it unusable for I/O. +func (f *File) Close() error { + return f.File.Close() +} + +// Info returns the here.Info of the file +func (f *File) Info() here.Info { + return f.her +} + +// Name retuns the name of the file in pkger format +func (f File) Name() string { + return f.path.String() +} + +// Readdir reads the contents of the directory associated with file and returns a slice of up to n FileInfo values, as would be returned by Lstat, in directory order. Subsequent calls on the same file will yield further FileInfos. +// +// If n > 0, Readdir returns at most n FileInfo structures. In this case, if Readdir returns an empty slice, it will return a non-nil error explaining why. At the end of a directory, the error is io.EOF. +// +// If n <= 0, Readdir returns all the FileInfo from the directory in a single slice. In this case, if Readdir succeeds (reads all the way to the end of the directory), it returns the slice and a nil error. If it encounters an error before the end of the directory, Readdir returns the FileInfo read until that point and a non-nil error. +func (f *File) Readdir(count int) ([]os.FileInfo, error) { + return f.File.Readdir(count) +} + +// Open implements the http.FileSystem interface. A FileSystem implements access to a collection of named files. The elements in a file path are separated by slash ('/', U+002F) characters, regardless of host operating system convention. +func (f *File) Open(name string) (http.File, error) { + fp := path.Join(f.Path().Name, name) + f2, err := f.pkging.Open(fp) + if err != nil { + return nil, err + } + return f2, nil +} + +// Path returns the here.Path of the file +func (f *File) Path() here.Path { + return f.path +} + +// Stat returns the FileInfo structure describing file. If there is an error, it will be of type *PathError. +func (f *File) Stat() (os.FileInfo, error) { + if f.info != nil { + return f.info, nil + } + + info, err := f.File.Stat() + if err != nil { + return nil, err + } + f.info = pkging.NewFileInfo(info) + return f.info, nil +} diff --git a/vendor/github.com/markbates/pkger/pkging/stdos/json.go b/vendor/github.com/markbates/pkger/pkging/stdos/json.go new file mode 100644 index 0000000..8a0cfbd --- /dev/null +++ b/vendor/github.com/markbates/pkger/pkging/stdos/json.go @@ -0,0 +1 @@ +package stdos diff --git a/vendor/github.com/markbates/pkger/pkging/stdos/stdos.go b/vendor/github.com/markbates/pkger/pkging/stdos/stdos.go new file mode 100644 index 0000000..b811702 --- /dev/null +++ b/vendor/github.com/markbates/pkger/pkging/stdos/stdos.go @@ -0,0 +1,223 @@ +package stdos + +import ( + "fmt" + "os" + "path/filepath" + "strings" + + "github.com/markbates/pkger/here" + "github.com/markbates/pkger/internal/maps" + "github.com/markbates/pkger/pkging" +) + +var _ pkging.Pkger = &Pkger{} + +type Pkger struct { + Here here.Info + infos *maps.Infos +} + +// New returns *Pkger for the provided here.Info +func New(her here.Info) (*Pkger, error) { + p := &Pkger{ + infos: &maps.Infos{}, + Here: her, + } + p.infos.Store(her.ImportPath, her) + return p, nil +} + +// Create creates the named file with mode 0666 (before umask) - It's actually 0644, truncating it if it already exists. If successful, methods on the returned File can be used for I/O; the associated file descriptor has mode O_RDWR. +func (fx *Pkger) Create(name string) (pkging.File, error) { + pt, err := fx.Parse(name) + if err != nil { + return nil, err + } + + her, err := fx.Info(pt.Pkg) + if err != nil { + return nil, err + } + + name = filepath.Join(her.Dir, pt.Name) + f, err := os.Create(name) + if err != nil { + return nil, err + } + + nf := &File{ + File: f, + her: her, + path: pt, + pkging: fx, + } + + info, err := f.Stat() + if err != nil { + return nil, err + } + nf.info = pkging.NewFileInfo(info) + return nf, nil +} + +// Current returns the here.Info representing the current Pkger implementation. +func (f *Pkger) Current() (here.Info, error) { + return f.Here, nil +} + +// Info returns the here.Info of the here.Path +func (f *Pkger) Info(p string) (here.Info, error) { + info, ok := f.infos.Load(p) + if ok { + return info, nil + } + + info, err := here.Package(p) + if err != nil { + return info, err + } + f.infos.Store(p, info) + return info, nil +} + +// MkdirAll creates a directory named path, along with any necessary parents, and returns nil, or else returns an error. The permission bits perm (before umask) are used for all directories that MkdirAll creates. If path is already a directory, MkdirAll does nothing and returns nil. +func (f *Pkger) MkdirAll(p string, perm os.FileMode) error { + pt, err := f.Parse(p) + if err != nil { + return err + } + info, err := f.Info(pt.Pkg) + if err != nil { + return err + } + return os.MkdirAll(filepath.Join(info.Dir, p), perm) +} + +// Open opens the named file for reading. If successful, methods on the returned file can be used for reading; the associated file descriptor has mode O_RDONLY. +func (fx *Pkger) Open(name string) (pkging.File, error) { + pt, err := fx.Parse(name) + if err != nil { + return nil, err + } + + her, err := fx.Info(pt.Pkg) + if err != nil { + return nil, err + } + + name = filepath.Join(her.Dir, pt.Name) + f, err := os.Open(name) + if err != nil { + return nil, err + } + + nf := &File{ + File: f, + her: her, + path: pt, + pkging: fx, + } + + info, err := f.Stat() + if err != nil { + return nil, err + } + nf.info = pkging.NewFileInfo(info) + + return nf, nil +} + +// Parse the string in here.Path format. +func (f *Pkger) Parse(p string) (here.Path, error) { + return f.Here.Parse(p) +} + +// Stat returns a FileInfo describing the named file. +func (fx *Pkger) Stat(name string) (os.FileInfo, error) { + pt, err := fx.Parse(name) + if err != nil { + return nil, err + } + + her, err := fx.Info(pt.Pkg) + if err != nil { + return nil, err + } + + info, err := os.Stat(filepath.Join(her.Dir, pt.Name)) + if err != nil { + return nil, err + } + + info = pkging.NewFileInfo(info) + + return info, nil +} + +// Walk walks the file tree rooted at root, calling walkFn for each file or directory in the tree, including root. All errors that arise visiting files and directories are filtered by walkFn. The files are walked in lexical order, which makes the output deterministic but means that for very large directories Walk can be inefficient. Walk does not follow symbolic links. - That is from the standard library. I know. Their grammar teachers can not be happy with them right now. +func (f *Pkger) Walk(p string, wf filepath.WalkFunc) error { + pt, err := f.Parse(p) + if err != nil { + return err + } + + info, err := f.Info(pt.Pkg) + if err != nil { + return err + } + + fp := filepath.Join(info.Dir, pt.Name) + err = filepath.Walk(fp, func(path string, fi os.FileInfo, err error) error { + if err != nil { + return err + } + + pt, err := f.Parse(fmt.Sprintf("%s:%s", pt.Pkg, path)) + if err != nil { + return err + } + + info, err := f.Info(pt.Pkg) + if err != nil { + return err + } + + path = strings.TrimPrefix(path, info.Dir) + path = strings.ReplaceAll(path, "\\", "/") + pt.Name = path + return wf(pt.String(), pkging.NewFileInfo(fi), nil) + }) + + return err +} + +// Remove removes the named file or (empty) directory. +func (fx *Pkger) Remove(name string) error { + pt, err := fx.Parse(name) + if err != nil { + return err + } + + info, err := fx.Info(pt.Pkg) + if err != nil { + return err + } + + return os.Remove(filepath.Join(info.Dir, pt.Name)) +} + +// RemoveAll removes path and any children it contains. It removes everything it can but returns the first error it encounters. If the path does not exist, RemoveAll returns nil (no error). +func (fx *Pkger) RemoveAll(name string) error { + pt, err := fx.Parse(name) + if err != nil { + return err + } + + info, err := fx.Info(pt.Pkg) + if err != nil { + return err + } + + return os.RemoveAll(filepath.Join(info.Dir, pt.Name)) +} diff --git a/vendor/github.com/markbates/pkger/pkging/wrap.go b/vendor/github.com/markbates/pkger/pkging/wrap.go new file mode 100644 index 0000000..438f955 --- /dev/null +++ b/vendor/github.com/markbates/pkger/pkging/wrap.go @@ -0,0 +1,145 @@ +package pkging + +import ( + "fmt" + "os" + "path/filepath" + + "github.com/markbates/pkger/here" +) + +func Wrap(parent, with Pkger) Pkger { + return withPkger{ + base: with, + parent: parent, + } +} + +type withPkger struct { + base Pkger + parent Pkger +} + +func (w withPkger) String() string { + if w.parent == nil { + return fmt.Sprintf("%T", w.base) + } + return fmt.Sprintf("%T > %T", w.base, w.parent) +} + +func (w withPkger) Parse(p string) (here.Path, error) { + pt, err := w.base.Parse(p) + if err != nil { + if w.parent != nil { + return w.parent.Parse(p) + } + return pt, err + } + return pt, nil +} + +func (w withPkger) Current() (here.Info, error) { + pt, err := w.base.Current() + if err != nil { + if w.parent != nil { + return w.parent.Current() + } + return pt, err + } + return pt, nil +} + +func (w withPkger) Info(p string) (here.Info, error) { + pt, err := w.base.Info(p) + if err != nil { + if w.parent != nil { + return w.parent.Info(p) + } + return pt, err + } + return pt, nil +} + +// Create creates the named file with mode 0666 (before umask) - It's actually 0644, truncating it if it already exists. If successful, methods on the returned File can be used for I/O; the associated file descriptor has mode O_RDWR. +func (w withPkger) Create(p string) (File, error) { + pt, err := w.base.Create(p) + if err != nil { + if w.parent != nil { + return w.parent.Create(p) + } + return pt, err + } + return pt, nil +} + +// MkdirAll creates a directory named path, along with any necessary parents, and returns nil, or else returns an error. The permission bits perm (before umask) are used for all directories that MkdirAll creates. If path is already a directory, MkdirAll does nothing and returns nil. +func (w withPkger) MkdirAll(p string, perm os.FileMode) error { + err := w.base.MkdirAll(p, perm) + if err != nil { + return err + } + if w.parent != nil { + return w.parent.MkdirAll(p, perm) + } + return nil +} + +// Open opens the named file for reading. If successful, methods on the returned file can be used for reading; the associated file descriptor has mode O_RDONLY. +func (w withPkger) Open(p string) (File, error) { + pt, err := w.base.Open(p) + if err != nil { + if w.parent != nil { + return w.parent.Open(p) + } + return pt, err + } + return pt, nil +} + +// Stat returns a FileInfo describing the named file. +func (w withPkger) Stat(p string) (os.FileInfo, error) { + pt, err := w.base.Stat(p) + if err != nil { + if w.parent != nil { + return w.parent.Stat(p) + } + return pt, err + } + return pt, nil +} + +// Walk walks the file tree rooted at root, calling walkFn for each file or directory in the tree, including root. All errors that arise visiting files and directories are filtered by walkFn. The files are walked in lexical order, which makes the output deterministic but means that for very large directories Walk can be inefficient. Walk does not follow symbolic links. - That is from the standard library. I know. Their grammar teachers can not be happy with them right now. +func (w withPkger) Walk(p string, wf filepath.WalkFunc) error { + err := w.base.Walk(p, wf) + if err != nil { + return err + } + if w.parent != nil { + return w.parent.Walk(p, wf) + } + return nil +} + +// Remove removes the named file or (empty) directory. +func (w withPkger) Remove(p string) error { + err := w.base.Remove(p) + if err != nil { + return err + } + if w.parent != nil { + return w.parent.Remove(p) + } + return nil +} + +// RemoveAll removes path and any children it contains. It removes everything it can but returns the first error it encounters. If the path does not exist, RemoveAll returns nil (no error). +func (w withPkger) RemoveAll(p string) error { + err := w.base.RemoveAll(p) + if err != nil { + return err + } + if w.parent != nil { + return w.parent.RemoveAll(p) + } + return nil +} diff --git a/vendor/github.com/markbates/pkger/version.go b/vendor/github.com/markbates/pkger/version.go new file mode 100644 index 0000000..2d5c955 --- /dev/null +++ b/vendor/github.com/markbates/pkger/version.go @@ -0,0 +1,4 @@ +package pkger + +// Version of pkger +var Version = "development" diff --git a/vendor/modules.txt b/vendor/modules.txt index f683647..e6265b9 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -47,6 +47,8 @@ github.com/aws/aws-sdk-go/service/sts github.com/aws/aws-sdk-go/service/sts/stsiface # github.com/go-test/deep v1.0.5 github.com/go-test/deep +# github.com/gobuffalo/here v0.6.2 +github.com/gobuffalo/here # github.com/google/uuid v1.1.1 github.com/google/uuid # github.com/huandu/xstrings v1.3.2 @@ -57,6 +59,12 @@ github.com/imdario/mergo github.com/jmespath/go-jmespath # github.com/kylelemons/godebug v1.1.0 github.com/kylelemons/godebug/diff +# github.com/markbates/pkger v0.17.1 +github.com/markbates/pkger +github.com/markbates/pkger/here +github.com/markbates/pkger/internal/maps +github.com/markbates/pkger/pkging +github.com/markbates/pkger/pkging/stdos # github.com/mitchellh/copystructure v1.0.0 github.com/mitchellh/copystructure # github.com/mitchellh/reflectwalk v1.0.0