@@ -2,6 +2,8 @@ package setup
22
33import (
44 "context"
5+ "embed"
6+ "os"
57
68 apimachinerytypes "k8s.io/apimachinery/pkg/types"
79 "k8s.io/klog/v2"
@@ -13,10 +15,14 @@ import (
1315 "sigs.k8s.io/e2e-framework/pkg/types"
1416 "sigs.k8s.io/e2e-framework/support/kind"
1517
18+ "github.com/openmcp-project/openmcp-testing/internal"
1619 "github.com/openmcp-project/openmcp-testing/pkg/providers"
1720 "github.com/openmcp-project/openmcp-testing/pkg/resources"
1821)
1922
23+ //go:embed config/*
24+ var configFS embed.FS
25+
2026type OpenMCPSetup struct {
2127 Namespace string
2228 Operator OpenMCPOperatorSetup
@@ -36,28 +42,33 @@ type OpenMCPOperatorSetup struct {
3642
3743// Bootstrap sets up a the minimum set of components of an openMCP installation
3844func (s * OpenMCPSetup ) Bootstrap (testenv env.Environment ) error {
45+ kindConfig := internal .MustTmpFileFromEmbedFS (configFS , "config/kind-config.yaml" )
46+ operatorTemplate := internal .MustTmpFileFromEmbedFS (configFS , "config/operator.yaml.tmpl" )
3947 platformClusterName := envconf .RandomName ("platform" , 16 )
4048 s .Operator .Namespace = s .Namespace
41- testenv .Setup (createPlatformCluster (platformClusterName )).
49+ testenv .Setup (createPlatformCluster (platformClusterName , kindConfig )).
4250 Setup (envfuncs .CreateNamespace (s .Namespace )).
43- Setup (s .installOpenMCPOperator ()).
51+ Setup (s .installOpenMCPOperator (operatorTemplate )).
4452 Setup (s .installClusterProviders ()).
4553 Setup (s .loadServiceProviderImages (platformClusterName )).
4654 Setup (s .installServiceProviders ()).
4755 Setup (s .verifyEnvironment ()).
48- Finish (s .cleanup ()).
56+ Finish (s .cleanup (kindConfig , operatorTemplate )).
4957 Finish (envfuncs .DestroyCluster (platformClusterName ))
5058 return nil
5159}
5260
53- func createPlatformCluster (name string ) types.EnvFunc {
61+ func createPlatformCluster (name string , kindConfig string ) types.EnvFunc {
5462 klog .Info ("create platform cluster..." )
55- return envfuncs .CreateClusterWithConfig (kind .NewProvider (), name , "../pkg/setup/kind/config.yaml" )
63+ return envfuncs .CreateClusterWithConfig (kind .NewProvider (), name , kindConfig )
5664}
5765
58- func (s * OpenMCPSetup ) cleanup () types.EnvFunc {
66+ func (s * OpenMCPSetup ) cleanup (tmpFiles ... string ) types.EnvFunc {
5967 return func (ctx context.Context , c * envconf.Config ) (context.Context , error ) {
6068 klog .Info ("cleaning up environment..." )
69+ for _ , f := range tmpFiles {
70+ os .RemoveAll (f )
71+ }
6172 for _ , sp := range s .ServiceProviders {
6273 if err := providers .DeleteServiceProvider (ctx , c , sp .Name , sp .WaitOpts ... ); err != nil {
6374 klog .Errorf ("delete service provider failed: %v" , err )
@@ -83,10 +94,10 @@ func (s *OpenMCPSetup) verifyEnvironment() types.EnvFunc {
8394 }
8495}
8596
86- func (s * OpenMCPSetup ) installOpenMCPOperator () types.EnvFunc {
97+ func (s * OpenMCPSetup ) installOpenMCPOperator (tmpl string ) types.EnvFunc {
8798 return func (ctx context.Context , c * envconf.Config ) (context.Context , error ) {
8899 // apply openmcp operator manifests
89- if _ , err := resources .CreateObjectsFromTemplateFile (ctx , c , "../pkg/setup/templates/openmcp-operator.yaml. tmpl" , s .Operator ); err != nil {
100+ if _ , err := resources .CreateObjectsFromTemplateFile (ctx , c , tmpl , s .Operator ); err != nil {
90101 return ctx , err
91102 }
92103 // wait for deployment to be ready
0 commit comments