Skip to content

Commit 87419a0

Browse files
bradfitzcodebien
authored andcommitted
cmd/xb, app/appengine: simplify build.golang.org deployment docs
Change-Id: I0057e5133f395de6924b94d130748db78d8b5ffc Reviewed-on: https://go-review.googlesource.com/c/build/+/205597 Reviewed-by: Dmitri Shuralyov <[email protected]>
1 parent 1fb12d9 commit 87419a0

File tree

4 files changed

+28
-13
lines changed

4 files changed

+28
-13
lines changed

.gcloudignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*.iso
2+
*.raw
3+
\.#*

app/appengine/Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
usage:
2+
echo "See Makefile for usage"
3+
exit 1
4+
5+
deploy:
6+
go install golang.org/x/build/cmd/xb
7+
GO111MODULE=on gcloud app --account=$$(xb google-email) --project=golang-org deploy app.yaml

app/appengine/README.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,5 @@ dev_appserver.py --enable_host_checking=false --host=0.0.0.0 --port=8080 .
1919
## Deploying
2020

2121
```sh
22-
gcloud config set project golang-org
23-
GO111MODULE=on gcloud app deploy app.yaml
24-
```
25-
26-
or, to not affect your gcloud state, use:
27-
28-
```
29-
GO111MODULE=on gcloud app [email protected] --project=golang-org deploy app.yaml
22+
make deploy
3023
```

cmd/xb/xb.go

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
// Examples:
1414
//
1515
// xb --staging kubectl ...
16+
// xb --prod kubectl ...
17+
// xb google-email # print the @google.com account from gcloud
1618
//
17-
// Currently kubectl is the only supported subcommand.
18-
1919
package main // import "golang.org/x/build/cmd/xb"
2020

2121
import (
@@ -25,6 +25,7 @@ import (
2525
"log"
2626
"os"
2727
"os/exec"
28+
"regexp"
2829
"strings"
2930

3031
"golang.org/x/build/buildenv"
@@ -36,10 +37,10 @@ var (
3637
)
3738

3839
func usage() {
39-
fmt.Fprintf(os.Stderr, `xb {prod,staging} <CMD> [<ARGS>...]
40+
fmt.Fprintf(os.Stderr, `xb [--prod or --staging] <CMD> [<ARGS>...]
4041
Example:
41-
xb staging kubectl ...
42-
xb prod gcloud ...
42+
xb --staging kubectl ...
43+
xb google-email
4344
`)
4445
os.Exit(1)
4546
}
@@ -68,6 +69,17 @@ func main() {
6869
runCmd()
6970
case "docker":
7071
runDocker()
72+
case "google-email":
73+
out, err := exec.Command("gcloud", "config", "configurations", "list").CombinedOutput()
74+
if err != nil {
75+
log.Fatalf("gcloud: %v, %s", err, out)
76+
}
77+
googRx := regexp.MustCompile(`\S+@google\.com\b`)
78+
e := googRx.FindString(string(out))
79+
if e == "" {
80+
log.Fatalf("didn't find @google.com address in gcloud config configurations list: %s", out)
81+
}
82+
fmt.Println(e)
7183
default:
7284
log.Fatalf("unknown command %q", cmd)
7385
}

0 commit comments

Comments
 (0)