3
0

Change ns clone/import to not require slugs

This commit is contained in:
Tomaž Jerman
2024-03-11 09:17:16 +01:00
parent 9a2bd3665c
commit 13d0cd514f
2 changed files with 40 additions and 0 deletions

View File

@@ -207,6 +207,11 @@ func (ctrl Namespace) Clone(ctx context.Context, r *request.NamespaceClone) (int
Slug: r.Slug,
}
// @todo temporary workaround cause Envoy requires some identifiable thing
if dup.Slug == "" {
dup.Slug = fmt.Sprintf("cl_%d", r.NamespaceID)
}
nodes, err := ctrl.gatherNodes(ctx, r.NamespaceID)
if err != nil {
return nil, err
@@ -217,6 +222,18 @@ func (ctrl Namespace) Clone(ctx context.Context, r *request.NamespaceClone) (int
}
ns, err := ctrl.namespace.Clone(ctx, r.NamespaceID, dup, decoder)
if err != nil {
return nil, err
}
// @todo temporary workaround cause Envoy requires some identifiable thing
if r.Slug == "" {
ns.Slug = ""
ns, err = ctrl.namespace.Update(ctx, ns)
if err != nil {
return nil, err
}
}
return ctrl.makePayload(ctx, ns, err)
}
@@ -279,7 +296,24 @@ func (ctrl Namespace) ImportRun(ctx context.Context, r *request.NamespaceImportR
}
)
// @todo temporary workaround cause Envoy requires some identifiable thing
if dup.Slug == "" {
dup.Slug = fmt.Sprintf("cl_%d", r.SessionID)
}
ns, err := ctrl.namespace.ImportRun(ctx, r.SessionID, dup)
if err != nil {
return nil, err
}
// @todo temporary workaround cause Envoy requires some identifiable thing
if r.Slug == "" {
ns.Slug = ""
ns, err = ctrl.namespace.Update(ctx, ns)
if err != nil {
return nil, err
}
}
return ctrl.makePayload(ctx, ns, err)
}

View File

@@ -485,6 +485,11 @@ func (svc namespace) ImportRun(ctx context.Context, sessionID uint64, dup *types
return err
}
newNS, err = store.LookupComposeNamespaceBySlug(ctx, s, newNS.Slug)
if err != nil {
return err
}
aProps.setNamespace(newNS)
return nil
})
@@ -493,6 +498,7 @@ func (svc namespace) ImportRun(ctx context.Context, sessionID uint64, dup *types
}
err = svc.reloadServices(ctx, newNS)
dup = newNS
return err
}()