From 0265e91a28596c8f93d52c3e51e72924aff7ca10 Mon Sep 17 00:00:00 2001 From: mpl Date: Fri, 30 Jan 2015 17:34:52 +0100 Subject: [PATCH] deploy/gce: redid the form Change-Id: I62fd3eb432f2c9a6f85d08adbb073e587a4387ab --- pkg/deploy/gce/deploy.go | 2 +- pkg/deploy/gce/handler.go | 90 +++++++++++++++++++++++++++++---------- 2 files changed, 68 insertions(+), 24 deletions(-) diff --git a/pkg/deploy/gce/deploy.go b/pkg/deploy/gce/deploy.go index 03644e32a..7b2d415ad 100644 --- a/pkg/deploy/gce/deploy.go +++ b/pkg/deploy/gce/deploy.go @@ -67,7 +67,7 @@ const ( configDir = "config" ConsoleURL = "https://console.developers.google.com" - HelpCreateProject = "Go to " + ConsoleURL + " to create a new Google Cloud project." + HelpCreateProject = "Go to " + ConsoleURL + " to create a new Google Cloud project" HelpEnableAPIs = `Enable the project APIs: in your project console, navigate to "APIs and auth", "APIs". In the list, enable "Google Cloud Storage", "Google Cloud Storage JSON API", and "Google Compute Engine".` helpDeleteInstance = `To delete an existing Compute Engine instance: in your project console, navigate to "Compute", "Compute Engine", and "VM instances". Select your instance and click "Delete".` HelpManageSSHKeys = `To manage/add SSH keys: in your project console, navigate to "Compute", "Compute Engine", and "VM instances". Click on your instance name. Scroll down to the SSH Keys section.` diff --git a/pkg/deploy/gce/handler.go b/pkg/deploy/gce/handler.go index b8bff5f92..c95e5086b 100644 --- a/pkg/deploy/gce/handler.go +++ b/pkg/deploy/gce/handler.go @@ -69,6 +69,22 @@ var ( "machine": Machine, "zone": Zone, } + // TODO(mpl): query for them, and cache them. + zoneValues = []string{ + "us-central1-a", + "us-central1-b", + "us-central1-f", + "europe-west1-b", + "europe-west1-c", + "asia-east1-a", + "asia-east1-b", + "asia-east1-c", + } + machineValues = []string{ + "g1-small", + "n1-highcpu-2", + } + // DevHandler: if true, use HTTP instead of HTTPS, force permissions prompt for OAuth, // do not actually create an instance. It has no effect if set after NewHandler is // called. @@ -201,9 +217,11 @@ func (h *DeployHandler) serveRoot(w http.ResponseWriter, r *http.Request) { h.tplMu.RLock() defer h.tplMu.RUnlock() if err := h.tpl.ExecuteTemplate(w, "withform", &TemplateData{ - Prefix: h.prefix, - Help: h.help, - Defaults: formDefaults, + Prefix: h.prefix, + Help: h.help, + Defaults: formDefaults, + ZoneValues: zoneValues, + MachineValues: machineValues, }); err != nil { h.Print(err) } @@ -404,11 +422,13 @@ func (h *DeployHandler) serveFormError(w http.ResponseWriter, err error, hints . h.tplMu.RLock() defer h.tplMu.RUnlock() if tplErr := h.tpl.ExecuteTemplate(w, "withform", &TemplateData{ - Prefix: h.prefix, - Help: h.help, - Err: err, - Hints: topHints, - Defaults: formDefaults, + Prefix: h.prefix, + Help: h.help, + Err: err, + Hints: topHints, + Defaults: formDefaults, + ZoneValues: zoneValues, + MachineValues: machineValues, }); tplErr != nil { h.Printf("Could not serve form error %q because: %v", err, tplErr) } @@ -460,6 +480,8 @@ func (h *DeployHandler) serveInstanceState(w http.ResponseWriter, r *http.Reques Project: conf.Project, Password: conf.Password, Defaults: formDefaults, + ZoneValues: zoneValues, + MachineValues: machineValues, }) return } @@ -703,6 +725,8 @@ type TemplateData struct { CertFingerprint string // SHA-256 fingerprint of the self-signed HTTPS certificate. ProjectConsoleURL string Password string // password provided by user. defaults to project ID. + ZoneValues []string + MachineValues []string } const toHyperlink = `$1$3` @@ -810,6 +834,7 @@ var tplHTML = ` {{if .InstanceIP}}

Success. Your Camlistore instance should be up at https://{{.InstanceIP}} (login: ` + camliUsername + `, password: {{.Password}}). It can take a couple of minutes to be ready.

+

Please bookmark this page in case you need to come back for the instruction.

{{end}} {{if .ProjectConsoleURL}}

@@ -850,25 +875,44 @@ var tplHTML = `

-

Create a new Google Cloud project

+

Deploy Camlistore on Google Cloud

-

{{.Help.createProject}}

-

{{.Help.enableAPIs}}

- -

Configure Google Compute Engine

- -

{{.Help.genCert}}

+

+This tool helps you create your own private Camlistore instance running on Google's cloud. Be sure to understand Google Compute Engine's pricing before proceeding. To delete your instance and stop paying Google for the virtual machine, visit the Google Cloud console. +

- - - - - - - + + + + + +
Project ID
Domain name
Zone
Instance name
Machine type
Password
SSH public key
Project ID
+
    +
  • New or existing Google Project.
  • +
  • Requirements:
  • +
      +
    • Enable billing. (Billing & settings)
    • +
    • APIs and auth > APIs > Google Cloud Storage
    • +
    • APIs and auth > APIs > Google Cloud Storage JSON API
    • +
    • APIs and auth > APIs > Google Compute Engine
    • +
    +
+
New password
New password for your Camlistore server.
Zone + +
Machine type + + + {{range $k, $v := .MachineValues}} + + {{end}} + +

(it will ask for permissions)
-
{{template "footer" .}}