Exemplo n.º 1
0
func DeleteConfiguration(w http.ResponseWriter, r *http.Request){
	body, _ := ioutil.ReadAll(r.Body)
	vars := mux.Vars(r)

	var cfg = database.Configuration{}
	json.Unmarshal(body, &cfg)


	cfg.Name = vars["name"]

	oldConfig := database.GetConfigurationByName(cfg.Name)

	cfg.ID = oldConfig.ID

	ok := cfg.DeleteConfiguration()

	if ok{
		json.NewEncoder(w).Encode(cfg)
	}else{
		json.NewEncoder(w).Encode(models.ApiError{
			Code: "error",
			Message: "Error on execute",
		})
	}


}
Exemplo n.º 2
0
func GetRepo(w http.ResponseWriter, r *http.Request) {
	vars := mux.Vars(r)
	repo := database.GetRepositoryByName(vars["name"])
	repo.Hooks = database.GetHooksByRepo(repo.ID)
	json.NewEncoder(w).Encode(repo)

}
Exemplo n.º 3
0
func GetRepoActions(w http.ResponseWriter, r *http.Request) {
	vars := mux.Vars(r)
	action := database.Action{
		Repository: vars["repo"],
	}

	json.NewEncoder(w).Encode(action.GetByRepository())

}
Exemplo n.º 4
0
func UpdateRepoHook(w http.ResponseWriter, r *http.Request) {
	body, _ := ioutil.ReadAll(r.Body)
	vars := mux.Vars(r)
	fmt.Println(vars)
	hook := database.Hook{}
	json.Unmarshal(body, &hook)

	hook.ID, _ = strconv.Atoi(vars["id"])

	hook.UpdateHook()

	json.NewEncoder(w).Encode(hook)

}
Exemplo n.º 5
0
func CreateRepoHook(w http.ResponseWriter, r *http.Request) {
	body, _ := ioutil.ReadAll(r.Body)
	vars := mux.Vars(r)

	repo := database.GetRepositoryByName(vars["name"])

	hook := database.Hook{}
	json.Unmarshal(body, &hook)

	hook.RepositoryId = repo.ID

	hook.SaveHook()

	json.NewEncoder(w).Encode(hook)

}