Domain-Connect / dc-template-linter

Domain Connect template linter
https://www.domainconnect.org/
Apache License 2.0
2 stars 1 forks source link

Warning on int in a string in a template #4

Closed pawel-kow closed 8 months ago

pawel-kow commented 8 months ago
➜dc-template-linter -loglevel warn bing.com.bingwebmasterdpoo.json 
2024-02-19T18:59:20+01:00 WRN do not quote an integer, it makes it string template=bing.com.bingwebmasterdpoo.json value=3600

➜ echo $?                                                                                          
1

Template fragment:

  "records": [
      {  
         "type":"CNAME",
         "host":"%WEBMASTERGUID%",
         "pointsTo":"verify.bing.com",
         "ttl":"3600"
      }
  ]

The issue reported could be about ttl being an Int field.

It's maybe not nice to have those and one should consider it legacy to have templates like this, but in fact it does not present any issue as such. The JSON Schema could cover for this:

      "TTL":{
         "anyOf":[
            {
               "type":"integer"
            },
            {
               "type":"string",
               "format":"integer"
            }
         ],
         "title":"TTL"
      }

Actually this is the only way of allowing variables in the numerical values without breaking the JSON of the template. There is already a request like this: https://github.com/Domain-Connect/spec/issues/88 There were also requests in the past to have ttl with a variable.

Ergo - for me it should not be a warning - rather an info.

kerolasa commented 8 months ago

I changed warning to be info level message in b7b85bc68c00104d5d8b99b6bb8d6f8ae8144c3a. If and when TTL among other numbers is changed to be a variable I will change the linter code again to check for number or a variable. But that's for later.