Skip to content

Commit b0ae9c2

Browse files
Merge pull request #76 from mauriciozanettisalomao/feat/lfxv2-1317-resolver-org-website
[LFXV2-1317] Update search parameter from domain to website in organization-service
2 parents 4adecd2 + 5ad467a commit b0ae9c2

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

cmd/lfx-v1-sync-helper/lfx_v1_client.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -324,12 +324,12 @@ func getV1OrganizationFromOrgSvc(ctx context.Context, sfid string) (*V1Organizat
324324
return org, nil
325325
}
326326

327-
// searchV1OrgsByDomain searches for organizations in the v1 Organization Service by domain.
327+
// searchV1OrgsByWebsite searches for organizations in the v1 Organization Service by website.
328328
// Returns the first matching organization, or nil if none found.
329-
func searchV1OrgsByDomain(ctx context.Context, domain string) (*V1Organization, error) {
329+
func searchV1OrgsByWebsite(ctx context.Context, website string) (*V1Organization, error) {
330330
baseURL := fmt.Sprintf("%sorganization-service/v1/orgs/search", cfg.LFXAPIGateway.String())
331331
params := url.Values{}
332-
params.Set("domain", domain)
332+
params.Set("website", website)
333333
fullURL := baseURL + "?" + params.Encode()
334334

335335
req, err := http.NewRequestWithContext(ctx, http.MethodGet, fullURL, nil)
@@ -349,7 +349,7 @@ func searchV1OrgsByDomain(ctx context.Context, domain string) (*V1Organization,
349349
}
350350

351351
if resp.StatusCode != http.StatusOK {
352-
return nil, fmt.Errorf("org service returned status %d searching by domain=%q: %s", resp.StatusCode, domain, string(body))
352+
return nil, fmt.Errorf("org service returned status %d searching by website=%q: %s", resp.StatusCode, website, string(body))
353353
}
354354

355355
var listResp V1OrganizationListResponse
@@ -413,12 +413,12 @@ func createV1OrgInOrgSvc(ctx context.Context, name, website string) (*V1Organiza
413413
}, nil
414414
}
415415

416-
// resolveV1OrgID resolves a v1 Organization SFID by searching by domain first.
417-
// If not found and both name and domain are provided, it creates a new org.
416+
// resolveV1OrgID resolves a v1 Organization SFID by searching by website first.
417+
// If not found and both name and website are provided, it creates a new org.
418418
// Returns empty string (no error) if the org cannot be found and there is insufficient data to create one.
419-
func resolveV1OrgID(ctx context.Context, name, domain string) (string, error) {
420-
if domain != "" {
421-
org, err := searchV1OrgsByDomain(ctx, domain)
419+
func resolveV1OrgID(ctx context.Context, name, website string) (string, error) {
420+
if website != "" {
421+
org, err := searchV1OrgsByWebsite(ctx, website)
422422
if err != nil {
423423
return "", fmt.Errorf("org search failed: %w", err)
424424
}
@@ -427,13 +427,13 @@ func resolveV1OrgID(ctx context.Context, name, domain string) (string, error) {
427427
}
428428
}
429429

430-
if name == "" || domain == "" {
431-
logger.With("name", name, "domain", domain).
430+
if name == "" || website == "" {
431+
logger.With("name", name, "website", website).
432432
DebugContext(ctx, "insufficient data to create v1 organization, skipping org resolution")
433433
return "", nil
434434
}
435435

436-
created, err := createV1OrgInOrgSvc(ctx, name, domain)
436+
created, err := createV1OrgInOrgSvc(ctx, name, website)
437437
if err != nil {
438438
return "", fmt.Errorf("org create failed: %w", err)
439439
}

0 commit comments

Comments
 (0)