Skip to content

Commit

Permalink
fix error when creating application
Browse files Browse the repository at this point in the history
  • Loading branch information
Vano2903 committed Oct 5, 2022
1 parent 07f82b0 commit 4657282
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
10 changes: 5 additions & 5 deletions applications_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ func (h Handler) NewApplicationHandler(w http.ResponseWriter, r *http.Request) {
return
}

//download the repo
repo, name, hash, err := h.util.DownloadGithubRepo(student.ID, appPost.GithubBranch, appPost.GithubRepoUrl)
//download the repoPath
repoPath, name, hash, err := h.util.DownloadGithubRepo(student.ID, appPost.GithubBranch, appPost.GithubRepoUrl)
if err != nil {
resp.Errorf(w, http.StatusInternalServerError, "error downloading the repo, try again in one minute: %v", err.Error())
return
}
fmt.Println("repo: ", repo)
fmt.Println("repo: ", repoPath)
fmt.Println("name: ", name)
fmt.Println("hash: ", hash)

Expand All @@ -73,7 +73,7 @@ func (h Handler) NewApplicationHandler(w http.ResponseWriter, r *http.Request) {
}

//create the image from the repo downloaded
imageName, imageID, err := h.cc.CreateImage(student.ID, port, name, repo, appPost.GithubBranch, appPost.Language, appPost.Envs)
imageName, imageID, err := h.cc.CreateImage(student.ID, port, name, appPost.GithubBranch, repoPath, appPost.Language, appPost.Envs)
if err != nil {
resp.Errorf(w, http.StatusInternalServerError, "error creating the image: %v", err.Error())
return
Expand Down Expand Up @@ -102,7 +102,7 @@ func (h Handler) NewApplicationHandler(w http.ResponseWriter, r *http.Request) {
}

//remove the repo after creating the application
err = os.RemoveAll(repo)
err = os.RemoveAll(repoPath)
if err != nil {
resp.Errorf(w, http.StatusInternalServerError, "error removing the repo: %v", err)
return
Expand Down
2 changes: 1 addition & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var (
oauthStateCleaningInterval = 5 * time.Minute
refreshTokenCleaningInterval = 5 * time.Minute
usersCleaningInterval = 1 * time.Minute
pollingIDsCleaningInterval = 10 * time.Second
pollingIDsCleaningInterval = 10 * time.Minute
executeCleaning chan string
)

Expand Down
7 changes: 4 additions & 3 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/go-git/go-git/v5/plumbing"
"github.com/tidwall/gjson"
"io"
"math/rand"
"net"
Expand All @@ -15,6 +13,9 @@ import (
"strings"
"time"

"github.com/go-git/go-git/v5/plumbing"
"github.com/tidwall/gjson"

"github.com/go-git/go-git/v5"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
Expand Down Expand Up @@ -175,7 +176,7 @@ func (u Util) DownloadGithubRepo(userID int, branch, url string) (string, string
return "", "", "", err
}
fmt.Println("ok")
return fmt.Sprintf("%s", tmpPath), repoName, commitHash.Hash.String(), nil
return tmpPath, repoName, commitHash.Hash.String(), nil
}

// GetMetadataFromRepo gets the description, default branch and all the branches of a GitHub repository
Expand Down

0 comments on commit 4657282

Please sign in to comment.