Skip to content

Commit

Permalink
added check if commas can be set
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Goll <[email protected]>
  • Loading branch information
mslacken authored and anderbubble committed Feb 7, 2024
1 parent 57a5e7d commit dcb21af
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
35 changes: 35 additions & 0 deletions internal/app/wwctl/node/set/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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)
}
Expand Down
4 changes: 0 additions & 4 deletions internal/pkg/node/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit dcb21af

Please sign in to comment.