(ctx context.Context, client gateway.IClientDriver)
| 283 | } |
| 284 | |
| 285 | func (i *imlAPIKeyModule) online(ctx context.Context, client gateway.IClientDriver) error { |
| 286 | |
| 287 | // 获取所有apikey |
| 288 | list, err := i.apikeyService.Search(ctx, "", nil, "create_at desc") |
| 289 | if err != nil { |
| 290 | return err |
| 291 | } |
| 292 | app := &gateway.ApplicationRelease{ |
| 293 | BasicItem: &gateway.BasicItem{ |
| 294 | ID: "apipark-global", |
| 295 | Description: "apipark global consumer", |
| 296 | Version: time.Now().Format("20060102150405"), |
| 297 | }, |
| 298 | Authorizations: utils.SliceToSlice(list, func(a *system_apikey.APIKey) *gateway.Authorization { |
| 299 | authCfg := map[string]interface{}{ |
| 300 | "apikey": utils.Md5(a.Value), |
| 301 | } |
| 302 | return &gateway.Authorization{ |
| 303 | Type: "apikey", |
| 304 | Position: "header", |
| 305 | TokenName: "Authorization", |
| 306 | Expire: a.Expired, |
| 307 | Config: authCfg, |
| 308 | HideCredential: true, |
| 309 | Label: map[string]string{ |
| 310 | "authorization": a.Id, |
| 311 | "authorization_name": a.Name, |
| 312 | }, |
| 313 | } |
| 314 | }), |
| 315 | } |
| 316 | err = client.Application().Online(ctx, app) |
| 317 | if err != nil { |
| 318 | return err |
| 319 | } |
| 320 | return nil |
| 321 | } |
| 322 | |
| 323 | func (i *imlAPIKeyModule) initGateway(ctx context.Context, clusterId string, clientDriver gateway.IClientDriver) error { |
| 324 | return i.online(ctx, clientDriver) |
no test coverage detected