• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

devpow112 / serverless-plugin-function-value / 12361806493

16 Dec 2024 09:41PM CUT coverage: 100.0%. Remained the same
12361806493

Pull #1215

github

web-flow
Merge 16b295179 into 6c7e4177a
Pull Request #1215: chore(deps-dev): bump @commitlint/cli from 19.6.0 to 19.6.1 in the commitlint group

1 of 1 branches covered (100.0%)

Branch coverage included in aggregate %.

20 of 20 relevant lines covered (100.0%)

3.05 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/function-value-plugin.js
1
const formatLog = (resolver, address, result) =>
2✔
2
  `\${${resolver}:${address}} => ${JSON.stringify(result)}`;
3✔
3

4
export default class FunctionValuePlugin {
5
  constructor(serverless, _, { log }) {
6
    const naming = serverless.getProvider('aws').naming;
6✔
7
    const functions = serverless.service.getAllFunctions();
6✔
8
    const classes = serverless.classes;
6✔
9

10
    const getLambdaLogicalId = address => {
6✔
11
      if (functions.includes(address)) {
6✔
12
        return naming.getLambdaLogicalId(address);
3✔
13
      }
14

15
      throw new classes.Error(`Function "${address}" not defined`);
3✔
16
    };
17

18
    this.configurationVariablesSources = {
6✔
19
      'fn.arn': {
20
        resolve: ({ address }) => {
21
          const result = { 'Fn::GetAtt': [getLambdaLogicalId(address), 'Arn'] };
2✔
22

23
          log.debug(formatLog('fn.arn', address, result));
1✔
24

25
          return { value: result };
1✔
26
        }
27
      },
28
      'fn.name': {
29
        resolve: ({ address }) => {
30
          const result = { Ref: getLambdaLogicalId(address) };
2✔
31

32
          log.debug(formatLog('fn.name', address, result));
1✔
33

34
          return { value: result };
1✔
35
        }
36
      },
37
      'fn.logicalid': {
38
        resolve: ({ address }) => {
39
          const result = getLambdaLogicalId(address);
2✔
40

41
          log.debug(formatLog('fn.logicalid', address, result));
1✔
42

43
          return { value: result };
1✔
44
        }
45
      }
46
    };
47
  }
48
}
2✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc