Skip to content

Commit 3903b9a

Browse files
serverless info returns yaml (#89)
1 parent 3f1a11b commit 3903b9a

File tree

3 files changed

+25
-9
lines changed

3 files changed

+25
-9
lines changed

deploy/lib/createFunctions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ module.exports = {
155155
params.runtime = this.validateRuntime(func, availableRuntimes, this.serverless.cli);
156156

157157
// checking if there is custom_domains set on function creation.
158-
if (func.custom_domains.length > 0) {
158+
if (func.custom_domains && func.custom_domains.length > 0) {
159159
this.serverless.cli.log("WARNING: custom_domains are available on function update only. "+
160160
"Redeploy your function to apply custom domains. Doc : https://www.scaleway.com/en/docs/compute/functions/how-to/add-a-custom-domain-name-to-a-function/")
161161
}

info/lib/display.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"use strict";
22

3+
const yaml = require('js-yaml');
4+
35
module.exports = {
46
displayInfo() {
57
const configInput = this.serverless.configurationInput;
@@ -17,13 +19,13 @@ module.exports = {
1719
) {
1820
this.listContainers(namespace.id).then((containers) => {
1921
containers.forEach((container) => {
20-
this.serverless.cli.log(JSON.stringify(container, null, "\t"));
22+
this.serverless.cli.log(yaml.dump(container));
2123
});
2224
});
2325
} else {
2426
this.listFunctions(namespace.id).then((functions) => {
2527
functions.forEach((func) => {
26-
this.serverless.cli.log(JSON.stringify(func, null, "\t"));
28+
this.serverless.cli.log(yaml.dump(func));
2729
});
2830
});
2931
}

provider/scalewayProvider.js

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,36 @@ class ScalewayProvider {
3838
}
3939

4040
setCredentials(options) {
41+
// On serverless info command we do not want log pollution from authentication.
42+
// This is necessary to use it in automated environment.
43+
let hideLog = false;
44+
if (this.serverless.configurationInput.service && this.serverless.configurationInput.service === 'serverlessInfo') {
45+
hideLog = true;
46+
}
4147
if (options['scw-token'] && options['scw-project']) {
42-
this.serverless.cli.log('Using credentials from command line parameters');
48+
if (!hideLog) {
49+
this.serverless.cli.log('Using credentials from command line parameters');
50+
}
4351
this.scwToken = options['scw-token'];
4452
this.scwProject = options['scw-project'];
4553
} else if (process.env.SCW_SECRET_KEY && process.env.SCW_DEFAULT_PROJECT_ID) {
46-
this.serverless.cli.log('Using credentials from system environment');
54+
if (!hideLog) {
55+
this.serverless.cli.log('Using credentials from system environment');
56+
}
4757
this.scwToken = process.env.SCW_SECRET_KEY;
4858
this.scwProject = process.env.SCW_DEFAULT_PROJECT_ID;
4959
} else if (process.env.SCW_TOKEN && process.env.SCW_PROJECT) {
50-
this.serverless.cli.log('Using credentials from system environment');
51-
this.serverless.cli.log('NOTICE: you are using deprecated environment variable notation,');
52-
this.serverless.cli.log('please update to SCW_SECRET_KEY and SCW_DEFAULT_PROJECT_ID');
60+
if (!hideLog) {
61+
this.serverless.cli.log('Using credentials from system environment');
62+
this.serverless.cli.log('NOTICE: you are using deprecated environment variable notation,');
63+
this.serverless.cli.log('please update to SCW_SECRET_KEY and SCW_DEFAULT_PROJECT_ID');
64+
}
5365
this.scwToken = process.env.SCW_TOKEN;
5466
this.scwProject = process.env.SCW_PROJECT;
5567
} else {
56-
this.serverless.cli.log('Using credentials from yml');
68+
if (!hideLog) {
69+
this.serverless.cli.log('Using credentials from yml');
70+
}
5771
this.scwToken = this.serverless.service.provider.scwToken || '';
5872
this.scwProject = this.serverless.service.provider.scwProject || '';
5973
}

0 commit comments

Comments
 (0)