Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assets: move away from gx #6414

Merged
merged 1 commit into from
Jun 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "assets/dir-index-html"]
path = assets/dir-index-html
url = git@github.com:ipfs/dir-index-html
3 changes: 1 addition & 2 deletions assets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ Instead, edit the source files and use `go generate` from within the
assets directory:

```
go get -u github.com/jteeuwen/go-bindata/...
go generate
go generate .
```
18 changes: 2 additions & 16 deletions assets/assets.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
//go:generate go-bindata -pkg=assets -prefix=$GOPATH/src/gx/ipfs/QmT1jwrqzSMjSjLG5oBd9w4P9vXPKQksWuf5ghsE3Q88ZV init-doc $GOPATH/src/gx/ipfs/QmT1jwrqzSMjSjLG5oBd9w4P9vXPKQksWuf5ghsE3Q88ZV/dir-index-html
//go:generate git submodule update --init ./dir-index-html
//go:generate go run github.com/go-bindata/go-bindata/go-bindata -pkg=assets init-doc dir-index-html/dir-index.html dir-index-html/knownIcons.txt
//go:generate gofmt -w bindata.go

package assets

import (
"fmt"
"os"
"path/filepath"

"github.com/ipfs/go-ipfs/core"
Expand All @@ -15,9 +14,6 @@ import (
files "github.com/ipfs/go-ipfs-files"
options "github.com/ipfs/interface-go-ipfs-core/options"
"github.com/ipfs/interface-go-ipfs-core/path"

// this import keeps gx from thinking the dep isn't used
_ "github.com/ipfs/dir-index-html"
)

// initDocPaths lists the paths for the docs we want to seed during --init
Expand All @@ -36,16 +32,6 @@ func SeedInitDocs(nd *core.IpfsNode) (cid.Cid, error) {
return addAssetList(nd, initDocPaths)
}

var initDirPath = filepath.Join(os.Getenv("GOPATH"), "gx", "ipfs", "QmT1jwrqzSMjSjLG5oBd9w4P9vXPKQksWuf5ghsE3Q88ZV", "dir-index-html")
var initDirIndex = []string{
filepath.Join(initDirPath, "knownIcons.txt"),
filepath.Join(initDirPath, "dir-index.html"),
}

func SeedInitDirIndex(nd *core.IpfsNode) (cid.Cid, error) {
return addAssetList(nd, initDirIndex)
}

func addAssetList(nd *core.IpfsNode, l []string) (cid.Cid, error) {
api, err := coreapi.NewCoreAPI(nd)
if err != nil {
Expand Down
8 changes: 0 additions & 8 deletions assets/assets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@ func TestEmbeddedDocs(t *testing.T) {
testNFiles(initDocPaths, 5, t, "documents")
}

func TestDirIndex(t *testing.T) {
t.Skip("skipping for now, code being tested is currently unused")
// TODO: import assets during init.
// this will require figuring out how to set the right paths up for
// referencing the code from its gx path
testNFiles(initDirIndex, 2, t, "assets")
}

func testNFiles(fs []string, wantCnt int, t *testing.T, ftype string) {
if len(fs) < wantCnt {
t.Fatalf("expected %d %s. got %d", wantCnt, ftype, len(fs))
Expand Down
170 changes: 32 additions & 138 deletions assets/bindata.go

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions assets/bindata_dep.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//+build never,!never
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work (bindata is downloaded on every build).
I've used buildtag tools for that during the initial port.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This just prevents us from importing it at runtime. IMO, we should fetch it when pulling in the dependencies (even if we don't need it right now).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any benefit for fetching it on every build but I don't mind it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should cache it. There's no real benefit to fetching it every build but, this way, we lock the version in. We're also doing this for our test dependencies and golangci-lint.


package assets

import (
// Make sure go mod tracks these deps but avoid including them in the
// actual build.
_ "github.com/go-bindata/go-bindata"
)
1 change: 1 addition & 0 deletions assets/dir-index-html
Submodule dir-index-html added at a2330d
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ require (
github.com/elgris/jsondiff v0.0.0-20160530203242-765b5c24c302
github.com/fatih/color v1.7.0 // indirect
github.com/fsnotify/fsnotify v1.4.7
github.com/go-bindata/go-bindata v3.1.1+incompatible
github.com/go-critic/go-critic v0.0.0-20181204210945-ee9bf5809ead // indirect
github.com/gogo/protobuf v1.2.1
github.com/golangci/golangci-lint v1.16.1-0.20190425135923-692dacb773b7
github.com/hashicorp/go-multierror v1.0.0
github.com/hashicorp/golang-lru v0.5.1
github.com/ipfs/dir-index-html v1.0.3
github.com/ipfs/go-bitswap v0.1.1
github.com/ipfs/go-block-format v0.0.2
github.com/ipfs/go-blockservice v0.1.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5Kwzbycv
github.com/fd/go-nat v1.0.0/go.mod h1:BTBu/CKvMmOMUPkKVef1pngt2WFH/lg7E6yQnulfp6E=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/go-bindata/go-bindata v3.1.1+incompatible h1:tR4f0e4VTO7LK6B2YWyAoVEzG9ByG1wrXB4TL9+jiYg=
github.com/go-bindata/go-bindata v3.1.1+incompatible/go.mod h1:xK8Dsgwmeed+BBsSy2XTopBn/8uK2HWuGSnA11C3Joo=
github.com/go-check/check v0.0.0-20180628173108-788fd7840127 h1:0gkP6mzaMqkmpcJYCFOLkIBwI7xFExG03bbkOkCvUPI=
github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclKsC9YodN5RgxqK/VD9HM9JsCSh7rNhMZE98=
github.com/go-critic/go-critic v0.0.0-20181204210945-c3db6069acc5/go.mod h1:Jc75BZJv2dNy7opKH6bF29VveDQHfGZ6Asn/3phBesg=
Expand Down Expand Up @@ -185,8 +187,6 @@ github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NH
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/ipfs/bbloom v0.0.1 h1:s7KkiBPfxCeDVo47KySjK0ACPc5GJRUxFpdyWEuDjhw=
github.com/ipfs/bbloom v0.0.1/go.mod h1:oqo8CVWsJFMOZqTglBG4wydCE4IQA/G2/SEofB0rjUI=
github.com/ipfs/dir-index-html v1.0.3 h1:cKdOjJBKJgewgcv97zOlqsNOle52N91d3nAkbQadnuY=
github.com/ipfs/dir-index-html v1.0.3/go.mod h1:TG9zbaH/+4MnkGel0xF4SLNhk+YZvBNo6jjBkO/LaWc=
github.com/ipfs/go-bitswap v0.0.3/go.mod h1:jadAZYsP/tcRMl47ZhFxhaNuDQoXawT8iHMg+iFoQbg=
github.com/ipfs/go-bitswap v0.0.9/go.mod h1:kAPf5qgn2W2DrgAcscZ3HrM9qh4pH+X8Fkk3UPrwvis=
github.com/ipfs/go-bitswap v0.1.0 h1:28YsHYw9ut6wootnImPXH0WpnU5Dbo3qm6cvQ6e6wYY=
Expand Down