You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pc...@apache.org on 2024/01/09 10:52:22 UTC
(camel-k) branch main updated: Fix number yaml format
This is an automated email from the ASF dual-hosted git repository.
pcongiusti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git
The following commit(s) were added to refs/heads/main by this push:
new fa4e658f9 Fix number yaml format
fa4e658f9 is described below
commit fa4e658f9ebca1fe7c44349ca68f54425d1b2299
Author: cdmikechen <cd...@hotmail.com>
AuthorDate: Tue Jan 9 07:54:22 2024 +0800
Fix number yaml format
---
pkg/util/dsl/flow.go | 5 +++--
pkg/util/dsl/flow_test.go | 2 ++
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/pkg/util/dsl/flow.go b/pkg/util/dsl/flow.go
index 6fd4ad4cb..32569e30a 100644
--- a/pkg/util/dsl/flow.go
+++ b/pkg/util/dsl/flow.go
@@ -62,8 +62,9 @@ func ToYamlDSL(flows []v1.Flow) ([]byte, error) {
return nil, err
}
jsondata := make([]map[string]interface{}, 0)
- err = json.Unmarshal(data, &jsondata)
- if err != nil {
+ d := json.NewDecoder(bytes.NewReader(data))
+ d.UseNumber()
+ if err := d.Decode(&jsondata); err != nil {
return nil, fmt.Errorf("error unmarshalling json: %w", err)
}
yamldata, err := yaml2.Marshal(&jsondata)
diff --git a/pkg/util/dsl/flow_test.go b/pkg/util/dsl/flow_test.go
index cd6cbcc9b..e67880f53 100644
--- a/pkg/util/dsl/flow_test.go
+++ b/pkg/util/dsl/flow_test.go
@@ -28,6 +28,8 @@ import (
func TestReadWriteYaml(t *testing.T) {
// yaml in conventional form as marshalled by the go runtime
yaml := `- from:
+ parameters:
+ period: 3600001
steps:
- to: log:info
uri: timer:tick