Ejemplo n.º 1
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 := config.LockEnvironment(ecl, p, env, lockStr)
	if err != nil {
		glog.Errorf("Failed to lock/unlock project=%s env=%s: %v", p, env, err)
		http.Error(w, err.Error(), http.StatusBadRequest)
		return
	}

	http.Redirect(w, r, "/", http.StatusSeeOther)
}
Ejemplo n.º 2
0
func TestUnlockingEnvironment(t *testing.T) {
	err := config.LockEnvironment(&MockEtcdClient{}, "test_project", "test_environment", "false")
	if err != nil {
		t.Fatalf("Can't unlock %s", err)
	}
}