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

Generated YAML programs have four-space files, despite two-space templates #361

Closed
cnunciato opened this issue Sep 12, 2022 · 7 comments
Closed
Assignees
Labels
area/core kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed

Comments

@cnunciato
Copy link
Member

What happened?

When I run pulumi new aws-yaml, for example, I get a program file with four-space formatting, despite that the template is defined with two-space indentation:

Source template:

name: ${PROJECT}
description: ${DESCRIPTION}
runtime: yaml
template:
  description: A minimal AWS Pulumi YAML program
  important: true
  config:
    aws:region:
      description: The AWS region to deploy into
      default: us-east-1

resources:
  # Create an AWS resource (S3 Bucket)
  my-bucket:
    type: aws:s3:Bucket

outputs:
  # Export the name of the bucket
  bucketName: ${my-bucket.id}

Resulting program:

name: yaml-test-2
description: A minimal AWS Pulumi YAML program
runtime: yaml
resources:
    # Create an AWS resource (S3 Bucket)
    my-bucket:
        type: aws:s3:Bucket
outputs:
    # Export the name of the bucket
    bucketName: ${my-bucket.id}

Steps to reproduce

Run pulumi new aws-yaml and examine the contents of Pulumi.yaml.

Expected Behavior

Pulumi.yaml uses two-space indentation, or at least indentation matching that of its source template file(s).

Actual Behavior

It uses four-space indentation.

Output of pulumi about

No response

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

@cnunciato cnunciato added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Sep 12, 2022
@dixler
Copy link
Contributor

dixler commented Sep 13, 2022

I think this is related to YAML roundtripping which is an existing issue in pulumi/pulumi. @iwahbe might have more context.

@dixler dixler added area/core and removed needs-triage Needs attention from the triage team labels Sep 13, 2022
@iwahbe
Copy link
Member

iwahbe commented Sep 13, 2022

I think this is related to YAML roundtripping which is an existing issue in pulumi/pulumi. @iwahbe might have more context.

This is definitely part of YAML rountripping. In this case I think we should just standardize on a number of spaces and enforce it. Regardless of if its 2 or 4, we should always output the same YAML.
CC @AaronFriel

@cnunciato
Copy link
Member Author

cnunciato commented Sep 13, 2022

Likely not relevant for the implementation, but what we choose (and I have no pref at all) should probably align with the spacing we use in all of our docs and examples as well. For me at least, it was copy-pasting two-space example code into these four-space-ified templates that led me to post this issue.

@lukehoban
Copy link
Member

FWIW - I believe we have decided on a two space standard, and should apply that everywhere. Agree with @cnunciato on aligning with examples codegen.

@mikhailshilkov
Copy link
Member

@AaronFriel let's take it on the YAML GA epic.

@aq17
Copy link
Contributor

aq17 commented Jan 6, 2023

@cnunciato I think this can be closed thanks to pulumi/pulumi#11456.

@AaronFriel
Copy link
Member

This is also now imposed by that same change, if a template contains 4 space indentation, that'll be overridden on save to 2.

@AaronFriel AaronFriel self-assigned this Jan 9, 2023
@AaronFriel AaronFriel added the resolution/fixed This issue was fixed label Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/core kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed
Projects
None yet
Development

No branches or pull requests

7 participants