Skip to content

Commit 6539412

Browse files
committed
initial
1 parent 68ca657 commit 6539412

File tree

26 files changed

+4433
-0
lines changed

26 files changed

+4433
-0
lines changed

Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM golang:buster as builder
2+
3+
ENV GO111MODULE=on \
4+
CGO_ENABLED=1 \
5+
GOOS=linux \
6+
GOARCH=amd64
7+
8+
WORKDIR /build
9+
10+
COPY go.mod .
11+
COPY go.sum .
12+
RUN go mod download
13+
14+
COPY . .
15+
16+
RUN go build -o filsnap ./cmd/filsnap
17+
18+
FROM debian:buster
19+
20+
COPY --from=builder /build/filsnap /usr/local/bin
21+
22+
ENTRYPOINT ["/usr/local/bin/filsnap"]
23+
CMD ["-help"]

LICENSE-APACHE

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
2+
3+
http://www.apache.org/licenses/LICENSE-2.0
4+
5+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

LICENSE-MIT

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
The MIT License (MIT)
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

Makefile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
SHELL=/usr/bin/env bash
2+
3+
unexport GOFLAGS
4+
5+
GOCC?=go
6+
7+
ldflags=-X=github.com/filecoin-project/filecoin-snapshot-mvp/build.CurrentCommit=+git.$(subst -,.,$(shell git describe --always --match=NeVeRmAtCh --dirty 2>/dev/null || git rev-parse --short HEAD 2>/dev/null))
8+
9+
ifneq ($(strip $(LDFLAGS)),)
10+
ldflags+=-extldflags=$(LDFLAGS)
11+
endif
12+
13+
GOFLAGS+=-ldflags="$(ldflags)"
14+
15+
BINS:=
16+
17+
all: filsnap
18+
.PHONY: all
19+
20+
clean:
21+
rm -rf $(BINS)
22+
.PHONY: clean
23+
24+
filsnap:
25+
$(GOCC) build $(GOFLAGS) -o filsnap ./cmd/filsnap/
26+
.PHONY: filsnap
27+
BINS+=filsnap

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# filsnap
2+
3+
filsnap is a software tool for creating chain exports / snapshots from lotus nodes.
4+
5+
## Contributing
6+
7+
PRs accepted.
8+
9+
## License
10+
11+
Dual-licensed under [MIT](https://github.com/travisperson/filsnap/blob/master/LICENSE-MIT) + [Apache 2.0](https://github.com/travisperson/filsnap/blob/master/LICENSE-APACHE)

build/version.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package build
2+
3+
var CurrentCommit string
4+
5+
const version = "v0.0.0-dev"
6+
7+
func Version() string {
8+
return version + CurrentCommit
9+
}

cmd/filsnap/cmds/cmds.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package cmds
2+
3+
import (
4+
"strings"
5+
6+
"github.com/ipfs/go-log/v2"
7+
"github.com/urfave/cli/v2"
8+
)
9+
10+
var logger = log.Logger("filsnap/cmds")
11+
12+
var Commands = []*cli.Command{cmdCreate, cmdDefaultConfig, cmdService}
13+
14+
func TrimDescription(desc string) string {
15+
lines := strings.Split(desc, "\n")
16+
lines = lines[1:]
17+
for i, line := range lines {
18+
lines[i] = strings.TrimLeft(line, "\t")
19+
}
20+
return strings.Join(lines, "\n")
21+
}

cmd/filsnap/cmds/config.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package cmds
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/travisperson/filsnap/pkg/config"
7+
"github.com/urfave/cli/v2"
8+
)
9+
10+
var cmdDefaultConfig = &cli.Command{
11+
Name: "default-config",
12+
Usage: "prints the default configuration",
13+
Description: TrimDescription(``),
14+
Flags: []cli.Flag{},
15+
Action: func(cctx *cli.Context) error {
16+
var icfg interface{}
17+
18+
cfg := config.DefaultConfig()
19+
cfg.Nodes = append(cfg.Nodes, config.Node{
20+
Address: "/ip4/127.0.0.1/1234",
21+
TokenPath: "/path/to/token",
22+
})
23+
icfg = cfg
24+
25+
bs, err := config.ConfigComment(icfg)
26+
if err != nil {
27+
return err
28+
}
29+
30+
fmt.Printf("%s", string(bs))
31+
32+
return nil
33+
},
34+
}

0 commit comments

Comments
 (0)