Skip to content

Commit

Permalink
Merge pull request #2 from jehiah/version_2
Browse files Browse the repository at this point in the history
Add --version for 0.1.0 release
  • Loading branch information
jehiah authored Sep 30, 2021
2 parents 52b7f9c + 7804c4e commit 98bfa9f
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
little_bigtable.db
little_bigtable
build
dist
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PREFIX=/usr/local
BINDIR=${PREFIX}/bin
DESTDIR=
BLDDIR = build
BLDDIR=build
BLDFLAGS=
EXT=
ifeq (${GOOS},windows)
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ Usage of ./little_bigtable:
the address to bind to on the local machine (default "localhost")
-port int
the port number to bind to on the local machine (default 9000)
-version
show version
```

In the environment for your application, set the `BIGTABLE_EMULATOR_HOST` environment variable to the host and port where `little_bigtable` is running. This environment variable is automatically detected by the Bigtable SDK or the `cbt` CLI. For example:

```bash
$ export BIGTABLE_EMULATOR_HOST="127.0.0.1:9000"
$ ./run_my_app
```

## Limitations
Expand Down
33 changes: 33 additions & 0 deletions dist.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

# 1. commit to bump the version (little_bigtable.go)
# 2. tag that commit
# 3. use dist.sh to produce tar.gz for all platforms
# 4. update the release metadata on github / upload the binaries

set -e

DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

version=$(awk '/version / {print $NF}' < $DIR/little_bigtable.go | sed 's/"//g')
goversion=$(go version | awk '{print $3}')

echo "... running tests"
./test.sh

mkdir -p dist
for target in "linux/amd64"; do
os=${target%/*}
arch=${target##*/}
echo "... building v$version for $os/$arch"
BUILD=$(mktemp -d ${TMPDIR:-/tmp}/build-XXXXX)
TARGET="little_bigtable-$version.$os-$arch.$goversion"
GOOS=$os GOARCH=$arch \
go build --tags "$os" -o $BUILD/$TARGET .
pushd $BUILD
sudo chown -R 0:0 $TARGET
tar czvf $TARGET.tar.gz $TARGET
mv $TARGET.tar.gz $DIR/dist
popd
sudo rm -r $BUILD
done
19 changes: 13 additions & 6 deletions little_bigtable.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,35 @@ import (
"flag"
"fmt"
"log"
"os"
"runtime"

"github.com/bitly/little_bigtable/bttest"
_ "github.com/mattn/go-sqlite3"
"google.golang.org/grpc"
)

var (
host = flag.String("host", "localhost", "the address to bind to on the local machine")
port = flag.Int("port", 9000, "the port number to bind to on the local machine")
dbFile = flag.String("db-file", "little_bigtable.db", "path to data file")
)

const (
maxMsgSize = 256 * 1024 * 1024 // 256 MiB
version = "0.1.0"
)

func main() {
host := flag.String("host", "localhost", "the address to bind to on the local machine")
port := flag.Int("port", 9000, "the port number to bind to on the local machine")
dbFile := flag.String("db-file", "little_bigtable.db", "path to data file")
showVersion := flag.Bool("version", false, "show version")

ctx := context.Background()
grpc.EnableTracing = false
flag.Parse()
log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)

if *showVersion {
fmt.Printf("little_bigtable v%s (built w/%s)", version, runtime.Version())
os.Exit(0)
}

if *dbFile == "" {
log.Fatal("missing --db-file")
}
Expand Down

0 comments on commit 98bfa9f

Please sign in to comment.