From 36039a38ea8463c31c14ce52c38f22cc93e72ede Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Fri, 24 Apr 2020 10:46:30 +0200 Subject: create: move validate after setting default ns validate the configuration only after we set the default namespaces. Signed-off-by: Giuseppe Scrivano --- pkg/specgen/generate/container_create.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'pkg/specgen/generate/container_create.go') diff --git a/pkg/specgen/generate/container_create.go b/pkg/specgen/generate/container_create.go index 1be77d315..369c64e1f 100644 --- a/pkg/specgen/generate/container_create.go +++ b/pkg/specgen/generate/container_create.go @@ -15,9 +15,6 @@ import ( // MakeContainer creates a container based on the SpecGenerator func MakeContainer(rt *libpod.Runtime, s *specgen.SpecGenerator) (*libpod.Container, error) { - if err := s.Validate(); err != nil { - return nil, errors.Wrap(err, "invalid config provided") - } rtc, err := rt.GetConfig() if err != nil { return nil, err @@ -94,6 +91,10 @@ func MakeContainer(rt *libpod.Runtime, s *specgen.SpecGenerator) (*libpod.Contai options = append(options, libpod.WithRootFSFromImage(newImage.ID(), s.Image, s.RawImageName)) + if err := s.Validate(); err != nil { + return nil, errors.Wrap(err, "invalid config provided") + } + runtimeSpec, err := SpecGenToOCI(s, rt, newImage) if err != nil { return nil, err -- cgit v1.2.3-54-g00ecf