@@ -14,9 +14,6 @@ import (
1414 corev1 "k8s.io/api/core/v1"
1515 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1616 "k8s.io/apimachinery/pkg/util/wait"
17- applyv1 "k8s.io/client-go/applyconfigurations/core/v1"
18-
19- kerrors "k8s.io/apimachinery/pkg/api/errors"
2017
2118 "github.com/google/go-containerregistry/pkg/v1/remote"
2219 "github.com/loft-sh/devspace/pkg/devspace/kubectl"
@@ -176,41 +173,7 @@ func (r *LocalRegistry) ensureNamespace(ctx devspacecontext.Context) error {
176173 return nil
177174 }
178175
179- // Try to get the namespace we need
180- _ , err := ctx .KubeClient ().
181- KubeClient ().
182- CoreV1 ().
183- Namespaces ().
184- Get (ctx .Context (), r .Namespace , metav1.GetOptions {})
185- // Ignore not found errors, but if we have any other type or error, report it
186- if err != nil && ! kerrors .IsNotFound (err ) {
187- return err
188- }
189- // And if we don't have errors, it means the namespace already exists.
190- if err == nil {
191- ctx .Log ().Debugf ("Namespace %s already exists, skipping creation" , r .Namespace )
192- return nil
193- }
194-
195- ctx .Log ().Debugf ("Namespace %s doesn't exist, attempting creation" , r .Namespace )
196- applyConfiguration , err := applyv1 .ExtractNamespace (& corev1.Namespace {
197- ObjectMeta : metav1.ObjectMeta {
198- Name : r .Namespace ,
199- },
200- }, ApplyFieldManager )
201- if err != nil {
202- return err
203- }
204-
205- _ , err = ctx .KubeClient ().KubeClient ().CoreV1 ().Namespaces ().Apply (
206- ctx .Context (),
207- applyConfiguration ,
208- metav1.ApplyOptions {
209- FieldManager : ApplyFieldManager ,
210- Force : true ,
211- },
212- )
213- return err
176+ return kubectl .EnsureNamespace (ctx .Context (), ctx .KubeClient (), r .Namespace , ctx .Log ())
214177}
215178
216179func (r * LocalRegistry ) SelectRegistryPod (ctx devspacecontext.Context ) (* corev1.Pod , error ) {
0 commit comments