Create an env using api

This commit is contained in:
2024-04-03 20:05:23 +02:00
parent b9a1fcd02a
commit affabc3c03
14 changed files with 213 additions and 76 deletions

View File

@ -14,7 +14,7 @@ func Create(ctx context.Context, client client.Client, obj client.Object, wait b
if err := client.Create(ctx, obj); err != nil {
return err
}
if wait{
if wait {
if err := WaitUntilCreated(ctx, client, obj, 10, time.Millisecond*50); err != nil {
return err
}
@ -23,13 +23,13 @@ func Create(ctx context.Context, client client.Client, obj client.Object, wait b
}
func SetOwnerRef(ctx context.Context, client client.Client, obj client.Object, owner client.Object) client.Object {
apiVersion := fmt.Sprintf("%s/%s", owner.GetObjectKind().GroupVersionKind().Group, owner.GetObjectKind().GroupVersionKind().Version)
apiVersion := fmt.Sprintf("%s/%s", owner.GetObjectKind().GroupVersionKind().Group, owner.GetObjectKind().GroupVersionKind().Version)
ownerReference := []metav1.OwnerReference{
{
APIVersion: apiVersion,
Kind: owner.GetObjectKind().GroupVersionKind().GroupKind().Kind,
Name: owner.GetName(),
UID: owner.GetUID(),
APIVersion: apiVersion,
Kind: owner.GetObjectKind().GroupVersionKind().GroupKind().Kind,
Name: owner.GetName(),
UID: owner.GetUID(),
},
}
obj.SetOwnerReferences(ownerReference)
@ -52,4 +52,3 @@ func WaitUntilCreated(ctx context.Context, client client.Client, obj client.Obje
}
return nil
}

View File

@ -1,12 +1,8 @@
package kube_test
import (
"testing"
"git.badhouseplants.net/softplayer/softplayer-backend/internal/helpers/kube"
"github.com/alecthomas/assert/v2"
)