Merge "playground: Restructure security packages"
diff --git a/client/Makefile b/client/Makefile
index 3e46715..5b65b96 100644
--- a/client/Makefile
+++ b/client/Makefile
@@ -1,7 +1,7 @@
 PATH := bin:node_modules/.bin:$(PATH)
-PATH := $(PATH):$(VANADIUM_ROOT)/environment/cout/node/bin
+PATH := $(PATH):$(V23_ROOT)/environment/cout/node/bin
 SHELL := /bin/bash -euo pipefail
-export GOPATH := $(VANADIUM_ROOT)/release/projects/playground/go:$(GOPATH)
+export GOPATH := $(V23_ROOT)/release/projects/playground/go:$(GOPATH)
 export VDLPATH := $(GOPATH)
 
 js_files := $(shell find browser -name "*.js")
@@ -57,7 +57,7 @@
 node_modules: package.json
 	@npm prune
 	# Temporary workaround: install pgbundle directly from source.
-	@npm install $(VANADIUM_ROOT)/release/projects/playground/pgbundle
+	@npm install $(V23_ROOT)/release/projects/playground/pgbundle
 	@npm install
 	@touch $@
 
diff --git a/client/lib/shell/pg_test_util.sh b/client/lib/shell/pg_test_util.sh
index 2722adc..4aec0b2 100755
--- a/client/lib/shell/pg_test_util.sh
+++ b/client/lib/shell/pg_test_util.sh
@@ -17,7 +17,7 @@
 setup_environment() {
   export GOPATH="$(pwd):$(v23 env GOPATH)"
   export VDLPATH="$(pwd):$(v23 env VDLPATH)"
-  export PATH="$(pwd):${shell_test_BIN_DIR}:${VANADIUM_ROOT}/environment/cout/node/bin:${PATH}"
+  export PATH="$(pwd):${shell_test_BIN_DIR}:${V23_ROOT}/environment/cout/node/bin:${PATH}"
 
   # We unset all environment variables that supply a principal in order to
   # simulate production playground setup.
@@ -31,7 +31,7 @@
 install_vanadium_js() {
   # TODO(nlacasse): Once release/javascript/core is publicly available in npm, replace this
   # with "npm install vanadium".
-  npm install --production "${VANADIUM_ROOT}/release/javascript/core"
+  npm install --production "${V23_ROOT}/release/javascript/core"
 }
 
 # Installs the pgbundle tool.
diff --git a/go/src/playground/.gitignore b/go/src/playground/.gitignore
index 2e1a024..17618d0 100644
--- a/go/src/playground/.gitignore
+++ b/go/src/playground/.gitignore
@@ -1,3 +1,3 @@
-deploy/netrc
+netrc
 config/*.json
 !config/db-*-example.json
diff --git a/go/src/playground/Dockerfile b/go/src/playground/Dockerfile
index cc7b6db..8af2303 100644
--- a/go/src/playground/Dockerfile
+++ b/go/src/playground/Dockerfile
@@ -8,21 +8,21 @@
 RUN ln -s "$(which nodejs)" "$(dirname $(which nodejs))/node"
 
 # Install Go. Note, the apt-get "golang" target is too old.
-RUN (cd /tmp; curl -O https://storage.googleapis.com/golang/go1.4.linux-amd64.tar.gz)
-RUN tar -C /usr/local -xzf /tmp/go1.4.linux-amd64.tar.gz
+RUN (cd /tmp; curl -O https://storage.googleapis.com/golang/go1.4.2.linux-amd64.tar.gz)
+RUN tar -C /usr/local -xzf /tmp/go1.4.2.linux-amd64.tar.gz
 ENV PATH /usr/local/go/bin:$PATH
 
 ENV HOME /root
-ENV VANADIUM_ROOT /usr/local/vanadium
-ENV GOPATH $VANADIUM_ROOT/release/projects/playground/go
+ENV V23_ROOT /usr/local/vanadium
+ENV GOPATH $V23_ROOT/release/projects/playground/go
 ENV VDLPATH $GOPATH
-ENV PATH $VANADIUM_ROOT/release/projects/playground/go/bin:$VANADIUM_ROOT/release/go/bin:$VANADIUM_ROOT/bin:$PATH
+ENV PATH $V23_ROOT/release/projects/playground/go/bin:$V23_ROOT/release/go/bin:$V23_ROOT/bin:$PATH
 
 # Setup Vanadium.
 # Note: This will be cached! If you want to re-build the docker image using
 # fresh Vanadium code, you must pass "--no-cache" to the docker build command.
 # See README.md.
-ADD deploy/netrc /root/.netrc
+ADD netrc /root/.netrc
 RUN curl -u vanadium:D6HT]P,LrJ7e https://v.io/bootstrap | bash
 RUN rm /root/.netrc
 
@@ -32,7 +32,7 @@
 # NOTE(sadovsky): NPM is flaky. If any of the NPM commands below fail, simply
 # retry them.
 WORKDIR /home/playground
-RUN npm install --production $VANADIUM_ROOT/release/javascript/core
+RUN npm install --production $V23_ROOT/release/javascript/core
 
 # Install Vanadium libraries and playground binaries.
 RUN v23 go install -v v.io/...
@@ -41,13 +41,13 @@
 # Uncomment the following lines to install a version of the builder tool using
 # your local version of the code. This is useful when developing and testing
 # local changes.
-#RUN rm -f $VANADIUM_ROOT/release/projects/playground/go/bin/builder
-#RUN rm -rf $VANADIUM_ROOT/release/projects/playground/go/src/playground/Makefile
-#RUN rm -rf $VANADIUM_ROOT/release/projects/playground/go/src/playground/builder/
-#RUN rm -rf $VANADIUM_ROOT/release/projects/playground/go/src/playground/lib/
-#ADD Makefile $VANADIUM_ROOT/release/projects/playground/go/src/playground/Makefile
-#ADD builder/ $VANADIUM_ROOT/release/projects/playground/go/src/playground/builder/
-#ADD lib/ $VANADIUM_ROOT/release/projects/playground/go/src/playground/lib/
+#RUN rm -f $V23_ROOT/release/projects/playground/go/bin/builder
+#RUN rm -rf $V23_ROOT/release/projects/playground/go/src/playground/Makefile
+#RUN rm -rf $V23_ROOT/release/projects/playground/go/src/playground/builder/
+#RUN rm -rf $V23_ROOT/release/projects/playground/go/src/playground/lib/
+#ADD Makefile $V23_ROOT/release/projects/playground/go/src/playground/Makefile
+#ADD builder/ $V23_ROOT/release/projects/playground/go/src/playground/builder/
+#ADD lib/ $V23_ROOT/release/projects/playground/go/src/playground/lib/
 #RUN make builder
 
 USER playground
diff --git a/go/src/playground/Makefile b/go/src/playground/Makefile
index abab1c3..b8d33f6 100644
--- a/go/src/playground/Makefile
+++ b/go/src/playground/Makefile
@@ -1,8 +1,8 @@
 PATH := bin:node_modules/.bin:$(PATH)
-PATH := $(PATH):$(VANADIUM_ROOT)/environment/cout/node/bin
-PATH := $(VANADIUM_ROOT)/release/projects/playground/go/bin:$(PATH)
+PATH := $(PATH):$(V23_ROOT)/environment/cout/node/bin
+PATH := $(V23_ROOT)/release/projects/playground/go/bin:$(PATH)
 SHELL := /bin/bash -euo pipefail
-export GOPATH := $(VANADIUM_ROOT)/release/projects/playground/go:$(GOPATH)
+export GOPATH := $(V23_ROOT)/release/projects/playground/go:$(GOPATH)
 export VDLPATH := $(GOPATH)
 
 host ?= 127.0.0.1
diff --git a/go/src/playground/README.md b/go/src/playground/README.md
index a9934ac..a838980 100644
--- a/go/src/playground/README.md
+++ b/go/src/playground/README.md
@@ -23,8 +23,8 @@
 
 Build the playground Docker image (this will take a while...):
 
-    $ cp ~/.netrc $VANADIUM_ROOT/release/projects/playground/go/src/playground/deploy/netrc
-    $ docker build -t playground $VANADIUM_ROOT/release/projects/playground/go/src/playground/.
+    $ cp ~/.netrc $V23_ROOT/release/projects/playground/go/src/playground/netrc
+    $ docker build -t playground $V23_ROOT/release/projects/playground/go/src/playground/.
 
 Note: If you want to ensure an up-to-date version of Vanadium is installed in
 the Docker image, run the above command with the "--no-cache" flag.
@@ -42,22 +42,22 @@
 
 Test your image (without running compilerd):
 
-    $ cd $VANADIUM_ROOT/release/projects/playground/client && make src/example_bundles
-    $ docker run -i playground < $VANADIUM_ROOT/release/projects/playground/client/bundles/fortune/bundle_js_go.json
+    $ cd $V23_ROOT/release/projects/playground/client && make src/example_bundles
+    $ docker run -i playground < $V23_ROOT/release/projects/playground/client/bundles/fortune/bundle_js_go.json
 
 ## Running the playground server (compilerd)
 
 Install the playground binaries:
 
-    $ GOPATH=$VANADIUM_ROOT/release/projects/playground/go v23 go install playground/...
+    $ GOPATH=$V23_ROOT/release/projects/playground/go v23 go install playground/...
 
 Run the compiler binary:
 
-    $ $VANADIUM_ROOT/release/projects/playground/go/bin/compilerd --listen-timeout=0 --address=localhost:8181
+    $ $V23_ROOT/release/projects/playground/go/bin/compilerd --listen-timeout=0 --address=localhost:8181
 
 Or, run it without Docker (for faster iterations during development):
 
-    $ PATH=$VANADIUM_ROOT/release/go/bin:$VANADIUM_ROOT/release/projects/playground/go/bin:$PATH compilerd --listen-timeout=0 --address=localhost:8181 --use-docker=false
+    $ PATH=$V23_ROOT/release/go/bin:$V23_ROOT/release/projects/playground/go/bin:$PATH compilerd --listen-timeout=0 --address=localhost:8181 --use-docker=false
 
 The server should now be running at http://localhost:8181 and responding to
 compile requests at http://localhost:8181/compile.
@@ -66,4 +66,4 @@
 make the client talk to your server. Add `?debug=1` to see debug info from
 the builder.
 
-TODO: storage
+TODO(ivanpi): Describe storage.
diff --git a/go/src/playground/compilerd/jobqueue/jobqueue_test.go b/go/src/playground/compilerd/jobqueue/jobqueue_test.go
index f5bfd44..4619318 100644
--- a/go/src/playground/compilerd/jobqueue/jobqueue_test.go
+++ b/go/src/playground/compilerd/jobqueue/jobqueue_test.go
@@ -27,7 +27,7 @@
 
 func init() {
 	// Compile builder binary and put in path.
-	pgDir := os.ExpandEnv("${VANADIUM_ROOT}/release/projects/playground/go")
+	pgDir := os.ExpandEnv("${V23_ROOT}/release/projects/playground/go")
 
 	cmd := exec.Command("make", "builder")
 	cmd.Dir = path.Join(pgDir, "src", "playground")
diff --git a/go/src/playground/deploy/pool_template.json b/go/src/playground/deploy/pool_template.json
deleted file mode 100644
index a8d077a..0000000
--- a/go/src/playground/deploy/pool_template.json
+++ /dev/null
@@ -1,38 +0,0 @@
-{
-  "template": {
-    "action": {
-      "commands": [
-        "sudo mount /dev/sdb1 /mnt",
-        "sudo docker load < /mnt/playground.tar.gz",
-        "sudo docker run playground &> /dev/null || true",
-        "start-stop-daemon --start -c ribrdb --exec /mnt/compilerd &> /tmp/compilerd.out &"
-      ]
-    },
-    "healthChecks": [{
-      "name": "healthz",
-      "path": "/healthz",
-      "port": "8181",
-    }],
-    "vmParams": {
-      "machineType": "n1-standard-1",
-      "baseInstanceName": "pg-replica",
-      "disksToCreate": [{
-        "boot": "true",
-        "initializeParams": {
-          "sourceImage": "https://www.googleapis.com/compute/v1/projects/google-containers/global/images/container-vm-v20140522",
-          "diskSizeGb": "200"
-        }
-      }],
-      "disksToAttach": [{
-        "source": "pg-data-20140820"
-      }],
-      "networkInterfaces": [{
-        "network": "playground",
-        "accessConfigs": [{
-          "type": "ONE_TO_ONE_NAT",
-          "name": "External NAT"
-        }]
-      }]
-    }
-  }
-}
diff --git a/go/src/playground/deploy/update.sh b/go/src/playground/deploy/update.sh
deleted file mode 100755
index c39a8f2..0000000
--- a/go/src/playground/deploy/update.sh
+++ /dev/null
@@ -1,102 +0,0 @@
-#!/bin/bash
-# Copyright 2015 The Vanadium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file.
-
-# Script to rebuild and deploy compilerd and the Docker image (builder) to the
-# playground backends.
-#
-# Usage:
-#   gcutil ssh --project google.com:veyron playground-master
-#   sudo su - veyron
-#   v23 update
-#   bash $VANADIUM_ROOT/release/projects/playground/go/src/playground/compilerd/update.sh
-
-set -e
-set -u
-
-readonly DATE=$(date +"%Y%m%d-%H%M%S")
-readonly DISK="pg-data-${DATE}"
-
-function unmount() {
-  sudo umount /mnt
-  gcloud compute --project "google.com:veyron" instances detach-disk --disk=${DISK} $(hostname) --zone us-central1-a
-}
-
-trap cleanup INT TERM EXIT
-
-function cleanup() {
-  # Unset the trap so that it doesn't run again on exit.
-  trap - INT TERM EXIT
-  if [[ -e /mnt/compilerd ]]; then
-    # The disk is still mounted on the master, which means it's not yet mounted
-    # on any backends. It's safe to unmount and delete it.
-    unmount
-    gcloud compute --project "google.com:veyron" disks delete ${DISK} --zone "us-central1-a"
-  fi
-  sudo docker rm ${DISK} &> /dev/null || true
-}
-
-function main() {
-  if [[ ! -e ~/.gitcookies ]]; then
-    echo "Unable to access git, missing ~/.gitcookies"
-    exit 1
-  fi
-  if [[ ! -e ~/.hgrc ]]; then
-    echo "Unable to access mercurial, missing ~/.hgrc"
-    exit 1
-  fi
-
-  local ROLLING="1"
-  if [[ $# -gt 0 && ("$1" == "--no-rolling") ]]; then
-    local ROLLING="0"
-  fi
-
-  gcloud compute --project "google.com:veyron" disks create ${DISK} --size "200" --zone "us-central1-a" --source-snapshot "pg-data-20140702" --type "pd-standard"
-  gcloud compute --project "google.com:veyron" instances attach-disk --disk=${DISK} $(hostname) --zone us-central1-a
-  sudo mount /dev/sdb1 /mnt
-
-  # Build the docker image.
-  cd ${VANADIUM_ROOT}/release/projects/playground/go/src/playground
-  cp ~/.gitcookies ./builder/gitcookies
-  cp ~/.hgrc ./builder/hgrc
-  sudo docker build --no-cache -t playground .
-  rm -f ./builder/gitcookies
-  rm -f ./builder/hgrc
-
-  # Export the docker image to disk.
-  sudo docker save -o /mnt/playground.tar.gz playground
-
-  # TODO(sadovsky): Before deploying the new playground image, we should run it
-  # with real input and make sure it works (produces the expected output).
-
-  # Copy the compilerd binary from the docker image to the disk.
-  # NOTE(sadovsky): The purpose of the following line is to create a container
-  # out of the docker image, so that we can copy out the compilerd binary.
-  # Annoyingly, the only way to create the container is to run the image.
-  # TODO(sadovsky): Why don't we just build compilerd using "v23 go install"?
-  sudo docker run --name=${DISK} playground &> /dev/null || true
-  sudo docker cp ${DISK}:/usr/local/vanadium/release/projects/playground/go/bin/compilerd /tmp
-  sudo mv /tmp/compilerd /mnt/compilerd
-  sudo docker rm ${DISK}
-
-  # Detach the disk so the backends can mount it.
-  unmount
-
-  # Update the template to use the new disk.
-  cd compilerd
-  sed -i -e s/pg-data-20140820/${DISK}/ pool_template.json
-  gcloud preview replica-pools --zone=us-central1-a update-template --template=pool_template.json playground-pool
-  git checkout -- pool_template.json
-
-  # Perform a rolling restart of all the replicas.
-  INSTANCES=$(gcloud preview replica-pools --zone=us-central1-a replicas --pool=playground-pool list|grep name:|cut -d: -f2)
-  for i in ${INSTANCES}; do
-    gcloud preview replica-pools --zone=us-central1-a replicas --pool=playground-pool restart ${i}
-    if [[ "$ROLLING" == "1" ]]; then
-      sleep 5m
-    fi
-  done
-}
-
-main "$@"
diff --git a/go/src/playground/playground_v23_test.go b/go/src/playground/playground_v23_test.go
index f105a00..c1fde73 100644
--- a/go/src/playground/playground_v23_test.go
+++ b/go/src/playground/playground_v23_test.go
@@ -22,9 +22,9 @@
 )
 
 func init() {
-	vanadiumRoot = os.Getenv("VANADIUM_ROOT")
+	vanadiumRoot = os.Getenv("V23_ROOT")
 	if len(vanadiumRoot) == 0 {
-		panic("VANADIUM_ROOT must be set")
+		panic("V23_ROOT must be set")
 	}
 	nodejsRoot = filepath.Join(vanadiumRoot, "environment/cout/node/bin")
 }
diff --git a/pgbundle/Makefile b/pgbundle/Makefile
index e0b5132..5ae2f19 100644
--- a/pgbundle/Makefile
+++ b/pgbundle/Makefile
@@ -1,4 +1,4 @@
-PATH := $(PATH):$(VANADIUM_ROOT)/environment/cout/node/bin
+PATH := $(PATH):$(V23_ROOT)/environment/cout/node/bin
 SHELL := /bin/bash -euo pipefail
 
 node_modules: package.json