added check if commas can be set

Signed-off-by: Christian Goll <cgoll@suse.com>
This commit is contained in:
Christian Goll
2023-09-29 11:42:00 +02:00
committed by Jonathon Anderson
parent 57a5e7d5ba
commit dcb21af5ba
3 changed files with 36 additions and 4 deletions

View File

@@ -145,6 +145,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- modules are now correctly included
- move hostlist into internal alongside other warewulf code #804
- uniform shebang usage in scripts of init.d folder #821
- Check if commas are allowes in node/profile set
## [4.4.0] 2023-01-18

View File

@@ -2,9 +2,12 @@ package set
import (
"bytes"
"os"
"testing"
"github.com/stretchr/testify/assert"
warewulfconf "github.com/warewulf/warewulf/internal/pkg/config"
"github.com/warewulf/warewulf/internal/pkg/node"
"github.com/warewulf/warewulf/internal/pkg/testenv"
"github.com/warewulf/warewulf/internal/pkg/warewulfd"
)
@@ -408,8 +411,40 @@ nodes:
- p2
tags:
nodetag1: nodevalue1
`},
{name: "single node set comma in comment",
args: []string{"n01", "--comment", "This is a , comment"},
wantErr: false,
stdout: "",
inDB: `WW_INTERNAL: 43
nodes:
n01:
comment: old comment
`,
outDb: `WW_INTERNAL: 43
nodeprofiles: {}
nodes:
n01:
comment: This is a , comment
profiles:
- default
`},
}
conf_yml := `WW_INTERNAL: 0`
tempWarewulfConf, warewulfConfErr := os.CreateTemp("", "warewulf.conf-")
assert.NoError(t, warewulfConfErr)
defer os.Remove(tempWarewulfConf.Name())
_, warewulfConfErr = tempWarewulfConf.Write([]byte(conf_yml))
assert.NoError(t, warewulfConfErr)
assert.NoError(t, tempWarewulfConf.Sync())
assert.NoError(t, warewulfconf.New().Read(tempWarewulfConf.Name()))
tempNodeConf, nodesConfErr := os.CreateTemp("", "nodes.conf-")
assert.NoError(t, nodesConfErr)
defer os.Remove(tempNodeConf.Name())
node.ConfigFile = tempNodeConf.Name()
warewulfd.SetNoDaemon()
for _, tt := range tests {
run_test(t, tt)
}

View File

@@ -17,10 +17,6 @@ must be called, as the commandline parser returns e.g. netip.IP objects which mu
back to strings.
*/
func (nodeConf *NodeConf) CreateFlags(baseCmd *cobra.Command, excludeList []string) (converters []func() error) {
/*
nodeInfoType := reflect.TypeOf(nodeConf)
nodeInfoVal := reflect.ValueOf(nodeConf)
*/
return RecursiveCreateFlags(nodeConf, baseCmd, excludeList)
}