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

Provide linting on the value part of key-value pair #2563

Open
yogesh-ti opened this issue Jan 23, 2023 · 2 comments
Open

Provide linting on the value part of key-value pair #2563

yogesh-ti opened this issue Jan 23, 2023 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@yogesh-ti
Copy link

yogesh-ti commented Jan 23, 2023

Is this feature request related to a new rule or cfn-lint capabilities?

New capability

Describe the feature you'd like to request

I am writing a custom rule in python.
My requirement includes to lint the warning on value part of key-value pair. Let's take the following snippet to understand.

{
    "AWSTemplateFormatVersion":"2010-09-09",
    "Resources":{
        "S3Bucket":{
            "Type": "AWS::S3::Bucket",
            "Properties":{
                "Name":"temp-s3-bucket"
            }
        }
    }
}

My usecase includes getting the exact position of "value" in a key-value pair. Considering the above case, let's assume that I have written some custom rule which will check the bucket name should only start with letter - "a". Now in cfn-lint custom ruleset, when I give the path value in return to match function Link, I give value as path=[S3Bucket,Properties,Name] which when run, will give the output warning as to change on (start: Line 7, col: 17 to end: Line 7, col 23), but my usecase is a little different.
I want to get the warning as start: Line 7, col 24 to end: Line 7, col 40. Which means in Key-Value as "Name":"temp-s3-bucket", i want the recommednation to be shown on "temp-s3-bucket" instead of "Name".

Describe the solution you'd like

Add an optional argument, lintOnKey defaults to true, if false then this lints the value for this key

@kddejong
Copy link
Contributor

@benbridts and @PatMyron what do you think of this idea? I think the idea is we would highlight the values and not the keys.

@kddejong kddejong self-assigned this Feb 15, 2023
@kddejong kddejong added the enhancement New feature or request label Feb 15, 2023
@PatMyron
Copy link
Contributor

Always more advanced possibilities for power users, but I tend to err on the side of simple interfaces / abstractions. Findings are generally understood by users regardless if the key or value is highlighted

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

No branches or pull requests

3 participants