Merge pull request #45985 from thaJeztah/libnetwork_remove_IsValidName
libnetwork/config: remove IsValidName utility
This commit is contained in:
commit
ee79423124
4 changed files with 2 additions and 20 deletions
|
@ -135,11 +135,6 @@ func OptionNetworkControlPlaneMTU(exp int) Option {
|
|||
}
|
||||
}
|
||||
|
||||
// IsValidName validates configuration objects supported by libnetwork
|
||||
func IsValidName(name string) bool {
|
||||
return strings.TrimSpace(name) != ""
|
||||
}
|
||||
|
||||
// OptionActiveSandboxes function returns an option setter for passing the sandboxes
|
||||
// which were active during previous daemon life
|
||||
func OptionActiveSandboxes(sandboxes map[string]interface{}) Option {
|
||||
|
|
|
@ -26,15 +26,3 @@ func TestOptionsLabels(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidName(t *testing.T) {
|
||||
if !IsValidName("test") {
|
||||
t.Fatal("Name validation fails for a name that must be accepted")
|
||||
}
|
||||
if IsValidName("") {
|
||||
t.Fatal("Name validation succeeds for a case when it is expected to fail")
|
||||
}
|
||||
if IsValidName(" ") {
|
||||
t.Fatal("Name validation succeeds for a case when it is expected to fail")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -480,7 +480,7 @@ func (c *Controller) NewNetwork(networkType, name string, id string, options ...
|
|||
}
|
||||
}
|
||||
|
||||
if !config.IsValidName(name) {
|
||||
if strings.TrimSpace(name) == "" {
|
||||
return nil, ErrInvalidName(name)
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/docker/docker/libnetwork/config"
|
||||
"github.com/docker/docker/libnetwork/datastore"
|
||||
"github.com/docker/docker/libnetwork/driverapi"
|
||||
"github.com/docker/docker/libnetwork/etchosts"
|
||||
|
@ -1150,7 +1149,7 @@ func (n *network) addEndpoint(ep *Endpoint) error {
|
|||
|
||||
func (n *network) CreateEndpoint(name string, options ...EndpointOption) (*Endpoint, error) {
|
||||
var err error
|
||||
if !config.IsValidName(name) {
|
||||
if strings.TrimSpace(name) == "" {
|
||||
return nil, ErrInvalidName(name)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue