Skip to content
Open
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
16 changes: 8 additions & 8 deletions cmd/config_load.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,6 @@ var configLoadCmd = &cobra.Command{
}

switch configFormat {
case types.ConfigFormatJson, types.ConfigFormatJsonIetf, types.ConfigFormatXml:
// TODO:
// lc.SetFlags()
rawParam.SetName(intentName).SetPrio(priority)
// if data is comming from stdin, store it in data
if strings.TrimSpace(configurationFile) == "-" {
rawParam.SetData(configByte)
}
case types.ConfigFormatSdc:

sdcC, err := LoadSDCConfigCR(configByte)
Expand All @@ -83,6 +75,14 @@ var configLoadCmd = &cobra.Command{
if err != nil {
return err
}
default:
// TODO:
// lc.SetFlags()
rawParam.SetName(intentName).SetPrio(priority)
// if data is comming from stdin, store it in data
if strings.TrimSpace(configurationFile) == "-" {
rawParam.SetData(configByte)
}
}

// if pipelineFile is set, then we need to generate just the pieline instruction equivalent of the actual command and exist
Expand Down
11 changes: 10 additions & 1 deletion pkg/configdiff/configdiff.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,14 +365,23 @@ func (c *ConfigDiff) TreeLoadData(ctx context.Context, cl *params.ConfigLoad) er
return err
}
importer = treejson.NewJsonTreeImporter(j)

case types.ConfigFormatYaml:
var y any
err = yaml.Unmarshal(intent.GetData(), &y)
if err != nil {
return err
}
// we use json importer since we're based basically on map[string]any
importer = treejson.NewJsonTreeImporter(y)
case types.ConfigFormatXml:
xmlDoc := etree.NewDocument()
err := xmlDoc.ReadFromBytes(intent.GetData())
if err != nil {
return err
}
importer = treexml.NewXmlTreeImporter(&xmlDoc.Element)
default:
return fmt.Errorf("import of format %s not supported yet", intent.GetFormat().String())
}

// overwrite running intent with running prio
Expand Down