Пример #1
0
// UnLockHandler allows you to unlock an environment
// http://127.0.0.1:8000/unlock?environment=staging&project=admin
func UnLockHandler(w http.ResponseWriter, r *http.Request) {
	c := etcd.NewClient([]string{*ETCDServer})
	p := r.FormValue("project")
	env := r.FormValue("environment")
	err := goship.LockEnvironment(c, p, env, "false")
	if err != nil {
		log.Println("ERROR: ", err)
		http.Error(w, err.Error(), http.StatusBadRequest)
		return
	}
	http.Redirect(w, r, "/", http.StatusSeeOther)
}
Пример #2
0
// handler allows you to lock or unlock an environment
func handler(ecl *etcd.Client, w http.ResponseWriter, r *http.Request, lock bool) {
	p := r.FormValue("project")
	env := r.FormValue("environment")

	lockStr := "false"
	if lock {
		lockStr = "true"
	}
	err := goship.LockEnvironment(ecl, p, env, lockStr)
	if err != nil {
		log.Println("ERROR: ", err)
		http.Error(w, err.Error(), http.StatusBadRequest)
		return
	}

	http.Redirect(w, r, "/", http.StatusSeeOther)
}
Пример #3
0
func TestUnlockingEnvironment(t *testing.T) {
	err := goship.LockEnvironment(&MockEtcdClient{}, "test_project", "test_environment", "false")
	if err != nil {
		t.Fatalf("Can't unlock %s", err)
	}
}