Skip to content

Commit

Permalink
Merge branch 'devel' into dependabot/go_modules/k8s.io/api-0.32.0
Browse files Browse the repository at this point in the history
  • Loading branch information
matoval authored Dec 19, 2024
2 parents bb90538 + d7b5f18 commit 12a98b0
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ updates:
labels:
- "dependencies"
- "go"
ignore:
- dependency-name: "golang"
versions: ["1.23", "1.24"]
- package-ecosystem: "github-actions"
directory: "/"
schedule:
Expand Down
2 changes: 1 addition & 1 deletion docs/source/user_guide/configuration_options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ Node
- Default value
- Type
* - ``id``
- Node ID can only contain a-z, A-Z, 0-9 or special characters . - _ @
- Node ID can only contain a-z, A-Z, 0-9 or special characters . - _ @ :
- local hostname
- string
* - ``datadir``
Expand Down
4 changes: 2 additions & 2 deletions pkg/types/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ func (cfg NodeCfg) Init() error {
}
cfg.ID = host
} else {
submitIDRegex := regexp.MustCompile(`^[.\-_@a-zA-Z0-9]*$`)
submitIDRegex := regexp.MustCompile(`^[.\-_@:a-zA-Z0-9]*$`)
match := submitIDRegex.FindSubmatch([]byte(cfg.ID))
if match == nil {
return fmt.Errorf("node id can only contain a-z, A-Z, 0-9 or special characters . - _ @ but received: %s", cfg.ID)
return fmt.Errorf("node id can only contain a-z, A-Z, 0-9 or special characters . - _ @ : but received: %s", cfg.ID)
}
}
if strings.ToLower(cfg.ID) == "localhost" {
Expand Down
39 changes: 39 additions & 0 deletions pkg/types/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package types

import "testing"

func TestMainInitNodeID(t *testing.T) {
mainInitNodeIDTestCases := []struct {
name string
nodeID string
expectedErr string
}{
{
name: "successful, no error",
nodeID: "t.e-s_t@1:234",
expectedErr: "",
},
{
name: "failed, charactered not allowed",
nodeID: "test!#&123",
expectedErr: "node id can only contain a-z, A-Z, 0-9 or special characters . - _ @ : but received: test!#&123",
},
}

for _, testCase := range mainInitNodeIDTestCases {
t.Run(testCase.name, func(t *testing.T) {
cfg := NodeCfg{
ID: testCase.nodeID,
}
err := cfg.Init()
if err == nil && testCase.expectedErr != "" {
t.Errorf("exected error but got no error")
} else if err != nil && err.Error() != testCase.expectedErr {
t.Errorf("expected error to be %s, but got: %s", testCase.expectedErr, err.Error())
}
t.Cleanup(func() {
cfg = NodeCfg{}
})
})
}
}
2 changes: 0 additions & 2 deletions pkg/workceptor/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ func TestCommandSetFromParams(t *testing.T) {
}

func TestUnredactedStatus(t *testing.T) {
t.Parallel()
wu, mockBaseWorkUnit, _, _ := createCommandTestSetup(t)
restartTestCases := []struct {
name string
Expand All @@ -101,7 +100,6 @@ func TestUnredactedStatus(t *testing.T) {
statusLock := &sync.RWMutex{}
for _, testCase := range restartTestCases {
t.Run(testCase.name, func(t *testing.T) {
t.Parallel()
mockBaseWorkUnit.EXPECT().GetStatusLock().Return(statusLock).Times(2)
mockBaseWorkUnit.EXPECT().GetStatusWithoutExtraData().Return(&workceptor.StatusFileData{})
mockBaseWorkUnit.EXPECT().GetStatusCopy().Return(workceptor.StatusFileData{
Expand Down

0 comments on commit 12a98b0

Please sign in to comment.