Skip to content

Commit

Permalink
Merge pull request #2693 from uselagoon/feature/facts-search-api-changes
Browse files Browse the repository at this point in the history
Fact api changes for fact search
  • Loading branch information
bomoko committed Aug 19, 2021
2 parents 92e32f1 + e4ab9a5 commit a30dddb
Show file tree
Hide file tree
Showing 17 changed files with 957 additions and 303 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/chromatic.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
name: 'Publish UI Storybook to Chromatic'

on:
# pull_request:
# branches:
# - main
push:
paths:
- "services/ui/**"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,8 @@ mutation PopulateApi {
openshift: 4
gitUrl: "ssh://git@172.17.0.1:2222/git/project18.git"
productionEnvironment: "Master"
problemsUi: 1
factsUi: 1
}
) {
id
Expand Down Expand Up @@ -502,7 +504,6 @@ mutation PopulateApi {
id
}


UIProject1Environment1addTask3: addTask(
input: {
name: "Drupal Archive"
Expand All @@ -523,6 +524,94 @@ mutation PopulateApi {
id
}

UIProject1Environment1addFacts: addFacts(
input: {
facts: [
{
name: "lagoon-category"
value: "saas"
environment: 3
source: ""
description: "Category of the site"
category: "Lagoon"
keyFact: true
},
{
name: "drupal-core"
value: "9.0.1"
environment: 3
source: "drush-pml"
description: "Drupal CMS version found on environment"
category: "Framework"
keyFact: true
},
{
name: "php-version"
value: "8.0.3"
environment: 3
source: "php-version"
description: "PHP version found on environment"
category: "Programming language"
keyFact: true
},
{
name: "Lagoon"
value: "21.3.0"
environment: 3
source: "env"
description: "Lagoon version"
category: "Platform"
keyFact: true
},
{
name: "interesting-package"
value: "1.0.0"
environment: 3
source: "local-dev"
description: "Description of interesting php package"
category: "Composer package"
},
{
name: "npm-module"
value: "2.0.0"
environment: 3
source: "local-dev"
description: "Description of node module"
category: "Node package"
},
{
name: "site-code-status"
value: "200"
environment: 3
source: "curl"
description: "Health check of site"
category: "Performance"
keyFact: true
}
]
}
) {
id
}

UIProject1Environment1addFactReference1: addFactReference(
input: {
fid: 2
name: "nginx.high-cotton.org"
}
) {
id
}

UIProject1Environment1addFactReference2: addFactReference(
input: {
fid: 2
name: "cli"
}
) {
id
}

UIProject1Environment2: addOrUpdateEnvironment(
input: {
id: 4
Expand Down Expand Up @@ -571,6 +660,77 @@ mutation PopulateApi {
) {
id
}

UIProject1Environment3addFacts: addFacts(
input: {
facts: [
{
name: "lagoon-category"
value: "saas"
environment: 5
source: ""
description: "Category of the site"
category: "Lagoon"
keyFact: true
},
{
name: "drupal-core"
value: "9.0.1"
environment: 5
source: "drush-pml"
description: "Drupal CMS version found on environment"
category: "Framework"
keyFact: true
},
{
name: "php-version"
value: "8.0.3"
environment: 5
source: "php-version"
description: "PHP version found on environment"
category: "Programming language"
keyFact: true
},
{
name: "Lagoon"
value: "21.3.0"
environment: 5
source: "env"
description: "Lagoon version"
category: "Platform"
keyFact: true
},
{
name: "interesting-package"
value: "1.0.0"
environment: 5
source: "local-dev"
description: "Description of interesting php package"
category: "Composer package"
},
{
name: "npm-module"
value: "2.0.0"
environment: 5
source: "local-dev"
description: "Description of node module"
category: "Node package"
},
{
name: "site-code-status"
value: "403"
environment: 5
source: "curl"
description: "Health check of site"
category: "Performance"
keyFact: true
}
]
}
) {
id
}

UIProject1Environment4: addOrUpdateEnvironment(
input: {
id: 6
Expand Down
11 changes: 10 additions & 1 deletion services/api-db/docker-entrypoint-initdb.d/00-tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -281,15 +281,24 @@ CREATE TABLE IF NOT EXISTS environment_fact (
environment int REFERENCES environment (id),
name varchar(300) NOT NULL,
value varchar(300) NOT NULL,
type ENUM('TEXT', 'URL', 'SEMVER') DEFAULT 'TEXT',
source varchar(300) DEFAULT '',
description TEXT NULL DEFAULT '',
created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
category TEXT NULL DEFAULT '',
key_fact TINYINT(1) NOT NULL DEFAULT(0),
UNIQUE(environment, name)
);

CREATE TABLE IF NOT EXISTS environment_fact_reference (
id int NOT NULL auto_increment PRIMARY KEY,
fid int NOT NULL REFERENCES environment_fact (id),
name varchar(300) NOT NULL,
UNIQUE(fid, name)
);

CREATE TABLE IF NOT EXISTS notification_webhook (
id int NOT NULL auto_increment PRIMARY KEY,
name varchar(50) UNIQUE,
webhook varchar(2000)
);
);
57 changes: 57 additions & 0 deletions services/api-db/docker-entrypoint-initdb.d/01-migrations.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1148,6 +1148,42 @@ CREATE OR REPLACE PROCEDURE
END;
$$

CREATE OR REPLACE PROCEDURE
add_fact_category_to_environment_fact()

BEGIN
IF NOT EXISTS(
SELECT NULL
FROM INFORMATION_SCHEMA.COLUMNS
WHERE
table_name = 'environment_fact'
AND table_schema = 'infrastructure'
AND column_name = 'category'
) THEN
ALTER TABLE `environment_fact`
ADD `category` TEXT NULL DEFAULT '';
END IF;
END;
$$

CREATE OR REPLACE PROCEDURE
add_fact_key_to_environment_fact()

BEGIN
IF NOT EXISTS(
SELECT NULL
FROM INFORMATION_SCHEMA.COLUMNS
WHERE
table_name = 'environment_fact'
AND table_schema = 'infrastructure'
AND column_name = 'key_fact'
) THEN
ALTER TABLE `environment_fact`
ADD `key_fact` TINYINT(1) NOT NULL DEFAULT(0);
END IF;
END;
$$

CREATE OR REPLACE PROCEDURE
update_user_password()

Expand Down Expand Up @@ -1255,6 +1291,24 @@ CREATE OR REPLACE PROCEDURE
END;
$$

CREATE OR REPLACE PROCEDURE
add_fact_type_to_environment_fact()

BEGIN
IF NOT EXISTS(
SELECT NULL
FROM INFORMATION_SCHEMA.COLUMNS
WHERE
table_name = 'environment_fact'
AND table_schema = 'infrastructure'
AND column_name = 'type'
) THEN
ALTER TABLE `environment_fact`
ADD `type` ENUM('TEXT', 'URL') NOT NULL DEFAULT 'TEXT';
END IF;
END;
$$

CREATE OR REPLACE PROCEDURE
add_enum_webhook_to_type_in_project_notification()

Expand Down Expand Up @@ -1367,6 +1421,9 @@ CALL update_user_password();
CALL add_problems_ui_to_project();
CALL add_facts_ui_to_project();
CALL add_fact_source_and_description_to_environment_fact();
CALL add_fact_type_to_environment_fact();
CALL add_fact_category_to_environment_fact();
CALL add_fact_key_to_environment_fact();
CALL add_metadata_to_project();
CALL add_min_max_to_billing_modifier();
CALL add_content_type_to_project_notification();
Expand Down
2 changes: 1 addition & 1 deletion services/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"jsonwebtoken": "^8.0.1",
"keycloak-admin": "https://github.com/amazeeio/keycloak-admin.git#bd015d2e34634f262c0827f00620657427e3c252",
"keycloak-connect": "^5.0.0",
"knex": "^0.20.2",
"knex": "^v0.95",
"mariadb": "^2.5.2",
"moment": "^2.24.0",
"morgan": "^1.9.0",
Expand Down
3 changes: 2 additions & 1 deletion services/api/src/bitbucket-sync/repo-permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ const syncUsersForProjects = async projects => {
R.pluck('emailAddress'),
// @ts-ignore
R.map(R.toLower)
// @ts-ignore
)(userPermissions) as [string];

//Refresh users in group for difference calculation
Expand Down Expand Up @@ -234,4 +235,4 @@ async function getLagoonUsersForGroup(lagoonProjectGroup: string) {
];
const syncResponse = await syncUsersForProjects(projects);
logger.info('Sync completed');
})();
})();

0 comments on commit a30dddb

Please sign in to comment.