@@ -10,6 +10,7 @@ import (
1010 stscobra "github.com/stackvista/stackstate-cli/internal/cobra"
1111 "github.com/stackvista/stackstate-cli/internal/common"
1212 "github.com/stackvista/stackstate-cli/internal/di"
13+ "sigs.k8s.io/kustomize/kyaml/yaml"
1314)
1415
1516const LongDescription = `Edit a dashboard.
@@ -60,19 +61,19 @@ func RunDashboardEditCommand(args *EditArgs) di.CmdWithApiFn {
6061 }
6162
6263 // Convert dashboard to pretty JSON for editing
63- originalJSON , err := json . MarshalIndent (dashboard , "" , " " )
64+ originalYAML , err := yaml . Marshal (dashboard )
6465 if err != nil {
65- return common .NewExecutionError (fmt .Errorf ("failed to marshal dashboard to JSON : %v" , err ))
66+ return common .NewExecutionError (fmt .Errorf ("failed to marshal dashboard to YAML : %v" , err ))
6667 }
6768
6869 // Open editor with the dashboard JSON
69- editedContent , err := cli .Editor .Edit ("dashboard-" , ".json " , strings .NewReader (string (originalJSON )))
70+ editedContent , err := cli .Editor .Edit ("dashboard-" , ".yaml " , strings .NewReader (string (originalYAML )))
7071 if err != nil {
7172 return common .NewExecutionError (fmt .Errorf ("failed to open editor: %v" , err ))
7273 }
7374
7475 // Check if any changes were made
75- if strings .Compare (string (originalJSON ), string (editedContent )) == 0 {
76+ if strings .Compare (string (originalYAML ), string (editedContent )) == 0 {
7677 if cli .IsJson () {
7778 cli .Printer .PrintJson (map [string ]interface {}{"message" : "No changes made" })
7879 } else {
@@ -81,13 +82,13 @@ func RunDashboardEditCommand(args *EditArgs) di.CmdWithApiFn {
8182 return nil
8283 }
8384
84- // Parse the edited JSON
85+ // Parse the edited YAML
8586 var editedDashboard map [string ]interface {}
86- if err := json .Unmarshal (editedContent , & editedDashboard ); err != nil {
87- return common .NewExecutionError (fmt .Errorf ("failed to parse edited JSON : %v" , err ))
87+ if err := yaml .Unmarshal (editedContent , & editedDashboard ); err != nil {
88+ return common .NewExecutionError (fmt .Errorf ("failed to parse edited YAML : %v" , err ))
8889 }
8990
90- // Create patch schema from the edited JSON
91+ // Create patch schema from the edited YAML
9192 patchSchema := stackstate_api .NewDashboardPatchSchema ()
9293
9394 if name , ok := editedDashboard ["name" ].(string ); ok && name != "" {
0 commit comments