Skip to content

Commit e8a911b

Browse files
authored
[confmap] Allow using map[string]any as string (#10615)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description <!-- Issue number if applicable --> Allow using strings parseable in YAML as `map[string]any` in inline position #### Link to tracking issue Relates to #10605 (does not fix it since it's not in inline position)
1 parent f2c56a3 commit e8a911b

File tree

4 files changed

+30
-6
lines changed

4 files changed

+30
-6
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
7+
component: confmap
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Allow using `map[string]any` values in string interpolation
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [10605]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# Optional: The change log or logs in which this entry should be included.
21+
# e.g. '[user]' or '[user, api]'
22+
# Include 'user' if the change is relevant to end users.
23+
# Include 'api' if there is a change to a library API.
24+
# Default: '[user]'
25+
change_logs: []

confmap/internal/e2e/types_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,12 +303,12 @@ func TestStrictTypeCasting(t *testing.T) {
303303
{
304304
value: "{\"field\": 123}",
305305
targetField: TargetFieldInlineString,
306-
resolveErr: "retrieved value does not have unambiguous string representation",
306+
expected: "inline field with {\"field\": 123} expansion",
307307
},
308308
{
309309
value: "1111:1111:1111:1111:1111::",
310310
targetField: TargetFieldInlineString,
311-
resolveErr: "retrieved value does not have unambiguous string representation",
311+
expected: "inline field with 1111:1111:1111:1111:1111:: expansion",
312312
},
313313
{
314314
value: "1111:1111:1111:1111:1111::",

confmap/provider.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func NewRetrievedFromYAML(yamlBytes []byte, opts ...RetrievedOption) (*Retrieved
141141
switch v := rawConf.(type) {
142142
case string:
143143
opts = append(opts, withStringRepresentation(v))
144-
case int, int32, int64, float32, float64, bool:
144+
case int, int32, int64, float32, float64, bool, map[string]any:
145145
opts = append(opts, withStringRepresentation(string(yamlBytes)))
146146
}
147147

confmap/provider_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,8 @@ func TestNewRetrievedFromYAMLString(t *testing.T) {
113113
value: 0.123,
114114
},
115115
{
116-
yaml: "{key: value}",
117-
value: map[string]any{"key": "value"},
118-
strReprErr: "retrieved value does not have unambiguous string representation",
116+
yaml: "{key: value}",
117+
value: map[string]any{"key": "value"},
119118
},
120119
}
121120

0 commit comments

Comments
 (0)