Skip to content

Commit

Permalink
feat(Telemetry): Inspect docker availability
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed May 31, 2023
1 parent 72b27cb commit 83670f9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/utils/telemetry/generate-payload.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ module.exports = ({
commandUsage,
variableSources,
isConsoleAuthenticated,
isDockerInstalled,
}) => {
let commandDurationMs;

Expand Down Expand Up @@ -197,6 +198,7 @@ module.exports = ({
const payload = {
ciName,
isTtyTerminal: process.stdin.isTTY && process.stdout.isTTY,
isDockerInstalled,
cliName: 'serverless',
command,
commandOptionNames,
Expand Down
10 changes: 10 additions & 0 deletions scripts/serverless.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ let serviceDir = null;
let configuration = null;
let serverless;
let isConsoleAuthenticated = false;
let isDockerInstalled;
const commandUsage = {};
const variableSourcesInConfig = new Set();

Expand Down Expand Up @@ -81,6 +82,7 @@ const finalize = async ({ error, shouldBeSync, telemetryData, shouldSendTelemetr
commandUsage,
variableSources: variableSourcesInConfig,
isConsoleAuthenticated,
isDockerInstalled,
}),
...telemetryData,
});
Expand Down Expand Up @@ -814,6 +816,14 @@ processSpanPromise = (async () => {
serverless = interactiveContext.serverless;
}
} else {
if (commands.join(' ') === 'deploy') {
const spawn = require('child-process-ext/spawn');
spawn('docker', ['--version']).then(
() => (isDockerInstalled = true),
() => (isDockerInstalled = false)
);
}

processLog.debug('run Serverless instance');
// Run command
await serverless.run();
Expand Down
5 changes: 5 additions & 0 deletions test/unit/lib/utils/telemetry/generate-payload.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ describe('test/unit/lib/utils/telemetry/generate-payload.test.js', () => {
},
isAutoUpdateEnabled: false,
isUsingCompose: false,
isDockerInstalled: undefined,
notificationsMode: 'on',
npmDependencies: ['fooDep', 'barDep', 'fooOpt', 'someDev', 'otherDev'],
triggeredDeprecations: [],
Expand Down Expand Up @@ -232,6 +233,7 @@ describe('test/unit/lib/utils/telemetry/generate-payload.test.js', () => {
},
isAutoUpdateEnabled: false,
isUsingCompose: false,
isDockerInstalled: undefined,
notificationsMode: 'on',
npmDependencies: [],
triggeredDeprecations: [],
Expand Down Expand Up @@ -274,6 +276,7 @@ describe('test/unit/lib/utils/telemetry/generate-payload.test.js', () => {
commandOptionNames: [],
isAutoUpdateEnabled: false,
isUsingCompose: false,
isDockerInstalled: undefined,
notificationsMode: 'on',
triggeredDeprecations: [],
installationType: 'global:other',
Expand Down Expand Up @@ -329,6 +332,7 @@ describe('test/unit/lib/utils/telemetry/generate-payload.test.js', () => {
},
isAutoUpdateEnabled: false,
isUsingCompose: false,
isDockerInstalled: undefined,
triggeredDeprecations: [],
installationType: 'global:other',
notificationsMode: 'on',
Expand Down Expand Up @@ -369,6 +373,7 @@ describe('test/unit/lib/utils/telemetry/generate-payload.test.js', () => {
commandOptionNames: [],
isAutoUpdateEnabled: false,
isUsingCompose: false,
isDockerInstalled: undefined,
notificationsMode: 'on',
triggeredDeprecations: [],
installationType: 'global:other',
Expand Down

0 comments on commit 83670f9

Please sign in to comment.