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

Enable l1-output-string #675

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changes/unreleased/Bug Fixes-675.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
component: codegen
kind: Bug Fixes
body: Maintain empty strings in converted programs to still be string literals in
YAML
time: 2024-11-14T15:15:07.587566353Z
custom:
PR: "675"
1 change: 0 additions & 1 deletion cmd/pulumi-language-yaml/language_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ func runTestingHost(t *testing.T) (string, testingrpc.LanguageTestClient) {
// Add test names here that are expected to fail and the reason why they are failing
var expectedFailures = map[string]string{
"l1-stack-reference": "TODO",
"l1-output-string": "TODO",
"l2-destroy": "TODO",
"l2-invoke-options": "TODO",
"l2-map-keys": "TODO",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
outputs:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accidentally commit the broken version of this file in #673

empty:
empty: ""
small: Hello world!
emoji: "\U0001F44B \"Hello \U0001019B!\" \U0001F60A"
escape: "Some ${common} \"characters\" 'that' need escaping: \\ (backslash), \t (tab), \e (escape), \a (bell), \0 (null), \U000E0021 (tag space)"
escapeNewline: "Some ${common} \"characters\" 'that' need escaping: \\ (backslash), \n (newline), \t (tab), \e (escape), \a (bell), \0 (null), \U000E0021 (tag space)"
escape: "Some $${common} \"characters\" 'that' need escaping: \\ (backslash), \t (tab), \e (escape), \a (bell), \0 (null), \U000E0021 (tag space)"
escapeNewline: "Some $${common} \"characters\" 'that' need escaping: \\ (backslash), \n (newline), \t (tab), \e (escape), \a (bell), \0 (null), \U000E0021 (tag space)"
large: |
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Expand Down
2 changes: 2 additions & 0 deletions pkg/pulumiyaml/codegen/gen_program.go
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,8 @@ func (g *generator) expr(e model.Expression) syn.Node {
return syn.Null()
case t.Equals(cty.String):
v := e.Value.AsString()
// This is a literal string so escape any ${ sequences in it
v = strings.ReplaceAll(v, "${", "$${")
return syn.String(v)
case t.Equals(cty.Number):
v := e.Value.AsBigFloat()
Expand Down
4 changes: 4 additions & 0 deletions pkg/pulumiyaml/syntax/encoding/yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,10 @@ func MarshalYAML(n syntax.Node) (*yaml.Node, syntax.Diagnostics) {
if originalValue != value {
yamlNode.Value = value
}
// if the empty string use double quotes so we get "" instead of nothing
if yamlNode.Value == "" {
yamlNode.Style = yaml.DoubleQuotedStyle
}
case *syntax.ListNode:
if yamlNode.Kind != yaml.SequenceNode && yamlNode.Kind != yaml.DocumentNode {
yamlNode.Kind = yaml.SequenceNode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ resources:
fn::toJSON:
Version: 2008-10-17
Statement:
- Sid:
- Sid: ""
Effect: Allow
Principal:
Service: ecs-tasks.amazonaws.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ resources:
fn::toJSON:
Version: 2008-10-17
Statement:
- Sid:
- Sid: ""
Effect: Allow
Principal:
Service: ecs-tasks.amazonaws.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ resources:
properties:
name:
fn::join:
-
- ""
- - fn::select:
- 0
- - foo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ resources:
name: pulumi-kubernetes-operator
rules:
- apiGroups:
-
- ""
resources:
- pods
- services
Expand Down Expand Up @@ -97,7 +97,7 @@ resources:
verbs:
- update
- apiGroups:
-
- ""
resources:
- pods
verbs:
Expand Down
Loading