1- package test
1+ package e2eutils
22
33import (
44 "context"
5+ "e2eutils/pkg/argo"
56 "errors"
7+ "log/slog"
8+ "reflect"
9+ "strings"
10+ "time"
11+
612 snapshotv1 "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1"
713 appsv1 "k8s.io/api/apps/v1"
814 corev1 "k8s.io/api/core/v1"
915 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1016 "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
1117 "k8s.io/apimachinery/pkg/runtime"
1218 "k8s.io/apimachinery/pkg/runtime/schema"
13- "k8s.io/client-go/discovery"
1419 "k8s.io/client-go/dynamic"
1520 "k8s.io/client-go/kubernetes"
16- "k8s.io/client-go/rest"
17- "log/slog"
18- "reflect"
1921 "sigs.k8s.io/e2e-framework/klient"
2022 "sigs.k8s.io/e2e-framework/klient/k8s"
2123 "sigs.k8s.io/e2e-framework/klient/wait"
2224 "sigs.k8s.io/e2e-framework/klient/wait/conditions"
23- "sigs.k8s.io/e2e-framework/pkg/envconf"
24- "strings"
25- "test/test/pkg/argo"
26- "test/test/pkg/git"
27- "test/test/pkg/helm"
28- "test/test/pkg/manifest"
29- "time"
3025)
3126
32- func PrepareTest (gitRepository string , applicationYaml string ) (argo.Application , argo.Application , []k8s.Object , error ) {
33- currGitBranch , err := git . GetCurrentGitBranch ()
27+ func PrepareArgoApp (gitRepository string , applicationYaml string ) (argo.Application , argo.Application , []k8s.Object , error ) {
28+ currGitBranch , err := GetCurrentGitBranch ()
3429 if err != nil {
3530 return argo.Application {}, argo.Application {}, nil , err
3631 }
@@ -41,7 +36,7 @@ func PrepareTest(gitRepository string, applicationYaml string) (argo.Application
4136 return argo.Application {}, argo.Application {}, nil , err
4237 }
4338
44- objects , err := manifest . GetKubernetesManifests (current )
39+ objects , err := GetKubernetesManifests (current )
4540 if err != nil {
4641 return current , argo.Application {}, nil , err
4742 }
@@ -54,7 +49,7 @@ func PrepareTest(gitRepository string, applicationYaml string) (argo.Application
5449 return argo.Application {}, argo.Application {}, nil , err
5550 }
5651
57- objects , err := manifest . GetKubernetesManifests (update )
52+ objects , err := GetKubernetesManifests (update )
5853 if err != nil {
5954 return argo.Application {}, argo.Application {}, nil , err
6055 }
@@ -78,16 +73,16 @@ func PrepareTest(gitRepository string, applicationYaml string) (argo.Application
7873}
7974
8075func deployHelmChart (applicationSource argo.ApplicationSource , namespace string , kubeConfigFile string ) error {
81- helmMgr := helm . GetHelmManager (kubeConfigFile )
76+ helmMgr := GetHelmManager (kubeConfigFile )
8277
8378 if ! strings .Contains (applicationSource .RepoURL , "oci://" ) {
84- err := helm . AddHelmRepository (helmMgr , applicationSource .RepoURL , applicationSource .Chart )
79+ err := AddHelmRepository (helmMgr , applicationSource .RepoURL , applicationSource .Chart )
8580 if err != nil {
8681 return err
8782 }
8883 }
8984
90- err := helm . DeployHelmChart (helmMgr , applicationSource , namespace )
85+ err := DeployHelmChart (helmMgr , applicationSource , namespace )
9186 if err != nil {
9287 return err
9388 }
@@ -124,36 +119,6 @@ func DeployHelmCharts(kubeConfigFile string, argoApplication argo.Application) e
124119 return nil
125120}
126121
127- func GetClient () (klient.Client , error ) {
128- cfg := envconf.Config {}
129- return cfg .Client (), nil
130- }
131-
132- func GetRestConfig () * rest.Config {
133- client , _ := GetClient ()
134- return client .RESTConfig ()
135- }
136-
137- func GetClientSet () (* kubernetes.Clientset , error ) {
138- kubeConfig := GetRestConfig ()
139- clientSet , err := kubernetes .NewForConfig (kubeConfig )
140- if err != nil {
141- return nil , err
142- }
143-
144- return clientSet , nil
145- }
146-
147- func GetDynClient () (* dynamic.DynamicClient , error ) {
148- kubeConfig := GetRestConfig ()
149- return dynamic .NewForConfig (kubeConfig )
150- }
151-
152- func GetDiscoveryClient () (* discovery.DiscoveryClient , error ) {
153- kubeConfig := GetRestConfig ()
154- return discovery .NewDiscoveryClientForConfig (kubeConfig )
155- }
156-
157122func CheckJobsCompleted (ctx context.Context , client klient.Client , namespace string ) error {
158123 kubeConfig := client .RESTConfig ()
159124 clientSet , err := kubernetes .NewForConfig (kubeConfig )
0 commit comments