From 8c8cdd37bf3d5f9d2aa85ab1694ff0e3aba1ce34 Mon Sep 17 00:00:00 2001 From: Christer Edvartsen Date: Fri, 5 Apr 2024 13:23:46 +0200 Subject: [PATCH] set ID on the SQL instance --- internal/k8s/naisjobs.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/k8s/naisjobs.go b/internal/k8s/naisjobs.go index f9a575edb..d597b5b33 100644 --- a/internal/k8s/naisjobs.go +++ b/internal/k8s/naisjobs.go @@ -79,7 +79,7 @@ func (c *Client) NaisJob(ctx context.Context, name, team, env string) (*model.Na return nil, c.error(ctx, err, "getting topics") } - storage, err := naisjobStorage(obj.(*unstructured.Unstructured), topics) + storage, err := naisjobStorage(obj.(*unstructured.Unstructured), topics, env) if err != nil { return nil, c.error(ctx, err, "getting storage") } @@ -617,7 +617,7 @@ func (c *Client) ToNaisJob(u *unstructured.Unstructured, env string) (*model.Nai return ret, nil } -func naisjobStorage(u *unstructured.Unstructured, topics []*model.Topic) ([]model.Storage, error) { +func naisjobStorage(u *unstructured.Unstructured, topics []*model.Topic, env string) ([]model.Storage, error) { naisjob := &naisv1.Naisjob{} if err := runtime.DefaultUnstructuredConverter.FromUnstructured(u.Object, naisjob); err != nil { return nil, fmt.Errorf("converting to application: %w", err) @@ -641,6 +641,7 @@ func naisjobStorage(u *unstructured.Unstructured, topics []*model.Topic) ([]mode if sqlInstance.Name == "" { sqlInstance.Name = naisjob.Name } + sqlInstance.ID = scalar.SqlInstanceIdent("sqlInstance_" + env + "_" + naisjob.GetNamespace() + "_" + sqlInstance.GetName()) ret = append(ret, sqlInstance) }