Coder Social home page Coder Social logo

Comments (8)

Acconut avatar Acconut commented on September 28, 2024 3

This seems to be a problem in the upstream HCL package we use. So I reported the error there: hashicorp/hcl#268. However, this has already been reported but there was no further activity: hashicorp/hcl#233

from json2hcl.

Acconut avatar Acconut commented on September 28, 2024

Are these escape characters in the resulting HCL harmful and cause it to be invalid or is it just an aesthetic concern?

from json2hcl.

lorengordon avatar lorengordon commented on September 28, 2024

The resulting HCL is invalid.

from json2hcl.

Acconut avatar Acconut commented on September 28, 2024

I have debugged this issue a bit and, if it's a bug, it originates in Hashicorp's HCL library (https://github.com/hashicorp/hcl). Since I am not well versed in HCL on my own, could you explain to me when a double quote needs to be escaped in HCL? Only when it's not inside a ${ ... } or never?

from json2hcl.

lorengordon avatar lorengordon commented on September 28, 2024

I'm on holiday this week and can't really test or research further as i don't have a computer. However, I cannot recall needing to escape double quotes at all in any of the HCL templates I've written.

from json2hcl.

beatcracker avatar beatcracker commented on September 28, 2024

I've similar issue with my own automated tool that generates JSON configuration.

Here is the generated configuration:

{
  "resource":[
    {
      "bitbucket_hook":{
        "bamboo":{
          "events":[
            "repo:push",
            "pullrequest:fulfilled"
          ],
          "url":"${format(var.bamboo_url, \"PRJ-KEY\", var.skip_branches ? \"true\" : \"false\")}",
          "description":"Trigger Bamboo build: PRJ-KEY",
          "owner":"${var.owner}",
          "repository":"${bitbucket_repository.PRJ-KEY}"
        }
      }
    }
  ]
}

This configuration is converted to:

"resource" "bitbucket_hook" "bamboo" {
  "events" = ["repo:push", "pullrequest:fulfilled"]
  "url" = "${format(var.bamboo_url, \"PRJ-KEY\", var.skip_branches ? \"true\" : \"false\")}"
  "description" = "Trigger Bamboo build: PRJ-KEY"
  "owner" = "${var.owner}"
  "repository" = "${bitbucket_repository.PRJ-KEY}"
}

As you can see, the arguments for the format function are not de-escaped. It should be this way:

  "url" = "${format(var.bamboo_url, "PRJ-KEY", var.skip_branches ? "true" : "false")}"

from json2hcl.

Acconut avatar Acconut commented on September 28, 2024

To be honest, I don't know HCL that well. Is "${format(var.bamboo_url, \"PRJ-KEY\", var.skip_branches ? \"true\" : \"false\")}" invalid?

from json2hcl.

beatcracker avatar beatcracker commented on September 28, 2024

Sorry, should've made that clear: yes, it's not a valid HCL.

from json2hcl.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.