-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.go
58 lines (47 loc) · 3.1 KB
/
test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package utils
import (
"github.com/equinor/radix-operator/pkg/apis/application"
"github.com/equinor/radix-operator/pkg/apis/applicationconfig"
"github.com/equinor/radix-operator/pkg/apis/deployment"
"github.com/equinor/radix-operator/pkg/apis/kube"
commontest "github.com/equinor/radix-operator/pkg/apis/test"
"github.com/equinor/radix-operator/pkg/apis/utils"
builders "github.com/equinor/radix-operator/pkg/apis/utils"
radixclient "github.com/equinor/radix-operator/pkg/client/clientset/versioned"
prometheusclient "github.com/prometheus-operator/prometheus-operator/pkg/client/versioned"
"k8s.io/client-go/kubernetes"
secretsstorevclient "sigs.k8s.io/secrets-store-csi-driver/pkg/client/clientset/versioned"
)
type clientSet struct {
client kubernetes.Interface
radixclient radixclient.Interface
promclient prometheusclient.Interface
commonTestUtils *commontest.Utils
secretproviderplient secretsstorevclient.Interface
}
// ApplyRegistrationWithSync syncs based on registration builder
func ApplyRegistrationWithSync(client kubernetes.Interface, radixclient radixclient.Interface, commonTestUtils *commontest.Utils, registrationBuilder utils.RegistrationBuilder) {
kubeUtils, _ := kube.New(client, radixclient, nil)
commonTestUtils.ApplyRegistration(registrationBuilder)
registration, _ := application.NewApplication(client, kubeUtils, radixclient, registrationBuilder.BuildRR())
registration.OnSync()
}
// ApplyApplicationWithSync syncs based on application builder, and default builder for registration.
func ApplyApplicationWithSync(client kubernetes.Interface, radixclient radixclient.Interface, commonTestUtils *commontest.Utils, applicationBuilder utils.ApplicationBuilder) {
registrationBuilder := applicationBuilder.GetRegistrationBuilder()
ApplyRegistrationWithSync(client, radixclient, commonTestUtils, registrationBuilder)
kubeUtils, _ := kube.New(client, radixclient, nil)
commonTestUtils.ApplyApplication(applicationBuilder)
applicationconfig, _ := applicationconfig.NewApplicationConfig(client, kubeUtils, radixclient, registrationBuilder.BuildRR(), applicationBuilder.BuildRA())
applicationconfig.OnSync()
}
// ApplyDeploymentWithSync syncs based on deployment builder, and default builders for application and registration.
func ApplyDeploymentWithSync(client kubernetes.Interface, radixclient radixclient.Interface, promclient prometheusclient.Interface, commonTestUtils *commontest.Utils, secretproviderclient secretsstorevclient.Interface, deploymentBuilder builders.DeploymentBuilder) {
applicationBuilder := deploymentBuilder.GetApplicationBuilder()
registrationBuilder := applicationBuilder.GetRegistrationBuilder()
ApplyApplicationWithSync(client, radixclient, commonTestUtils, applicationBuilder)
kubeUtils, _ := kube.New(client, radixclient, secretproviderclient)
rd, _ := commonTestUtils.ApplyDeployment(deploymentBuilder)
deployment := deployment.NewDeployment(client, kubeUtils, radixclient, promclient, registrationBuilder.BuildRR(), rd, false, "123456", []deployment.IngressAnnotationProvider{}, []deployment.AuxiliaryResourceManager{})
_ = deployment.OnSync()
}