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

please preserve leading whitespace after the ytt inline-code token #823

Open
dreftymac opened this issue Mar 31, 2023 · 2 comments
Open
Labels
carvel accepted This issue should be considered for future work and that the triage process has been completed enhancement This issue is a feature request

Comments

@dreftymac
Copy link

dreftymac commented Mar 31, 2023

Overview

  • indentation_preserve_request
  • ytt version 0.45.0

Problem

  • ytt processing does not preserve leading whitespace for #@ expressions
  • ytt appears to remove all whitespace after the #@ when evaluating ytt-enhanced YAML

Example

  • consider the following well-formed ytt YAML document
  • we use a ytt function to output a variable
  • we use ytt #@ expressions to specify inline python/starlark code inside the function
  • we define a multiline string variable str_multiline
  • we then assign the function result to yaml data output
## -------------------------------------------------------------------
## begin_ ytt.functions

#@ def feature_request_preserve_indentation():
  #@ str_multiline = ('''
  #@  charlie_info:
  #@    charlie_one:    111
  #@    charlie_two:    222
  #@    charlie_three:  333
  #@  delta_info:
  #@    delta_one:      111
  #@    delta_two:      222
  #@    delta_three:    333
  #@  echo_info:
  #@    echo_one:       111
  #@    echo_two:       222
  #@    echo_three:     333
  #@ ''')
  #@ return(str_multiline)
#@ end

## -------------------------------------------------------------------
## begin_ yaml data output

dataroot:
  demo_string: #@ feature_request_preserve_indentation()

Results

  • we do not want the undesirable result BEFORE
  • instead, we want the desirable result AFTER

Non desired result -- BEFORE

dataroot:
  demo_string: |2

    charlie_info:
    charlie_one:    111
    charlie_two:    222
    charlie_three:  333
    delta_info:
    delta_one:      111
    delta_two:      222
    delta_three:    333
    echo_info:
    echo_one:       111
    echo_two:       222
    echo_three:     333

Yes desired result -- AFTER

dataroot:
  demo_string: |
    charlie_info:
      charlie_one:    111
      charlie_two:    222
      charlie_three:  333
    delta_info:
      delta_one:      111
      delta_two:      222
      delta_three:    333
    echo_info:
      echo_one:       111
      echo_two:       222
      echo_three:     333

Feature request

  • please allow ytt code regions to preserve leading whitespace that appears after the #@ token

Rationale

  • sometimes whitespace is significant (as in this example where the #@ token is used for a multiline string variable
  • the current parsing strategy seems to assume that leading whitespace after the #@ token is not relevant
  • this assumption (if correct) limits the kind of code one can deploy using ytt

Vote on this request

This is an invitation to the community to vote on issues, to help us prioritize our backlog. Use the "smiley face" up to the right of this comment to vote.

👍 "I would like to see this addressed as soon as possible"
👎 "There are other more important things to focus on right now"

We are also happy to receive and review Pull Requests if you want to help working on this issue.

@dreftymac dreftymac added carvel triage This issue has not yet been triaged for relevance enhancement This issue is a feature request labels Mar 31, 2023
@github-actions
Copy link

This issue is being marked as stale due to a long period of inactivity and will be closed in 5 days if there is no response.

@github-actions github-actions bot added the stale This issue has had no activity for a while and will be closed soon label May 11, 2023
@vmunishwar vmunishwar removed the stale This issue has had no activity for a while and will be closed soon label Jun 5, 2023
@vmunishwar vmunishwar reopened this Jun 5, 2023
@vmunishwar
Copy link
Contributor

Sorry for the late reply. Thanks for adding this issue. We are able to reproduce this issue. We will analyze this further and get back to you soon.
Thanks for reaching out!

@vmunishwar vmunishwar added carvel accepted This issue should be considered for future work and that the triage process has been completed and removed carvel triage This issue has not yet been triaged for relevance labels Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
carvel accepted This issue should be considered for future work and that the triage process has been completed enhancement This issue is a feature request
Projects
Archived in project
Development

No branches or pull requests

2 participants