Commit 03f529f8 authored by Varunkumar Manohar's avatar Varunkumar Manohar
Browse files

Publish subproject creation status to a pubsub

parent f32ad52d
Pipeline #33725 failed with stages
in 8 seconds
......@@ -865,6 +865,11 @@
"extend": "^3.0.2"
}
},
"@google-cloud/precise-date": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/@google-cloud/precise-date/-/precise-date-2.0.3.tgz",
"integrity": "sha512-+SDJ3ZvGkF7hzo6BGa8ZqeK3F6Z4+S+KviC9oOK+XCs3tfMyJCh/4j93XIWINgMMDIh9BgEvlw4306VxlXIlYA=="
},
"@google-cloud/projectify": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/@google-cloud/projectify/-/projectify-2.0.1.tgz",
......@@ -875,6 +880,117 @@
"resolved": "https://registry.npmjs.org/@google-cloud/promisify/-/promisify-2.0.3.tgz",
"integrity": "sha512-d4VSA86eL/AFTe5xtyZX+ePUjE8dIFu2T8zmdeNBSa5/kNgXPCx/o/wbFNHAGLJdGnk1vddRuMESD9HbOC8irw=="
},
"@google-cloud/pubsub": {
"version": "2.10.0",
"resolved": "https://registry.npmjs.org/@google-cloud/pubsub/-/pubsub-2.10.0.tgz",
"integrity": "sha512-XM/Fc6/W/LYzGH2pnhGLDR5E6JNZFMfzyUFP5bWgC4FK1KqIZ4g6hrnCCO38G4JfH2i1IuSQuefPF7FrZZo9tw==",
"requires": {
"@google-cloud/paginator": "^3.0.0",
"@google-cloud/precise-date": "^2.0.0",
"@google-cloud/projectify": "^2.0.0",
"@google-cloud/promisify": "^2.0.0",
"@opentelemetry/api": "^0.12.0",
"@opentelemetry/tracing": "^0.12.0",
"@types/duplexify": "^3.6.0",
"@types/long": "^4.0.0",
"arrify": "^2.0.0",
"extend": "^3.0.2",
"google-auth-library": "^7.0.0",
"google-gax": "^2.9.2",
"is-stream-ended": "^0.1.4",
"lodash.snakecase": "^4.1.1",
"p-defer": "^3.0.0"
},
"dependencies": {
"@opentelemetry/api": {
"version": "0.12.0",
"resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-0.12.0.tgz",
"integrity": "sha512-Dn4vU5GlaBrIWzLpsM6xbJwKHdlpwBQ4Bd+cL9ofJP3hKT8jBXpBpribmyaqAzrajzzl2Yt8uTa9rFVLfjDAvw==",
"requires": {
"@opentelemetry/context-base": "^0.12.0"
}
},
"@opentelemetry/context-base": {
"version": "0.12.0",
"resolved": "https://registry.npmjs.org/@opentelemetry/context-base/-/context-base-0.12.0.tgz",
"integrity": "sha512-UXwSsXo3F3yZ1dIBOG9ID8v2r9e+bqLWoizCtTb8rXtwF+N5TM7hzzvQz72o3nBU+zrI/D5e+OqAYK8ZgDd3DA=="
},
"gaxios": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/gaxios/-/gaxios-4.2.0.tgz",
"integrity": "sha512-Ms7fNifGv0XVU+6eIyL9LB7RVESeML9+cMvkwGS70xyD6w2Z80wl6RiqiJ9k1KFlJCUTQqFFc8tXmPQfSKUe8g==",
"requires": {
"abort-controller": "^3.0.0",
"extend": "^3.0.2",
"https-proxy-agent": "^5.0.0",
"is-stream": "^2.0.0",
"node-fetch": "^2.3.0"
}
},
"gcp-metadata": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-4.2.1.tgz",
"integrity": "sha512-tSk+REe5iq/N+K+SK1XjZJUrFPuDqGZVzCy2vocIHIGmPlTGsa8owXMJwGkrXr73NO0AzhPW4MF2DEHz7P2AVw==",
"requires": {
"gaxios": "^4.0.0",
"json-bigint": "^1.0.0"
}
},
"google-auth-library": {
"version": "7.0.3",
"resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-7.0.3.tgz",
"integrity": "sha512-6wJNYqY1QUr5I2lWaUkkzOT2b9OCNhNQrdFOt/bsBbGb7T7NCdEvrBsXraUm+KTUGk2xGlQ7m9RgUd4Llcw8NQ==",
"requires": {
"arrify": "^2.0.0",
"base64-js": "^1.3.0",
"ecdsa-sig-formatter": "^1.0.11",
"fast-text-encoding": "^1.0.0",
"gaxios": "^4.0.0",
"gcp-metadata": "^4.2.0",
"gtoken": "^5.0.4",
"jws": "^4.0.0",
"lru-cache": "^6.0.0"
}
},
"is-stream": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.0.tgz",
"integrity": "sha512-XCoy+WlUr7d1+Z8GgSuXmpuUFC9fOhRXglJMx+dwLKTkL44Cjd4W1Z5P+BQZpr+cR93aGP4S/s7Ftw6Nd/kiEw=="
},
"jwa": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/jwa/-/jwa-2.0.0.tgz",
"integrity": "sha512-jrZ2Qx916EA+fq9cEAeCROWPTfCwi1IVHqT2tapuqLEVVDKFDENFw1oL+MwrTvH6msKxsd1YTDVw6uKEcsrLEA==",
"requires": {
"buffer-equal-constant-time": "1.0.1",
"ecdsa-sig-formatter": "1.0.11",
"safe-buffer": "^5.0.1"
}
},
"jws": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/jws/-/jws-4.0.0.tgz",
"integrity": "sha512-KDncfTmOZoOMTFG4mBlG0qUIOlc03fmzH+ru6RgYVZhPkyiy/92Owlt/8UEN+a4TXR1FQetfIpJE8ApdvdVxTg==",
"requires": {
"jwa": "^2.0.0",
"safe-buffer": "^5.0.1"
}
},
"lru-cache": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
"integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
"requires": {
"yallist": "^4.0.0"
}
},
"yallist": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A=="
}
}
},
"@google-cloud/storage": {
"version": "5.7.0",
"resolved": "https://registry.npmjs.org/@google-cloud/storage/-/storage-5.7.0.tgz",
......@@ -1509,6 +1625,108 @@
"resolved": "https://registry.npmjs.org/@opentelemetry/context-base/-/context-base-0.6.1.tgz",
"integrity": "sha512-5bHhlTBBq82ti3qPT15TRxkYTFPPQWbnkkQkmHPtqiS1XcTB69cEKd3Jm7Cfi/vkPoyxapmePE9tyA7EzLt8SQ=="
},
"@opentelemetry/core": {
"version": "0.12.0",
"resolved": "https://registry.npmjs.org/@opentelemetry/core/-/core-0.12.0.tgz",
"integrity": "sha512-oLZIkmTNWTJXzo1eA4dGu/S7wOVtylsgnEsCmhSJGhrJVDXm1eW/aGuNs3DVBeuxp0ZvQLAul3/PThsC3YrnzA==",
"requires": {
"@opentelemetry/api": "^0.12.0",
"@opentelemetry/context-base": "^0.12.0",
"semver": "^7.1.3"
},
"dependencies": {
"@opentelemetry/api": {
"version": "0.12.0",
"resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-0.12.0.tgz",
"integrity": "sha512-Dn4vU5GlaBrIWzLpsM6xbJwKHdlpwBQ4Bd+cL9ofJP3hKT8jBXpBpribmyaqAzrajzzl2Yt8uTa9rFVLfjDAvw==",
"requires": {
"@opentelemetry/context-base": "^0.12.0"
}
},
"@opentelemetry/context-base": {
"version": "0.12.0",
"resolved": "https://registry.npmjs.org/@opentelemetry/context-base/-/context-base-0.12.0.tgz",
"integrity": "sha512-UXwSsXo3F3yZ1dIBOG9ID8v2r9e+bqLWoizCtTb8rXtwF+N5TM7hzzvQz72o3nBU+zrI/D5e+OqAYK8ZgDd3DA=="
},
"lru-cache": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
"integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
"requires": {
"yallist": "^4.0.0"
}
},
"semver": {
"version": "7.3.5",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz",
"integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==",
"requires": {
"lru-cache": "^6.0.0"
}
},
"yallist": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A=="
}
}
},
"@opentelemetry/resources": {
"version": "0.12.0",
"resolved": "https://registry.npmjs.org/@opentelemetry/resources/-/resources-0.12.0.tgz",
"integrity": "sha512-8cYvIKB68cyupc7D6SWzkLtt13mbjgxMahL4JKCM6hWPyiGSJlPFEAey4XFXI5LLpPZRYTPHLVoLqI/xwCFZZA==",
"requires": {
"@opentelemetry/api": "^0.12.0",
"@opentelemetry/core": "^0.12.0"
},
"dependencies": {
"@opentelemetry/api": {
"version": "0.12.0",
"resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-0.12.0.tgz",
"integrity": "sha512-Dn4vU5GlaBrIWzLpsM6xbJwKHdlpwBQ4Bd+cL9ofJP3hKT8jBXpBpribmyaqAzrajzzl2Yt8uTa9rFVLfjDAvw==",
"requires": {
"@opentelemetry/context-base": "^0.12.0"
}
},
"@opentelemetry/context-base": {
"version": "0.12.0",
"resolved": "https://registry.npmjs.org/@opentelemetry/context-base/-/context-base-0.12.0.tgz",
"integrity": "sha512-UXwSsXo3F3yZ1dIBOG9ID8v2r9e+bqLWoizCtTb8rXtwF+N5TM7hzzvQz72o3nBU+zrI/D5e+OqAYK8ZgDd3DA=="
}
}
},
"@opentelemetry/semantic-conventions": {
"version": "0.12.0",
"resolved": "https://registry.npmjs.org/@opentelemetry/semantic-conventions/-/semantic-conventions-0.12.0.tgz",
"integrity": "sha512-BuCcDW0uLNYYTns0/LwXkJ8lp8aDm7kpS+WunEmPAPRSCe6ciOYRvzn5reqJfX93rf+6A3U2SgrBnCTH+0qoQQ=="
},
"@opentelemetry/tracing": {
"version": "0.12.0",
"resolved": "https://registry.npmjs.org/@opentelemetry/tracing/-/tracing-0.12.0.tgz",
"integrity": "sha512-2TUGhTGkhgnxTciHCNAILPSeyXageJewRqfP9wOrx65sKd/jgvNYoY8nYf4EVWVMirDOxKDsmYgUkjdQrwb2dg==",
"requires": {
"@opentelemetry/api": "^0.12.0",
"@opentelemetry/context-base": "^0.12.0",
"@opentelemetry/core": "^0.12.0",
"@opentelemetry/resources": "^0.12.0",
"@opentelemetry/semantic-conventions": "^0.12.0"
},
"dependencies": {
"@opentelemetry/api": {
"version": "0.12.0",
"resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-0.12.0.tgz",
"integrity": "sha512-Dn4vU5GlaBrIWzLpsM6xbJwKHdlpwBQ4Bd+cL9ofJP3hKT8jBXpBpribmyaqAzrajzzl2Yt8uTa9rFVLfjDAvw==",
"requires": {
"@opentelemetry/context-base": "^0.12.0"
}
},
"@opentelemetry/context-base": {
"version": "0.12.0",
"resolved": "https://registry.npmjs.org/@opentelemetry/context-base/-/context-base-0.12.0.tgz",
"integrity": "sha512-UXwSsXo3F3yZ1dIBOG9ID8v2r9e+bqLWoizCtTb8rXtwF+N5TM7hzzvQz72o3nBU+zrI/D5e+OqAYK8ZgDd3DA=="
}
}
},
"@opentelemetry/types": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/@opentelemetry/types/-/types-0.2.0.tgz",
......@@ -1697,6 +1915,14 @@
"resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.5.tgz",
"integrity": "sha512-Q1y515GcOdTHgagaVFhHnIFQ38ygs/kmxdNpvpou+raI9UO3YZcHDngBSYKQklcKlvA7iuQlmIKbzvmxcOE9CQ=="
},
"@types/duplexify": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/@types/duplexify/-/duplexify-3.6.0.tgz",
"integrity": "sha512-5zOA53RUlzN74bvrSGwjudssD9F3a797sDZQkiYpUOxW+WHaXTCPz4/d5Dgi6FKnOqZ2CpaTo0DhgIfsXAOE/A==",
"requires": {
"@types/node": "*"
}
},
"@types/express": {
"version": "4.17.2",
"resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.2.tgz",
......@@ -4528,6 +4754,62 @@
"integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==",
"dev": true
},
"gtoken": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/gtoken/-/gtoken-5.2.1.tgz",
"integrity": "sha512-OY0BfPKe3QnMsY9MzTHTSKn+Vl2l1CcLe6BwDEQj00mbbkl5nyQ/7EUREstg4fQNZ8iYE7br4JJ7TdKeDOPWmw==",
"requires": {
"gaxios": "^4.0.0",
"google-p12-pem": "^3.0.3",
"jws": "^4.0.0"
},
"dependencies": {
"gaxios": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/gaxios/-/gaxios-4.2.0.tgz",
"integrity": "sha512-Ms7fNifGv0XVU+6eIyL9LB7RVESeML9+cMvkwGS70xyD6w2Z80wl6RiqiJ9k1KFlJCUTQqFFc8tXmPQfSKUe8g==",
"requires": {
"abort-controller": "^3.0.0",
"extend": "^3.0.2",
"https-proxy-agent": "^5.0.0",
"is-stream": "^2.0.0",
"node-fetch": "^2.3.0"
}
},
"google-p12-pem": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/google-p12-pem/-/google-p12-pem-3.0.3.tgz",
"integrity": "sha512-wS0ek4ZtFx/ACKYF3JhyGe5kzH7pgiQ7J5otlumqR9psmWMYc+U9cErKlCYVYHoUaidXHdZ2xbo34kB+S+24hA==",
"requires": {
"node-forge": "^0.10.0"
}
},
"is-stream": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.0.tgz",
"integrity": "sha512-XCoy+WlUr7d1+Z8GgSuXmpuUFC9fOhRXglJMx+dwLKTkL44Cjd4W1Z5P+BQZpr+cR93aGP4S/s7Ftw6Nd/kiEw=="
},
"jwa": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/jwa/-/jwa-2.0.0.tgz",
"integrity": "sha512-jrZ2Qx916EA+fq9cEAeCROWPTfCwi1IVHqT2tapuqLEVVDKFDENFw1oL+MwrTvH6msKxsd1YTDVw6uKEcsrLEA==",
"requires": {
"buffer-equal-constant-time": "1.0.1",
"ecdsa-sig-formatter": "1.0.11",
"safe-buffer": "^5.0.1"
}
},
"jws": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/jws/-/jws-4.0.0.tgz",
"integrity": "sha512-KDncfTmOZoOMTFG4mBlG0qUIOlc03fmzH+ru6RgYVZhPkyiy/92Owlt/8UEN+a4TXR1FQetfIpJE8ApdvdVxTg==",
"requires": {
"jwa": "^2.0.0",
"safe-buffer": "^5.0.1"
}
}
}
},
"handlebars": {
"version": "4.7.3",
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.3.tgz",
......@@ -5662,6 +5944,11 @@
"integrity": "sha1-gNZJLcFHCGS79YNTO2UfQqn1JBU=",
"dev": true
},
"lodash.snakecase": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/lodash.snakecase/-/lodash.snakecase-4.1.1.tgz",
"integrity": "sha1-OdcUo1NXFHg3rv1ktdy7Fr7Nj40="
},
"lodash.some": {
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/lodash.some/-/lodash.some-4.6.0.tgz",
......@@ -6912,6 +7199,11 @@
"os-tmpdir": "^1.0.0"
}
},
"p-defer": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/p-defer/-/p-defer-3.0.0.tgz",
"integrity": "sha512-ugZxsxmtTln604yeYd29EGrNhazN2lywetzpKhfmQjW/VJmhpDmWbiX+h0zL8V91R0UXkhb3KtPmyq9PZw3aYw=="
},
"p-finally": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz",
......
......@@ -14,8 +14,8 @@
import { SubProjectModel } from '../../../services/subproject';
import { AbstractSeistore, SeistoreFactory } from '../../seistore';
import { Utils } from '../../../shared';
import { AbstractSeistore, SeistoreFactory } from '../../seistore';
@SeistoreFactory.register('aws')
export class AwsSeistore extends AbstractSeistore {
public checkExtraSubprojectCreateParams(requestBody: any, subproject: SubProjectModel) { return; }
......@@ -26,4 +26,8 @@ export class AwsSeistore extends AbstractSeistore {
const email = payload.username;
return internalSwapForSauth ? Utils.checkSauthV1EmailDomainName(email) : email;
}
public async pushSubprojectCreationStatus(subproject: SubProjectModel,
status: string): Promise<string> {
return 'true';
}
}
......@@ -30,4 +30,8 @@ export class AzureSeistore extends AbstractSeistore {
const email = payload.email === Config.IMP_SERVICE_ACCOUNT_SIGNER ? payload.obo : payload.email;
return internalSwapForSauth ? Utils.checkSauthV1EmailDomainName(email) : email;
}
public async pushSubprojectCreationStatus(
subproject: SubProjectModel, status: string): Promise<string> {
return 'true';
}
}
......@@ -14,8 +14,8 @@
// limitations under the License.
// ============================================================================
import { Config, ConfigFactory } from '../../config';
import fs from 'fs';
import { Config, ConfigFactory } from '../../config';
@ConfigFactory.register('google')
export class ConfigGoogle extends Config {
......@@ -51,6 +51,9 @@ export class ConfigGoogle extends Config {
// max len for a group name in DE
public static DES_GROUP_CHAR_LIMIT = 128;
// pubsub topic
public static PUBSUBTOPIC: string;
public async init(): Promise<void> {
// load des target audiance for service to service communication
......@@ -70,6 +73,8 @@ export class ConfigGoogle extends Config {
ConfigGoogle.SERVICE_IDENTITY_PRIVATE_KEY_ID = data.private_key_id;
}
ConfigGoogle.PUBSUBTOPIC = process.env.PUBSUBTOPIC !== undefined ? process.env.PUBSUBTOPIC : 'subproject-operations';
await Config.initServiceConfiguration({
SERVICE_ENV: process.env.APP_ENVIRONMENT_IDENTIFIER,
SERVICE_PORT: +process.env.PORT || 5000,
......@@ -107,7 +112,7 @@ export class ConfigGoogle extends Config {
FEATURE_FLAG_LOGGING: process.env.FEATURE_FLAG_LOGGING !== undefined ?
process.env.FEATURE_FLAG_LOGGING !== 'false' : true,
FEATURE_FLAG_STACKDRIVER_EXPORTER: process.env.FEATURE_FLAG_STACKDRIVER_EXPORTER !== undefined ?
process.env.FEATURE_FLAG_STACKDRIVER_EXPORTER !== 'false' : true
process.env.FEATURE_FLAG_STACKDRIVER_EXPORTER !== 'false' : true,
});
}
......
......@@ -14,42 +14,53 @@
// limitations under the License.
// ============================================================================
import { PubSub } from '@google-cloud/pubsub';
import { SubProjectModel } from '../../../services/subproject';
import { Error, Params, Utils } from '../../../shared';
import { Config } from '../../config';
import { AbstractSeistore, SeistoreFactory } from '../../seistore';
import { ConfigGoogle } from './config';
// reference time zone and clss locations
const KSTORAGE_CLASS = ['MULTI_REGIONAL', 'REGIONAL', 'NEARLINE', 'COLDLINE'];
const KSTORAGE_LOCATION_MR = ['ASIA', 'EU', 'US'];
const KSTORAGE_LOCATION_RG = [
'NORTHAMERICA-NORTHEAST1',
'US-CENTRAL1',
'US-EAST1',
'US-EAST4',
'US-WEST1',
'US-WEST2',
'US-WEST3',
'US-WEST4',
'SOUTHAMERICA-EAST1',
'EUROPE-NORTH1',
'EUROPE-WEST1',
'EUROPE-WEST2',
'EUROPE-WEST3',
'EUROPE-WEST4',
'EUROPE-WEST6',
'ASIA-EAST1',
'ASIA-EAST2',
'ASIA-NORTHEAST1',
'ASIA-NORTHEAST2',
'ASIA-NORTHEAST3',
'ASIA-SOUTH1',
'ASIA-SOUTHEAST1',
'ASIA-SOUTHEAST2',
'AUSTRALIA-SOUTHEAST1'];
'NORTHAMERICA-NORTHEAST1',
'US-CENTRAL1',
'US-EAST1',
'US-EAST4',
'US-WEST1',
'US-WEST2',
'US-WEST3',
'US-WEST4',
'SOUTHAMERICA-EAST1',
'EUROPE-NORTH1',
'EUROPE-WEST1',
'EUROPE-WEST2',
'EUROPE-WEST3',
'EUROPE-WEST4',
'EUROPE-WEST6',
'ASIA-EAST1',
'ASIA-EAST2',
'ASIA-NORTHEAST1',
'ASIA-NORTHEAST2',
'ASIA-NORTHEAST3',
'ASIA-SOUTH1',
'ASIA-SOUTHEAST1',
'ASIA-SOUTHEAST2',
'AUSTRALIA-SOUTHEAST1'];
@SeistoreFactory.register('google')
export class GoogleSeistore extends AbstractSeistore {
private pubSubClient: PubSub;
constructor() {
super();
this.pubSubClient = new PubSub();
}
public checkExtraSubprojectCreateParams(requestBody: any, subproject: SubProjectModel) {
subproject.storage_class = requestBody.storage_class;
......@@ -103,4 +114,25 @@ export class GoogleSeistore extends AbstractSeistore {
const email = payload.email === Config.IMP_SERVICE_ACCOUNT_SIGNER ? payload.obo : payload.email;
return internalSwapForSauth ? Utils.checkSauthV1EmailDomainName(email) : email;
}
public async pushSubprojectCreationStatus(subproject: SubProjectModel, status: string): Promise<string> {
const data = JSON.stringify({
subproject,
type: 'subproject',
status
});
const pubSubTopic = 'projects/' + ConfigGoogle.SERVICE_CLOUD_PROJECT + '/topics/' + ConfigGoogle.PUBSUBTOPIC;
const dataBuffer = Buffer.from(data);
try {
const messageID = await this.pubSubClient
.topic(pubSubTopic)
.publish(dataBuffer);
return messageID;
} catch (error) {
return null;
}
}
}
......@@ -18,4 +18,9 @@ export class IbmSeistore extends AbstractSeistore {
return internalSwapForSauth ? Utils.checkSauthV1EmailDomainName(email) : email;
}
public async pushSubprojectCreationStatus(
subproject: SubProjectModel, status: string): Promise<string> {
return 'true';
}
}
......@@ -20,11 +20,15 @@ import { CloudFactory } from './cloud';
export interface ISeistore {
checkExtraSubprojectCreateParams(requestBody: any, subproject: SubProjectModel): void;
getEmailFromTokenPayload(userCredentials: string, internalSwapForSauth: boolean): Promise<string>;
pushSubprojectCreationStatus(subproject: SubProjectModel, status: string): Promise<string>;
}
export abstract class AbstractSeistore implements ISeistore {
public abstract checkExtraSubprojectCreateParams(requestBody: any, subproject: SubProjectModel): void;
public abstract getEmailFromTokenPayload(userCredentials: string, internalSwapForSauth: boolean): Promise<string>;
public abstract pushSubprojectCreationStatus
(subproject: SubProjectModel, status: string): Promise<string>;
}
export class SeistoreFactory extends CloudFactory {
......
......@@ -17,7 +17,7 @@
import { Request as expRequest, Response as expResponse } from 'express';
import { SubProjectModel } from '.';
import { Auth, AuthGroups } from '../../auth';
import { Config, JournalFactoryTenantClient, StorageFactory } from '../../cloud';
import { Config, JournalFactoryTenantClient, LoggerFactory, StorageFactory } from '../../cloud';
import { SeistoreFactory } from '../../cloud/seistore';
import { Error, Feature, FeatureFlags, Response } from '../../shared';
import { DatasetDAO, PaginationModel } from '../dataset';
......@@ -119,13 +119,13 @@ export class SubProjectHandler {
' already exists in the tenant project ' + subproject.tenant));
}
const adminGroup = SubprojectGroups.dataAdminGroup(tenant.name, subproject.name, tenant.esd)
const viewerGroup = SubprojectGroups.dataViewerGroup(tenant.name, subproject.name, tenant.esd)
const adminGroup = SubprojectGroups.dataAdminGroup(tenant.name, subproject.name, tenant.esd);
const viewerGroup = SubprojectGroups.dataViewerGroup(tenant.name, subproject.name, tenant.esd);
const adminGroupName = adminGroup.split('@')[0]
const viewerGroupName = viewerGroup.split('@')[0]
const adminGroupName = adminGroup.split('@')[0];
const viewerGroupName = viewerGroup.split('@')[0];
SubProjectHandler.validateGroupNamesLength(adminGroupName, viewerGroupName, subproject)
SubProjectHandler.validateGroupNamesLength(adminGroupName, viewerGroupName, subproject);
if (FeatureFlags.isEnabled(Feature.AUTHORIZATION)) {
// check if groups exist
......@@ -167,9 +167,9 @@ export class SubProjectHandler {
subproject.gcs_bucket = await this.getBucketName(tenant);
subproject.acls.admins = subproject.acls.admins ? subproject.acls.admins.concat([adminGroup])
.filter((group, index, self) => self.indexOf(group) === index) : [adminGroup]
.filter((group, index, self) => self.indexOf(group) === index) : [adminGroup];
subproject.acls.viewers = subproject.acls.viewers ? subproject.acls.viewers.concat([viewerGroup])
.filter((group, index, self) => self.indexOf(group) === index) : [viewerGroup]
.filter((group, index, self) => self.indexOf(group) === index) : [viewerGroup];
// Create the GCS bucket resource
const storage = StorageFactory.build(Config.CLOUDPROVIDER, tenant);
......@@ -199,6 +199,13 @@ export class SubProjectHandler {
}
}