Skip to content

Commit

Permalink
fix(api): get integration with clear password from services (#5149)
Browse files Browse the repository at this point in the history
  • Loading branch information
fsamin authored Apr 28, 2020
1 parent 581a47c commit 423fb27
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions engine/api/project_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,32 @@ func (api *API) getProjectIntegrationHandler() service.Handler {
projectKey := vars[permProjectKey]
integrationName := vars["integrationName"]

integration, err := integration.LoadProjectIntegrationByName(api.mustDB(), projectKey, integrationName)
if err != nil {
return sdk.WrapError(err, "Cannot load integration %s/%s", projectKey, integrationName)
var integ sdk.ProjectIntegration
var err error

clearPassword := FormBool(r, "clearPassword")
if clearPassword {
if !isService(ctx) {
return sdk.ErrForbidden
}
integ, err = integration.LoadProjectIntegrationByNameWithClearPassword(api.mustDB(), projectKey, integrationName)
if err != nil {
return sdk.WrapError(err, "Cannot load integration %s/%s", projectKey, integrationName)
}
} else {
integ, err = integration.LoadProjectIntegrationByName(api.mustDB(), projectKey, integrationName)
if err != nil {
return sdk.WrapError(err, "Cannot load integration %s/%s", projectKey, integrationName)
}
}
plugins, err := plugin.LoadAllByIntegrationModelID(api.mustDB(), integration.IntegrationModelID)

plugins, err := plugin.LoadAllByIntegrationModelID(api.mustDB(), integ.IntegrationModelID)
if err != nil {
return sdk.WrapError(err, "Cannot load integration %s/%s", projectKey, integrationName)
return sdk.WrapError(err, "Cannot load integration plugin %s/%s", projectKey, integrationName)
}
integration.GRPCPlugins = plugins
return service.WriteJSON(w, integration, http.StatusOK)
integ.GRPCPlugins = plugins

return service.WriteJSON(w, integ, http.StatusOK)
}
}

Expand Down

0 comments on commit 423fb27

Please sign in to comment.