func RegistryDelete(rw http.ResponseWriter, r *http.Request) *httperr.Error { // server := mux.Vars(r)["server"] server := r.FormValue("server") env, acs, err := models.GetPrivateRegistriesAuth() if err != nil { return httperr.Server(err) } ac, ok := acs[server] if !ok { return httperr.Errorf(404, "no such registry: %s", server) } models.DockerLogout(ac) delete(acs, server) dat, err := json.Marshal(acs) if err != nil { return httperr.Server(err) } env["DOCKER_AUTH_DATA"] = string(dat) err = models.PutRackSettings(env) if err != nil { return httperr.Server(err) } return RenderJson(rw, ac) }
func RegistryCreate(rw http.ResponseWriter, r *http.Request) *httperr.Error { ac := docker.AuthConfiguration{ Username: GetForm(r, "username"), Password: GetForm(r, "password"), Email: GetForm(r, "email"), ServerAddress: GetForm(r, "serveraddress"), } _, err := models.DockerLogin(ac) if err != nil { return httperr.Errorf(400, "Could not login to server with provided credentials") } env, acs, err := models.GetPrivateRegistriesAuth() if err != nil { return httperr.Server(err) } acs[ac.ServerAddress] = ac dat, err := json.Marshal(acs) if err != nil { return httperr.Server(err) } env["DOCKER_AUTH_DATA"] = string(dat) err = models.PutRackSettings(env) if err != nil { return httperr.Server(err) } return RenderJson(rw, ac) }