Create an env using api
This commit is contained in:
@ -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
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,8 @@
|
||||
package kube_test
|
||||
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"git.badhouseplants.net/softplayer/softplayer-backend/internal/helpers/kube"
|
||||
"github.com/alecthomas/assert/v2"
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user