@@ -72,7 +72,7 @@ const (
72
72
73
73
// SecretConvertor converts a kubernetes secret into a mobile.ServiceConfig
74
74
type SecretConvertor interface {
75
- Convert (s * Service ) (* ServiceConfig , error )
75
+ Convert (id string , params map [ string ] string ) (* ServiceConfig , error )
76
76
}
77
77
78
78
//ServiceConfigs are collection of configurations for services in a specific namespace
@@ -110,10 +110,10 @@ func (i ignoredFields) Contains(field string) bool {
110
110
var defaultIgnored = ignoredFields {"password" , "token" , "url" , "uri" , "name" , "type" , "id" }
111
111
112
112
//Convert a kubernetes secret to a mobile.ServiceConfig
113
- func (dsc defaultSecretConvertor ) Convert (s * Service ) (* ServiceConfig , error ) {
113
+ func (dsc defaultSecretConvertor ) Convert (id string , params map [ string ] string ) (* ServiceConfig , error ) {
114
114
config := map [string ]interface {}{}
115
115
headers := map [string ]string {}
116
- for k , v := range s . Params {
116
+ for k , v := range params {
117
117
if ! defaultIgnored .Contains (k ) {
118
118
config [k ] = string (v )
119
119
}
@@ -122,21 +122,21 @@ func (dsc defaultSecretConvertor) Convert(s *Service) (*ServiceConfig, error) {
122
122
config ["headers" ] = headers
123
123
}
124
124
return & ServiceConfig {
125
- ID : string ( s . ID ) ,
126
- Name : string ( s . Name ) ,
127
- URL : string ( s . Host ) ,
128
- Type : string ( s . Type ) ,
125
+ ID : id ,
126
+ Name : params [ "name" ] ,
127
+ URL : params [ "uri" ] ,
128
+ Type : params [ "type" ] ,
129
129
Config : config ,
130
130
}, nil
131
131
}
132
132
133
133
type keycloakSecretConvertor struct {}
134
134
135
135
//Convert a kubernetes keycloak secret into a keycloak mobile.ServiceConfig
136
- func (ksc keycloakSecretConvertor ) Convert (s * Service ) (* ServiceConfig , error ) {
136
+ func (ksc keycloakSecretConvertor ) Convert (id string , params map [ string ] string ) (* ServiceConfig , error ) {
137
137
config := map [string ]interface {}{}
138
138
headers := map [string ]string {}
139
- err := json .Unmarshal ([]byte (s . Params ["public_installation" ]), & config )
139
+ err := json .Unmarshal ([]byte (params ["public_installation" ]), & config )
140
140
if err != nil {
141
141
return nil , errors .Wrap (err , "failed to unmarshall keycloak configuration " )
142
142
}
@@ -145,25 +145,25 @@ func (ksc keycloakSecretConvertor) Convert(s *Service) (*ServiceConfig, error) {
145
145
}
146
146
return & ServiceConfig {
147
147
Config : config ,
148
- Name : string ( s . Name ) ,
149
- URL : string (s . Host ),
150
- Type : string (s . Type ),
151
- ID : string (s . ID ),
148
+ ID : id ,
149
+ Name : string (params [ "name" ] ),
150
+ URL : string (params [ "uri" ] ),
151
+ Type : string (params [ "type" ] ),
152
152
}, nil
153
153
}
154
154
155
155
type syncSecretConvertor struct {}
156
156
157
157
//Convert a kubernetes Sync Server secret into a keycloak mobile.ServiceConfig
158
- func (scc syncSecretConvertor ) Convert (s * Service ) (* ServiceConfig , error ) {
158
+ func (scc syncSecretConvertor ) Convert (id string , params map [ string ] string ) (* ServiceConfig , error ) {
159
159
config := map [string ]interface {}{
160
- "url" : s . Host ,
160
+ "url" : params [ "host" ] ,
161
161
}
162
162
headers := map [string ]string {}
163
163
164
- acAppID , acAppIDExists := s . Params ["apicast_app_id" ]
165
- acAppKey , acAppKeyExists := s . Params ["apicast_app_key" ]
166
- acRoute , acRouteExists := s . Params ["apicast_route" ]
164
+ acAppID , acAppIDExists := params ["apicast_app_id" ]
165
+ acAppKey , acAppKeyExists := params ["apicast_app_key" ]
166
+ acRoute , acRouteExists := params ["apicast_route" ]
167
167
if acAppIDExists && acAppKeyExists && acRouteExists {
168
168
headers ["app_id" ] = acAppID
169
169
headers ["app_key" ] = acAppKey
@@ -175,10 +175,10 @@ func (scc syncSecretConvertor) Convert(s *Service) (*ServiceConfig, error) {
175
175
176
176
return & ServiceConfig {
177
177
Config : config ,
178
- Name : string ( s . Name ) ,
179
- URL : string ( s . Host ) ,
180
- Type : string ( s . Type ) ,
181
- ID : string ( s . ID ) ,
178
+ ID : id ,
179
+ Name : params [ "name" ] ,
180
+ URL : params [ "uri" ] ,
181
+ Type : params [ "type" ] ,
182
182
}, nil
183
183
}
184
184
0 commit comments