forked from kyma-project/kyma
-
Notifications
You must be signed in to change notification settings - Fork 0
/
remote_environment.go
83 lines (73 loc) · 2.53 KB
/
remote_environment.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package suite
import (
"fmt"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/kyma-project/kyma/components/remote-environment-broker/pkg/apis/remoteenvironment/v1alpha1"
"github.com/kyma-project/kyma/components/remote-environment-broker/pkg/client/clientset/versioned"
"github.com/stretchr/testify/require"
)
func (ts *TestSuite) createRemoteEnvironmentResources() {
client, err := versioned.NewForConfig(ts.config)
require.NoError(ts.t, err)
displayName := fmt.Sprintf("acc-test-re-name-%s", ts.TestID)
rei := client.RemoteenvironmentV1alpha1().RemoteEnvironments()
_, err = rei.Create(fixRemoteEnvironment(ts.remoteEnvironmentName, ts.accessLabel, ts.osbServiceId, ts.gatewayUrl, displayName))
require.NoError(ts.t, err)
emi := client.RemoteenvironmentV1alpha1().EnvironmentMappings(ts.namespace)
_, err = emi.Create(fixEnvironmentMapping(ts.remoteEnvironmentName))
require.NoError(ts.t, err)
}
func (ts *TestSuite) deleteRemoteEnvironment() {
client, err := versioned.NewForConfig(ts.config)
require.NoError(ts.t, err)
rei := client.RemoteenvironmentV1alpha1().RemoteEnvironments()
err = rei.Delete(ts.remoteEnvironmentName, &metav1.DeleteOptions{})
require.NoError(ts.t, err)
}
func fixEnvironmentMapping(name string) *v1alpha1.EnvironmentMapping {
return &v1alpha1.EnvironmentMapping{
TypeMeta: metav1.TypeMeta{
Kind: "EnvironmentMapping",
APIVersion: "remoteenvironment.kyma.cx/v1alpha1",
},
ObjectMeta: metav1.ObjectMeta{
Name: name,
},
}
}
func fixRemoteEnvironment(name, accessLabel, serviceId, gatewayUrl, displayName string) *v1alpha1.RemoteEnvironment {
return &v1alpha1.RemoteEnvironment{
TypeMeta: metav1.TypeMeta{
Kind: "RemoteEnvironment",
APIVersion: "remoteenvironment.kyma.cx/v1alpha1",
},
ObjectMeta: metav1.ObjectMeta{
Name: name,
},
Spec: v1alpha1.RemoteEnvironmentSpec{
Source: v1alpha1.Source{
Namespace: "com.ns",
Type: "commerce",
Environment: "production",
},
AccessLabel: "re-access-label",
Description: "Remote Environment used by remote-environment acceptance test",
Services: []v1alpha1.Service{
{
ID: serviceId,
ProviderDisplayName: "provider",
DisplayName: displayName,
LongDescription: "Remote Environment Service Class used by remote-environment acceptance test",
Tags: []string{},
Entries: []v1alpha1.Entry{
{
Type: "API",
AccessLabel: accessLabel,
GatewayUrl: gatewayUrl,
},
},
},
},
},
}
}