@@ -20,6 +20,7 @@ import (
20
20
21
21
corev1 "k8s.io/api/core/v1"
22
22
23
+ liqov1beta1 "github.com/liqotech/liqo/apis/core/v1beta1"
23
24
nwforge "github.com/liqotech/liqo/pkg/liqo-controller-manager/networking/forge"
24
25
"github.com/liqotech/liqo/pkg/liqoctl/authenticate"
25
26
"github.com/liqotech/liqo/pkg/liqoctl/factory"
@@ -40,6 +41,7 @@ type Options struct {
40
41
41
42
// Networking options
42
43
NetworkingDisabled bool
44
+ ServerServiceLocation * argsutils.StringEnum
43
45
ServerServiceType * argsutils.StringEnum
44
46
ServerServicePort int32
45
47
ServerServiceNodePort int32
@@ -65,6 +67,9 @@ type Options struct {
65
67
func NewOptions (localFactory * factory.Factory ) * Options {
66
68
return & Options {
67
69
LocalFactory : localFactory ,
70
+ ServerServiceLocation : argsutils .NewEnum (
71
+ []string {string (liqov1beta1 .ConsumerRole ), string (liqov1beta1 .ProviderRole )},
72
+ string (nwforge .DefaultGwServerLocation )),
68
73
ServerServiceType : argsutils .NewEnum (
69
74
[]string {string (corev1 .ServiceTypeLoadBalancer ), string (corev1 .ServiceTypeNodePort ), string (corev1 .ServiceTypeClusterIP )},
70
75
string (nwforge .DefaultGwServerServiceType )),
@@ -109,25 +114,34 @@ func (o *Options) RunPeer(ctx context.Context) error {
109
114
}
110
115
111
116
func ensureNetworking (ctx context.Context , o * Options ) error {
117
+ localFactory := o .LocalFactory
118
+ remoteFactory := o .RemoteFactory
119
+
120
+ // Invert the local and remote factories if the server service position is Consumer.
121
+ if o .ServerServiceLocation .Value == string (liqov1beta1 .ConsumerRole ) {
122
+ localFactory = o .RemoteFactory
123
+ remoteFactory = o .LocalFactory
124
+ }
125
+
112
126
networkOptions := network.Options {
113
- LocalFactory : o . LocalFactory ,
114
- RemoteFactory : o . RemoteFactory ,
127
+ LocalFactory : localFactory ,
128
+ RemoteFactory : remoteFactory ,
115
129
116
130
Timeout : o .Timeout ,
117
131
Wait : true ,
118
132
SkipValidation : o .SkipValidation ,
119
133
120
134
ServerGatewayType : nwforge .DefaultGwServerType ,
121
135
ServerTemplateName : nwforge .DefaultGwServerTemplateName ,
122
- ServerTemplateNamespace : o . RemoteFactory .LiqoNamespace ,
136
+ ServerTemplateNamespace : remoteFactory .LiqoNamespace ,
123
137
ServerServiceType : o .ServerServiceType ,
124
138
ServerServicePort : o .ServerServicePort ,
125
139
ServerServiceNodePort : o .ServerServiceNodePort ,
126
140
ServerServiceLoadBalancerIP : o .ServerServiceLoadBalancerIP ,
127
141
128
142
ClientGatewayType : nwforge .DefaultGwClientType ,
129
143
ClientTemplateName : nwforge .DefaultGwClientTemplateName ,
130
- ClientTemplateNamespace : o . LocalFactory .LiqoNamespace ,
144
+ ClientTemplateNamespace : localFactory .LiqoNamespace ,
131
145
ClientConnectAddress : o .ClientConnectAddress ,
132
146
ClientConnectPort : o .ClientConnectPort ,
133
147
0 commit comments