Skip to content
No description, website, or topics provided.
Go Dockerfile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore First commit Nov 7, 2017
Dockerfile Fix readme instructions and add a proper build time test Nov 7, 2017
LICENSE
README.md
bigtable-emulator.go
bigtable-emulator_test.go Fix readme instructions and add a proper build time test Nov 7, 2017

README.md

Bigtable emulator Docker image

This repository contains the Google Cloud Bigtable emulator, which is an in memory Go implementation of Bigtable allowing to create integration tests and a local development environment. Warning: this is not a production tool.

The emulator is offered in the Google Cloud SDK. However, it might be difficult or overkill to install the SDK on every development and CI box. In those situations, this image provides a lightweight alternative (< 17MB). It also provides an easy way to setup necessary tables and column families at startup.

Using it

To start it, run the following command:

docker run -d -p 9035:9035 shopify/bigtable-emulator

You can specify the tables and column families you need using the -cf switch. The format is a comma separated list of <instance>.<table>.<column family>. Ex:

docker run -d -p 9035:9035 shopify/bigtable-emulator -cf dev.records.data,dev.records.metadata

Connecting to it

You have to set the BIGTABLE_EMULATOR_HOST environment variable to the right docker host and container port (localhost:9035 in most cases). Then:

import (
  "cloud.google.com/go/bigtable"
  "golang.org/x/net/context"
  "golang.org/x/oauth2"
  "google.golang.org/api/option"
)

type devTokenSource struct{}

func (devTokenSource) Token() (*oauth2.Token, error) {
  return new(oauth2.Token), nil
}

func NewDevBigTableClient() (*bigtable.Client, error) {
  ctx := context.Background()
  project := "dev"
  instance := "dev"
  return bigtable.NewClient(
    ctx, 
    project, 
    instance,
    option.WithTokenSource(&devTokenSource{}),
  )
}

License

This software is available under the MIT license (see 'LICENSE' file for more details).

You can’t perform that action at this time.