Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to pass relative paths to cfn-lint? #90

Open
craighurley opened this issue Apr 4, 2020 · 2 comments
Open

Is it possible to pass relative paths to cfn-lint? #90

craighurley opened this issue Apr 4, 2020 · 2 comments

Comments

@craighurley
Copy link

Plugin Version: 0.10.20
VS Code version: 1.43.2
OS: Darwin x64 19.4.0

Is it possible to make the cfn-lint plugin use relative paths from the project root rather than absolute paths?

The reason I ask is that I am trying to use cfn-lint in a docker container to avoid pip dependency conflicts I'm having. Outside of VS Code, running cfn-lint in the container against templates works successfully.

In order to make VS Code use the container I do the following:

  1. Create a script at $HOME/bin/cfn-lint
  2. Configure the path to cfn-lint in the VS Code plugin settings to: $HOME/bin/cfn-lint.

The script at $HOME/bin/cfn-lint which I use to pass arguments from VS Code to the container is as follows:

#!/usr/bin/env bash
set -e
docker run --rm -v $PWD:/workdir:ro craighurley/cfn-lint "$@"
exit 0

Now I do the following:

A. Open a project with a project root of /Users/hurley/Projects/example/.
B. Open a CFN template at ./templates/ec2.yaml
C. VS Code correctly calls the script and passes the template, but because it uses absolute paths it fails with the following:

Settings: {"cfnLint":{"enableAutocomplete":true,"validateUsingJsonSchema":false,"path":"$HOME/bin/cfn-lint","appendRules":[],"ignoreRules":["E3012","W2001","W3011"],"overrideSpecPath":""}}
Determined this file is a CloudFormation Template. file:///Users/hurley/Projects/example/templates/ec2.yaml. Found the string AWSTemplateFormatVersion
running............. $HOME/bin/cfn-lint --format,json,--ignore-checks,E3012,--ignore-checks,W2001,--ignore-checks,W3011,--,"/Users/hurley/Projects/example/templates/ec2.yaml"
2020-04-04 10:04:19,384 - cfnlint.decode - ERROR - Template file not found: /Users/hurley/Projects/example/templates/ec2.yaml

child process exited with code 2 and signal null

The reason for the error is because the container has a volume mapped from /Users/hurley/Projects/example/ on my local machine to /workdir in the container, so cfn-lint inside the container is not aware of /Users/hurley/Projects/example/.

@craighurley
Copy link
Author

craighurley commented Apr 4, 2020

This issue would also help in my case: #60

@PatMyron
Copy link
Contributor

The reason I ask is that I am trying to use cfn-lint in a docker container to avoid pip dependency conflicts I'm having

Sorry about the delayed response. Not sure if this fits your use-case, but figured I'd mention the online demo pre-configures the environment with dependencies and could be a potential alternative without installation problems

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants