* UNUSED CODE - PLEASE REVIEW AND DELETE IF IT DOESN'T APPLY func (m *EndpointsModule) getS3EndpointsPerRegion(wg *sync.WaitGroup, semaphore chan struct{}, dataReceiver chan Endpoint) { defer func() { m.CommandCounter.DecrExecuting() m.CommandCounter.IncrComplete() wg.Done() }() se
(wg *sync.WaitGroup, semaphore chan struct{}, dataReceiver chan Endpoint)
| 1433 | } |
| 1434 | */ |
| 1435 | func (m *EndpointsModule) getCloudfrontEndpoints(wg *sync.WaitGroup, semaphore chan struct{}, dataReceiver chan Endpoint) { |
| 1436 | defer func() { |
| 1437 | m.CommandCounter.DecrExecuting() |
| 1438 | m.CommandCounter.IncrComplete() |
| 1439 | wg.Done() |
| 1440 | |
| 1441 | }() |
| 1442 | semaphore <- struct{}{} |
| 1443 | defer func() { |
| 1444 | <-semaphore |
| 1445 | }() |
| 1446 | // m.CommandCounter.IncrTotal() |
| 1447 | m.CommandCounter.DecrPending() |
| 1448 | m.CommandCounter.IncrExecuting() |
| 1449 | // "PaginationMarker" is a control variable used for output continuity, as AWS return the output in pages. |
| 1450 | var PaginationControl *string |
| 1451 | var awsService = "Cloudfront" |
| 1452 | var protocol = "https" |
| 1453 | var r = "Global" |
| 1454 | var public = "True" |
| 1455 | |
| 1456 | // This for loop exits at the end depending on whether the output hits its last page (see pagination control block at the end of the loop). |
| 1457 | for { |
| 1458 | ListDistributions, err := m.CloudfrontClient.ListDistributions( |
| 1459 | context.TODO(), |
| 1460 | &cloudfront.ListDistributionsInput{ |
| 1461 | Marker: PaginationControl, |
| 1462 | }, |
| 1463 | ) |
| 1464 | if err != nil { |
| 1465 | if errors.As(err, &oe) { |
| 1466 | m.Errors = append(m.Errors, fmt.Sprintf(" Error: Region: %s, Service: %s, Operation: %s", r, oe.Service(), oe.Operation())) |
| 1467 | } |
| 1468 | m.modLog.Error(err.Error()) |
| 1469 | m.CommandCounter.IncrError() |
| 1470 | break |
| 1471 | } |
| 1472 | if ListDistributions.DistributionList.Quantity == nil { |
| 1473 | break |
| 1474 | } |
| 1475 | // var public string |
| 1476 | // var hostnames []string |
| 1477 | // var aliases []string |
| 1478 | // var origins []string |
| 1479 | |
| 1480 | for _, item := range ListDistributions.DistributionList.Items { |
| 1481 | name := aws.ToString(item.DomainName) |
| 1482 | public = "True" |
| 1483 | var port int32 = 443 |
| 1484 | endpoint := fmt.Sprintf("https://%s", aws.ToString(item.DomainName)) |
| 1485 | dataReceiver <- Endpoint{ |
| 1486 | AWSService: awsService, |
| 1487 | Region: r, |
| 1488 | Name: name, |
| 1489 | Endpoint: endpoint, |
| 1490 | Port: port, |
| 1491 | Protocol: protocol, |
| 1492 | Public: public, |
no test coverage detected