Skip to content

Commit

Permalink
fix: 🚧 use last log method
Browse files Browse the repository at this point in the history
fix: ⚡ comment validation at repo creation
fix: 🚑 double encoding app repo url
  • Loading branch information
ArnaudTA committed May 23, 2023
1 parent 1ac2f6c commit 8864cb0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 38 deletions.
11 changes: 1 addition & 10 deletions apps/server/src/controllers/admin/logs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { adminGroupPath } from 'shared/src/utils/const.js'
import { addReqLogs } from '../../utils/logger.js'
import { sendForbidden, sendNotFound, sendOk } from '../../utils/response.js'
import { getAllLogs } from '../../models/queries/log-queries.js'

Expand All @@ -8,18 +7,10 @@ export const getLogsController = async (req, res) => {

try {
const logs = await getAllLogs()
addReqLogs({
req,
description: 'Organisations récupérées avec succès',
})

sendOk(res, logs)
} catch (error) {
const description = 'Echec de la récupération des organisations'
addReqLogs({
req,
description,
error,
})
sendNotFound(res, description)
}
}
39 changes: 13 additions & 26 deletions apps/server/src/controllers/repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
} from '../models/queries/environment-queries.js'
import { filterObjectByKeys } from '../utils/queries-tools.js'
import { addReqLogs } from '../utils/logger.js'
import { sendOk, sendCreated, sendUnprocessableContent, sendNotFound, sendBadRequest, sendForbidden } from '../utils/response.js'
import { sendOk, sendCreated, sendNotFound, sendBadRequest, sendForbidden } from '../utils/response.js'
import { getOrganizationById } from '../models/queries/organization-queries.js'
import { addLogs } from '../models/queries/log-queries.js'
import { gitlabUrl, projectRootDir } from '../utils/env.js'
Expand Down Expand Up @@ -103,31 +103,18 @@ export const createRepositoryController = async (req, res) => {
let project
let repo
try {
const isValid = await hooksFns.createProject({ owner: user }, true)

if (isValid?.failed) {
try {
const reasons = Object.values(isValid)
.filter(({ status }) => status?.result === 'KO')
.map(({ status }) => status?.message)
.join('; ')
sendUnprocessableContent(res, reasons)

addReqLogs({
req,
description: 'Dépôt récupéré avec succès',
extras: {
reasons,
},
error: new Error('Failed to validation repository creation'),
})
} catch (error) {
addReqLogs({ req, error, description: 'Failed at precheck repo creation' })
} finally {
addLogs('Create Project Validation', { isValid }, user.id)
}
return
}
// const isValid = await hooksFns.createProject({ owner: user }, true)

// if (isValid?.failed) {
// const reasons = Object.values(isValid)
// .filter(({ status }) => status?.result === 'KO')
// .map(({ status }) => status?.message)
// .join('; ')
// sendUnprocessableContent(res, reasons)
// req.log.error(reasons)
// addLogs('Create Project Validation', { reasons }, user.id)
// return
// }
project = await getProjectById(projectId)
if (!project) throw new Error('Le projet n\'existe pas')

Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/plugins/core/argo/repo-secret.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const getSecretObject = ({ repo, project, organization }) => {
},
},
stringData: {
url: Buffer.from(repo.url).toString('base64'),
url: repo.url,
},
}
}
2 changes: 1 addition & 1 deletion apps/server/src/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const createHook = () => {
const execute = async (args, isOnlyValidation = false) => {
let payload = { args }

const steps = isOnlyValidation ? [check] : [check, pre, main, post, save]
const steps = isOnlyValidation ? [check] : [pre, main, post, save]

for (const step of steps) {
payload = await executeStep(step, payload)
Expand Down

0 comments on commit 8864cb0

Please sign in to comment.