context: Ensure context name is valid on import

Signed-off-by: Chris Crone <christopher.crone@docker.com>
(cherry picked from commit 9ecc69d17e)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Chris Crone
2020-09-24 16:24:24 +02:00
committed by Sebastiaan van Stijn
parent a2f0cf527b
commit 8c2872d2a3
7 changed files with 40 additions and 25 deletions

View File

@ -137,7 +137,7 @@ func createNewContext(o *CreateOptions, stackOrchestrator command.Orchestrator,
}
func checkContextNameForCreation(s store.Reader, name string) error {
if err := validateContextName(name); err != nil {
if err := store.ValidateContextName(name); err != nil {
return err
}
if _, err := s.GetMetadata(name); !store.IsErrContextDoesNotExist(err) {