Fix RepositoryURL with its validator

pull/2972/head
ssbkang 2019-07-02 18:07:56 +12:00
parent f496776490
commit 5d169ad827
3 changed files with 5 additions and 4 deletions

View File

@ -61,6 +61,7 @@ func (service *Service) ClonePrivateRepositoryWithDeploymentKey(repositoryURL, r
} }
repositoryURL = strings.Replace(repositoryURL, "https://", "git@", 1) repositoryURL = strings.Replace(repositoryURL, "https://", "git@", 1)
repositoryURL = strings.Replace(repositoryURL, "github.com/", "github.com:", 1)
repositoryURL += ".git" repositoryURL += ".git"
options := &git.CloneOptions{ options := &git.CloneOptions{

View File

@ -54,7 +54,7 @@ func (handler *Handler) deploymentkeyCreate(w http.ResponseWriter, r *http.Reque
return &httperror.HandlerError{http.StatusInternalServerError, "Unable to persist the deployment key inside the database", err} return &httperror.HandlerError{http.StatusInternalServerError, "Unable to persist the deployment key inside the database", err}
} }
// hideFields(deploymentkey) hideFields(deploymentkey)
return response.JSON(w, deploymentkey) return response.JSON(w, deploymentkey)
} }

View File

@ -113,17 +113,17 @@ func (payload *swarmStackFromGitRepositoryPayload) Validate(r *http.Request) err
return portainer.Error("Invalid Swarm ID") return portainer.Error("Invalid Swarm ID")
} }
// Need to improve validators for SSH based URL and deployment key type
/*
if govalidator.IsNull(payload.RepositoryURL) || !govalidator.IsURL(payload.RepositoryURL) { if govalidator.IsNull(payload.RepositoryURL) || !govalidator.IsURL(payload.RepositoryURL) {
return portainer.Error("Invalid repository URL. Must correspond to a valid URL format") return portainer.Error("Invalid repository URL. Must correspond to a valid URL format")
} }
// Need to improve validators for SSH based URL and deployment key type
/*
if payload.RepositoryAuthentication && (govalidator.IsNull(payload.RepositoryDeploymentKey)) || (govalidator.IsNull(payload.RepositoryUsername) || govalidator.IsNull(payload.RepositoryPassword)) { if payload.RepositoryAuthentication && (govalidator.IsNull(payload.RepositoryDeploymentKey)) || (govalidator.IsNull(payload.RepositoryUsername) || govalidator.IsNull(payload.RepositoryPassword)) {
return portainer.Error("Invalid repository credentials or deploymenet key. Either Username & password or a deployment key must be specified when authentication is enabled") return portainer.Error("Invalid repository credentials or deploymenet key. Either Username & password or a deployment key must be specified when authentication is enabled")
} }
*/ */
if govalidator.IsNull(payload.ComposeFilePathInRepository) { if govalidator.IsNull(payload.ComposeFilePathInRepository) {
payload.ComposeFilePathInRepository = filesystem.ComposeFileDefaultName payload.ComposeFilePathInRepository = filesystem.ComposeFileDefaultName
} }