Skip to content
This repository has been archived by the owner on Dec 1, 2023. It is now read-only.

Commit

Permalink
initial release tooling
Browse files Browse the repository at this point in the history
  • Loading branch information
mjpitz committed Sep 4, 2021
1 parent f1f22bc commit d7b5475
Show file tree
Hide file tree
Showing 9 changed files with 266 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/api/
/dist/
/gen/
/vendor/
/docs/openapiv2/
26 changes: 26 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
project_name: aetherfs

snapshot:
name_template: "{{ .ShortCommit }}"

builds:
- id: aetherfs
main: ./main.go
binary: aetherfs
goos:
- darwin
- linux
goarch:
- amd64
- arm64
hooks:
post: make .proto-tar VERSION={{ .Version }}

archives:
- id: aetherfs
name_template: "aetherfs_{{ .Os }}_{{ .Arch }}"
builds:
- aetherfs

checksum:
name_template: 'aetherfs_checksums.txt'
7 changes: 7 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This is the list of AetherFS's significant contributors.
#
# This does not necessarily list everyone who has contributed code,
# especially since many employees of one corporation may be contributing.
# To see the full list of contributors, see the revision history in
# source control.
Mya Pitzeruse <mya@aetherfs.tech>
53 changes: 49 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,69 @@ Welcome to aetherfs!

Targets:
help provides help text
dist recompiles aetherfs binaries
docker/devtools rebuild docker container containing developer tools
gen regenerate the API code from protocol buffers
legal prepends legal header to source code
release releases aetherfs

endef
export HELP_TEXT

help:
@echo "$$HELP_TEXT"

legal: .legal
.legal:
addlicense -f ./legal/header.txt -skip yaml .

docker/devtools: .docker/devtools
.docker/devtools:
docker build ./docker/devtools -t $(SKAFFOLD_DEFAULT_REPO)/aetherfs-devtools

gen: .gen
.gen:
@rm -rf api gen
docker run --rm -it -v $(CWD):/home -w /home $(SKAFFOLD_DEFAULT_REPO)/aetherfs-devtools sh -c 'buf lint && buf generate'
docker run --rm -it \
-v $(CWD):/home \
-w /home \
$(SKAFFOLD_DEFAULT_REPO)/aetherfs-devtools \
sh -c 'buf lint && buf generate'

legal: .legal
.legal:
addlicense -f ./legal/header.txt -skip yaml .
dist: .dist
.dist:
docker run --rm -it \
-v $(CWD):/home \
-w /home \
$(SKAFFOLD_DEFAULT_REPO)/aetherfs-devtools \
sh -c "goreleaser --snapshot --skip-publish --rm-dist"

# release - used to generate core release assets such as binaries and container images.

VERSION ?= latest

release:
docker run --rm -it \
-v $(CWD):/home \
-w /home \
$(SKAFFOLD_DEFAULT_REPO)/aetherfs-devtools \
sh -c "goreleaser"

docker buildx build . \
--platform linux/amd64,linux/arm64 \
--tag $(SKAFFOLD_DEFAULT_REPO)/aetherfs:latest \
--tag $(SKAFFOLD_DEFAULT_REPO)/aetherfs:$(VERSION) \
--push

# proto-tar - invoked from goreleaser to produce a tar.gz of proto files for the version.
# todo: use bufs image concept

PROTO = $(PWD)/proto
DIST = $(PWD)/dist

.proto-tar:
[[ -d "$(DIST)/aetherfs_proto" ]] || { \
mkdir -p $(DIST)/aetherfs_proto; \
cp -R $(PROTO)/* $(DIST)/aetherfs_proto; \
tar -czf $(DIST)/aetherfs_proto.tar.gz -C $(DIST)/aetherfs_proto/ . ; \
}
5 changes: 3 additions & 2 deletions docker/devtools/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ FROM ubuntu:21.04
ARG GO_VERSION=1.16.4
ARG PROTOC_VERSION=3.15.7

RUN apt-get update -y && apt-get install -y curl unzip gnupg2
RUN apt-get update -y && apt-get install -y curl unzip gnupg2 git build-essential

RUN curl -sSLo go.tar.gz https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz && \
tar -C /usr/local -zxf go.tar.gz && \
Expand All @@ -31,4 +31,5 @@ RUN GOBIN=/usr/local/bin go get \
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@v2.5.0 \
google.golang.org/protobuf/cmd/protoc-gen-go@v1.27.1 \
google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.1.0 \
github.com/envoyproxy/protoc-gen-validate@v0.6.1
github.com/envoyproxy/protoc-gen-validate@v0.6.1 \
github.com/goreleaser/goreleaser@v0.177.0
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.16

require (
github.com/grpc-ecosystem/grpc-gateway/v2 v2.5.0
github.com/urfave/cli/v2 v2.3.0
google.golang.org/genproto v0.0.0-20210617175327-b9e0b3197ced
google.golang.org/grpc v1.38.0
google.golang.org/protobuf v1.27.1
Expand Down
10 changes: 10 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMn
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/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/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
Expand Down Expand Up @@ -116,13 +118,20 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o
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/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/urfave/cli/v2 v2.3.0 h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M=
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down Expand Up @@ -383,6 +392,7 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8
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/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
Expand Down
50 changes: 50 additions & 0 deletions internal/authors/parse.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright (C) The AetherFS Authors - All Rights Reserved
//
// Proprietary and confidential.
// Unauthorized copying of this file, via any medium is strictly prohibited.
// Written by Mya Pitzeruse, September 2021

package authors

import (
"strings"

"github.com/urfave/cli/v2"
)

// Parse parses the contents of the authors file. The file is format based on Google's open source guidelines. For more
// information, see https://opensource.google/docs/releasing/authors/
func Parse(contents string) []*cli.Author {
lines := strings.Split(contents, "\n")
results := make([]*cli.Author, 0, len(lines))

for _, line := range lines {
idx := strings.Index(line, "#")
if idx > -1 {
line = line[:idx]
}

line := strings.TrimSpace(line)

name := line
email := ""

start := strings.LastIndex(line, "<")
end := strings.LastIndex(line, ">")

// emails are optional
if start > -1 && end > -1 {
name = strings.TrimSpace(line[:start])
email = line[start+1 : end]
}

if name != "" {
results = append(results, &cli.Author{
Name: name,
Email: email,
})
}
}

return results
}
119 changes: 119 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
// Copyright (C) The AetherFS Authors - All Rights Reserved
//
// Proprietary and confidential.
// Unauthorized copying of this file, via any medium is strictly prohibited.
// Written by Mya Pitzeruse, September 2021
package main

import (
"context"
_ "embed"
"fmt"
"log"
"os"
"os/signal"
"syscall"
"time"

"github.com/urfave/cli/v2"

"github.com/mjpitz/aetherfs/internal/authors"
)

//go:embed AUTHORS
var authorsFileContents string

var version string
var commit string
var date string

func main() {
compiled, err := time.Parse(time.RFC3339, date)
if err != nil {
compiled = time.Now()
}

if version == "" {
version = "dev"
}

if commit == "" {
commit = "HEAD"
}

app := &cli.App{
Name: "aetherfs",
Usage: "A publish once, consume many file system for small to medium datasets",
UsageText: "aetherfs <command>",
Version: fmt.Sprintf("%s (%s)", version, commit),
Commands: []*cli.Command{
{
Name: "agent",
Usage: "Starts the aetherfs-agent process",
UsageText: "aetherfs agent [options]",
Action: func(ctx *cli.Context) error {
log.Print("running agent")
<-ctx.Done()
return nil
},
},
{
Name: "server",
Usage: "Starts the aetherfs-server process",
UsageText: "aetherfs server [options]",
Action: func(ctx *cli.Context) error {
log.Print("running server")
<-ctx.Done()
return nil
},
},
{
Name: "push",
Usage: "Pushes a dataset into AetherFS",
UsageText: "aetherfs push [options] <path>",
Action: func(ctx *cli.Context) error {
log.Print("pushing dataset")
return nil
},
},
{
Name: "pull",
Usage: "Pulls a dataset from AetherFS",
UsageText: "aetherfs pull [options] <dataset> [path]",
Action: func(ctx *cli.Context) error {
log.Print("pulling dataset")
return nil
},
},
},
Flags: []cli.Flag{},
Before: func(ctx *cli.Context) error {
var cancel context.CancelFunc
ctx.Context, cancel = context.WithCancel(ctx.Context)

halt := make(chan os.Signal, 1)
signal.Notify(halt, syscall.SIGINT, syscall.SIGTERM)

go func() {
<-halt
signal.Stop(halt)

cancel()
}()

return nil
},
After: func(ctx *cli.Context) error {
// teardown plugins
// - destroy outgoing connections
// - ensure db files are closed
// - etc
return nil
},
Compiled: compiled,
Authors: authors.Parse(authorsFileContents),
Copyright: fmt.Sprintf("Copyright %d The AetherFS Authors - All Rights Reserved", compiled.Year()),
}

_ = app.Run(os.Args)
}

0 comments on commit d7b5475

Please sign in to comment.