question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hi guys, we are using this great library(!) to generate configuration files for our microservices.

It works perfectly and we have no issues with that, but there is one thing that we could improve in generated files.

Basically this is what we get after using YamlBuilders to create yaml file:

application:
  name: template
  "instance-id": "${random.uuid}"
  version: @project.version@
server:
  port: 8081
spring:
  kafka:
    "bootstrap-servers": "localhost:8092"
  cloud:
    kubernetes:
      enabled: false

as you can see, some of the key/values are quoted – ".

Is there a poissibility to always skip quotes so the outcome would be:

application:
  name: template
  instance-id: ${random.uuid}
  version: @project.version@
server:
  port: 8081
spring:
  kafka:
    bootstrap-servers: localhost:8092
  cloud:
    kubernetes:
      enabled: false

?

I search docs and closed tickets, but could not find answer for my question.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
sta-szekcommented, Apr 28, 2021

I see, thanks for providing detailed explanation and customization example! 🚀

1reaction
amihaiemilcommented, Apr 28, 2021

@sta-szek There is no option to unquote them. There were lengthy discussions around here about special characters and quotation, so we decided to just quote (escape) any string (key or value) which contains YAML special characters such as : or -.

However, don’t forget that both YamlMapping and YamlSequence are interfaces, so you can most likely write your own decorator which would remove these quotations. Something like this:

public final class Unqouted implements YamlMapping {
    private final YamlMapping original;

    public Unqoted(final YamlMapping original) {
        this.original = original;
    }

    //implement the methods of YamlMapping, delegate what you need to the original
   //and remove quotes from the returned values/keys where needed.
}

Then you would just use this class as follows:

final YamlMapping unqoted = new Unquoted(
    YamlMappingBuilder
    ...
    .build()
);

And this unqoted YamlMapping should behave/print as you wish, without qoutes 😄

Does this help? I’m afraid there is no other option.

We will not change the quoting mechanism because, as I said, there were a lot of discussions and we finally come to a point where most users are happy.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Optional Quotes - BrainyQuote
Optional Quotes · The rule of law means that law and justice are upheld by an independent judiciary. · Growing old is mandatory;...
Read more >
Citation Guide: Optional Elements - LibGuides
All citations should include the following elements: 1. Author. 2. Title of Source.
Read more >
Optional Line Items on Quotes - Jobber Help Center
Optional line items provide clients with extra products and services they can choose to add onto their quote. Maybe these are items that...
Read more >
Optional Items | Quoter Software
Cross-sell & upsell with optionals. This feature will give you the ability to add line items to your quotes that are optional for...
Read more >
Making Price Lines Optional in a Sales Quote - QuoteCloud
Sometimes it may be useful to let a customer decide between different products or price options. This can be acheived by grouping price...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found