message: Third time's a charm
diff: @@ -219,9 +219,29 @@ async function resetHarborWebhook(sqlClient: MariaClient, harborClient, lagoonPr
  return true
  }
  -async function deleteProject(lagoonProjectName: string) {
  - // Delete harbor project
  +export const createHarborOperations = (sqlClient /* : MariaSQL */) => ({
  + addProject: async (lagoonProjectName, projectID) => {
  + // Create harbor project
  + const harborProjectID = await createHarborProject(sqlClient, harborClient, lagoonProjectName)
  + if (harborProjectID == "") {return}
  +
  + // Create robot account for new harbor project
  + var harborTokenInfo = await createRobot(sqlClient, harborClient, lagoonProjectName, harborProjectID)
  + if (harborTokenInfo == false) {return}
  +
  + // Remove previously set internal registry env vars
  + if (! await removeHarborEnvVars(sqlClient, lagoonProjectName)) {return}
  + // Set required Lagoon env vars to enable Harbor on this project
  + if (! await addEnvVar(sqlClient, lagoonProjectName, "INTERNAL_REGISTRY_URL", lagoonHarborRoute, "INTERNAL_CONTAINER_REGISTRY", projectID)) {return}
  + if (! await addEnvVar(sqlClient, lagoonProjectName, "INTERNAL_REGISTRY_USERNAME", harborTokenInfo.name, "INTERNAL_CONTAINER_REGISTRY", projectID)) {return}
  + if (! await addEnvVar(sqlClient, lagoonProjectName, "INTERNAL_REGISTRY_PASSWORD", harborTokenInfo.token, "INTERNAL_CONTAINER_REGISTRY", projectID)) {return}
  +
  + // Reset harbor project webhook to point to this Lagoon's Harbor
  + if (! await resetHarborWebhook(sqlClient, harborClient, lagoonProjectName, lagoonWebhookAddress, harborProjectID)) {return}
  + },
  +
  + deleteProject: async (lagoonProjectName) => {
  // Get existing harbor project's id
  try {
  const res = await harborClient.get(`projects?name=${lagoonProjectName}`)
  @@ -273,26 +293,4 @@ async function deleteProject(lagoonProjectName: string) {
  logger.info(`Unable to delete the harbor project "${lagoonProjectName}", error: ${err}`)
  }
  }
  -
  -export const createHarborOperations = (sqlClient /* : MariaSQL */) => ({
  - addProject: async (lagoonProjectName, projectID) => {
  - // Create harbor project
  - const harborProjectID = await createHarborProject(sqlClient, harborClient, lagoonProjectName)
  - if (harborProjectID == "") {return}
  -
  - // Create robot account for new harbor project
  - var harborTokenInfo = await createRobot(sqlClient, harborClient, lagoonProjectName, harborProjectID)
  - if (harborTokenInfo == false) {return}
  -
  - // Remove previously set internal registry env vars
  - if (! await removeHarborEnvVars(sqlClient, lagoonProjectName)) {return}
  -
  - // Set required Lagoon env vars to enable Harbor on this project
  - if (! await addEnvVar(sqlClient, lagoonProjectName, "INTERNAL_REGISTRY_URL", lagoonHarborRoute, "INTERNAL_CONTAINER_REGISTRY", projectID)) {return}
  - if (! await addEnvVar(sqlClient, lagoonProjectName, "INTERNAL_REGISTRY_USERNAME", harborTokenInfo.name, "INTERNAL_CONTAINER_REGISTRY", projectID)) {return}
  - if (! await addEnvVar(sqlClient, lagoonProjectName, "INTERNAL_REGISTRY_PASSWORD", harborTokenInfo.token, "INTERNAL_CONTAINER_REGISTRY", projectID)) {return}
  -
  - // Reset harbor project webhook to point to this Lagoon's Harbor
  - if (! await resetHarborWebhook(sqlClient, harborClient, lagoonProjectName, lagoonWebhookAddress, harborProjectID)) {return}
  - }
  })
  