(r string, wg *sync.WaitGroup, semaphore chan struct{}, dataReceiver chan Endpoint)
| 481 | } |
| 482 | |
| 483 | func (m *EndpointsModule) getEksClustersPerRegion(r string, wg *sync.WaitGroup, semaphore chan struct{}, dataReceiver chan Endpoint) { |
| 484 | defer func() { |
| 485 | m.CommandCounter.DecrExecuting() |
| 486 | m.CommandCounter.IncrComplete() |
| 487 | wg.Done() |
| 488 | |
| 489 | }() |
| 490 | semaphore <- struct{}{} |
| 491 | defer func() { |
| 492 | <-semaphore |
| 493 | }() |
| 494 | // m.CommandCounter.IncrTotal() |
| 495 | m.CommandCounter.DecrPending() |
| 496 | m.CommandCounter.IncrExecuting() |
| 497 | // "PaginationMarker" is a control variable used for output continuity, as AWS return the output in pages. |
| 498 | |
| 499 | Clusters, err := sdk.CachedEKSListClusters(m.EKSClient, aws.ToString(m.Caller.Account), r) |
| 500 | if err != nil { |
| 501 | m.modLog.Error(err.Error()) |
| 502 | m.CommandCounter.IncrError() |
| 503 | return |
| 504 | } |
| 505 | |
| 506 | for _, cluster := range Clusters { |
| 507 | ClusterDetails, err := sdk.CachedEKSDescribeCluster(m.EKSClient, aws.ToString(m.Caller.Account), r, cluster) |
| 508 | |
| 509 | if err != nil { |
| 510 | if errors.As(err, &oe) { |
| 511 | m.Errors = append(m.Errors, fmt.Sprintf(" Error: Region: %s, Service: %s, Operation: %s", r, oe.Service(), oe.Operation())) |
| 512 | } |
| 513 | m.modLog.Error(err.Error()) |
| 514 | m.CommandCounter.IncrError() |
| 515 | continue |
| 516 | } |
| 517 | var endpoint string |
| 518 | var name string |
| 519 | var public string |
| 520 | vpcConfig := ClusterDetails.ResourcesVpcConfig.EndpointPublicAccess |
| 521 | if vpcConfig { |
| 522 | // |
| 523 | if ClusterDetails.ResourcesVpcConfig.PublicAccessCidrs[0] == "0.0.0.0/0" { |
| 524 | public = "True" |
| 525 | } else { |
| 526 | public = "False" |
| 527 | } |
| 528 | } |
| 529 | |
| 530 | endpoint = aws.ToString(ClusterDetails.Endpoint) |
| 531 | name = aws.ToString(ClusterDetails.Name) |
| 532 | dataReceiver <- Endpoint{ |
| 533 | AWSService: "Eks", |
| 534 | Region: r, |
| 535 | Name: name, |
| 536 | Endpoint: endpoint, |
| 537 | Port: 443, |
| 538 | Protocol: "https", |
| 539 | Public: public, |
| 540 | } |
no test coverage detected