Skip to content

Commit

Permalink
wip: implement tenantId support
Browse files Browse the repository at this point in the history
  • Loading branch information
nikku committed Sep 1, 2023
1 parent 2874d72 commit 66bc75f
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 9 deletions.
18 changes: 12 additions & 6 deletions app/lib/zeebe-api/zeebe-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ const { X509Certificate } = require('node:crypto');

const {
pick,
values
values,
reduce
} = require('min-dash');

const errorReasons = {
Expand Down Expand Up @@ -107,6 +108,10 @@ class ZeebeAPI {

const client = await this._getZeebeClient(endpoint);

this._log.debug('check connection', {
parameters: withoutSecrets(parameters)
});

try {
await client.topology();
return { success: true };
Expand Down Expand Up @@ -135,6 +140,7 @@ class ZeebeAPI {
endpoint,
filePath,
name,
tenantId,
diagramType
} = parameters;

Expand All @@ -149,11 +155,11 @@ class ZeebeAPI {
const client = await this._getZeebeClient(endpoint);

try {

const response = await client.deployResource({
process: contents,
name: this._prepareDeploymentName(name, filePath, diagramType),

// tenantId
tenantId
});

return {
Expand Down Expand Up @@ -182,7 +188,8 @@ class ZeebeAPI {
const {
endpoint,
variables,
processId
processId,
tenantId
} = parameters;

this._log.debug('run', {
Expand All @@ -196,8 +203,7 @@ class ZeebeAPI {
const response = await client.createProcessInstance({
bpmnProcessId: processId,
variables,

// tenantId
tenantId
});

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,10 @@ export default class DeploymentPlugin extends PureComponent {
deployTab(tab, config) {
const { file: { path } } = tab;
const {
deployment: { name },
deployment: {
name,
tenantId
},
endpoint
} = config;

Expand All @@ -217,6 +220,7 @@ export default class DeploymentPlugin extends PureComponent {
return zeebeAPI.deploy({
filePath: path,
name,
tenantId,
endpoint,
diagramType: tab.type === 'cloud-dmn' ? 'dmn' : 'bpmn'
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const CLIENT_ID = 'Client ID';
export const CLIENT_SECRET = 'Client secret';
export const CLUSTER_URL = 'Cluster URL';
export const REMEMBER_CREDENTIALS = 'Remember credentials';
export const TENANT_ID = 'Tenant ID';

export const MUST_PROVIDE_A_VALUE = 'Must provide a value.';
export const CONTACT_POINT_MUST_NOT_BE_EMPTY = 'Cluster endpoint must not be empty.';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
CONTACT_POINT_HINT,
OAUTH_URL,
AUDIENCE,
TENANT_ID,
CLIENT_ID,
CLIENT_SECRET,
CLUSTER_URL,
Expand Down Expand Up @@ -265,6 +266,12 @@ export default class DeploymentPluginOverlay extends React.PureComponent {
hint={ CONTACT_POINT_HINT }
autoFocus
/>
<Field
name="deployment.tenantId"
component={ TextInput }
label={ TENANT_ID }
hint="Optional"
/>
<Field
name="endpoint.authType"
component={ Radio }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,12 @@ export default class StartInstancePlugin extends PureComponent {
try {

// (3.1) trigger run
const startInstanceResult = await zeebeAPI.run({ processId, endpoint, ...decoratedConfig });
const startInstanceResult = await zeebeAPI.run({
processId,
tenantId: deploymentConfig.tenantId,
endpoint,
...decoratedConfig
});

// (3.1.1) handle start instance error
if (!startInstanceResult.success) {
Expand Down
6 changes: 5 additions & 1 deletion client/src/remote/__tests__/ZeebeAPISpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ describe('<ZeebeAPI>', function() {

const name = 'deployment';

const tenantId = 'tenant-1';

const endpoint = {
targetType: targetTypes.SELF_HOSTED,
authType: authTypes.NONE,
Expand All @@ -192,13 +194,15 @@ describe('<ZeebeAPI>', function() {
zeebeAPI.deploy({
filePath,
name,
endpoint
endpoint,
tenantId
});

// then
expect(sendSpy).to.have.been.calledWith('zeebe:deploy', {
filePath,
name,
tenantId,
endpoint: {
type: targetTypes.SELF_HOSTED,
url: contactPoint
Expand Down

0 comments on commit 66bc75f

Please sign in to comment.