Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/dashmate/configs/migrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,8 @@ module.exports = {
.forEach(([name, config]) => {
if (config.platform) {
config.platform.enable = name !== 'mainnet';
} else {
config.platform = (systemConfigs[name] || systemConfigs.base).platform;
}

if (systemConfigs[name]) {
Expand Down
2 changes: 1 addition & 1 deletion packages/dashmate/src/commands/reset.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ResetCommand extends ConfigBaseCommand {
throw new Error(`Cannot hard reset non-system config "${config.getName()}"`);
}

if (!config.isPlatformEnabled() && isPlatformOnlyReset) {
if (!config.get('platform.enable') && isPlatformOnlyReset) {
throw new Error('Cannot reset platform only if platform services are not enabled in config');
}

Expand Down
2 changes: 1 addition & 1 deletion packages/dashmate/src/commands/status/platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class PlatformStatusCommand extends ConfigBaseCommand {
config,
getPlatformScope,
) {
if (!config.isPlatformEnabled()) {
if (!config.get('platform.enable')) {
throw new Error('Platform is not supported for this node type and network');
}

Expand Down
22 changes: 2 additions & 20 deletions packages/dashmate/src/config/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,6 @@ class Config {
return this;
}

/**
* Remove by path
*
* @param {string} path
* @returns {Config}
*/
remove(path) {
return this.set(path, undefined);
}

/**
* Get options
*
Expand Down Expand Up @@ -171,7 +161,7 @@ class Config {
dockerComposeFiles.push('docker-compose.sentinel.yml');
}

if (this.isPlatformEnabled()) {
if (this.get('platform.enable')) {
dockerComposeFiles.push('docker-compose.platform.yml');

if (this.get('platform.sourcePath') !== null) {
Expand All @@ -188,7 +178,7 @@ class Config {
...convertObjectToEnvs(this.getOptions()),
};

if (this.isPlatformEnabled()) {
if (this.get('platform.enable')) {
envs = {
...envs,

Expand All @@ -212,14 +202,6 @@ class Config {

return envs;
}

/**
*
* @returns {boolean}
*/
isPlatformEnabled() {
return this.has('platform') && this.get('platform.enable');
}
}

Config.ajv = new Ajv({ coerceTypes: true });
Expand Down
2 changes: 1 addition & 1 deletion packages/dashmate/src/listr/tasks/resetNodeTaskFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function resetNodeTaskFactory(
},
{
title: 'Remove platform services and associated data',
enabled: (ctx) => ctx.isPlatformOnlyReset && config.isPlatformEnabled(),
enabled: (ctx) => ctx.isPlatformOnlyReset && config.get('platform.enable'),
task: async () => {
// Remove containers
const coreContainerNames = ['core', 'sentinel'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function configureTenderdashTaskFactory(
return new Listr([
{
task: async (ctx) => {
const platformConfigs = configGroup.filter((config) => config.isPlatformEnabled());
const platformConfigs = configGroup.filter((config) => config.get('platform.enable'));

const subTasks = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ function configureSSLCertificateTaskFactory(
{
title: 'Configure SSL certificate',
task: async (ctx, task) => {
// TODO Move to upper function to show output in upper task?
const choices = [
{ name: SSL_PROVIDERS.ZEROSSL, message: 'ZeroSSL' },
{ name: SSL_PROVIDERS.FILE, message: 'File on disk' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ function setupLocalPresetTaskFactory(
config.set('core.miner.enable', true);

// Disable platform for the seed node
config.remove('platform');
config.set('platform.enable', false);
} else {
config.set('description', `local node #${nodeIndex}`);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,7 @@ function setupRegularPresetTaskFactory(

ctx.config = new Config(ctx.preset, systemConfigs[ctx.preset]);

if (!ctx.isHP) {
delete ctx.config.remove('platform');
}

ctx.config.set('platform.enable', ctx.isHP);
ctx.config.set('core.masternode.enable', ctx.nodeType === NODE_TYPE_MASTERNODE);

// eslint-disable-next-line no-param-reassign
Expand Down Expand Up @@ -132,7 +129,7 @@ function setupRegularPresetTaskFactory(
task: () => configureNodeTask(),
},
{
enabled: (ctx) => ctx.config && ctx.config.isPlatformEnabled(),
enabled: (ctx) => ctx.config && ctx.config.get('platform.enable'),
task: () => configureSSLCertificateTask(),
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function obtainSelfSignedCertificateTaskFactory(
return new Listr([
{
task: async (ctx) => {
const platformConfigs = configGroup.filter((config) => config.isPlatformEnabled());
const platformConfigs = configGroup.filter((config) => config.get('platform.enable'));

const subTasks = platformConfigs.map((config) => ({
title: `Create certificate for ${config.getName()}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function startGroupNodesTaskFactory(
));

const platformBuildConfig = configGroup.find((config) => (
config.has('platform.sourcePath') && config.get('platform.sourcePath') !== null
config.get('platform.enable') && config.get('platform.sourcePath') !== null
));

return new Listr([
Expand Down Expand Up @@ -155,7 +155,7 @@ function startGroupNodesTaskFactory(
enabled: (ctx) => Boolean(ctx.waitForReadiness),
task: () => {
const tasks = configGroup
.filter((config) => config.isPlatformEnabled())
.filter((config) => config.get('platform.enable'))
.map((config) => ({
title: `Wait for ${config.getName()} node`,
task: () => waitForNodeToBeReadyTask(config),
Expand Down
4 changes: 2 additions & 2 deletions packages/dashmate/src/listr/tasks/startNodeTaskFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function startNodeTaskFactory(
}

// Check Drive log files are created
if (config.isPlatformEnabled()) {
if (config.get('platform.enable')) {
const prettyFilePath = config.get('platform.drive.abci.log.prettyFile.path');

// Remove directory that could potentially be created by Docker mount
Expand Down Expand Up @@ -84,7 +84,7 @@ function startNodeTaskFactory(
},
{
enabled: (ctx) => !ctx.skipBuildServices
&& config.has('platform.sourcePath')
&& config.get('platform.enable')
&& config.get('platform.sourcePath') !== null,
task: () => buildServicesTask(config),
},
Expand Down
4 changes: 2 additions & 2 deletions packages/dashmate/src/status/scopes/overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function getOverviewScopeFactory(getCoreScope,
};

const platform = {
enabled: config.isPlatformEnabled(),
enabled: config.get('platform.enable'),
tenderdash: null,
};

Expand All @@ -59,7 +59,7 @@ function getOverviewScopeFactory(getCoreScope,
masternode.nodeState = nodeState;
}

if (config.isPlatformEnabled()) {
if (config.get('platform.enable')) {
const { tenderdash } = await getPlatformScope(config);

platform.tenderdash = tenderdash;
Expand Down
2 changes: 1 addition & 1 deletion packages/dashmate/src/status/scopes/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function getServicesScopeFactory(dockerCompose) {
});
}

if (config.isPlatformEnabled()) {
if (config.get('platform.enable')) {
Object.assign(serviceHumanNames, {
drive_abci: 'Drive ABCI',
drive_tenderdash: 'Drive Tenderdash',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function renderServiceTemplatesFactory() {
.sync(`${templatesPath}/**/*.dot`)
// Do not render platform templates if it's not configured
.filter((templatePath) => (
!templatePath.includes('templates/platform') || config.isPlatformEnabled()
!templatePath.includes('templates/platform') || config.get('platform.enable')
));

const configFiles = {};
Expand Down
3 changes: 1 addition & 2 deletions packages/dashmate/test/unit/status/scopes/overview.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ describe('getOverviewScopeFactory', () => {
config = {
get: this.sinon.stub(),
toEnvs: this.sinon.stub(),
isPlatformEnabled: this.sinon.stub(),
};

getOverviewScope = getOverviewScopeFactory(mockGetCoreScope,
Expand Down Expand Up @@ -74,7 +73,7 @@ describe('getOverviewScopeFactory', () => {
});

it('should not load if masternode or platform disabled ', async () => {
config.isPlatformEnabled.returns(false);
config.get.withArgs('platform.enable').returns(false);
config.get.withArgs('core.masternode.enable').returns(false);
config.get.withArgs('network').returns('mainnet');

Expand Down
1 change: 0 additions & 1 deletion packages/dashmate/test/unit/status/scopes/platform.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ describe('getPlatformScopeFactory', () => {
config = {
get: this.sinon.stub(),
toEnvs: this.sinon.stub(),
isPlatformEnabled: this.sinon.stub(),
};

getPlatformScope = getPlatformScopeFactory(mockDockerCompose,
Expand Down
1 change: 0 additions & 1 deletion packages/dashmate/test/unit/status/scopes/services.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ describe('getServicesScopeFactory', () => {
config = {
get: this.sinon.stub(),
toEnvs: this.sinon.stub(),
isPlatformEnabled: this.sinon.stub(),
};

getServicesScope = getServicesScopeFactory(mockDockerCompose);
Expand Down