Skip to content

Commit

Permalink
remove upstream primary service discovery
Browse files Browse the repository at this point in the history
  • Loading branch information
pirog committed Jul 18, 2024
1 parent 02ff306 commit 0b7036e
Showing 1 changed file with 0 additions and 20 deletions.
20 changes: 0 additions & 20 deletions utils/get-app.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const path = require('path');
const uniq = require('lodash/uniq');

/*
* Helper to load landofile
Expand All @@ -23,25 +22,6 @@ module.exports = (files, userConfRoot) => {
// slugify project
config.project = require('@lando/core/utils/slugify')(config.name);

// discover a default/primary service for legacy considerations
const services = Object.entries(config?.services ?? []).map(([service, config]) => ({name: service, ...config}));
const apis = uniq(services.map(service => parseInt(service.api)));

// if the api is only v4 then look for a primary service or the first one if none is set
if (apis.length === 1 && parseInt(apis[0]) === 4) {
const service = services.find(service => service.primary === true) ?? services[0] ?? {};
config.primary = service.name;

// otherwise this is a mixed environment so default appserver or first non v4 service if it exists
} else {
const service = services.find(service => service.name === 'appserver') ?? services.find(service => parseInt(service.api) !== 4) ?? {};
config.primary = service.name;
}

// if we still dont have a primary service it might be because its hidden in a recipe, if that is the case then
// we can assume its just the appserver?
if (!config.primary && config.recipe) config.primary = 'appserver';

// merge and return
return require('lodash/merge')({}, config, {
configFiles: files,
Expand Down

0 comments on commit 0b7036e

Please sign in to comment.