Skip to content

Commit

Permalink
chore: merge branch 'main' into keycloak-21-realm-import
Browse files Browse the repository at this point in the history
  • Loading branch information
shreddedbacon committed Jan 14, 2024
2 parents 84b103d + 63b8d2b commit 884e7a2
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 5 deletions.
Binary file not shown.
Binary file not shown.
4 changes: 2 additions & 2 deletions docs/using-lagoon-advanced/ssh.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ You can upload your SSH key(s) through the UI. Log in as you normally would.

In the upper right hand corner, click on Settings:

![Click "Settings" in the upper right hand corner](./drupal-example project 2021-11-18 19-03-22.png)
![Click "Settings" in the upper right hand corner](./ui-settings.png)

You will then see a page where you can upload your SSH key(s), and it will show any uploaded keys. Paste your key into the text box, give it a name, and click "Add." That's it! Add additional keys as needed.

![Paste your key into the text box.](./settings 2021-11-18 19-03-48.png)
![Paste your key into the text box.](./ui-ssh.png)

### Via Command Line

Expand Down
Binary file added docs/using-lagoon-advanced/ui-settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/using-lagoon-advanced/ui-ssh.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.up = function(knex) {
return Promise.all([
knex.schema.raw(`
DELETE ef
FROM environment_fact ef
LEFT JOIN environment e ON ef.environment = e.id
WHERE e.id IS NULL OR e.deleted != '0000-00-00 00:00:00' OR e.project not in (select id from project)
`),
knex.schema.raw(`
DELETE ep
FROM environment_problem ep
LEFT JOIN environment e ON ep.environment = e.id
WHERE e.id IS NULL OR e.deleted != '0000-00-00 00:00:00' OR e.project not in (select id from project)
`),
]);
};

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.down = function(knex) {
return knex.schema;
};
15 changes: 15 additions & 0 deletions services/api/src/resources/environment/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { Pool } from 'mariadb';
import { asyncPipe } from '@lagoon/commons/dist/util/func';
import { query } from '../../util/db';
import { Sql } from './sql';
import { Sql as problemSql } from '../problem/sql';
import { Sql as factSql } from '../fact/sql';
import { Helpers as projectHelpers } from '../project/helpers';
// import { logger } from '../../loggers/logger';

Expand Down Expand Up @@ -48,6 +50,19 @@ export const Helpers = (sqlClientPool: Pool) => {
sqlClientPool,
Sql.deleteEnvironment(name, pid)
);

// Here we clean up insights attached to the environment

await query(
sqlClientPool,
factSql.deleteFactsForEnvironment(eid)
);

await query(
sqlClientPool,
problemSql.deleteProblemsForEnvironment(eid)
);

},
getEnvironmentsDeploytarget: async (eid) => {
const rows = await query(
Expand Down
7 changes: 7 additions & 0 deletions services/api/src/resources/fact/sql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ export const Sql = {
})
.del()
.toString(),
deleteFactsForEnvironment: (environment) => // Used when removing environments.
knex('environment_fact')
.where({
environment
})
.del()
.toString(),
deleteFactsFromSource: (environment, source) =>
knex('environment_fact')
.where({ environment, source })
Expand Down
7 changes: 7 additions & 0 deletions services/api/src/resources/problem/sql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@ export const Sql = {
}
return q.del().toString();
},
deleteProblemsForEnvironment: (environment) => { // This should be used primarily to remove problems when deleting an environment
let q = knex('environment_problem')
.where({
environment: environment
});
return q.del().toString();
},
deleteProblemsFromSource: (environment, source, service) =>
knex('environment_problem')
.where({
Expand Down
6 changes: 3 additions & 3 deletions services/logs2notifications/internal/handler/email_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (h *Messaging) processEmailTemplates(notification *Notification) (string, s
if err != nil {
eventSplit := strings.Split(notification.Event, ":")
if eventSplit[0] != "problem" {
return "", "", "", "", "", nil
return "", "", "", "", "", fmt.Errorf("no matching event")
}
if eventSplit[1] == "insert" {
tpl = "problemNotification"
Expand Down Expand Up @@ -127,7 +127,7 @@ func (h *Messaging) processEmailTemplates(notification *Notification) (string, s
case "problemNotification":
eventSplit := strings.Split(notification.Event, ":")
if eventSplit[0] != "problem" && eventSplit[1] == "insert" {
return "", "", "", "", "", nil
return "", "", "", "", "", fmt.Errorf("no matching event")
}
mainHTMLTpl = `[{{.ProjectName}}] New problem found for <code>{{.EnvironmentName}}</code>
<ul><li>* Service: {{.ServiceName}}</li>{{ if ne .Severity "" }}
Expand All @@ -142,7 +142,7 @@ func (h *Messaging) processEmailTemplates(notification *Notification) (string, s
notification.Meta.EnvironmentName,
)
default:
return "", "", "", "", "", nil
return "", "", "", "", "", fmt.Errorf("no matching event")
}

var body bytes.Buffer
Expand Down

0 comments on commit 884e7a2

Please sign in to comment.