Skip to content

Commit

Permalink
fix docker env name validation logic (#52)
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Ye <[email protected]>

Signed-off-by: Ben Ye <[email protected]>
  • Loading branch information
yeya24 authored Sep 23, 2022
1 parent 45de9fc commit 8fa9daa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions env_docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ func generateName() (string, error) {
}

func validateName(name string) error {
if len(name) < 1 && len(name) > 16 {
return errors.Newf("name can't be smaller than 1 and over 16 character long due to docker network name constraints, got: %v", name)
if len(name) < 1 || len(name) > 16 {
return errors.Newf("name can't be smaller than 1 or over 16 character long due to docker network name constraints, got: %v", name)
}
if !envNamePattern.MatchString(name) {
return errors.Newf("name can have only %v characters due to docker network name constraints, got: %v", envNamePattern.String(), name)
Expand Down
4 changes: 2 additions & 2 deletions env_docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestValidateName(t *testing.T) {
}{
{
name: "",
expectedErr: errors.New("name can have only ^[-a-zA-Z\\d]{1,16}$ characters due to docker network name constraints, got: "),
expectedErr: errors.New("name can't be smaller than 1 or over 16 character long due to docker network name constraints, got: "),
},
{
name: "e2e-testName",
Expand All @@ -52,7 +52,7 @@ func TestValidateName(t *testing.T) {
},
{
name: "e2e_testNamelongerthanexpected",
expectedErr: errors.New("name can have only ^[-a-zA-Z\\d]{1,16}$ characters due to docker network name constraints, got: e2e_testNamelongerthanexpected"),
expectedErr: errors.New("name can't be smaller than 1 or over 16 character long due to docker network name constraints, got: e2e_testNamelongerthanexpected"),
},
{
name: func() string {
Expand Down

0 comments on commit 8fa9daa

Please sign in to comment.