mirror of
https://github.com/ysoftdevs/gardener-extension-shoot-fleet-agent.git
synced 2026-04-23 16:58:56 +02:00
Initial v1.0.0 commit
This commit is contained in:
3
vendor/github.com/gobuffalo/packr/v2/.gometalinter.json
generated
vendored
Normal file
3
vendor/github.com/gobuffalo/packr/v2/.gometalinter.json
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"Enable": ["vet", "golint", "goimports", "deadcode", "gotype", "ineffassign", "misspell", "nakedret", "unconvert", "megacheck", "varcheck"]
|
||||
}
|
||||
42
vendor/github.com/gobuffalo/packr/v2/.goreleaser.yml
generated
vendored
Normal file
42
vendor/github.com/gobuffalo/packr/v2/.goreleaser.yml
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
# Code generated by github.com/gobuffalo/release. DO NOT EDIT.
|
||||
# Edit .goreleaser.yml.plush instead
|
||||
|
||||
builds:
|
||||
-
|
||||
goos:
|
||||
- darwin
|
||||
- linux
|
||||
- windows
|
||||
goarch:
|
||||
- ppc64le
|
||||
- 386
|
||||
- amd64
|
||||
env:
|
||||
- CGO_ENABLED=0
|
||||
ignore:
|
||||
- goos: darwin
|
||||
goarch: ppc64le
|
||||
- goos: windows
|
||||
goarch: ppc64le
|
||||
main: ./packr2/main.go
|
||||
binary: packr2
|
||||
|
||||
checksum:
|
||||
name_template: 'checksums.txt'
|
||||
|
||||
snapshot:
|
||||
name_template: "{{ .Tag }}-next"
|
||||
|
||||
changelog:
|
||||
sort: asc
|
||||
filters:
|
||||
exclude:
|
||||
- '^docs:'
|
||||
- '^test:'
|
||||
|
||||
brews:
|
||||
-
|
||||
github:
|
||||
owner: gobuffalo
|
||||
name: homebrew-tap
|
||||
|
||||
39
vendor/github.com/gobuffalo/packr/v2/.goreleaser.yml.plush
generated
vendored
Normal file
39
vendor/github.com/gobuffalo/packr/v2/.goreleaser.yml.plush
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
builds:
|
||||
-
|
||||
goos:
|
||||
- darwin
|
||||
- linux
|
||||
- windows
|
||||
goarch:
|
||||
- ppc64le
|
||||
- 386
|
||||
- amd64
|
||||
env:
|
||||
- CGO_ENABLED=0
|
||||
ignore:
|
||||
- goos: darwin
|
||||
goarch: ppc64le
|
||||
- goos: windows
|
||||
goarch: ppc64le
|
||||
main: ./packr2/main.go
|
||||
binary: packr2
|
||||
|
||||
checksum:
|
||||
name_template: 'checksums.txt'
|
||||
|
||||
snapshot:
|
||||
name_template: "{{ .Tag }}-next"
|
||||
|
||||
changelog:
|
||||
sort: asc
|
||||
filters:
|
||||
exclude:
|
||||
- '^docs:'
|
||||
- '^test:'
|
||||
<%= if (brew) { %>
|
||||
brews:
|
||||
-
|
||||
github:
|
||||
owner: gobuffalo
|
||||
name: homebrew-tap
|
||||
<% } %>
|
||||
8
vendor/github.com/gobuffalo/packr/v2/LICENSE.txt
generated
vendored
Normal file
8
vendor/github.com/gobuffalo/packr/v2/LICENSE.txt
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
The MIT License (MIT)
|
||||
Copyright (c) 2016 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.
|
||||
46
vendor/github.com/gobuffalo/packr/v2/Makefile
generated
vendored
Normal file
46
vendor/github.com/gobuffalo/packr/v2/Makefile
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
TAGS ?= "sqlite"
|
||||
GO_BIN ?= go
|
||||
|
||||
install: deps
|
||||
echo "installing packr v2"
|
||||
packr2
|
||||
$(GO_BIN) install -v ./packr2
|
||||
|
||||
tidy:
|
||||
ifeq ($(GO111MODULE),on)
|
||||
$(GO_BIN) mod tidy
|
||||
else
|
||||
echo skipping go mod tidy
|
||||
endif
|
||||
|
||||
deps:
|
||||
$(GO_BIN) get -tags ${TAGS} -t ./...
|
||||
$(GO_BIN) install -v ./packr2
|
||||
make tidy
|
||||
|
||||
build: deps
|
||||
packr2
|
||||
$(GO_BIN) build -v ./packr2
|
||||
make tidy
|
||||
|
||||
test:
|
||||
packr2
|
||||
$(GO_BIN) test -tags ${TAGS} ./...
|
||||
make tidy
|
||||
|
||||
lint:
|
||||
gometalinter --vendor ./... --deadline=1m --skip=internal
|
||||
|
||||
update:
|
||||
$(GO_BIN) get -u -tags ${TAGS} ./...
|
||||
make tidy
|
||||
make install
|
||||
make test
|
||||
make tidy
|
||||
|
||||
release-test:
|
||||
$(GO_BIN) test -tags ${TAGS} -race ./...
|
||||
|
||||
release:
|
||||
release -y -f version.go
|
||||
make tidy
|
||||
239
vendor/github.com/gobuffalo/packr/v2/README.md
generated
vendored
Normal file
239
vendor/github.com/gobuffalo/packr/v2/README.md
generated
vendored
Normal file
@@ -0,0 +1,239 @@
|
||||
**NOTICE: Please consider migrating your projects to github.com/markbates/pkger. It has an idiomatic API, minimal dependencies, a stronger test suite (tested directly against the std lib counterparts), transparent tooling, and more.**
|
||||
|
||||
https://blog.gobuffalo.io/introducing-pkger-static-file-embedding-in-go-1ce76dc79c65
|
||||
|
||||
# Packr (v2)
|
||||
|
||||
[](https://godoc.org/github.com/gobuffalo/packr/v2)
|
||||
|
||||
Packr is a simple solution for bundling static assets inside of Go binaries. Most importantly it does it in a way that is friendly to developers while they are developing.
|
||||
|
||||
## Intro Video
|
||||
|
||||
To get an idea of the what and why of Packr, please enjoy this short video: [https://vimeo.com/219863271](https://vimeo.com/219863271).
|
||||
|
||||
## Library Installation
|
||||
|
||||
```text
|
||||
$ go get -u github.com/gobuffalo/packr/v2/...
|
||||
```
|
||||
|
||||
## Binary Installation
|
||||
|
||||
```text
|
||||
$ go get -u github.com/gobuffalo/packr/v2/packr2
|
||||
```
|
||||
|
||||
## New File Format FAQs
|
||||
|
||||
In version `v2.0.0` the file format changed and is not backward compatible with the `packr-v1.x` library.
|
||||
|
||||
#### Can `packr-v1.x` read the new format?
|
||||
|
||||
No, it can not. Because of the way the new file format works porting it to `packr-v1.x` would be difficult. PRs are welcome though. :)
|
||||
|
||||
#### Can `packr-v2.x` read `packr-v1.x` files?
|
||||
|
||||
Yes it can, but that ability will eventually be phased out. Because of that we recommend moving to the new format.
|
||||
|
||||
#### Can `packr-v2.x` generate `packr-v1.x` files?
|
||||
|
||||
Yes it can, but that ability will eventually be phased out. Because of that we recommend moving to the new format.
|
||||
|
||||
The `--legacy` command is available on all commands that generate `-packr.go` files.
|
||||
|
||||
```bash
|
||||
$ packr2 --legacy
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### In Code
|
||||
|
||||
The first step in using Packr is to create a new box. A box represents a folder on disk. Once you have a box you can get `string` or `[]byte` representations of the file.
|
||||
|
||||
```go
|
||||
// set up a new box by giving it a name and an optional (relative) path to a folder on disk:
|
||||
box := packr.New("My Box", "./templates")
|
||||
|
||||
// Get the string representation of a file, or an error if it doesn't exist:
|
||||
html, err := box.FindString("index.html")
|
||||
|
||||
// Get the []byte representation of a file, or an error if it doesn't exist:
|
||||
html, err := box.Find("index.html")
|
||||
```
|
||||
|
||||
### What is a Box?
|
||||
|
||||
A box represents a folder, and any sub-folders, on disk that you want to have access to in your binary. When compiling a binary using the `packr2` CLI the contents of the folder will be converted into Go files that can be compiled inside of a "standard" go binary. Inside of the compiled binary the files will be read from memory. When working locally the files will be read directly off of disk. This is a seamless switch that doesn't require any special attention on your part.
|
||||
|
||||
#### Example
|
||||
|
||||
Assume the follow directory structure:
|
||||
|
||||
```
|
||||
├── main.go
|
||||
└── templates
|
||||
├── admin
|
||||
│ └── index.html
|
||||
└── index.html
|
||||
```
|
||||
|
||||
The following program will read the `./templates/admin/index.html` file and print it out.
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gobuffalo/packr/v2"
|
||||
)
|
||||
|
||||
func main() {
|
||||
box := packr.New("myBox", "./templates")
|
||||
|
||||
s, err := box.FindString("admin/index.html")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
fmt.Println(s)
|
||||
}
|
||||
```
|
||||
|
||||
### Development Made Easy
|
||||
|
||||
In order to get static files into a Go binary, those files must first be converted to Go code. To do that, Packr, ships with a few tools to help build binaries. See below.
|
||||
|
||||
During development, however, it is painful to have to keep running a tool to compile those files.
|
||||
|
||||
Packr uses the following resolution rules when looking for a file:
|
||||
|
||||
1. Look for the file in-memory (inside a Go binary)
|
||||
1. Look for the file on disk (during development)
|
||||
|
||||
Because Packr knows how to fall through to the file system, developers don't need to worry about constantly compiling their static files into a binary. They can work unimpeded.
|
||||
|
||||
Packr takes file resolution a step further. When declaring a new box you use a relative path, `./templates`. When Packr receives this call it calculates out the absolute path to that directory. By doing this it means you can be guaranteed that Packr can find your files correctly, even if you're not running in the directory that the box was created in. This helps with the problem of testing, where Go changes the `pwd` for each package, making relative paths difficult to work with. This is not a problem when using Packr.
|
||||
|
||||
---
|
||||
|
||||
## Usage with HTTP
|
||||
|
||||
A box implements the [`http.FileSystem`](https://golang.org/pkg/net/http/#FileSystem) interface, meaning it can be used to serve static files.
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gobuffalo/packr/v2"
|
||||
)
|
||||
|
||||
func main() {
|
||||
box := packr.New("someBoxName", "./templates")
|
||||
|
||||
http.Handle("/", http.FileServer(box))
|
||||
http.ListenAndServe(":3000", nil)
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Building a Binary
|
||||
|
||||
Before you build your Go binary, run the `packr2` command first. It will look for all the boxes in your code and then generate `.go` files that pack the static files into bytes that can be bundled into the Go binary.
|
||||
|
||||
```
|
||||
$ packr2
|
||||
```
|
||||
|
||||
Then run your `go build command` like normal.
|
||||
|
||||
*NOTE*: It is not recommended to check-in these generated `-packr.go` files. They can be large, and can easily become out of date if not careful. It is recommended that you always run `packr2 clean` after running the `packr2` tool.
|
||||
|
||||
#### Cleaning Up
|
||||
|
||||
When you're done it is recommended that you run the `packr2 clean` command. This will remove all of the generated files that Packr created for you.
|
||||
|
||||
```
|
||||
$ packr2 clean
|
||||
```
|
||||
|
||||
Why do you want to do this? Packr first looks to the information stored in these generated files, if the information isn't there it looks to disk. This makes it easy to work with in development.
|
||||
|
||||
---
|
||||
|
||||
## Debugging
|
||||
|
||||
The `packr2` command passes all arguments down to the underlying `go` command, this includes the `-v` flag to print out `go build` information. Packr looks for the `-v` flag, and will turn on its own verbose logging. This is very useful for trying to understand what the `packr` command is doing when it is run.
|
||||
|
||||
---
|
||||
|
||||
## FAQ
|
||||
|
||||
### Compilation Errors with Go Templates
|
||||
|
||||
Q: I have a program with Go template files, those files are named `foo.go` and look like the following:
|
||||
|
||||
```
|
||||
// Copyright {{.Year}} {{.Author}}. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package {{.Project}}
|
||||
```
|
||||
|
||||
When I run `packr2` I get errors like:
|
||||
|
||||
```
|
||||
expected 'IDENT', found '{'
|
||||
```
|
||||
|
||||
A: Packr works by searching your `.go` files for [`github.com/gobuffalo/packr/v2#New`](https://godoc.org/github.com/gobuffalo/packr/v2#New) or [`github.com/gobuffalo/packr/v2#NewBox`](https://godoc.org/github.com/gobuffalo/packr/v2#NewBox) calls. Because those files aren't "proper" Go files, Packr can't parse them to find the box declarations. To fix this you need to tell Packr to ignore those files when searching for boxes. A couple solutions to this problem are:
|
||||
|
||||
* Name the files something else. The `.tmpl` extension is the idiomatic way of naming these types of files.
|
||||
* Rename the folder containing these files to start with an `_`, for example `_templates`. Packr, like Go, will ignore folders starting with the `_` character when searching for boxes.
|
||||
|
||||
### Dynamic Box Paths
|
||||
|
||||
Q: I need to set the path of a box using a variable, but `packr.New("foo", myVar)` doesn't work correctly.
|
||||
|
||||
A: Packr attempts to "automagically" set it's resolution directory when using [`github.com/gobuffalo/packr/v2#New`](https://godoc.org/github.com/gobuffalo/packr/v2#New), however, for dynamic paths you need to set it manually:
|
||||
|
||||
```go
|
||||
box := packr.New("foo", "|")
|
||||
box.ResolutionDir = myVar
|
||||
```
|
||||
|
||||
### I don't want to pack files, but still use the Packr interface.
|
||||
|
||||
Q: I want to write code that using the Packr tools, but doesn't actually pack the files into my binary. How can I do that?
|
||||
|
||||
A: Using [`github.com/gobuffalo/packr/v2#Folder`](https://godoc.org/github.com/gobuffalo/packr/v2#Folder) gives you back a `*packr.Box` that can be used as normal, but is excluded by the Packr tool when compiling.
|
||||
|
||||
### Packr Finds No Boxes
|
||||
|
||||
Q: I run `packr2 -v` but it doesn't find my boxes:
|
||||
|
||||
```
|
||||
DEBU[2019-03-18T18:48:52+01:00] *parser.Parser#NewFromRoots found prospects=0
|
||||
DEBU[2019-03-18T18:48:52+01:00] found 0 boxes
|
||||
```
|
||||
|
||||
A: Packr works by parsing `.go` files to find [`github.com/gobuffalo/packr/v2#Box`](https://godoc.org/github.com/gobuffalo/packr/v2#Box) and [`github.com/gobuffalo/packr/v2#NewBox`](https://godoc.org/github.com/gobuffalo/packr/v2#NewBox) declarations. If there aren't any `.go` in the folder that `packr2` is run in it can not find those declarations. To fix this problem run the `packr2` command in the directory containing your `.go` files.
|
||||
|
||||
### Box Interfaces
|
||||
|
||||
Q: I want to be able to easily test my applications by passing in mock boxes. How do I do that?
|
||||
|
||||
A: Packr boxes and files conform to the interfaces found at [`github.com/gobuffalo/packd`](https://godoc.org/github.com/gobuffalo/packd). Change your application to use those interfaces instead of the concrete Packr types.
|
||||
|
||||
```go
|
||||
// using concrete type
|
||||
func myFunc(box *packr.Box) {}
|
||||
|
||||
// using interfaces
|
||||
func myFunc(box packd.Box) {}
|
||||
```
|
||||
32
vendor/github.com/gobuffalo/packr/v2/SHOULDERS.md
generated
vendored
Normal file
32
vendor/github.com/gobuffalo/packr/v2/SHOULDERS.md
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
# /Users/smichalak/dev/packr/v2 Stands on the Shoulders of Giants
|
||||
|
||||
/Users/smichalak/dev/packr/v2 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/gobuffalo/logger](https://godoc.org/github.com/gobuffalo/logger)
|
||||
|
||||
* [github.com/gobuffalo/packd](https://godoc.org/github.com/gobuffalo/packd)
|
||||
|
||||
* [github.com/karrick/godirwalk](https://godoc.org/github.com/karrick/godirwalk)
|
||||
|
||||
* [github.com/konsorten/go-windows-terminal-sequences](https://godoc.org/github.com/konsorten/go-windows-terminal-sequences)
|
||||
|
||||
* [github.com/markbates/errx](https://godoc.org/github.com/markbates/errx)
|
||||
|
||||
* [github.com/markbates/oncer](https://godoc.org/github.com/markbates/oncer)
|
||||
|
||||
* [github.com/markbates/safe](https://godoc.org/github.com/markbates/safe)
|
||||
|
||||
* [github.com/rogpeppe/go-internal](https://godoc.org/github.com/rogpeppe/go-internal)
|
||||
|
||||
* [github.com/sirupsen/logrus](https://godoc.org/github.com/sirupsen/logrus)
|
||||
|
||||
* [github.com/spf13/cobra](https://godoc.org/github.com/spf13/cobra)
|
||||
|
||||
* [github.com/stretchr/testify](https://godoc.org/github.com/stretchr/testify)
|
||||
|
||||
* [golang.org/x/sync](https://godoc.org/golang.org/x/sync)
|
||||
|
||||
* [golang.org/x/tools](https://godoc.org/golang.org/x/tools)
|
||||
240
vendor/github.com/gobuffalo/packr/v2/box.go
generated
vendored
Normal file
240
vendor/github.com/gobuffalo/packr/v2/box.go
generated
vendored
Normal file
@@ -0,0 +1,240 @@
|
||||
package packr
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/gobuffalo/packd"
|
||||
"github.com/gobuffalo/packr/v2/file"
|
||||
"github.com/gobuffalo/packr/v2/file/resolver"
|
||||
"github.com/gobuffalo/packr/v2/plog"
|
||||
"github.com/markbates/oncer"
|
||||
)
|
||||
|
||||
var _ packd.Box = &Box{}
|
||||
var _ packd.HTTPBox = &Box{}
|
||||
var _ packd.Addable = &Box{}
|
||||
var _ packd.Walkable = &Box{}
|
||||
var _ packd.Finder = &Box{}
|
||||
|
||||
// Box represent a folder on a disk you want to
|
||||
// have access to in the built Go binary.
|
||||
type Box struct {
|
||||
Path string `json:"path"`
|
||||
Name string `json:"name"`
|
||||
ResolutionDir string `json:"resolution_dir"`
|
||||
DefaultResolver resolver.Resolver `json:"default_resolver"`
|
||||
resolvers resolversMap
|
||||
dirs dirsMap
|
||||
}
|
||||
|
||||
// NewBox returns a Box that can be used to
|
||||
// retrieve files from either disk or the embedded
|
||||
// binary.
|
||||
// Deprecated: Use New instead.
|
||||
func NewBox(path string) *Box {
|
||||
oncer.Deprecate(0, "packr.NewBox", "Use packr.New instead.")
|
||||
return New(path, path)
|
||||
}
|
||||
|
||||
// New returns a new Box with the name of the box
|
||||
// and the path of the box.
|
||||
func New(name string, path string) *Box {
|
||||
plog.Debug("packr", "New", "name", name, "path", path)
|
||||
b, _ := findBox(name)
|
||||
if b != nil {
|
||||
return b
|
||||
}
|
||||
|
||||
b = construct(name, path)
|
||||
plog.Debug(b, "New", "Box", b, "ResolutionDir", b.ResolutionDir)
|
||||
b, err := placeBox(b)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return b
|
||||
}
|
||||
|
||||
// Folder returns a Box that will NOT be packed.
|
||||
// This is useful for writing tests or tools that
|
||||
// need to work with a folder at runtime.
|
||||
func Folder(path string) *Box {
|
||||
return New(path, path)
|
||||
}
|
||||
|
||||
// SetResolver allows for the use of a custom resolver for
|
||||
// the specified file
|
||||
func (b *Box) SetResolver(file string, res resolver.Resolver) {
|
||||
d := filepath.Dir(file)
|
||||
b.dirs.Store(d, true)
|
||||
plog.Debug(b, "SetResolver", "file", file, "resolver", fmt.Sprintf("%T", res))
|
||||
b.resolvers.Store(resolver.Key(file), res)
|
||||
}
|
||||
|
||||
// AddString converts t to a byteslice and delegates to AddBytes to add to b.data
|
||||
func (b *Box) AddString(path string, t string) error {
|
||||
return b.AddBytes(path, []byte(t))
|
||||
}
|
||||
|
||||
// AddBytes sets t in b.data by the given path
|
||||
func (b *Box) AddBytes(path string, t []byte) error {
|
||||
m := map[string]file.File{}
|
||||
f, err := file.NewFile(path, t)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
m[resolver.Key(path)] = f
|
||||
res := resolver.NewInMemory(m)
|
||||
b.SetResolver(path, res)
|
||||
return nil
|
||||
}
|
||||
|
||||
// FindString returns either the string of the requested
|
||||
// file or an error if it can not be found.
|
||||
func (b *Box) FindString(name string) (string, error) {
|
||||
bb, err := b.Find(name)
|
||||
return string(bb), err
|
||||
}
|
||||
|
||||
// Find returns either the byte slice of the requested
|
||||
// file or an error if it can not be found.
|
||||
func (b *Box) Find(name string) ([]byte, error) {
|
||||
f, err := b.Resolve(name)
|
||||
if err != nil {
|
||||
return []byte(""), err
|
||||
}
|
||||
bb := &bytes.Buffer{}
|
||||
io.Copy(bb, f)
|
||||
return bb.Bytes(), nil
|
||||
}
|
||||
|
||||
// Has returns true if the resource exists in the box
|
||||
func (b *Box) Has(name string) bool {
|
||||
_, err := b.Find(name)
|
||||
return err == nil
|
||||
}
|
||||
|
||||
// HasDir returns true if the directory exists in the box
|
||||
func (b *Box) HasDir(name string) bool {
|
||||
oncer.Do("packr2/box/HasDir"+b.Name, func() {
|
||||
for _, f := range b.List() {
|
||||
for d := filepath.Dir(f); d != "."; d = filepath.Dir(d) {
|
||||
b.dirs.Store(d, true)
|
||||
}
|
||||
}
|
||||
})
|
||||
if name == "/" {
|
||||
return b.Has("index.html")
|
||||
}
|
||||
_, ok := b.dirs.Load(name)
|
||||
return ok
|
||||
}
|
||||
|
||||
// Open returns a File using the http.File interface
|
||||
func (b *Box) Open(name string) (http.File, error) {
|
||||
plog.Debug(b, "Open", "name", name)
|
||||
f, err := b.Resolve(name)
|
||||
if err != nil {
|
||||
if len(filepath.Ext(name)) == 0 {
|
||||
return b.openWoExt(name)
|
||||
}
|
||||
return f, err
|
||||
}
|
||||
f, err = file.NewFileR(name, f)
|
||||
plog.Debug(b, "Open", "name", f.Name(), "file", f.Name())
|
||||
return f, err
|
||||
}
|
||||
|
||||
func (b *Box) openWoExt(name string) (http.File, error) {
|
||||
if !b.HasDir(name) {
|
||||
id := path.Join(name, "index.html")
|
||||
if b.Has(id) {
|
||||
return b.Open(id)
|
||||
}
|
||||
return nil, os.ErrNotExist
|
||||
}
|
||||
d, err := file.NewDir(name)
|
||||
plog.Debug(b, "Open", "name", name, "dir", d)
|
||||
return d, err
|
||||
}
|
||||
|
||||
// List shows "What's in the box?"
|
||||
func (b *Box) List() []string {
|
||||
var keys []string
|
||||
|
||||
b.Walk(func(path string, info File) error {
|
||||
if info == nil {
|
||||
return nil
|
||||
}
|
||||
finfo, _ := info.FileInfo()
|
||||
if !finfo.IsDir() {
|
||||
keys = append(keys, path)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
sort.Strings(keys)
|
||||
return keys
|
||||
}
|
||||
|
||||
// Resolve will attempt to find the file in the box,
|
||||
// returning an error if the find can not be found.
|
||||
func (b *Box) Resolve(key string) (file.File, error) {
|
||||
key = strings.TrimPrefix(key, "/")
|
||||
|
||||
var r resolver.Resolver
|
||||
|
||||
b.resolvers.Range(func(k string, vr resolver.Resolver) bool {
|
||||
lk := strings.ToLower(resolver.Key(k))
|
||||
lkey := strings.ToLower(resolver.Key(key))
|
||||
if lk == lkey {
|
||||
r = vr
|
||||
return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
|
||||
if r == nil {
|
||||
r = b.DefaultResolver
|
||||
if r == nil {
|
||||
r = resolver.DefaultResolver
|
||||
if r == nil {
|
||||
return nil, fmt.Errorf("resolver.DefaultResolver is nil")
|
||||
}
|
||||
}
|
||||
}
|
||||
plog.Debug(r, "Resolve", "box", b.Name, "key", key)
|
||||
|
||||
f, err := r.Resolve(b.Name, key)
|
||||
if err != nil {
|
||||
z, err := resolver.ResolvePathInBase(resolver.OsPath(b.ResolutionDir), filepath.FromSlash(path.Clean("/"+resolver.OsPath(key))))
|
||||
if err != nil {
|
||||
plog.Debug(r, "Resolve", "box", b.Name, "key", key, "err", err)
|
||||
return f, err
|
||||
}
|
||||
|
||||
f, err = r.Resolve(b.Name, z)
|
||||
if err != nil {
|
||||
plog.Debug(r, "Resolve", "box", b.Name, "key", z, "err", err)
|
||||
return f, err
|
||||
}
|
||||
b, err := ioutil.ReadAll(f)
|
||||
if err != nil {
|
||||
return f, err
|
||||
}
|
||||
f, err = file.NewFile(key, b)
|
||||
if err != nil {
|
||||
return f, err
|
||||
}
|
||||
}
|
||||
plog.Debug(r, "Resolve", "box", b.Name, "key", key, "file", f.Name())
|
||||
return f, nil
|
||||
}
|
||||
73
vendor/github.com/gobuffalo/packr/v2/box_map.go
generated
vendored
Normal file
73
vendor/github.com/gobuffalo/packr/v2/box_map.go
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
//go:generate mapgen -name "box" -zero "nil" -go-type "*Box" -pkg "" -a "New(`test-a`, ``)" -b "New(`test-b`, ``)" -c "New(`test-c`, ``)" -bb "New(`test-bb`, ``)" -destination "packr"
|
||||
// Code generated by github.com/gobuffalo/mapgen. DO NOT EDIT.
|
||||
|
||||
package packr
|
||||
|
||||
import (
|
||||
"sort"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// boxMap wraps sync.Map and uses the following types:
|
||||
// key: string
|
||||
// value: *Box
|
||||
type boxMap struct {
|
||||
data sync.Map
|
||||
}
|
||||
|
||||
// Delete the key from the map
|
||||
func (m *boxMap) Delete(key string) {
|
||||
m.data.Delete(key)
|
||||
}
|
||||
|
||||
// Load the key from the map.
|
||||
// Returns *Box or bool.
|
||||
// A false return indicates either the key was not found
|
||||
// or the value is not of type *Box
|
||||
func (m *boxMap) Load(key string) (*Box, bool) {
|
||||
i, ok := m.data.Load(key)
|
||||
if !ok {
|
||||
return nil, false
|
||||
}
|
||||
s, ok := i.(*Box)
|
||||
return s, ok
|
||||
}
|
||||
|
||||
// LoadOrStore will return an existing key or
|
||||
// store the value if not already in the map
|
||||
func (m *boxMap) LoadOrStore(key string, value *Box) (*Box, bool) {
|
||||
i, _ := m.data.LoadOrStore(key, value)
|
||||
s, ok := i.(*Box)
|
||||
return s, ok
|
||||
}
|
||||
|
||||
// Range over the *Box values in the map
|
||||
func (m *boxMap) Range(f func(key string, value *Box) bool) {
|
||||
m.data.Range(func(k, v interface{}) bool {
|
||||
key, ok := k.(string)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
value, ok := v.(*Box)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
return f(key, value)
|
||||
})
|
||||
}
|
||||
|
||||
// Store a *Box in the map
|
||||
func (m *boxMap) Store(key string, value *Box) {
|
||||
m.data.Store(key, value)
|
||||
}
|
||||
|
||||
// Keys returns a list of keys in the map
|
||||
func (m *boxMap) Keys() []string {
|
||||
var keys []string
|
||||
m.Range(func(key string, value *Box) bool {
|
||||
keys = append(keys, key)
|
||||
return true
|
||||
})
|
||||
sort.Strings(keys)
|
||||
return keys
|
||||
}
|
||||
79
vendor/github.com/gobuffalo/packr/v2/deprecated.go
generated
vendored
Normal file
79
vendor/github.com/gobuffalo/packr/v2/deprecated.go
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
package packr
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/gobuffalo/packr/v2/file"
|
||||
"github.com/gobuffalo/packr/v2/file/resolver"
|
||||
"github.com/markbates/oncer"
|
||||
)
|
||||
|
||||
// File has been deprecated and file.File should be used instead
|
||||
type File = file.File
|
||||
|
||||
var (
|
||||
// ErrResOutsideBox gets returned in case of the requested resources being outside the box
|
||||
// Deprecated
|
||||
ErrResOutsideBox = fmt.Errorf("can't find a resource outside the box")
|
||||
)
|
||||
|
||||
// PackBytes packs bytes for a file into a box.
|
||||
// Deprecated
|
||||
func PackBytes(box string, name string, bb []byte) {
|
||||
b := NewBox(box)
|
||||
d := resolver.NewInMemory(map[string]file.File{})
|
||||
f, err := file.NewFile(name, bb)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := d.Pack(name, f); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
b.SetResolver(name, d)
|
||||
}
|
||||
|
||||
// PackBytesGzip packets the gzipped compressed bytes into a box.
|
||||
// Deprecated
|
||||
func PackBytesGzip(box string, name string, bb []byte) error {
|
||||
// TODO: this function never did what it was supposed to do!
|
||||
PackBytes(box, name, bb)
|
||||
return nil
|
||||
}
|
||||
|
||||
// PackJSONBytes packs JSON encoded bytes for a file into a box.
|
||||
// Deprecated
|
||||
func PackJSONBytes(box string, name string, jbb string) error {
|
||||
var bb []byte
|
||||
err := json.Unmarshal([]byte(jbb), &bb)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
PackBytes(box, name, bb)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Bytes is deprecated. Use Find instead
|
||||
func (b *Box) Bytes(name string) []byte {
|
||||
bb, _ := b.Find(name)
|
||||
oncer.Deprecate(0, "github.com/gobuffalo/packr/v2#Box.Bytes", "Use github.com/gobuffalo/packr/v2#Box.Find instead.")
|
||||
return bb
|
||||
}
|
||||
|
||||
// MustBytes is deprecated. Use Find instead.
|
||||
func (b *Box) MustBytes(name string) ([]byte, error) {
|
||||
oncer.Deprecate(0, "github.com/gobuffalo/packr/v2#Box.MustBytes", "Use github.com/gobuffalo/packr/v2#Box.Find instead.")
|
||||
return b.Find(name)
|
||||
}
|
||||
|
||||
// String is deprecated. Use FindString instead
|
||||
func (b *Box) String(name string) string {
|
||||
oncer.Deprecate(0, "github.com/gobuffalo/packr/v2#Box.String", "Use github.com/gobuffalo/packr/v2#Box.FindString instead.")
|
||||
return string(b.Bytes(name))
|
||||
}
|
||||
|
||||
// MustString is deprecated. Use FindString instead
|
||||
func (b *Box) MustString(name string) (string, error) {
|
||||
oncer.Deprecate(0, "github.com/gobuffalo/packr/v2#Box.MustString", "Use github.com/gobuffalo/packr/v2#Box.FindString instead.")
|
||||
return b.FindString(name)
|
||||
}
|
||||
82
vendor/github.com/gobuffalo/packr/v2/dirs_map.go
generated
vendored
Normal file
82
vendor/github.com/gobuffalo/packr/v2/dirs_map.go
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
//go:generate mapgen -name "dirs" -zero "false" -go-type "bool" -pkg "" -a "nil" -b "nil" -c "nil" -bb "nil" -destination "packr"
|
||||
// Code generated by github.com/gobuffalo/mapgen. DO NOT EDIT.
|
||||
|
||||
package packr
|
||||
|
||||
import (
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// dirsMap wraps sync.Map and uses the following types:
|
||||
// key: string
|
||||
// value: bool
|
||||
type dirsMap struct {
|
||||
data sync.Map
|
||||
}
|
||||
|
||||
// Delete the key from the map
|
||||
func (m *dirsMap) Delete(key string) {
|
||||
m.data.Delete(m.normalizeKey(key))
|
||||
}
|
||||
|
||||
// Load the key from the map.
|
||||
// Returns bool or bool.
|
||||
// A false return indicates either the key was not found
|
||||
// or the value is not of type bool
|
||||
func (m *dirsMap) Load(key string) (bool, bool) {
|
||||
i, ok := m.data.Load(m.normalizeKey(key))
|
||||
if !ok {
|
||||
return false, false
|
||||
}
|
||||
s, ok := i.(bool)
|
||||
return s, ok
|
||||
}
|
||||
|
||||
// LoadOrStore will return an existing key or
|
||||
// store the value if not already in the map
|
||||
func (m *dirsMap) LoadOrStore(key string, value bool) (bool, bool) {
|
||||
i, _ := m.data.LoadOrStore(m.normalizeKey(key), value)
|
||||
s, ok := i.(bool)
|
||||
return s, ok
|
||||
}
|
||||
|
||||
// Range over the bool values in the map
|
||||
func (m *dirsMap) Range(f func(key string, value bool) bool) {
|
||||
m.data.Range(func(k, v interface{}) bool {
|
||||
key, ok := k.(string)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
value, ok := v.(bool)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
return f(key, value)
|
||||
})
|
||||
}
|
||||
|
||||
// Store a bool in the map
|
||||
func (m *dirsMap) Store(key string, value bool) {
|
||||
d := m.normalizeKey(key)
|
||||
m.data.Store(d, value)
|
||||
m.data.Store(strings.TrimPrefix(d, "/"), value)
|
||||
}
|
||||
|
||||
// Keys returns a list of keys in the map
|
||||
func (m *dirsMap) Keys() []string {
|
||||
var keys []string
|
||||
m.Range(func(key string, value bool) bool {
|
||||
keys = append(keys, key)
|
||||
return true
|
||||
})
|
||||
sort.Strings(keys)
|
||||
return keys
|
||||
}
|
||||
|
||||
func (m *dirsMap) normalizeKey(key string) string {
|
||||
key = strings.Replace(key, "\\", "/", -1)
|
||||
|
||||
return key
|
||||
}
|
||||
32
vendor/github.com/gobuffalo/packr/v2/file/file.go
generated
vendored
Normal file
32
vendor/github.com/gobuffalo/packr/v2/file/file.go
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
package file
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
|
||||
"github.com/gobuffalo/packd"
|
||||
)
|
||||
|
||||
// File represents a virtual, or physical, backing of
|
||||
// a file object in a Box
|
||||
type File = packd.File
|
||||
|
||||
// FileMappable types are capable of returning a map of
|
||||
// path => File
|
||||
type FileMappable interface {
|
||||
FileMap() map[string]File
|
||||
}
|
||||
|
||||
// NewFile returns a virtual File implementation
|
||||
func NewFile(name string, b []byte) (File, error) {
|
||||
return packd.NewFile(name, bytes.NewReader(b))
|
||||
}
|
||||
|
||||
// NewDir returns a virtual dir implementation
|
||||
func NewDir(name string) (File, error) {
|
||||
return packd.NewDir(name)
|
||||
}
|
||||
|
||||
func NewFileR(name string, r io.Reader) (File, error) {
|
||||
return packd.NewFile(name, r)
|
||||
}
|
||||
38
vendor/github.com/gobuffalo/packr/v2/file/info.go
generated
vendored
Normal file
38
vendor/github.com/gobuffalo/packr/v2/file/info.go
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
package file
|
||||
|
||||
import (
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
type info struct {
|
||||
Path string
|
||||
Contents []byte
|
||||
size int64
|
||||
modTime time.Time
|
||||
isDir bool
|
||||
}
|
||||
|
||||
func (f info) Name() string {
|
||||
return f.Path
|
||||
}
|
||||
|
||||
func (f info) Size() int64 {
|
||||
return f.size
|
||||
}
|
||||
|
||||
func (f info) Mode() os.FileMode {
|
||||
return 0444
|
||||
}
|
||||
|
||||
func (f info) ModTime() time.Time {
|
||||
return f.modTime
|
||||
}
|
||||
|
||||
func (f info) IsDir() bool {
|
||||
return f.isDir
|
||||
}
|
||||
|
||||
func (f info) Sys() interface{} {
|
||||
return nil
|
||||
}
|
||||
111
vendor/github.com/gobuffalo/packr/v2/file/resolver/disk.go
generated
vendored
Normal file
111
vendor/github.com/gobuffalo/packr/v2/file/resolver/disk.go
generated
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
package resolver
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/gobuffalo/packr/v2/file"
|
||||
"github.com/gobuffalo/packr/v2/plog"
|
||||
"github.com/karrick/godirwalk"
|
||||
)
|
||||
|
||||
var _ Resolver = &Disk{}
|
||||
|
||||
type Disk struct {
|
||||
Root string
|
||||
}
|
||||
|
||||
func (d Disk) String() string {
|
||||
return String(&d)
|
||||
}
|
||||
|
||||
func (d *Disk) Resolve(box string, name string) (file.File, error) {
|
||||
var err error
|
||||
path := OsPath(name)
|
||||
if !filepath.IsAbs(path) {
|
||||
path, err = ResolvePathInBase(OsPath(d.Root), path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
fi, err := os.Stat(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if fi.IsDir() {
|
||||
return nil, os.ErrNotExist
|
||||
}
|
||||
if bb, err := ioutil.ReadFile(path); err == nil {
|
||||
return file.NewFile(OsPath(name), bb)
|
||||
}
|
||||
return nil, os.ErrNotExist
|
||||
}
|
||||
|
||||
// ResolvePathInBase returns a path that is guaranteed to be inside of the base directory or an error
|
||||
func ResolvePathInBase(base, path string) (string, error) {
|
||||
// Determine the absolute file path of the base directory
|
||||
d, err := filepath.Abs(base)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
// Return the base directory if no file was requested
|
||||
if path == "/" || path == "\\" {
|
||||
return d, nil
|
||||
}
|
||||
|
||||
// Resolve the absolute file path after combining the key with base
|
||||
p, err := filepath.Abs(filepath.Join(d, path))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
// Verify that the resolved path is inside of the base directory
|
||||
if !strings.HasPrefix(p, d+string(filepath.Separator)) {
|
||||
return "", os.ErrNotExist
|
||||
}
|
||||
return p, nil
|
||||
}
|
||||
|
||||
var _ file.FileMappable = &Disk{}
|
||||
|
||||
func (d *Disk) FileMap() map[string]file.File {
|
||||
moot := &sync.Mutex{}
|
||||
m := map[string]file.File{}
|
||||
root := OsPath(d.Root)
|
||||
if _, err := os.Stat(root); err != nil {
|
||||
return m
|
||||
}
|
||||
callback := func(path string, de *godirwalk.Dirent) error {
|
||||
if _, err := os.Stat(root); err != nil {
|
||||
return nil
|
||||
}
|
||||
if !de.IsRegular() {
|
||||
return nil
|
||||
}
|
||||
moot.Lock()
|
||||
name := strings.TrimPrefix(path, root+string(filepath.Separator))
|
||||
b, err := ioutil.ReadFile(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
m[name], err = file.NewFile(name, b)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
moot.Unlock()
|
||||
return nil
|
||||
}
|
||||
err := godirwalk.Walk(root, &godirwalk.Options{
|
||||
FollowSymbolicLinks: true,
|
||||
Callback: callback,
|
||||
})
|
||||
if err != nil {
|
||||
plog.Logger.Errorf("[%s] error walking %v", root, err)
|
||||
}
|
||||
return m
|
||||
}
|
||||
314
vendor/github.com/gobuffalo/packr/v2/file/resolver/encoding/hex/hex.go
generated
vendored
Normal file
314
vendor/github.com/gobuffalo/packr/v2/file/resolver/encoding/hex/hex.go
generated
vendored
Normal file
@@ -0,0 +1,314 @@
|
||||
// Copyright 2009 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package hex implements hexadecimal encoding and decoding.
|
||||
package hex
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
)
|
||||
|
||||
const hextable = "0123456789abcdef"
|
||||
|
||||
// EncodedLen returns the length of an encoding of n source bytes.
|
||||
// Specifically, it returns n * 2.
|
||||
func EncodedLen(n int) int { return n * 2 }
|
||||
|
||||
// Encode encodes src into EncodedLen(len(src))
|
||||
// bytes of dst. As a convenience, it returns the number
|
||||
// of bytes written to dst, but this value is always EncodedLen(len(src)).
|
||||
// Encode implements hexadecimal encoding.
|
||||
func Encode(dst, src []byte) int {
|
||||
for i, v := range src {
|
||||
dst[i*2] = hextable[v>>4]
|
||||
dst[i*2+1] = hextable[v&0x0f]
|
||||
}
|
||||
|
||||
return len(src) * 2
|
||||
}
|
||||
|
||||
// ErrLength reports an attempt to decode an odd-length input
|
||||
// using Decode or DecodeString.
|
||||
// The stream-based Decoder returns io.ErrUnexpectedEOF instead of ErrLength.
|
||||
var ErrLength = fmt.Errorf("encoding/hex: odd length hex string")
|
||||
|
||||
// InvalidByteError values describe errors resulting from an invalid byte in a hex string.
|
||||
type InvalidByteError byte
|
||||
|
||||
func (e InvalidByteError) Error() string {
|
||||
return fmt.Sprintf("encoding/hex: invalid byte: %#U", rune(e))
|
||||
}
|
||||
|
||||
// DecodedLen returns the length of a decoding of x source bytes.
|
||||
// Specifically, it returns x / 2.
|
||||
func DecodedLen(x int) int { return x / 2 }
|
||||
|
||||
// Decode decodes src into DecodedLen(len(src)) bytes,
|
||||
// returning the actual number of bytes written to dst.
|
||||
//
|
||||
// Decode expects that src contains only hexadecimal
|
||||
// characters and that src has even length.
|
||||
// If the input is malformed, Decode returns the number
|
||||
// of bytes decoded before the error.
|
||||
func Decode(dst, src []byte) (int, error) {
|
||||
var i int
|
||||
for i = 0; i < len(src)/2; i++ {
|
||||
a, ok := fromHexChar(src[i*2])
|
||||
if !ok {
|
||||
return i, InvalidByteError(src[i*2])
|
||||
}
|
||||
b, ok := fromHexChar(src[i*2+1])
|
||||
if !ok {
|
||||
return i, InvalidByteError(src[i*2+1])
|
||||
}
|
||||
dst[i] = (a << 4) | b
|
||||
}
|
||||
if len(src)%2 == 1 {
|
||||
// Check for invalid char before reporting bad length,
|
||||
// since the invalid char (if present) is an earlier problem.
|
||||
if _, ok := fromHexChar(src[i*2]); !ok {
|
||||
return i, InvalidByteError(src[i*2])
|
||||
}
|
||||
return i, ErrLength
|
||||
}
|
||||
return i, nil
|
||||
}
|
||||
|
||||
// fromHexChar converts a hex character into its value and a success flag.
|
||||
func fromHexChar(c byte) (byte, bool) {
|
||||
switch {
|
||||
case '0' <= c && c <= '9':
|
||||
return c - '0', true
|
||||
case 'a' <= c && c <= 'f':
|
||||
return c - 'a' + 10, true
|
||||
case 'A' <= c && c <= 'F':
|
||||
return c - 'A' + 10, true
|
||||
}
|
||||
|
||||
return 0, false
|
||||
}
|
||||
|
||||
// EncodeToString returns the hexadecimal encoding of src.
|
||||
func EncodeToString(src []byte) string {
|
||||
dst := make([]byte, EncodedLen(len(src)))
|
||||
Encode(dst, src)
|
||||
return string(dst)
|
||||
}
|
||||
|
||||
// DecodeString returns the bytes represented by the hexadecimal string s.
|
||||
//
|
||||
// DecodeString expects that src contains only hexadecimal
|
||||
// characters and that src has even length.
|
||||
// If the input is malformed, DecodeString returns
|
||||
// the bytes decoded before the error.
|
||||
func DecodeString(s string) ([]byte, error) {
|
||||
src := []byte(s)
|
||||
// We can use the source slice itself as the destination
|
||||
// because the decode loop increments by one and then the 'seen' byte is not used anymore.
|
||||
n, err := Decode(src, src)
|
||||
return src[:n], err
|
||||
}
|
||||
|
||||
// Dump returns a string that contains a hex dump of the given data. The format
|
||||
// of the hex dump matches the output of `hexdump -C` on the command line.
|
||||
func Dump(data []byte) string {
|
||||
var buf bytes.Buffer
|
||||
dumper := Dumper(&buf)
|
||||
dumper.Write(data)
|
||||
dumper.Close()
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
// bufferSize is the number of hexadecimal characters to buffer in encoder and decoder.
|
||||
const bufferSize = 1024
|
||||
|
||||
type encoder struct {
|
||||
w io.Writer
|
||||
err error
|
||||
out [bufferSize]byte // output buffer
|
||||
}
|
||||
|
||||
// NewEncoder returns an io.Writer that writes lowercase hexadecimal characters to w.
|
||||
func NewEncoder(w io.Writer) io.Writer {
|
||||
return &encoder{w: w}
|
||||
}
|
||||
|
||||
func (e *encoder) Write(p []byte) (n int, err error) {
|
||||
for len(p) > 0 && e.err == nil {
|
||||
chunkSize := bufferSize / 2
|
||||
if len(p) < chunkSize {
|
||||
chunkSize = len(p)
|
||||
}
|
||||
|
||||
var written int
|
||||
encoded := Encode(e.out[:], p[:chunkSize])
|
||||
written, e.err = e.w.Write(e.out[:encoded])
|
||||
n += written / 2
|
||||
p = p[chunkSize:]
|
||||
}
|
||||
return n, e.err
|
||||
}
|
||||
|
||||
type decoder struct {
|
||||
r io.Reader
|
||||
err error
|
||||
in []byte // input buffer (encoded form)
|
||||
arr [bufferSize]byte // backing array for in
|
||||
}
|
||||
|
||||
// NewDecoder returns an io.Reader that decodes hexadecimal characters from r.
|
||||
// NewDecoder expects that r contain only an even number of hexadecimal characters.
|
||||
func NewDecoder(r io.Reader) io.Reader {
|
||||
return &decoder{r: r}
|
||||
}
|
||||
|
||||
func (d *decoder) Read(p []byte) (n int, err error) {
|
||||
// Fill internal buffer with sufficient bytes to decode
|
||||
if len(d.in) < 2 && d.err == nil {
|
||||
var numCopy, numRead int
|
||||
numCopy = copy(d.arr[:], d.in) // Copies either 0 or 1 bytes
|
||||
numRead, d.err = d.r.Read(d.arr[numCopy:])
|
||||
d.in = d.arr[:numCopy+numRead]
|
||||
if d.err == io.EOF && len(d.in)%2 != 0 {
|
||||
if _, ok := fromHexChar(d.in[len(d.in)-1]); !ok {
|
||||
d.err = InvalidByteError(d.in[len(d.in)-1])
|
||||
} else {
|
||||
d.err = io.ErrUnexpectedEOF
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Decode internal buffer into output buffer
|
||||
if numAvail := len(d.in) / 2; len(p) > numAvail {
|
||||
p = p[:numAvail]
|
||||
}
|
||||
numDec, err := Decode(p, d.in[:len(p)*2])
|
||||
d.in = d.in[2*numDec:]
|
||||
if err != nil {
|
||||
d.in, d.err = nil, err // Decode error; discard input remainder
|
||||
}
|
||||
|
||||
if len(d.in) < 2 {
|
||||
return numDec, d.err // Only expose errors when buffer fully consumed
|
||||
}
|
||||
return numDec, nil
|
||||
}
|
||||
|
||||
// Dumper returns a WriteCloser that writes a hex dump of all written data to
|
||||
// w. The format of the dump matches the output of `hexdump -C` on the command
|
||||
// line.
|
||||
func Dumper(w io.Writer) io.WriteCloser {
|
||||
return &dumper{w: w}
|
||||
}
|
||||
|
||||
type dumper struct {
|
||||
w io.Writer
|
||||
rightChars [18]byte
|
||||
buf [14]byte
|
||||
used int // number of bytes in the current line
|
||||
n uint // number of bytes, total
|
||||
closed bool
|
||||
}
|
||||
|
||||
func toChar(b byte) byte {
|
||||
if b < 32 || b > 126 {
|
||||
return '.'
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func (h *dumper) Write(data []byte) (n int, err error) {
|
||||
if h.closed {
|
||||
return 0, fmt.Errorf("encoding/hex: dumper closed")
|
||||
}
|
||||
|
||||
// Output lines look like:
|
||||
// 00000010 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d |./0123456789:;<=|
|
||||
// ^ offset ^ extra space ^ ASCII of line.
|
||||
for i := range data {
|
||||
if h.used == 0 {
|
||||
// At the beginning of a line we print the current
|
||||
// offset in hex.
|
||||
h.buf[0] = byte(h.n >> 24)
|
||||
h.buf[1] = byte(h.n >> 16)
|
||||
h.buf[2] = byte(h.n >> 8)
|
||||
h.buf[3] = byte(h.n)
|
||||
Encode(h.buf[4:], h.buf[:4])
|
||||
h.buf[12] = ' '
|
||||
h.buf[13] = ' '
|
||||
_, err = h.w.Write(h.buf[4:])
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
Encode(h.buf[:], data[i:i+1])
|
||||
h.buf[2] = ' '
|
||||
l := 3
|
||||
if h.used == 7 {
|
||||
// There's an additional space after the 8th byte.
|
||||
h.buf[3] = ' '
|
||||
l = 4
|
||||
} else if h.used == 15 {
|
||||
// At the end of the line there's an extra space and
|
||||
// the bar for the right column.
|
||||
h.buf[3] = ' '
|
||||
h.buf[4] = '|'
|
||||
l = 5
|
||||
}
|
||||
_, err = h.w.Write(h.buf[:l])
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
n++
|
||||
h.rightChars[h.used] = toChar(data[i])
|
||||
h.used++
|
||||
h.n++
|
||||
if h.used == 16 {
|
||||
h.rightChars[16] = '|'
|
||||
h.rightChars[17] = '\n'
|
||||
_, err = h.w.Write(h.rightChars[:])
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
h.used = 0
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (h *dumper) Close() (err error) {
|
||||
// See the comments in Write() for the details of this format.
|
||||
if h.closed {
|
||||
return
|
||||
}
|
||||
h.closed = true
|
||||
if h.used == 0 {
|
||||
return
|
||||
}
|
||||
h.buf[0] = ' '
|
||||
h.buf[1] = ' '
|
||||
h.buf[2] = ' '
|
||||
h.buf[3] = ' '
|
||||
h.buf[4] = '|'
|
||||
nBytes := h.used
|
||||
for h.used < 16 {
|
||||
l := 3
|
||||
if h.used == 7 {
|
||||
l = 4
|
||||
} else if h.used == 15 {
|
||||
l = 5
|
||||
}
|
||||
_, err = h.w.Write(h.buf[:l])
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
h.used++
|
||||
}
|
||||
h.rightChars[nBytes] = '|'
|
||||
h.rightChars[nBytes+1] = '\n'
|
||||
_, err = h.w.Write(h.rightChars[:nBytes+2])
|
||||
return
|
||||
}
|
||||
112
vendor/github.com/gobuffalo/packr/v2/file/resolver/hex_gzip.go
generated
vendored
Normal file
112
vendor/github.com/gobuffalo/packr/v2/file/resolver/hex_gzip.go
generated
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
package resolver
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"compress/gzip"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/gobuffalo/packr/v2/file/resolver/encoding/hex"
|
||||
"github.com/gobuffalo/packr/v2/plog"
|
||||
|
||||
"github.com/gobuffalo/packr/v2/file"
|
||||
)
|
||||
|
||||
var _ Resolver = &HexGzip{}
|
||||
|
||||
type HexGzip struct {
|
||||
packed map[string]string
|
||||
unpacked map[string]string
|
||||
moot *sync.RWMutex
|
||||
}
|
||||
|
||||
func (hg HexGzip) String() string {
|
||||
return String(&hg)
|
||||
}
|
||||
|
||||
var _ file.FileMappable = &HexGzip{}
|
||||
|
||||
func (hg *HexGzip) FileMap() map[string]file.File {
|
||||
hg.moot.RLock()
|
||||
var names []string
|
||||
for k := range hg.packed {
|
||||
names = append(names, k)
|
||||
}
|
||||
hg.moot.RUnlock()
|
||||
m := map[string]file.File{}
|
||||
for _, n := range names {
|
||||
if f, err := hg.Resolve("", n); err == nil {
|
||||
m[n] = f
|
||||
}
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
func (hg *HexGzip) Resolve(box string, name string) (file.File, error) {
|
||||
plog.Debug(hg, "Resolve", "box", box, "name", name)
|
||||
hg.moot.Lock()
|
||||
defer hg.moot.Unlock()
|
||||
|
||||
if s, ok := hg.unpacked[name]; ok {
|
||||
return file.NewFile(name, []byte(s))
|
||||
}
|
||||
packed, ok := hg.packed[name]
|
||||
if !ok {
|
||||
return nil, os.ErrNotExist
|
||||
}
|
||||
|
||||
unpacked, err := UnHexGzipString(packed)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
f, err := file.NewFile(OsPath(name), []byte(unpacked))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
hg.unpacked[name] = f.String()
|
||||
return f, nil
|
||||
}
|
||||
|
||||
func NewHexGzip(files map[string]string) (*HexGzip, error) {
|
||||
if files == nil {
|
||||
files = map[string]string{}
|
||||
}
|
||||
|
||||
hg := &HexGzip{
|
||||
packed: files,
|
||||
unpacked: map[string]string{},
|
||||
moot: &sync.RWMutex{},
|
||||
}
|
||||
|
||||
return hg, nil
|
||||
}
|
||||
|
||||
func HexGzipString(s string) (string, error) {
|
||||
bb := &bytes.Buffer{}
|
||||
enc := hex.NewEncoder(bb)
|
||||
zw := gzip.NewWriter(enc)
|
||||
io.Copy(zw, strings.NewReader(s))
|
||||
zw.Close()
|
||||
|
||||
return bb.String(), nil
|
||||
}
|
||||
|
||||
func UnHexGzipString(packed string) (string, error) {
|
||||
br := bytes.NewBufferString(packed)
|
||||
dec := hex.NewDecoder(br)
|
||||
zr, err := gzip.NewReader(dec)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
defer zr.Close()
|
||||
|
||||
b, err := ioutil.ReadAll(zr)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return string(b), nil
|
||||
}
|
||||
21
vendor/github.com/gobuffalo/packr/v2/file/resolver/ident.go
generated
vendored
Normal file
21
vendor/github.com/gobuffalo/packr/v2/file/resolver/ident.go
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
package resolver
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func Key(s string) string {
|
||||
s = strings.Replace(s, "\\", "/", -1)
|
||||
return s
|
||||
}
|
||||
|
||||
func OsPath(s string) string {
|
||||
if runtime.GOOS == "windows" {
|
||||
s = strings.Replace(s, "/", string(filepath.Separator), -1)
|
||||
} else {
|
||||
s = strings.Replace(s, "\\", string(filepath.Separator), -1)
|
||||
}
|
||||
return s
|
||||
}
|
||||
63
vendor/github.com/gobuffalo/packr/v2/file/resolver/in_memory.go
generated
vendored
Normal file
63
vendor/github.com/gobuffalo/packr/v2/file/resolver/in_memory.go
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
package resolver
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
|
||||
"github.com/gobuffalo/packd"
|
||||
"github.com/gobuffalo/packr/v2/file"
|
||||
"github.com/gobuffalo/packr/v2/plog"
|
||||
)
|
||||
|
||||
var _ Resolver = &InMemory{}
|
||||
|
||||
type InMemory struct {
|
||||
*packd.MemoryBox
|
||||
}
|
||||
|
||||
func (d InMemory) String() string {
|
||||
return String(&d)
|
||||
}
|
||||
|
||||
func (d *InMemory) Resolve(box string, name string) (file.File, error) {
|
||||
b, err := d.MemoryBox.Find(name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return file.NewFile(name, b)
|
||||
}
|
||||
|
||||
func (d *InMemory) Pack(name string, f file.File) error {
|
||||
plog.Debug(d, "Pack", "name", name)
|
||||
b, err := ioutil.ReadAll(f)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
d.AddBytes(name, b)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *InMemory) FileMap() map[string]file.File {
|
||||
m := map[string]file.File{}
|
||||
d.Walk(func(path string, file file.File) error {
|
||||
m[path] = file
|
||||
return nil
|
||||
})
|
||||
return m
|
||||
}
|
||||
|
||||
func NewInMemory(files map[string]file.File) *InMemory {
|
||||
if files == nil {
|
||||
files = map[string]file.File{}
|
||||
}
|
||||
box := packd.NewMemoryBox()
|
||||
|
||||
for p, f := range files {
|
||||
if b, err := ioutil.ReadAll(f); err == nil {
|
||||
box.AddBytes(p, b)
|
||||
}
|
||||
}
|
||||
|
||||
return &InMemory{
|
||||
MemoryBox: box,
|
||||
}
|
||||
}
|
||||
7
vendor/github.com/gobuffalo/packr/v2/file/resolver/packable.go
generated
vendored
Normal file
7
vendor/github.com/gobuffalo/packr/v2/file/resolver/packable.go
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
package resolver
|
||||
|
||||
import "github.com/gobuffalo/packr/v2/file"
|
||||
|
||||
type Packable interface {
|
||||
Pack(name string, f file.File) error
|
||||
}
|
||||
33
vendor/github.com/gobuffalo/packr/v2/file/resolver/resolver.go
generated
vendored
Normal file
33
vendor/github.com/gobuffalo/packr/v2/file/resolver/resolver.go
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
package resolver
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/gobuffalo/packr/v2/file"
|
||||
)
|
||||
|
||||
type Resolver interface {
|
||||
Resolve(string, string) (file.File, error)
|
||||
}
|
||||
|
||||
func defaultResolver() Resolver {
|
||||
pwd, _ := os.Getwd()
|
||||
return &Disk{
|
||||
Root: pwd,
|
||||
}
|
||||
}
|
||||
|
||||
var DefaultResolver = defaultResolver()
|
||||
|
||||
func String(r Resolver) string {
|
||||
m := map[string]interface{}{
|
||||
"name": fmt.Sprintf("%T", r),
|
||||
}
|
||||
if fm, ok := r.(file.FileMappable); ok {
|
||||
m["files"] = fm
|
||||
}
|
||||
b, _ := json.Marshal(m)
|
||||
return string(b)
|
||||
}
|
||||
19
vendor/github.com/gobuffalo/packr/v2/go.mod
generated
vendored
Normal file
19
vendor/github.com/gobuffalo/packr/v2/go.mod
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
module github.com/gobuffalo/packr/v2
|
||||
|
||||
go 1.13
|
||||
|
||||
require (
|
||||
github.com/gobuffalo/logger v1.0.3
|
||||
github.com/gobuffalo/packd v1.0.0
|
||||
github.com/karrick/godirwalk v1.15.8
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
|
||||
github.com/markbates/errx v1.1.0
|
||||
github.com/markbates/oncer v1.0.0
|
||||
github.com/markbates/safe v1.0.1
|
||||
github.com/rogpeppe/go-internal v1.5.2
|
||||
github.com/sirupsen/logrus v1.4.2
|
||||
github.com/spf13/cobra v0.0.6
|
||||
github.com/stretchr/testify v1.5.1
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e
|
||||
golang.org/x/tools v0.0.0-20200308013534-11ec41452d41
|
||||
)
|
||||
180
vendor/github.com/gobuffalo/packr/v2/go.sum
generated
vendored
Normal file
180
vendor/github.com/gobuffalo/packr/v2/go.sum
generated
vendored
Normal file
@@ -0,0 +1,180 @@
|
||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
|
||||
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
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/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/gobuffalo/logger v1.0.3 h1:YaXOTHNPCvkqqA7w05A4v0k2tCdpr+sgFlgINbQ6gqc=
|
||||
github.com/gobuffalo/logger v1.0.3/go.mod h1:SoeejUwldiS7ZsyCBphOGURmWdwUFXs0J7TCjEhjKxM=
|
||||
github.com/gobuffalo/packd v1.0.0 h1:6ERZvJHfe24rfFmA9OaoKBdC7+c9sydrytMg8SdFGBM=
|
||||
github.com/gobuffalo/packd v1.0.0/go.mod h1:6VTc4htmJRFB7u1m/4LeMTWjFoYrUiBkU9Fdec9hrhI=
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
||||
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
|
||||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
|
||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
|
||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
github.com/karrick/godirwalk v1.15.8 h1:7+rWAZPn9zuRxaIqqT8Ohs2Q2Ac0msBqwRdxNCr2VVs=
|
||||
github.com/karrick/godirwalk v1.15.8/go.mod h1:j4mkqPuvaLI8mp1DroR3P6ad7cyYd4c1qeJ3RV7ULlk=
|
||||
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||
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/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||
github.com/markbates/errx v1.1.0 h1:QDFeR+UP95dO12JgW+tgi2UVfo0V8YBHiUIOaeBPiEI=
|
||||
github.com/markbates/errx v1.1.0/go.mod h1:PLa46Oex9KNbVDZhKel8v1OT7hD5JZ2eI7AHhA0wswc=
|
||||
github.com/markbates/oncer v1.0.0 h1:E83IaVAHygyndzPimgUYJjbshhDTALZyXxvk9FOlQRY=
|
||||
github.com/markbates/oncer v1.0.0/go.mod h1:Z59JA581E9GP6w96jai+TGqafHPW+cPfRxz2aSZ0mcI=
|
||||
github.com/markbates/safe v1.0.1 h1:yjZkbvRM6IzKj9tlu/zMJLS0n/V351OZWRnF3QfaUxI=
|
||||
github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
|
||||
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
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/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||
github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
|
||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
|
||||
github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
|
||||
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
|
||||
github.com/rogpeppe/go-internal v1.5.2 h1:qLvObTrvO/XRCqmkKxUlOBc48bI3efyDuAZe25QiF0w=
|
||||
github.com/rogpeppe/go-internal v1.5.2/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
|
||||
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
||||
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
|
||||
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
||||
github.com/spf13/cobra v0.0.6 h1:breEStsVwemnKh2/s6gMvSdMEkwW0sK8vGStnlVBMCs=
|
||||
github.com/spf13/cobra v0.0.6/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=
|
||||
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
|
||||
github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
|
||||
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
|
||||
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
|
||||
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
|
||||
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
|
||||
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
||||
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
||||
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20191122220453-ac88ee75c92c h1:/nJuwDLoL/zrqY6gf57vxC+Pi+pZ8bfhpPkicO5H7W4=
|
||||
golang.org/x/crypto v0.0.0-20191122220453-ac88ee75c92c/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20200308013534-11ec41452d41 h1:9Di9iYgOt9ThCipBxChBVhgNipDoE5mxO84rQV7D0FE=
|
||||
golang.org/x/tools v0.0.0-20200308013534-11ec41452d41/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
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/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
|
||||
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
72
vendor/github.com/gobuffalo/packr/v2/helpers.go
generated
vendored
Normal file
72
vendor/github.com/gobuffalo/packr/v2/helpers.go
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
package packr
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/gobuffalo/packr/v2/plog"
|
||||
)
|
||||
|
||||
func construct(name string, path string) *Box {
|
||||
return &Box{
|
||||
Path: path,
|
||||
Name: name,
|
||||
ResolutionDir: resolutionDir(path),
|
||||
resolvers: resolversMap{},
|
||||
dirs: dirsMap{},
|
||||
}
|
||||
}
|
||||
|
||||
func resolutionDirTestFilename(filename, og string) (string, bool) {
|
||||
ng := filepath.Join(filepath.Dir(filename), og)
|
||||
|
||||
// // this little hack courtesy of the `-cover` flag!!
|
||||
cov := filepath.Join("_test", "_obj_test")
|
||||
ng = strings.Replace(ng, string(filepath.Separator)+cov, "", 1)
|
||||
|
||||
if resolutionDirExists(ng, og) {
|
||||
return ng, true
|
||||
}
|
||||
|
||||
ng = filepath.Join(os.Getenv("GOPATH"), "src", ng)
|
||||
if resolutionDirExists(ng, og) {
|
||||
return ng, true
|
||||
}
|
||||
|
||||
return og, false
|
||||
}
|
||||
|
||||
func resolutionDirExists(s, og string) bool {
|
||||
_, err := os.Stat(s)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
plog.Debug("packr", "resolutionDir", "original", og, "resolved", s)
|
||||
return true
|
||||
}
|
||||
|
||||
func resolutionDir(og string) string {
|
||||
ng, _ := filepath.Abs(og)
|
||||
|
||||
if resolutionDirExists(ng, og) {
|
||||
return ng
|
||||
}
|
||||
|
||||
// packr.New
|
||||
_, filename, _, _ := runtime.Caller(3)
|
||||
ng, ok := resolutionDirTestFilename(filename, og)
|
||||
if ok {
|
||||
return ng
|
||||
}
|
||||
|
||||
// packr.NewBox (deprecated)
|
||||
_, filename, _, _ = runtime.Caller(4)
|
||||
ng, ok = resolutionDirTestFilename(filename, og)
|
||||
if ok {
|
||||
return ng
|
||||
}
|
||||
|
||||
return og
|
||||
}
|
||||
37
vendor/github.com/gobuffalo/packr/v2/internal/envy.go
generated
vendored
Normal file
37
vendor/github.com/gobuffalo/packr/v2/internal/envy.go
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
"os"
|
||||
"runtime"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Mods returns true when go modules supports is enabled
|
||||
func Mods() bool {
|
||||
go111 := os.Getenv("GO111MODULE")
|
||||
|
||||
if !inGoPath() {
|
||||
return go111 != "off"
|
||||
}
|
||||
|
||||
return go111 == "on"
|
||||
}
|
||||
|
||||
func inGoPath() bool {
|
||||
pwd, _ := os.Getwd()
|
||||
for _, p := range GoPaths() {
|
||||
if strings.HasPrefix(pwd, p) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// GoPaths return the defined gopath list.
|
||||
func GoPaths() []string {
|
||||
gp := os.Getenv("GOPATH")
|
||||
if runtime.GOOS == "windows" {
|
||||
return strings.Split(gp, ";") // Windows uses a different separator
|
||||
}
|
||||
return strings.Split(gp, ":")
|
||||
}
|
||||
113
vendor/github.com/gobuffalo/packr/v2/jam/pack.go
generated
vendored
Normal file
113
vendor/github.com/gobuffalo/packr/v2/jam/pack.go
generated
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
package jam
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
"time"
|
||||
|
||||
"github.com/gobuffalo/packr/v2/jam/parser"
|
||||
"github.com/gobuffalo/packr/v2/jam/store"
|
||||
"github.com/gobuffalo/packr/v2/plog"
|
||||
)
|
||||
|
||||
// PackOptions ...
|
||||
type PackOptions struct {
|
||||
IgnoreImports bool
|
||||
Legacy bool
|
||||
StoreCmd string
|
||||
Roots []string
|
||||
RootsOptions *parser.RootsOptions
|
||||
}
|
||||
|
||||
// Pack the roots given + PWD
|
||||
func Pack(opts PackOptions) error {
|
||||
pwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
opts.Roots = append(opts.Roots, pwd)
|
||||
if err := Clean(opts.Roots...); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if opts.RootsOptions == nil {
|
||||
opts.RootsOptions = &parser.RootsOptions{}
|
||||
}
|
||||
|
||||
if opts.IgnoreImports {
|
||||
opts.RootsOptions.IgnoreImports = true
|
||||
}
|
||||
|
||||
p, err := parser.NewFromRoots(opts.Roots, opts.RootsOptions)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
boxes, err := p.Run()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// reduce boxes - remove ones we don't want
|
||||
// MB: current assumption is we want all these
|
||||
// boxes, just adding a comment suggesting they're
|
||||
// might be a reason to exclude some
|
||||
|
||||
plog.Logger.Debugf("found %d boxes", len(boxes))
|
||||
|
||||
if len(opts.StoreCmd) != 0 {
|
||||
return ShellPack(opts, boxes)
|
||||
}
|
||||
|
||||
var st store.Store = store.NewDisk("", "")
|
||||
|
||||
if opts.Legacy {
|
||||
st = store.NewLegacy()
|
||||
}
|
||||
|
||||
for _, b := range boxes {
|
||||
if b.Name == store.DISK_GLOBAL_KEY {
|
||||
continue
|
||||
}
|
||||
if err := st.Pack(b); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if cl, ok := st.(io.Closer); ok {
|
||||
return cl.Close()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ShellPack ...
|
||||
func ShellPack(opts PackOptions, boxes parser.Boxes) error {
|
||||
b, err := json.Marshal(boxes)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
|
||||
defer cancel()
|
||||
c := exec.CommandContext(ctx, opts.StoreCmd, string(b))
|
||||
c.Stdout = os.Stdout
|
||||
c.Stderr = os.Stderr
|
||||
return c.Run()
|
||||
|
||||
}
|
||||
|
||||
// Clean ...
|
||||
func Clean(args ...string) error {
|
||||
pwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
args = append(args, pwd)
|
||||
for _, root := range args {
|
||||
if err := store.Clean(root); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
52
vendor/github.com/gobuffalo/packr/v2/jam/parser/args.go
generated
vendored
Normal file
52
vendor/github.com/gobuffalo/packr/v2/jam/parser/args.go
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
package parser
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// FromArgs is useful when writing packr store-cmd binaries.
|
||||
/*
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/gobuffalo/packr/v2/jam/parser"
|
||||
"github.com/markbates/s3packr/s3packr"
|
||||
)
|
||||
|
||||
func main() {
|
||||
err := parser.FromArgs(os.Args[1:], func(boxes parser.Boxes) error {
|
||||
for _, box := range boxes {
|
||||
s3 := s3packr.New(box)
|
||||
if err := s3.Pack(box); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
*/
|
||||
func FromArgs(args []string, fn func(Boxes) error) error {
|
||||
if len(args) == 0 {
|
||||
return fmt.Errorf("you must supply a payload")
|
||||
}
|
||||
payload := args[0]
|
||||
if len(payload) == 0 {
|
||||
return fmt.Errorf("you must supply a payload")
|
||||
}
|
||||
|
||||
var boxes Boxes
|
||||
err := json.Unmarshal([]byte(payload), &boxes)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return fn(boxes)
|
||||
}
|
||||
40
vendor/github.com/gobuffalo/packr/v2/jam/parser/box.go
generated
vendored
Normal file
40
vendor/github.com/gobuffalo/packr/v2/jam/parser/box.go
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
package parser
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Box found while parsing a file
|
||||
type Box struct {
|
||||
Name string // name of the box
|
||||
Path string // relative path of folder NewBox("./templates")
|
||||
AbsPath string // absolute path of Path
|
||||
Package string // the package name the box was found in
|
||||
PWD string // the PWD when the parser was run
|
||||
PackageDir string // the absolute path of the package where the box was found
|
||||
}
|
||||
|
||||
type Boxes []*Box
|
||||
|
||||
// String - json returned
|
||||
func (b Box) String() string {
|
||||
x, _ := json.Marshal(b)
|
||||
return string(x)
|
||||
}
|
||||
|
||||
// NewBox stub from the name and the path provided
|
||||
func NewBox(name string, path string) *Box {
|
||||
if len(name) == 0 {
|
||||
name = path
|
||||
}
|
||||
name = strings.Replace(name, "\"", "", -1)
|
||||
pwd, _ := os.Getwd()
|
||||
box := &Box{
|
||||
Name: name,
|
||||
Path: path,
|
||||
PWD: pwd,
|
||||
}
|
||||
return box
|
||||
}
|
||||
54
vendor/github.com/gobuffalo/packr/v2/jam/parser/file.go
generated
vendored
Normal file
54
vendor/github.com/gobuffalo/packr/v2/jam/parser/file.go
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
package parser
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
// File that is to be parsed
|
||||
type File struct {
|
||||
io.Reader
|
||||
Path string
|
||||
AbsPath string
|
||||
}
|
||||
|
||||
// Name of the file "app.go"
|
||||
func (f File) Name() string {
|
||||
return f.Path
|
||||
}
|
||||
|
||||
// String returns the contents of the reader
|
||||
func (f *File) String() string {
|
||||
src, _ := ioutil.ReadAll(f)
|
||||
f.Reader = bytes.NewReader(src)
|
||||
return string(src)
|
||||
}
|
||||
|
||||
func (s *File) Write(p []byte) (int, error) {
|
||||
bb := &bytes.Buffer{}
|
||||
i, err := bb.Write(p)
|
||||
s.Reader = bb
|
||||
return i, err
|
||||
}
|
||||
|
||||
// NewFile takes the name of the file you want to
|
||||
// write to and a reader to reader from
|
||||
func NewFile(path string, r io.Reader) *File {
|
||||
if r == nil {
|
||||
r = &bytes.Buffer{}
|
||||
}
|
||||
if seek, ok := r.(io.Seeker); ok {
|
||||
seek.Seek(0, 0)
|
||||
}
|
||||
abs := path
|
||||
if !filepath.IsAbs(path) {
|
||||
abs, _ = filepath.Abs(path)
|
||||
}
|
||||
return &File{
|
||||
Reader: r,
|
||||
Path: path,
|
||||
AbsPath: abs,
|
||||
}
|
||||
}
|
||||
112
vendor/github.com/gobuffalo/packr/v2/jam/parser/finder.go
generated
vendored
Normal file
112
vendor/github.com/gobuffalo/packr/v2/jam/parser/finder.go
generated
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
package parser
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go/build"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gobuffalo/packr/v2/plog"
|
||||
"github.com/karrick/godirwalk"
|
||||
"github.com/markbates/errx"
|
||||
"github.com/markbates/oncer"
|
||||
)
|
||||
|
||||
type finder struct {
|
||||
id time.Time
|
||||
}
|
||||
|
||||
func (fd *finder) key(m, dir string) string {
|
||||
return fmt.Sprintf("%s-*parser.finder#%s-%s", fd.id, m, dir)
|
||||
}
|
||||
|
||||
// findAllGoFiles *.go files for a given diretory
|
||||
func (fd *finder) findAllGoFiles(dir string) ([]string, error) {
|
||||
var err error
|
||||
var names []string
|
||||
oncer.Do(fd.key("findAllGoFiles", dir), func() {
|
||||
plog.Debug(fd, "findAllGoFiles", "dir", dir)
|
||||
|
||||
callback := func(path string, do *godirwalk.Dirent) error {
|
||||
ext := filepath.Ext(path)
|
||||
if ext != ".go" {
|
||||
return nil
|
||||
}
|
||||
//check if path is a dir
|
||||
fi, err := os.Stat(path)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if fi.IsDir() {
|
||||
return nil
|
||||
}
|
||||
|
||||
names = append(names, path)
|
||||
return nil
|
||||
}
|
||||
err = godirwalk.Walk(dir, &godirwalk.Options{
|
||||
FollowSymbolicLinks: true,
|
||||
Callback: callback,
|
||||
})
|
||||
})
|
||||
|
||||
return names, err
|
||||
}
|
||||
|
||||
func (fd *finder) findAllGoFilesImports(dir string) ([]string, error) {
|
||||
var err error
|
||||
var names []string
|
||||
oncer.Do(fd.key("findAllGoFilesImports", dir), func() {
|
||||
ctx := build.Default
|
||||
|
||||
if len(ctx.SrcDirs()) == 0 {
|
||||
err = fmt.Errorf("no src directories found")
|
||||
return
|
||||
}
|
||||
|
||||
pkg, err := ctx.ImportDir(dir, 0)
|
||||
if strings.HasPrefix(pkg.ImportPath, "github.com/gobuffalo/packr") {
|
||||
return
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
if !strings.Contains(err.Error(), "cannot find package") {
|
||||
if _, ok := errx.Unwrap(err).(*build.NoGoError); !ok {
|
||||
err = err
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if pkg.Goroot {
|
||||
return
|
||||
}
|
||||
if len(pkg.GoFiles) <= 0 {
|
||||
return
|
||||
}
|
||||
|
||||
plog.Debug(fd, "findAllGoFilesImports", "dir", dir)
|
||||
|
||||
names, _ = fd.findAllGoFiles(dir)
|
||||
for _, n := range pkg.GoFiles {
|
||||
names = append(names, filepath.Join(pkg.Dir, n))
|
||||
}
|
||||
for _, imp := range pkg.Imports {
|
||||
if len(ctx.SrcDirs()) == 0 {
|
||||
continue
|
||||
}
|
||||
d := ctx.SrcDirs()[len(ctx.SrcDirs())-1]
|
||||
ip := filepath.Join(d, imp)
|
||||
n, err := fd.findAllGoFilesImports(ip)
|
||||
if err != nil && len(n) != 0 {
|
||||
names = n
|
||||
return
|
||||
}
|
||||
names = append(names, n...)
|
||||
}
|
||||
})
|
||||
return names, err
|
||||
}
|
||||
43
vendor/github.com/gobuffalo/packr/v2/jam/parser/gogen.go
generated
vendored
Normal file
43
vendor/github.com/gobuffalo/packr/v2/jam/parser/gogen.go
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
package parser
|
||||
|
||||
import (
|
||||
"go/ast"
|
||||
"go/parser"
|
||||
"go/token"
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
"github.com/gobuffalo/packd"
|
||||
"github.com/markbates/errx"
|
||||
)
|
||||
|
||||
// ParsedFile ...
|
||||
type ParsedFile struct {
|
||||
File packd.SimpleFile
|
||||
FileSet *token.FileSet
|
||||
Ast *ast.File
|
||||
Lines []string
|
||||
}
|
||||
|
||||
// ParseFileMode ...
|
||||
func ParseFileMode(gf packd.SimpleFile, mode parser.Mode) (ParsedFile, error) {
|
||||
pf := ParsedFile{
|
||||
FileSet: token.NewFileSet(),
|
||||
File: gf,
|
||||
}
|
||||
|
||||
src := gf.String()
|
||||
f, err := parser.ParseFile(pf.FileSet, gf.Name(), src, mode)
|
||||
if err != nil && errx.Unwrap(err) != io.EOF {
|
||||
return pf, err
|
||||
}
|
||||
pf.Ast = f
|
||||
|
||||
pf.Lines = strings.Split(src, "\n")
|
||||
return pf, nil
|
||||
}
|
||||
|
||||
// ParseFile ...
|
||||
func ParseFile(gf packd.SimpleFile) (ParsedFile, error) {
|
||||
return ParseFileMode(gf, 0)
|
||||
}
|
||||
46
vendor/github.com/gobuffalo/packr/v2/jam/parser/parser.go
generated
vendored
Normal file
46
vendor/github.com/gobuffalo/packr/v2/jam/parser/parser.go
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
package parser
|
||||
|
||||
import (
|
||||
"os"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/gobuffalo/packr/v2/plog"
|
||||
)
|
||||
|
||||
// Parser to find boxes
|
||||
type Parser struct {
|
||||
Prospects []*File // a list of files to check for boxes
|
||||
IgnoreImports bool
|
||||
}
|
||||
|
||||
// Run the parser and run any boxes found
|
||||
func (p *Parser) Run() (Boxes, error) {
|
||||
var boxes Boxes
|
||||
for _, pros := range p.Prospects {
|
||||
plog.Debug(p, "Run", "parsing", pros.Name())
|
||||
v := NewVisitor(pros)
|
||||
pbr, err := v.Run()
|
||||
if err != nil {
|
||||
return boxes, err
|
||||
}
|
||||
for _, b := range pbr {
|
||||
plog.Debug(p, "Run", "file", pros.Name(), "box", b.Name)
|
||||
boxes = append(boxes, b)
|
||||
}
|
||||
}
|
||||
|
||||
pwd, _ := os.Getwd()
|
||||
sort.Slice(boxes, func(a, b int) bool {
|
||||
b1 := boxes[a]
|
||||
return !strings.HasPrefix(b1.AbsPath, pwd)
|
||||
})
|
||||
return boxes, nil
|
||||
}
|
||||
|
||||
// New Parser from a list of File
|
||||
func New(prospects ...*File) *Parser {
|
||||
return &Parser{
|
||||
Prospects: prospects,
|
||||
}
|
||||
}
|
||||
77
vendor/github.com/gobuffalo/packr/v2/jam/parser/prospect.go
generated
vendored
Normal file
77
vendor/github.com/gobuffalo/packr/v2/jam/parser/prospect.go
generated
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
package parser
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/gobuffalo/packr/v2/file/resolver"
|
||||
"github.com/gobuffalo/packr/v2/plog"
|
||||
)
|
||||
|
||||
var DefaultIgnoredFolders = []string{".", "_", "vendor", "node_modules", "_fixtures", "testdata"}
|
||||
|
||||
func IsProspect(path string, ignore ...string) (status bool) {
|
||||
// plog.Debug("parser", "IsProspect", "path", path, "ignore", ignore)
|
||||
defer func() {
|
||||
if status {
|
||||
plog.Debug("parser", "IsProspect (TRUE)", "path", path, "status", status)
|
||||
}
|
||||
}()
|
||||
if path == "." {
|
||||
return true
|
||||
}
|
||||
|
||||
ext := filepath.Ext(path)
|
||||
dir := filepath.Dir(path)
|
||||
|
||||
fi, _ := os.Stat(path)
|
||||
if fi != nil {
|
||||
if fi.IsDir() {
|
||||
dir = filepath.Base(path)
|
||||
} else {
|
||||
if len(ext) > 0 {
|
||||
dir = filepath.Base(filepath.Dir(path))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
path = strings.ToLower(path)
|
||||
dir = strings.ToLower(dir)
|
||||
|
||||
if strings.HasSuffix(path, "-packr.go") {
|
||||
return false
|
||||
}
|
||||
|
||||
if strings.HasSuffix(path, "_test.go") {
|
||||
return false
|
||||
}
|
||||
|
||||
ignore = append(ignore, DefaultIgnoredFolders...)
|
||||
for i, x := range ignore {
|
||||
ignore[i] = strings.TrimSpace(strings.ToLower(x))
|
||||
}
|
||||
|
||||
parts := strings.Split(resolver.OsPath(path), string(filepath.Separator))
|
||||
if len(parts) == 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
for _, i := range ignore {
|
||||
for _, p := range parts {
|
||||
if strings.HasPrefix(p, i) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
un := filepath.Base(path)
|
||||
if len(ext) != 0 {
|
||||
un = filepath.Base(filepath.Dir(path))
|
||||
}
|
||||
if strings.HasPrefix(un, "_") {
|
||||
return false
|
||||
}
|
||||
|
||||
return ext == ".go"
|
||||
}
|
||||
89
vendor/github.com/gobuffalo/packr/v2/jam/parser/roots.go
generated
vendored
Normal file
89
vendor/github.com/gobuffalo/packr/v2/jam/parser/roots.go
generated
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
package parser
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/gobuffalo/packr/v2/plog"
|
||||
"github.com/karrick/godirwalk"
|
||||
)
|
||||
|
||||
type RootsOptions struct {
|
||||
IgnoreImports bool
|
||||
Ignores []string
|
||||
}
|
||||
|
||||
func (r RootsOptions) String() string {
|
||||
x, _ := json.Marshal(r)
|
||||
return string(x)
|
||||
}
|
||||
|
||||
// NewFromRoots scans the file roots provided and returns a
|
||||
// new Parser containing the prospects
|
||||
func NewFromRoots(roots []string, opts *RootsOptions) (*Parser, error) {
|
||||
if opts == nil {
|
||||
opts = &RootsOptions{}
|
||||
}
|
||||
|
||||
if len(roots) == 0 {
|
||||
pwd, _ := os.Getwd()
|
||||
roots = append(roots, pwd)
|
||||
}
|
||||
p := New()
|
||||
plog.Debug(p, "NewFromRoots", "roots", roots, "options", opts)
|
||||
callback := func(path string, de *godirwalk.Dirent) error {
|
||||
if IsProspect(path, opts.Ignores...) {
|
||||
if de.IsDir() {
|
||||
return nil
|
||||
}
|
||||
roots = append(roots, path)
|
||||
return nil
|
||||
}
|
||||
if de.IsDir() {
|
||||
return filepath.SkipDir
|
||||
}
|
||||
return nil
|
||||
}
|
||||
wopts := &godirwalk.Options{
|
||||
FollowSymbolicLinks: true,
|
||||
Callback: callback,
|
||||
}
|
||||
for _, root := range roots {
|
||||
plog.Debug(p, "NewFromRoots", "walking", root)
|
||||
err := godirwalk.Walk(root, wopts)
|
||||
if err != nil {
|
||||
return p, err
|
||||
}
|
||||
}
|
||||
|
||||
dd := map[string]string{}
|
||||
fd := &finder{id: time.Now()}
|
||||
for _, r := range roots {
|
||||
var names []string
|
||||
if opts.IgnoreImports {
|
||||
names, _ = fd.findAllGoFiles(r)
|
||||
} else {
|
||||
names, _ = fd.findAllGoFilesImports(r)
|
||||
}
|
||||
for _, n := range names {
|
||||
if IsProspect(n) {
|
||||
plog.Debug(p, "NewFromRoots", "mapping", n)
|
||||
dd[n] = n
|
||||
}
|
||||
}
|
||||
}
|
||||
for path := range dd {
|
||||
plog.Debug(p, "NewFromRoots", "reading file", path)
|
||||
b, err := ioutil.ReadFile(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
p.Prospects = append(p.Prospects, NewFile(path, bytes.NewReader(b)))
|
||||
}
|
||||
plog.Debug(p, "NewFromRoots", "found prospects", len(p.Prospects))
|
||||
return p, nil
|
||||
}
|
||||
324
vendor/github.com/gobuffalo/packr/v2/jam/parser/visitor.go
generated
vendored
Normal file
324
vendor/github.com/gobuffalo/packr/v2/jam/parser/visitor.go
generated
vendored
Normal file
@@ -0,0 +1,324 @@
|
||||
package parser
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go/ast"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/gobuffalo/packd"
|
||||
)
|
||||
|
||||
type Visitor struct {
|
||||
File packd.SimpleFile
|
||||
Package string
|
||||
boxes map[string]*Box
|
||||
errors []error
|
||||
}
|
||||
|
||||
func NewVisitor(f *File) *Visitor {
|
||||
return &Visitor{
|
||||
File: f,
|
||||
boxes: map[string]*Box{},
|
||||
errors: []error{},
|
||||
}
|
||||
}
|
||||
|
||||
func (v *Visitor) Run() (Boxes, error) {
|
||||
var boxes Boxes
|
||||
pf, err := ParseFile(v.File)
|
||||
if err != nil {
|
||||
return boxes, err
|
||||
}
|
||||
|
||||
v.Package = pf.Ast.Name.Name
|
||||
ast.Walk(v, pf.Ast)
|
||||
|
||||
for _, vb := range v.boxes {
|
||||
boxes = append(boxes, vb)
|
||||
}
|
||||
|
||||
sort.Slice(boxes, func(i, j int) bool {
|
||||
return boxes[i].Name < boxes[j].Name
|
||||
})
|
||||
|
||||
if len(v.errors) > 0 {
|
||||
s := make([]string, len(v.errors))
|
||||
for i, e := range v.errors {
|
||||
s[i] = e.Error()
|
||||
}
|
||||
return boxes, err
|
||||
}
|
||||
return boxes, nil
|
||||
}
|
||||
|
||||
func (v *Visitor) Visit(node ast.Node) ast.Visitor {
|
||||
if node == nil {
|
||||
return v
|
||||
}
|
||||
if err := v.eval(node); err != nil {
|
||||
v.errors = append(v.errors, err)
|
||||
}
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (v *Visitor) eval(node ast.Node) error {
|
||||
switch t := node.(type) {
|
||||
case *ast.CallExpr:
|
||||
return v.evalExpr(t)
|
||||
case *ast.Ident:
|
||||
return v.evalIdent(t)
|
||||
case *ast.GenDecl:
|
||||
for _, n := range t.Specs {
|
||||
if err := v.eval(n); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
case *ast.FuncDecl:
|
||||
if t.Body == nil {
|
||||
return nil
|
||||
}
|
||||
for _, b := range t.Body.List {
|
||||
if err := v.evalStmt(b); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
case *ast.ValueSpec:
|
||||
for _, e := range t.Values {
|
||||
if err := v.evalExpr(e); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (v *Visitor) evalStmt(stmt ast.Stmt) error {
|
||||
switch t := stmt.(type) {
|
||||
case *ast.ExprStmt:
|
||||
return v.evalExpr(t.X)
|
||||
case *ast.AssignStmt:
|
||||
for _, e := range t.Rhs {
|
||||
if err := v.evalArgs(e); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (v *Visitor) evalExpr(expr ast.Expr) error {
|
||||
switch t := expr.(type) {
|
||||
case *ast.CallExpr:
|
||||
if t.Fun == nil {
|
||||
return nil
|
||||
}
|
||||
for _, a := range t.Args {
|
||||
switch at := a.(type) {
|
||||
case *ast.CallExpr:
|
||||
if sel, ok := t.Fun.(*ast.SelectorExpr); ok {
|
||||
return v.evalSelector(at, sel)
|
||||
}
|
||||
|
||||
if err := v.evalArgs(at); err != nil {
|
||||
return err
|
||||
}
|
||||
case *ast.CompositeLit:
|
||||
for _, e := range at.Elts {
|
||||
if err := v.evalExpr(e); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ft, ok := t.Fun.(*ast.SelectorExpr); ok {
|
||||
return v.evalSelector(t, ft)
|
||||
}
|
||||
case *ast.KeyValueExpr:
|
||||
return v.evalExpr(t.Value)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (v *Visitor) evalArgs(expr ast.Expr) error {
|
||||
switch at := expr.(type) {
|
||||
case *ast.CompositeLit:
|
||||
for _, e := range at.Elts {
|
||||
if err := v.evalExpr(e); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
case *ast.CallExpr:
|
||||
if at.Fun == nil {
|
||||
return nil
|
||||
}
|
||||
switch st := at.Fun.(type) {
|
||||
case *ast.SelectorExpr:
|
||||
if err := v.evalSelector(at, st); err != nil {
|
||||
return err
|
||||
}
|
||||
case *ast.Ident:
|
||||
return v.evalIdent(st)
|
||||
}
|
||||
for _, a := range at.Args {
|
||||
if err := v.evalArgs(a); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (v *Visitor) evalSelector(expr *ast.CallExpr, sel *ast.SelectorExpr) error {
|
||||
x, ok := sel.X.(*ast.Ident)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
if x.Name == "packr" {
|
||||
switch sel.Sel.Name {
|
||||
case "New":
|
||||
if len(expr.Args) != 2 {
|
||||
return fmt.Errorf("`New` requires two arguments")
|
||||
}
|
||||
|
||||
zz := func(e ast.Expr) (string, error) {
|
||||
switch at := e.(type) {
|
||||
case *ast.Ident:
|
||||
switch at.Obj.Kind {
|
||||
case ast.Var:
|
||||
if as, ok := at.Obj.Decl.(*ast.AssignStmt); ok {
|
||||
return v.fromVariable(as)
|
||||
}
|
||||
case ast.Con:
|
||||
if vs, ok := at.Obj.Decl.(*ast.ValueSpec); ok {
|
||||
return v.fromConstant(vs)
|
||||
}
|
||||
}
|
||||
return "", v.evalIdent(at)
|
||||
case *ast.BasicLit:
|
||||
return at.Value, nil
|
||||
case *ast.CallExpr:
|
||||
return "", v.evalExpr(at)
|
||||
}
|
||||
return "", fmt.Errorf("can't handle %T", e)
|
||||
}
|
||||
|
||||
k1, err := zz(expr.Args[0])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
k2, err := zz(expr.Args[1])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
v.addBox(k1, k2)
|
||||
|
||||
return nil
|
||||
case "NewBox":
|
||||
for _, e := range expr.Args {
|
||||
switch at := e.(type) {
|
||||
case *ast.Ident:
|
||||
switch at.Obj.Kind {
|
||||
case ast.Var:
|
||||
if as, ok := at.Obj.Decl.(*ast.AssignStmt); ok {
|
||||
v.addVariable("", as)
|
||||
}
|
||||
case ast.Con:
|
||||
if vs, ok := at.Obj.Decl.(*ast.ValueSpec); ok {
|
||||
v.addConstant("", vs)
|
||||
}
|
||||
}
|
||||
return v.evalIdent(at)
|
||||
case *ast.BasicLit:
|
||||
v.addBox("", at.Value)
|
||||
case *ast.CallExpr:
|
||||
return v.evalExpr(at)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (v *Visitor) evalIdent(i *ast.Ident) error {
|
||||
if i.Obj == nil {
|
||||
return nil
|
||||
}
|
||||
if s, ok := i.Obj.Decl.(*ast.AssignStmt); ok {
|
||||
return v.evalStmt(s)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (v *Visitor) addBox(name string, path string) {
|
||||
if len(name) == 0 {
|
||||
name = path
|
||||
}
|
||||
name = strings.Replace(name, "\"", "", -1)
|
||||
path = strings.Replace(path, "\"", "", -1)
|
||||
abs := path
|
||||
if _, ok := v.boxes[name]; !ok {
|
||||
box := NewBox(name, path)
|
||||
box.Package = v.Package
|
||||
|
||||
pd := filepath.Dir(v.File.Name())
|
||||
pwd, _ := os.Getwd()
|
||||
if !filepath.IsAbs(pd) {
|
||||
pd = filepath.Join(pwd, pd)
|
||||
}
|
||||
box.PackageDir = pd
|
||||
|
||||
if !filepath.IsAbs(abs) {
|
||||
abs = filepath.Join(pd, abs)
|
||||
}
|
||||
box.AbsPath = abs
|
||||
v.boxes[name] = box
|
||||
}
|
||||
}
|
||||
func (v *Visitor) fromVariable(as *ast.AssignStmt) (string, error) {
|
||||
if len(as.Rhs) == 1 {
|
||||
if bs, ok := as.Rhs[0].(*ast.BasicLit); ok {
|
||||
return bs.Value, nil
|
||||
}
|
||||
}
|
||||
return "", fmt.Errorf("unable to find value from variable %v", as)
|
||||
}
|
||||
|
||||
func (v *Visitor) addVariable(bn string, as *ast.AssignStmt) error {
|
||||
bv, err := v.fromVariable(as)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
if len(bn) == 0 {
|
||||
bn = bv
|
||||
}
|
||||
v.addBox(bn, bv)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (v *Visitor) fromConstant(vs *ast.ValueSpec) (string, error) {
|
||||
if len(vs.Values) == 1 {
|
||||
if bs, ok := vs.Values[0].(*ast.BasicLit); ok {
|
||||
return bs.Value, nil
|
||||
}
|
||||
}
|
||||
return "", fmt.Errorf("unable to find value from constant %v", vs)
|
||||
}
|
||||
|
||||
func (v *Visitor) addConstant(bn string, vs *ast.ValueSpec) error {
|
||||
if len(vs.Values) == 1 {
|
||||
if bs, ok := vs.Values[0].(*ast.BasicLit); ok {
|
||||
bv := bs.Value
|
||||
if len(bn) == 0 {
|
||||
bn = bv
|
||||
}
|
||||
v.addBox(bn, bv)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
75
vendor/github.com/gobuffalo/packr/v2/jam/store/clean.go
generated
vendored
Normal file
75
vendor/github.com/gobuffalo/packr/v2/jam/store/clean.go
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/gobuffalo/packr/v2/jam/parser"
|
||||
)
|
||||
|
||||
func Clean(root string) error {
|
||||
defer func() {
|
||||
packd := filepath.Join(root, "packrd")
|
||||
os.RemoveAll(packd)
|
||||
}()
|
||||
|
||||
p, err := parser.NewFromRoots([]string{root}, &parser.RootsOptions{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
boxes, err := p.Run()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
d := NewDisk("", "")
|
||||
for _, box := range boxes {
|
||||
if err := d.Clean(box); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func clean(root string) error {
|
||||
if len(root) == 0 {
|
||||
pwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
root = pwd
|
||||
}
|
||||
if _, err := os.Stat(root); err != nil {
|
||||
return nil
|
||||
}
|
||||
defer func() {
|
||||
packd := filepath.Join(root, "packrd")
|
||||
os.RemoveAll(packd)
|
||||
}()
|
||||
|
||||
err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if info.IsDir() {
|
||||
if filepath.Base(path) == "packrd" {
|
||||
os.RemoveAll(path)
|
||||
return filepath.SkipDir
|
||||
}
|
||||
}
|
||||
if strings.HasSuffix(path, "-packr.go") {
|
||||
err := os.RemoveAll(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
348
vendor/github.com/gobuffalo/packr/v2/jam/store/disk.go
generated
vendored
Normal file
348
vendor/github.com/gobuffalo/packr/v2/jam/store/disk.go
generated
vendored
Normal file
@@ -0,0 +1,348 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"compress/gzip"
|
||||
"crypto/md5"
|
||||
"fmt"
|
||||
"go/build"
|
||||
"html/template"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/gobuffalo/packr/v2/internal"
|
||||
"github.com/karrick/godirwalk"
|
||||
|
||||
"github.com/gobuffalo/packr/v2/file/resolver/encoding/hex"
|
||||
"github.com/gobuffalo/packr/v2/plog"
|
||||
"github.com/rogpeppe/go-internal/modfile"
|
||||
|
||||
"github.com/gobuffalo/packr/v2/jam/parser"
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
||||
var _ Store = &Disk{}
|
||||
|
||||
const DISK_GLOBAL_KEY = "__packr_global__"
|
||||
|
||||
type Disk struct {
|
||||
DBPath string
|
||||
DBPackage string
|
||||
global map[string]string
|
||||
boxes map[string]*parser.Box
|
||||
moot *sync.RWMutex
|
||||
}
|
||||
|
||||
func NewDisk(path string, pkg string) *Disk {
|
||||
if len(path) == 0 {
|
||||
path = "packrd"
|
||||
}
|
||||
if len(pkg) == 0 {
|
||||
pkg = "packrd"
|
||||
}
|
||||
if !filepath.IsAbs(path) {
|
||||
path, _ = filepath.Abs(path)
|
||||
}
|
||||
return &Disk{
|
||||
DBPath: path,
|
||||
DBPackage: pkg,
|
||||
global: map[string]string{},
|
||||
boxes: map[string]*parser.Box{},
|
||||
moot: &sync.RWMutex{},
|
||||
}
|
||||
}
|
||||
|
||||
func (d *Disk) FileNames(box *parser.Box) ([]string, error) {
|
||||
path := box.AbsPath
|
||||
if len(box.AbsPath) == 0 {
|
||||
path = box.Path
|
||||
}
|
||||
var names []string
|
||||
if _, err := os.Stat(path); err != nil {
|
||||
return names, nil
|
||||
}
|
||||
err := godirwalk.Walk(path, &godirwalk.Options{
|
||||
FollowSymbolicLinks: true,
|
||||
Callback: func(path string, de *godirwalk.Dirent) error {
|
||||
if !de.IsRegular() {
|
||||
return nil
|
||||
}
|
||||
names = append(names, path)
|
||||
return nil
|
||||
},
|
||||
})
|
||||
return names, err
|
||||
}
|
||||
|
||||
func (d *Disk) Files(box *parser.Box) ([]*parser.File, error) {
|
||||
var files []*parser.File
|
||||
names, err := d.FileNames(box)
|
||||
if err != nil {
|
||||
return files, err
|
||||
}
|
||||
for _, n := range names {
|
||||
b, err := ioutil.ReadFile(n)
|
||||
if err != nil {
|
||||
return files, err
|
||||
}
|
||||
f := parser.NewFile(n, bytes.NewReader(b))
|
||||
files = append(files, f)
|
||||
}
|
||||
return files, nil
|
||||
}
|
||||
|
||||
func (d *Disk) Pack(box *parser.Box) error {
|
||||
plog.Debug(d, "Pack", "box", box.Name)
|
||||
d.boxes[box.Name] = box
|
||||
names, err := d.FileNames(box)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, n := range names {
|
||||
_, ok := d.global[n]
|
||||
if ok {
|
||||
continue
|
||||
}
|
||||
k := makeKey(box, n)
|
||||
// not in the global, so add it!
|
||||
d.global[n] = k
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *Disk) Clean(box *parser.Box) error {
|
||||
root := box.PackageDir
|
||||
if len(root) == 0 {
|
||||
return fmt.Errorf("can't clean an empty box.PackageDir")
|
||||
}
|
||||
plog.Debug(d, "Clean", "box", box.Name, "root", root)
|
||||
return clean(root)
|
||||
}
|
||||
|
||||
type options struct {
|
||||
Package string
|
||||
GlobalFiles map[string]string
|
||||
Boxes []optsBox
|
||||
GK string
|
||||
}
|
||||
|
||||
type optsBox struct {
|
||||
Name string
|
||||
Path string
|
||||
}
|
||||
|
||||
// Close ...
|
||||
func (d *Disk) Close() error {
|
||||
if len(d.boxes) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
xb := &parser.Box{Name: DISK_GLOBAL_KEY}
|
||||
opts := options{
|
||||
Package: d.DBPackage,
|
||||
GlobalFiles: map[string]string{},
|
||||
GK: makeKey(xb, d.DBPath),
|
||||
}
|
||||
|
||||
wg := errgroup.Group{}
|
||||
for k, v := range d.global {
|
||||
func(k, v string) {
|
||||
wg.Go(func() error {
|
||||
bb := &bytes.Buffer{}
|
||||
enc := hex.NewEncoder(bb)
|
||||
zw := gzip.NewWriter(enc)
|
||||
f, err := os.Open(k)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer f.Close()
|
||||
io.Copy(zw, f)
|
||||
if err := zw.Close(); err != nil {
|
||||
return err
|
||||
}
|
||||
d.moot.Lock()
|
||||
opts.GlobalFiles[makeKey(xb, k)] = bb.String()
|
||||
d.moot.Unlock()
|
||||
return nil
|
||||
})
|
||||
}(k, v)
|
||||
}
|
||||
|
||||
if err := wg.Wait(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, b := range d.boxes {
|
||||
ob := optsBox{
|
||||
Name: b.Name,
|
||||
}
|
||||
opts.Boxes = append(opts.Boxes, ob)
|
||||
}
|
||||
|
||||
sort.Slice(opts.Boxes, func(a, b int) bool {
|
||||
return opts.Boxes[a].Name < opts.Boxes[b].Name
|
||||
})
|
||||
|
||||
fm := template.FuncMap{
|
||||
"printBox": func(ob optsBox) (template.HTML, error) {
|
||||
box := d.boxes[ob.Name]
|
||||
if box == nil {
|
||||
return "", fmt.Errorf("could not find box %s", ob.Name)
|
||||
}
|
||||
fn, err := d.FileNames(box)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if len(fn) == 0 {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
type file struct {
|
||||
Resolver string
|
||||
ForwardPath string
|
||||
}
|
||||
|
||||
tmpl, err := template.New("box.go").Parse(diskGlobalBoxTmpl)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var files []file
|
||||
for _, s := range fn {
|
||||
p := strings.TrimPrefix(s, box.AbsPath)
|
||||
p = strings.TrimPrefix(p, string(filepath.Separator))
|
||||
files = append(files, file{
|
||||
Resolver: strings.Replace(p, "\\", "/", -1),
|
||||
ForwardPath: makeKey(box, s),
|
||||
})
|
||||
}
|
||||
opts := map[string]interface{}{
|
||||
"Box": box,
|
||||
"Files": files,
|
||||
}
|
||||
|
||||
bb := &bytes.Buffer{}
|
||||
if err := tmpl.Execute(bb, opts); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return template.HTML(bb.String()), nil
|
||||
},
|
||||
}
|
||||
|
||||
os.MkdirAll(d.DBPath, 0755)
|
||||
fp := filepath.Join(d.DBPath, "packed-packr.go")
|
||||
global, err := os.Create(fp)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer global.Close()
|
||||
|
||||
tmpl := template.New(fp).Funcs(fm)
|
||||
tmpl, err = tmpl.Parse(diskGlobalTmpl)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := tmpl.Execute(global, opts); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var ip string
|
||||
if internal.Mods() {
|
||||
// Starting in 1.12, we can rely on Go's method for
|
||||
// resolving where go.mod resides. Prior versions will
|
||||
// simply return an empty string.
|
||||
cmd := exec.Command("go", "env", "GOMOD")
|
||||
out, err := cmd.Output()
|
||||
if err != nil {
|
||||
return fmt.Errorf("go.mod cannot be read or does not exist while go module is enabled")
|
||||
}
|
||||
mp := strings.TrimSpace(string(out))
|
||||
if mp == "" {
|
||||
// We are on a prior version of Go; try and do
|
||||
// the resolution ourselves.
|
||||
mp = filepath.Join(filepath.Dir(d.DBPath), "go.mod")
|
||||
if _, err := os.Stat(mp); err != nil {
|
||||
mp = filepath.Join(d.DBPath, "go.mod")
|
||||
}
|
||||
}
|
||||
|
||||
moddata, err := ioutil.ReadFile(mp)
|
||||
if err != nil {
|
||||
return fmt.Errorf("go.mod cannot be read or does not exist while go module is enabled")
|
||||
}
|
||||
ip = modfile.ModulePath(moddata)
|
||||
if ip == "" {
|
||||
return fmt.Errorf("go.mod is malformed")
|
||||
}
|
||||
ip = filepath.Join(ip, strings.TrimPrefix(filepath.Dir(d.DBPath), filepath.Dir(mp)))
|
||||
ip = strings.Replace(ip, "\\", "/", -1)
|
||||
} else {
|
||||
ip = filepath.Dir(d.DBPath)
|
||||
srcs := internal.GoPaths()
|
||||
srcs = append(srcs, build.Default.SrcDirs()...)
|
||||
for _, x := range srcs {
|
||||
ip = strings.TrimPrefix(ip, "/private")
|
||||
ip = strings.TrimPrefix(ip, x)
|
||||
}
|
||||
ip = strings.TrimPrefix(ip, string(filepath.Separator))
|
||||
ip = strings.TrimPrefix(ip, "src")
|
||||
ip = strings.TrimPrefix(ip, string(filepath.Separator))
|
||||
|
||||
ip = strings.Replace(ip, "\\", "/", -1)
|
||||
}
|
||||
ip = path.Join(ip, d.DBPackage)
|
||||
|
||||
for _, n := range opts.Boxes {
|
||||
b := d.boxes[n.Name]
|
||||
if b == nil {
|
||||
continue
|
||||
}
|
||||
p := filepath.Join(b.PackageDir, b.Package+"-packr.go")
|
||||
f, err := os.Create(p)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
o := struct {
|
||||
Package string
|
||||
Import string
|
||||
}{
|
||||
Package: b.Package,
|
||||
Import: ip,
|
||||
}
|
||||
|
||||
tmpl, err := template.New(p).Parse(diskImportTmpl)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := tmpl.Execute(f, o); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// resolve file paths (only) for the boxes
|
||||
// compile "global" db
|
||||
// resolve files for boxes to point at global db
|
||||
// write global db to disk (default internal/packr)
|
||||
// write boxes db to disk (default internal/packr)
|
||||
// write -packr.go files in each package (1 per package) that init the global db
|
||||
|
||||
func makeKey(box *parser.Box, path string) string {
|
||||
w := md5.New()
|
||||
fmt.Fprint(w, path)
|
||||
h := hex.EncodeToString(w.Sum(nil))
|
||||
return h
|
||||
}
|
||||
51
vendor/github.com/gobuffalo/packr/v2/jam/store/disk_tmpl.go
generated
vendored
Normal file
51
vendor/github.com/gobuffalo/packr/v2/jam/store/disk_tmpl.go
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
package store
|
||||
|
||||
const diskGlobalTmpl = `// +build !skippackr
|
||||
// Code generated by github.com/gobuffalo/packr/v2. DO NOT EDIT.
|
||||
|
||||
// You can use the "packr2 clean" command to clean up this,
|
||||
// and any other packr generated files.
|
||||
package {{.Package}}
|
||||
|
||||
import (
|
||||
"github.com/gobuffalo/packr/v2"
|
||||
"github.com/gobuffalo/packr/v2/file/resolver"
|
||||
)
|
||||
|
||||
var _ = func() error {
|
||||
const gk = "{{.GK}}"
|
||||
g := packr.New(gk, "")
|
||||
hgr, err := resolver.NewHexGzip(map[string]string{
|
||||
{{- range $k, $v := .GlobalFiles }}
|
||||
"{{$k}}": "{{$v}}",
|
||||
{{- end }}
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
g.DefaultResolver = hgr
|
||||
|
||||
{{- range $box := .Boxes}}
|
||||
{{ printBox $box -}}
|
||||
{{ end }}
|
||||
return nil
|
||||
}()
|
||||
`
|
||||
|
||||
const diskImportTmpl = `// +build !skippackr
|
||||
// Code generated by github.com/gobuffalo/packr/v2. DO NOT EDIT.
|
||||
|
||||
// You can use the "packr clean" command to clean up this,
|
||||
// and any other packr generated files.
|
||||
package {{.Package}}
|
||||
|
||||
import _ "{{.Import}}"
|
||||
`
|
||||
|
||||
const diskGlobalBoxTmpl = `
|
||||
func() {
|
||||
b := packr.New("{{.Box.Name}}", "{{.Box.Path}}")
|
||||
{{- range $file := .Files }}
|
||||
b.SetResolver("{{$file.Resolver}}", packr.Pointer{ForwardBox: gk, ForwardPath: "{{$file.ForwardPath}}"})
|
||||
{{- end }}
|
||||
}()`
|
||||
39
vendor/github.com/gobuffalo/packr/v2/jam/store/env.go
generated
vendored
Normal file
39
vendor/github.com/gobuffalo/packr/v2/jam/store/env.go
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
|
||||
var goPath = filepath.Join(os.Getenv("HOME"), "go")
|
||||
|
||||
func init() {
|
||||
var once sync.Once
|
||||
once.Do(func() {
|
||||
cmd := exec.Command("go", "env", "GOPATH")
|
||||
b, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
goPath = strings.TrimSpace(string(b))
|
||||
})
|
||||
}
|
||||
|
||||
// GoPath returns the current GOPATH env var
|
||||
// or if it's missing, the default.
|
||||
func GoPath() string {
|
||||
return goPath
|
||||
}
|
||||
|
||||
// GoBin returns the current GO_BIN env var
|
||||
// or if it's missing, a default of "go"
|
||||
func GoBin() string {
|
||||
go_bin := os.Getenv("GO_BIN")
|
||||
if go_bin == "" {
|
||||
return "go"
|
||||
}
|
||||
return go_bin
|
||||
}
|
||||
44
vendor/github.com/gobuffalo/packr/v2/jam/store/fn.go
generated
vendored
Normal file
44
vendor/github.com/gobuffalo/packr/v2/jam/store/fn.go
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gobuffalo/packr/v2/jam/parser"
|
||||
)
|
||||
|
||||
var _ Store = &FnStore{}
|
||||
|
||||
type FnStore struct {
|
||||
FileNamesFn func(*parser.Box) ([]string, error)
|
||||
FilesFn func(*parser.Box) ([]*parser.File, error)
|
||||
PackFn func(*parser.Box) error
|
||||
CleanFn func(*parser.Box) error
|
||||
}
|
||||
|
||||
func (f *FnStore) FileNames(box *parser.Box) ([]string, error) {
|
||||
if f.FileNamesFn == nil {
|
||||
return []string{}, fmt.Errorf("FileNames not implemented")
|
||||
}
|
||||
return f.FileNames(box)
|
||||
}
|
||||
|
||||
func (f *FnStore) Files(box *parser.Box) ([]*parser.File, error) {
|
||||
if f.FilesFn == nil {
|
||||
return []*parser.File{}, fmt.Errorf("Files not implemented")
|
||||
}
|
||||
return f.FilesFn(box)
|
||||
}
|
||||
|
||||
func (f *FnStore) Pack(box *parser.Box) error {
|
||||
if f.PackFn == nil {
|
||||
return fmt.Errorf("Pack not implemented")
|
||||
}
|
||||
return f.PackFn(box)
|
||||
}
|
||||
|
||||
func (f *FnStore) Clean(box *parser.Box) error {
|
||||
if f.CleanFn == nil {
|
||||
return fmt.Errorf("Clean not implemented")
|
||||
}
|
||||
return f.Clean(box)
|
||||
}
|
||||
129
vendor/github.com/gobuffalo/packr/v2/jam/store/legacy.go
generated
vendored
Normal file
129
vendor/github.com/gobuffalo/packr/v2/jam/store/legacy.go
generated
vendored
Normal file
@@ -0,0 +1,129 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"html/template"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/gobuffalo/packr/v2/jam/parser"
|
||||
)
|
||||
|
||||
var _ Store = &Legacy{}
|
||||
|
||||
type Legacy struct {
|
||||
*Disk
|
||||
boxes map[string][]legacyBox
|
||||
}
|
||||
|
||||
func NewLegacy() *Legacy {
|
||||
return &Legacy{
|
||||
Disk: NewDisk("", ""),
|
||||
boxes: map[string][]legacyBox{},
|
||||
}
|
||||
}
|
||||
|
||||
func (l *Legacy) Pack(box *parser.Box) error {
|
||||
files, err := l.Files(box)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var fcs []legacyFile
|
||||
|
||||
for _, f := range files {
|
||||
n := strings.TrimPrefix(f.Name(), box.AbsPath+string(filepath.Separator))
|
||||
c, err := l.prepFile(f)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fcs = append(fcs, legacyFile{Name: n, Contents: c})
|
||||
}
|
||||
|
||||
sort.Slice(fcs, func(a, b int) bool {
|
||||
return fcs[a].Name < fcs[b].Name
|
||||
})
|
||||
|
||||
lbs := l.boxes[box.PackageDir]
|
||||
lbs = append(lbs, legacyBox{
|
||||
Box: box,
|
||||
Files: fcs,
|
||||
})
|
||||
l.boxes[box.PackageDir] = lbs
|
||||
return nil
|
||||
}
|
||||
|
||||
func (l *Legacy) prepFile(r io.Reader) (string, error) {
|
||||
bb := &bytes.Buffer{}
|
||||
if _, err := io.Copy(bb, r); err != nil {
|
||||
return "", err
|
||||
}
|
||||
b, err := json.Marshal(bb.Bytes())
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return strings.Replace(string(b), "\"", "\\\"", -1), nil
|
||||
}
|
||||
|
||||
// Close ...
|
||||
func (l *Legacy) Close() error {
|
||||
for _, b := range l.boxes {
|
||||
if len(b) == 0 {
|
||||
continue
|
||||
}
|
||||
bx := b[0].Box
|
||||
pkg := bx.Package
|
||||
opts := map[string]interface{}{
|
||||
"Package": pkg,
|
||||
"Boxes": b,
|
||||
}
|
||||
p := filepath.Join(bx.PackageDir, "a_"+bx.Package+"-packr.go.tmpl")
|
||||
tmpl, err := template.New(p).Parse(legacyTmpl)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
f, err := os.Create(p)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := tmpl.Execute(f, opts); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type legacyBox struct {
|
||||
Box *parser.Box
|
||||
Files []legacyFile
|
||||
}
|
||||
|
||||
type legacyFile struct {
|
||||
Name string
|
||||
Contents string
|
||||
}
|
||||
|
||||
var legacyTmpl = `// Code generated by github.com/gobuffalo/packr. DO NOT EDIT.
|
||||
|
||||
package {{.Package}}
|
||||
|
||||
import "github.com/gobuffalo/packr"
|
||||
|
||||
// You can use the "packr clean" command to clean up this,
|
||||
// and any other packr generated files.
|
||||
func init() {
|
||||
{{- range $box := .Boxes }}
|
||||
{{- range $box.Files }}
|
||||
_ = packr.PackJSONBytes("{{$box.Box.Name}}", "{{.Name}}", "{{.Contents}}")
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
}
|
||||
`
|
||||
12
vendor/github.com/gobuffalo/packr/v2/jam/store/store.go
generated
vendored
Normal file
12
vendor/github.com/gobuffalo/packr/v2/jam/store/store.go
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"github.com/gobuffalo/packr/v2/jam/parser"
|
||||
)
|
||||
|
||||
type Store interface {
|
||||
FileNames(*parser.Box) ([]string, error)
|
||||
Files(*parser.Box) ([]*parser.File, error)
|
||||
Pack(*parser.Box) error
|
||||
Clean(*parser.Box) error
|
||||
}
|
||||
56
vendor/github.com/gobuffalo/packr/v2/packr.go
generated
vendored
Normal file
56
vendor/github.com/gobuffalo/packr/v2/packr.go
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
package packr
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gobuffalo/packr/v2/file/resolver"
|
||||
"github.com/gobuffalo/packr/v2/jam/parser"
|
||||
"github.com/gobuffalo/packr/v2/plog"
|
||||
"github.com/markbates/safe"
|
||||
)
|
||||
|
||||
var boxes = &boxMap{}
|
||||
|
||||
var _ = safe.Run(func() {
|
||||
p, err := parser.NewFromRoots([]string{}, nil)
|
||||
if err != nil {
|
||||
plog.Logger.Error(err)
|
||||
return
|
||||
}
|
||||
boxes, err := p.Run()
|
||||
if err != nil {
|
||||
plog.Logger.Error(err)
|
||||
return
|
||||
}
|
||||
for _, box := range boxes {
|
||||
b := construct(box.Name, box.AbsPath)
|
||||
_, err = placeBox(b)
|
||||
if err != nil {
|
||||
plog.Logger.Error(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
func findBox(name string) (*Box, error) {
|
||||
key := resolver.Key(name)
|
||||
plog.Debug("packr", "findBox", "name", name, "key", key)
|
||||
|
||||
b, ok := boxes.Load(key)
|
||||
if !ok {
|
||||
plog.Debug("packr", "findBox", "name", name, "key", key, "found", ok)
|
||||
return nil, fmt.Errorf("could not find box %s", name)
|
||||
}
|
||||
|
||||
plog.Debug(b, "found", "box", b)
|
||||
return b, nil
|
||||
}
|
||||
|
||||
func placeBox(b *Box) (*Box, error) {
|
||||
key := resolver.Key(b.Name)
|
||||
eb, _ := boxes.LoadOrStore(key, b)
|
||||
|
||||
plog.Debug("packr", "placeBox", "name", eb.Name, "path", eb.Path, "resolution directory", eb.ResolutionDir)
|
||||
return eb, nil
|
||||
}
|
||||
21
vendor/github.com/gobuffalo/packr/v2/packr2/LICENSE
generated
vendored
Normal file
21
vendor/github.com/gobuffalo/packr/v2/packr2/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright © 2018 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.
|
||||
28
vendor/github.com/gobuffalo/packr/v2/packr2/cmd/build.go
generated
vendored
Normal file
28
vendor/github.com/gobuffalo/packr/v2/packr2/cmd/build.go
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gobuffalo/packr/v2/jam"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var buildCmd = &cobra.Command{
|
||||
Use: "build",
|
||||
Short: "Wraps the go build command with packr",
|
||||
DisableFlagParsing: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
cargs := parseArgs(args)
|
||||
if globalOptions.Verbose {
|
||||
fmt.Println(dont)
|
||||
}
|
||||
if err := jam.Pack(globalOptions.PackOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
return goCmd("build", cargs...)
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(buildCmd)
|
||||
}
|
||||
18
vendor/github.com/gobuffalo/packr/v2/packr2/cmd/clean.go
generated
vendored
Normal file
18
vendor/github.com/gobuffalo/packr/v2/packr2/cmd/clean.go
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/gobuffalo/packr/v2/jam"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var cleanCmd = &cobra.Command{
|
||||
Use: "clean",
|
||||
Short: "removes any *-packr.go files",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return jam.Clean(args...)
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(cleanCmd)
|
||||
}
|
||||
23
vendor/github.com/gobuffalo/packr/v2/packr2/cmd/fix.go
generated
vendored
Normal file
23
vendor/github.com/gobuffalo/packr/v2/packr2/cmd/fix.go
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
packr "github.com/gobuffalo/packr/v2"
|
||||
"github.com/gobuffalo/packr/v2/packr2/cmd/fix"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// fixCmd represents the info command
|
||||
var fixCmd = &cobra.Command{
|
||||
Use: "fix",
|
||||
Short: fmt.Sprintf("will attempt to fix a application's API to match packr version %s", packr.Version),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return fix.Run()
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
fixCmd.Flags().BoolVarP(&fix.YesToAll, "y", "", false, "update all without asking for confirmation")
|
||||
rootCmd.AddCommand(fixCmd)
|
||||
}
|
||||
49
vendor/github.com/gobuffalo/packr/v2/packr2/cmd/fix/fix.go
generated
vendored
Normal file
49
vendor/github.com/gobuffalo/packr/v2/packr2/cmd/fix/fix.go
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
package fix
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/gobuffalo/packr/v2/jam/store"
|
||||
)
|
||||
|
||||
//YesToAll will be used by the command to skip the questions
|
||||
var YesToAll bool
|
||||
|
||||
var replace = map[string]string{
|
||||
"github.com/gobuffalo/packr": "github.com/gobuffalo/packr/v2",
|
||||
}
|
||||
|
||||
var ic = ImportConverter{
|
||||
Data: replace,
|
||||
}
|
||||
|
||||
var checks = []Check{
|
||||
// packrClean,
|
||||
ic.Process,
|
||||
}
|
||||
|
||||
func packrClean(r *Runner) error {
|
||||
pwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
store.Clean(pwd)
|
||||
return nil
|
||||
}
|
||||
|
||||
func ask(q string) bool {
|
||||
if YesToAll {
|
||||
return true
|
||||
}
|
||||
|
||||
fmt.Printf("? %s [y/n]\n", q)
|
||||
|
||||
reader := bufio.NewReader(os.Stdin)
|
||||
text, _ := reader.ReadString('\n')
|
||||
|
||||
text = strings.ToLower(strings.TrimSpace(text))
|
||||
return text == "y" || text == "yes"
|
||||
}
|
||||
251
vendor/github.com/gobuffalo/packr/v2/packr2/cmd/fix/imports.go
generated
vendored
Normal file
251
vendor/github.com/gobuffalo/packr/v2/packr2/cmd/fix/imports.go
generated
vendored
Normal file
@@ -0,0 +1,251 @@
|
||||
package fix
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"go/ast"
|
||||
"go/parser"
|
||||
"go/printer"
|
||||
"go/token"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/tools/go/ast/astutil"
|
||||
)
|
||||
|
||||
// ImportConverter will changes imports from a -> b
|
||||
type ImportConverter struct {
|
||||
Data map[string]string
|
||||
}
|
||||
|
||||
// Process will walk all the .go files in an application, excluding ./vendor.
|
||||
// It will then attempt to convert any old import paths to any new import paths
|
||||
// used by this version Buffalo.
|
||||
func (c ImportConverter) Process(r *Runner) error {
|
||||
fmt.Println("~~~ Rewriting Imports ~~~")
|
||||
|
||||
err := filepath.Walk(".", c.processFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if _, err := os.Stat("Gopkg.toml"); err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
b, err := ioutil.ReadFile("Gopkg.toml")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for k := range c.Data {
|
||||
if bytes.Contains(b, []byte(k)) {
|
||||
r.Warnings = append(r.Warnings, fmt.Sprintf("Your Gopkg.toml contains the following import that need to be changed MANUALLY: %s", k))
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c ImportConverter) processFile(p string, info os.FileInfo, err error) error {
|
||||
er := onlyRelevantFiles(p, info, err, func(p string) error {
|
||||
err := c.rewriteFile(p)
|
||||
if err != nil {
|
||||
err = err
|
||||
}
|
||||
|
||||
return err
|
||||
})
|
||||
|
||||
return er
|
||||
}
|
||||
|
||||
func (c ImportConverter) rewriteFile(name string) error {
|
||||
// create an empty fileset.
|
||||
fset := token.NewFileSet()
|
||||
|
||||
// parse the .go file.
|
||||
// we are parsing the entire file with comments, so we don't lose anything
|
||||
// if we need to write it back out.
|
||||
f, err := parser.ParseFile(fset, name, nil, parser.ParseComments)
|
||||
if err != nil {
|
||||
e := err.Error()
|
||||
msg := "expected 'package', found 'EOF'"
|
||||
if e[len(e)-len(msg):] == msg {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
changed := false
|
||||
funcs := []*ast.FuncDecl{}
|
||||
for _, d := range f.Decls {
|
||||
if fn, isFn := d.(*ast.FuncDecl); isFn {
|
||||
funcs = append(funcs, fn)
|
||||
}
|
||||
}
|
||||
|
||||
for _, fun := range funcs {
|
||||
ast.Inspect(fun, func(node ast.Node) bool {
|
||||
switch n := node.(type) {
|
||||
case *ast.CallExpr:
|
||||
fn, ok := n.Fun.(*ast.SelectorExpr)
|
||||
if !ok || fn.Sel == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
sel := fn.Sel
|
||||
i, ok := fn.X.(*ast.Ident)
|
||||
if !ok {
|
||||
return true
|
||||
}
|
||||
if i.Name != "packr" {
|
||||
return true
|
||||
}
|
||||
if sel.Name == "NewBox" {
|
||||
sel.Name = "New"
|
||||
n.Args = append(n.Args, n.Args[0])
|
||||
changed = true
|
||||
}
|
||||
if sel.Name == "MustBytes" {
|
||||
sel.Name = "Find"
|
||||
changed = true
|
||||
}
|
||||
if sel.Name == "MustBytes" {
|
||||
sel.Name = "Find"
|
||||
changed = true
|
||||
}
|
||||
}
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
for key, value := range c.Data {
|
||||
if !astutil.DeleteImport(fset, f, key) {
|
||||
continue
|
||||
}
|
||||
|
||||
astutil.AddImport(fset, f, value)
|
||||
changed = true
|
||||
}
|
||||
|
||||
commentsChanged, err := c.handleFileComments(f)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
changed = changed || commentsChanged
|
||||
|
||||
// if no change occurred, then we don't need to write to disk, just return.
|
||||
if !changed {
|
||||
return nil
|
||||
}
|
||||
|
||||
// since the imports changed, resort them.
|
||||
ast.SortImports(fset, f)
|
||||
|
||||
// create a temporary file, this easily avoids conflicts.
|
||||
temp, err := writeTempResult(name, fset, f)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// rename the .temp to .go
|
||||
return os.Rename(temp, name)
|
||||
}
|
||||
|
||||
func (c ImportConverter) handleFileComments(f *ast.File) (bool, error) {
|
||||
change := false
|
||||
|
||||
for _, cg := range f.Comments {
|
||||
for _, cl := range cg.List {
|
||||
if !strings.HasPrefix(cl.Text, "// import \"") {
|
||||
continue
|
||||
}
|
||||
|
||||
// trim off extra comment stuff
|
||||
ctext := cl.Text
|
||||
ctext = strings.TrimPrefix(ctext, "// import")
|
||||
ctext = strings.TrimSpace(ctext)
|
||||
|
||||
// unquote the comment import path value
|
||||
ctext, err := strconv.Unquote(ctext)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
// match the comment import path with the given replacement map
|
||||
if ctext, ok := c.match(ctext); ok {
|
||||
cl.Text = "// import " + strconv.Quote(ctext)
|
||||
change = true
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return change, nil
|
||||
}
|
||||
|
||||
// match takes an import path and replacement map.
|
||||
func (c ImportConverter) match(importpath string) (string, bool) {
|
||||
for key, value := range c.Data {
|
||||
if !strings.HasPrefix(importpath, key) {
|
||||
continue
|
||||
}
|
||||
|
||||
result := strings.Replace(importpath, key, value, 1)
|
||||
return result, true
|
||||
}
|
||||
|
||||
return importpath, false
|
||||
}
|
||||
|
||||
//onlyRelevantFiles processes only .go files excluding folders like node_modules and vendor.
|
||||
func onlyRelevantFiles(p string, fi os.FileInfo, err error, fn func(p string) error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if fi.IsDir() && p != "." {
|
||||
for _, n := range []string{"_", ".", "vendor", "node_modules", ".git"} {
|
||||
base := filepath.Base(p)
|
||||
if strings.HasPrefix(base, n) {
|
||||
return filepath.SkipDir
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
ext := filepath.Ext(p)
|
||||
if ext != ".go" {
|
||||
return nil
|
||||
}
|
||||
|
||||
return fn(p)
|
||||
}
|
||||
|
||||
func writeTempResult(name string, fset *token.FileSet, f *ast.File) (string, error) {
|
||||
temp := name + ".temp"
|
||||
w, err := os.Create(temp)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
// write changes to .temp file, and include proper formatting.
|
||||
err = (&printer.Config{Mode: printer.TabIndent | printer.UseSpaces, Tabwidth: 8}).Fprint(w, fset, f)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
// close the writer
|
||||
err = w.Close()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return temp, nil
|
||||
}
|
||||
47
vendor/github.com/gobuffalo/packr/v2/packr2/cmd/fix/runner.go
generated
vendored
Normal file
47
vendor/github.com/gobuffalo/packr/v2/packr2/cmd/fix/runner.go
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
package fix
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
packr "github.com/gobuffalo/packr/v2"
|
||||
)
|
||||
|
||||
// Check interface for runnable checker functions
|
||||
type Check func(*Runner) error
|
||||
|
||||
// Runner will run all compatible checks
|
||||
type Runner struct {
|
||||
Warnings []string
|
||||
}
|
||||
|
||||
// Run all compatible checks
|
||||
func Run() error {
|
||||
fmt.Printf("! This updater will attempt to update your application to packr version: %s\n", packr.Version)
|
||||
if !ask("Do you wish to continue?") {
|
||||
fmt.Println("~~~ cancelling update ~~~")
|
||||
return nil
|
||||
}
|
||||
|
||||
r := &Runner{
|
||||
Warnings: []string{},
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if len(r.Warnings) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println("\n\n----------------------------")
|
||||
fmt.Printf("!!! (%d) Warnings Were Found !!!\n\n", len(r.Warnings))
|
||||
for _, w := range r.Warnings {
|
||||
fmt.Printf("[WARNING]: %s\n", w)
|
||||
}
|
||||
}()
|
||||
|
||||
for _, c := range checks {
|
||||
if err := c(r); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
67
vendor/github.com/gobuffalo/packr/v2/packr2/cmd/gocmd.go
generated
vendored
Normal file
67
vendor/github.com/gobuffalo/packr/v2/packr2/cmd/gocmd.go
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/gobuffalo/packr/v2/plog"
|
||||
)
|
||||
|
||||
func goCmd(name string, args ...string) error {
|
||||
cargs := []string{name}
|
||||
cargs = append(cargs, args...)
|
||||
if len(args) > 0 {
|
||||
err := func() error {
|
||||
path := "."
|
||||
|
||||
pwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if fi, err := os.Stat(filepath.Join(pwd, args[len(args)-1])); err == nil {
|
||||
if fi.IsDir() {
|
||||
return nil
|
||||
}
|
||||
path = fi.Name()
|
||||
}
|
||||
|
||||
if filepath.Ext(path) != ".go" {
|
||||
return nil
|
||||
}
|
||||
|
||||
path, err = filepath.Abs(filepath.Dir(path))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
files, err := ioutil.ReadDir(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, f := range files {
|
||||
if strings.HasSuffix(f.Name(), "-packr.go") {
|
||||
cargs = append(cargs, f.Name())
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
goBin := os.Getenv("GO_BIN")
|
||||
if goBin == "" {
|
||||
goBin = "go"
|
||||
}
|
||||
cp := exec.Command(goBin, cargs...)
|
||||
plog.Logger.Debug(strings.Join(cp.Args, " "))
|
||||
cp.Stderr = os.Stderr
|
||||
cp.Stdin = os.Stdin
|
||||
cp.Stdout = os.Stdout
|
||||
return cp.Run()
|
||||
}
|
||||
43
vendor/github.com/gobuffalo/packr/v2/packr2/cmd/install.go
generated
vendored
Normal file
43
vendor/github.com/gobuffalo/packr/v2/packr2/cmd/install.go
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gobuffalo/packr/v2/jam"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
const dont = `Please don't.
|
||||
The following commands have been deprecated and should not be used:
|
||||
|
||||
* packr2 build
|
||||
* packr2 install
|
||||
|
||||
They are, I'll be kind and say, "problematic" and cause more issues
|
||||
than than the actually solve. Sorry about that. My bad.
|
||||
|
||||
It is recommended you use two commands instead:
|
||||
|
||||
$ packr2
|
||||
$ go build/install
|
||||
`
|
||||
|
||||
var installCmd = &cobra.Command{
|
||||
Use: "install",
|
||||
Short: "Don't. ru",
|
||||
DisableFlagParsing: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
cargs := parseArgs(args)
|
||||
if globalOptions.Verbose {
|
||||
fmt.Println(dont)
|
||||
}
|
||||
if err := jam.Pack(globalOptions.PackOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
return goCmd("install", cargs...)
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(installCmd)
|
||||
}
|
||||
25
vendor/github.com/gobuffalo/packr/v2/packr2/cmd/pack.go
generated
vendored
Normal file
25
vendor/github.com/gobuffalo/packr/v2/packr2/cmd/pack.go
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
package cmd
|
||||
|
||||
func parseArgs(args []string) []string {
|
||||
var cargs []string
|
||||
for _, a := range args {
|
||||
if a == "--legacy" {
|
||||
globalOptions.Legacy = true
|
||||
continue
|
||||
}
|
||||
if a == "--verbose" {
|
||||
globalOptions.Verbose = true
|
||||
continue
|
||||
}
|
||||
if a == "--silent" {
|
||||
globalOptions.Silent = true
|
||||
continue
|
||||
}
|
||||
if a == "--ignore-imports" {
|
||||
globalOptions.IgnoreImports = true
|
||||
continue
|
||||
}
|
||||
cargs = append(cargs, a)
|
||||
}
|
||||
return cargs
|
||||
}
|
||||
82
vendor/github.com/gobuffalo/packr/v2/packr2/cmd/root.go
generated
vendored
Normal file
82
vendor/github.com/gobuffalo/packr/v2/packr2/cmd/root.go
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/gobuffalo/logger"
|
||||
"github.com/gobuffalo/packr/v2/jam"
|
||||
"github.com/gobuffalo/packr/v2/plog"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var globalOptions = struct {
|
||||
jam.PackOptions
|
||||
Verbose bool
|
||||
Silent bool
|
||||
}{
|
||||
PackOptions: jam.PackOptions{},
|
||||
}
|
||||
|
||||
var rootCmd = &cobra.Command{
|
||||
Use: "packr2",
|
||||
Short: "Packr is a simple solution for bundling static assets inside of Go binaries.",
|
||||
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
||||
for _, a := range args {
|
||||
if a == "--legacy" {
|
||||
globalOptions.Legacy = true
|
||||
continue
|
||||
}
|
||||
if a == "-v" || a == "--verbose" {
|
||||
globalOptions.Verbose = true
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
// if the last argument is a .go file or directory we should
|
||||
// find boxes from there, not from the current directory.
|
||||
// packr2 build -v cmd/main.go
|
||||
if len(args) > 0 {
|
||||
i := len(args) - 1
|
||||
dir := args[i]
|
||||
if _, err := os.Stat(dir); err == nil {
|
||||
if filepath.Ext(dir) == ".go" {
|
||||
dir = filepath.Dir(dir)
|
||||
}
|
||||
os.Chdir(dir)
|
||||
args[i] = filepath.Base(args[i])
|
||||
}
|
||||
}
|
||||
|
||||
if globalOptions.Verbose {
|
||||
plog.Logger = logger.New(logger.DebugLevel)
|
||||
}
|
||||
if globalOptions.Silent {
|
||||
plog.Logger = logger.New(logger.FatalLevel)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
opts := globalOptions.PackOptions
|
||||
roots := opts.Roots
|
||||
roots = append(roots, args...)
|
||||
opts.Roots = roots
|
||||
return jam.Pack(opts)
|
||||
},
|
||||
}
|
||||
|
||||
// Execute adds all child commands to the root command and sets flags appropriately.
|
||||
// This is called by main.main(). It only needs to happen once to the rootCmd.
|
||||
func Execute() {
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.PersistentFlags().BoolVarP(&globalOptions.Verbose, "verbose", "v", false, "enables verbose logging")
|
||||
rootCmd.PersistentFlags().BoolVar(&globalOptions.Legacy, "legacy", false, "uses the legacy resolution and packing system (assumes first arg || pwd for input path)")
|
||||
rootCmd.PersistentFlags().BoolVar(&globalOptions.Silent, "silent", false, "silences all output")
|
||||
rootCmd.PersistentFlags().BoolVar(&globalOptions.IgnoreImports, "ignore-imports", false, "when set to true packr won't resolve imports for boxes")
|
||||
rootCmd.PersistentFlags().StringVar(&globalOptions.StoreCmd, "store-cmd", "", "sub command to use for packing")
|
||||
}
|
||||
21
vendor/github.com/gobuffalo/packr/v2/packr2/cmd/version.go
generated
vendored
Normal file
21
vendor/github.com/gobuffalo/packr/v2/packr2/cmd/version.go
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
packr "github.com/gobuffalo/packr/v2"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var versionCmd = &cobra.Command{
|
||||
Use: "version",
|
||||
Short: "shows packr version",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
fmt.Println(packr.Version)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(versionCmd)
|
||||
}
|
||||
7
vendor/github.com/gobuffalo/packr/v2/packr2/main.go
generated
vendored
Normal file
7
vendor/github.com/gobuffalo/packr/v2/packr2/main.go
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
package main
|
||||
|
||||
import "github.com/gobuffalo/packr/v2/packr2/cmd"
|
||||
|
||||
func main() {
|
||||
cmd.Execute()
|
||||
}
|
||||
41
vendor/github.com/gobuffalo/packr/v2/plog/plog.go
generated
vendored
Normal file
41
vendor/github.com/gobuffalo/packr/v2/plog/plog.go
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
package plog
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/gobuffalo/logger"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
var Logger = logger.New(logger.ErrorLevel)
|
||||
|
||||
func Debug(t interface{}, m string, args ...interface{}) {
|
||||
if len(args)%2 == 1 {
|
||||
args = append(args, "")
|
||||
}
|
||||
f := logrus.Fields{}
|
||||
for i := 0; i < len(args); i += 2 {
|
||||
k := fmt.Sprint(args[i])
|
||||
v := args[i+1]
|
||||
if s, ok := v.(fmt.Stringer); ok {
|
||||
f[k] = s.String()
|
||||
continue
|
||||
}
|
||||
if s, ok := v.(string); ok {
|
||||
f[k] = s
|
||||
continue
|
||||
}
|
||||
if b, err := json.Marshal(v); err == nil {
|
||||
f[k] = string(b)
|
||||
continue
|
||||
}
|
||||
f[k] = v
|
||||
}
|
||||
e := Logger.WithFields(f)
|
||||
if s, ok := t.(string); ok {
|
||||
e.Debugf("%s#%s", s, m)
|
||||
return
|
||||
}
|
||||
e.Debugf("%T#%s", t, m)
|
||||
}
|
||||
32
vendor/github.com/gobuffalo/packr/v2/pointer.go
generated
vendored
Normal file
32
vendor/github.com/gobuffalo/packr/v2/pointer.go
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
package packr
|
||||
|
||||
import (
|
||||
"github.com/gobuffalo/packr/v2/file"
|
||||
"github.com/gobuffalo/packr/v2/file/resolver"
|
||||
"github.com/gobuffalo/packr/v2/plog"
|
||||
)
|
||||
|
||||
// Pointer is a resolvr which resolves
|
||||
// a file from a different box.
|
||||
type Pointer struct {
|
||||
ForwardBox string
|
||||
ForwardPath string
|
||||
}
|
||||
|
||||
var _ resolver.Resolver = Pointer{}
|
||||
|
||||
// Resolve attempts to find the file in the specific box
|
||||
// with the specified key
|
||||
func (p Pointer) Resolve(box string, path string) (file.File, error) {
|
||||
plog.Debug(p, "Resolve", "box", box, "path", path, "forward-box", p.ForwardBox, "forward-path", p.ForwardPath)
|
||||
b, err := findBox(p.ForwardBox)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
f, err := b.Resolve(p.ForwardPath)
|
||||
if err != nil {
|
||||
return f, err
|
||||
}
|
||||
plog.Debug(p, "Resolve", "box", box, "path", path, "file", f)
|
||||
return file.NewFileR(path, f)
|
||||
}
|
||||
75
vendor/github.com/gobuffalo/packr/v2/resolvers_map.go
generated
vendored
Normal file
75
vendor/github.com/gobuffalo/packr/v2/resolvers_map.go
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
//go:generate mapgen -name "resolvers" -zero "nil" -go-type "resolver.Resolver" -pkg "" -a "nil" -b "nil" -c "nil" -bb "nil" -destination "packr"
|
||||
// Code generated by github.com/gobuffalo/mapgen. DO NOT EDIT.
|
||||
|
||||
package packr
|
||||
|
||||
import (
|
||||
"sort"
|
||||
"sync"
|
||||
|
||||
"github.com/gobuffalo/packr/v2/file/resolver"
|
||||
)
|
||||
|
||||
// resolversMap wraps sync.Map and uses the following types:
|
||||
// key: string
|
||||
// value: resolver.Resolver
|
||||
type resolversMap struct {
|
||||
data sync.Map
|
||||
}
|
||||
|
||||
// Delete the key from the map
|
||||
func (m *resolversMap) Delete(key string) {
|
||||
m.data.Delete(key)
|
||||
}
|
||||
|
||||
// Load the key from the map.
|
||||
// Returns resolver.Resolver or bool.
|
||||
// A false return indicates either the key was not found
|
||||
// or the value is not of type resolver.Resolver
|
||||
func (m *resolversMap) Load(key string) (resolver.Resolver, bool) {
|
||||
i, ok := m.data.Load(key)
|
||||
if !ok {
|
||||
return nil, false
|
||||
}
|
||||
s, ok := i.(resolver.Resolver)
|
||||
return s, ok
|
||||
}
|
||||
|
||||
// LoadOrStore will return an existing key or
|
||||
// store the value if not already in the map
|
||||
func (m *resolversMap) LoadOrStore(key string, value resolver.Resolver) (resolver.Resolver, bool) {
|
||||
i, _ := m.data.LoadOrStore(key, value)
|
||||
s, ok := i.(resolver.Resolver)
|
||||
return s, ok
|
||||
}
|
||||
|
||||
// Range over the resolver.Resolver values in the map
|
||||
func (m *resolversMap) Range(f func(key string, value resolver.Resolver) bool) {
|
||||
m.data.Range(func(k, v interface{}) bool {
|
||||
key, ok := k.(string)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
value, ok := v.(resolver.Resolver)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
return f(key, value)
|
||||
})
|
||||
}
|
||||
|
||||
// Store a resolver.Resolver in the map
|
||||
func (m *resolversMap) Store(key string, value resolver.Resolver) {
|
||||
m.data.Store(key, value)
|
||||
}
|
||||
|
||||
// Keys returns a list of keys in the map
|
||||
func (m *resolversMap) Keys() []string {
|
||||
var keys []string
|
||||
m.Range(func(key string, value resolver.Resolver) bool {
|
||||
keys = append(keys, key)
|
||||
return true
|
||||
})
|
||||
sort.Strings(keys)
|
||||
return keys
|
||||
}
|
||||
4
vendor/github.com/gobuffalo/packr/v2/version.go
generated
vendored
Normal file
4
vendor/github.com/gobuffalo/packr/v2/version.go
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
package packr
|
||||
|
||||
// Version of Packr
|
||||
const Version = "v2.8.1"
|
||||
80
vendor/github.com/gobuffalo/packr/v2/walk.go
generated
vendored
Normal file
80
vendor/github.com/gobuffalo/packr/v2/walk.go
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
package packr
|
||||
|
||||
import (
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/gobuffalo/packd"
|
||||
"github.com/gobuffalo/packr/v2/file"
|
||||
"github.com/gobuffalo/packr/v2/file/resolver"
|
||||
"github.com/gobuffalo/packr/v2/plog"
|
||||
)
|
||||
|
||||
// WalkFunc is used to walk a box
|
||||
type WalkFunc = packd.WalkFunc
|
||||
|
||||
// Walk will traverse the box and call the WalkFunc for each file in the box/folder.
|
||||
func (b *Box) Walk(wf WalkFunc) error {
|
||||
m := map[string]file.File{}
|
||||
|
||||
dr := b.DefaultResolver
|
||||
if dr == nil {
|
||||
cd := resolver.OsPath(b.ResolutionDir)
|
||||
dr = &resolver.Disk{Root: cd}
|
||||
}
|
||||
if fm, ok := dr.(file.FileMappable); ok {
|
||||
for n, f := range fm.FileMap() {
|
||||
m[n] = f
|
||||
}
|
||||
}
|
||||
var err error
|
||||
b.resolvers.Range(func(n string, r resolver.Resolver) bool {
|
||||
var f file.File
|
||||
f, err = r.Resolve("", n)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
keep := true
|
||||
for k := range m {
|
||||
if strings.EqualFold(k, n) {
|
||||
keep = false
|
||||
}
|
||||
}
|
||||
if keep {
|
||||
m[n] = f
|
||||
}
|
||||
return true
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var keys = make([]string, 0, len(m))
|
||||
for k := range m {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
|
||||
for _, k := range keys {
|
||||
osPath := resolver.OsPath(k)
|
||||
plog.Debug(b, "Walk", "path", k, "osPath", osPath)
|
||||
if err := wf(osPath, m[k]); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// WalkPrefix will call box.Walk and call the WalkFunc when it finds paths that have a matching prefix
|
||||
func (b *Box) WalkPrefix(prefix string, wf WalkFunc) error {
|
||||
ipref := resolver.OsPath(prefix)
|
||||
return b.Walk(func(path string, f File) error {
|
||||
ipath := resolver.OsPath(path)
|
||||
if strings.HasPrefix(ipath, ipref) {
|
||||
if err := wf(path, f); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user