github-vet / github-vet/rangeloop-pointer-findings
trek10inc/awsets: lister/eks_cluster.go; 78 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [trek10inc/awsets](https://www.github.com/trek10inc/awsets) at [lister/eks_cluster.go](https://github.com/trek10inc/awsets/blob/92e0054d69b0d5bd0c17536cb00404848a45f0b6/lister/eks_cluster.go#L49-L126)
Below is the message reported by the analyzer for this snippet of code. Beware that the analyzer only reports the first issue it finds, so please do not limit your consideration to the contents of the below message.
> reference to clusterName was used in a composite literal at line 51
[Click here to see the code in its original context.](https://github.com/trek10inc/awsets/blob/92e0054d69b0d5bd0c17536cb00404848a45f0b6/lister/eks_cluster.go#L49-L126)
Click here to show the 78 line(s) of Go which triggered the analyzer.
```go
for _, clusterName := range res.Clusters {
clusterRes, err := svc.DescribeCluster(ctx.Context, &eks.DescribeClusterInput{
Name: &clusterName,
})
if err != nil {
return nil, fmt.Errorf("failed to describe cluster %s: %w", clusterName, err)
}
cluster := clusterRes.Cluster
r := resource.New(ctx, resource.EksCluster, cluster.Name, cluster.Name, cluster)
r.AddARNRelation(resource.IamRole, cluster.RoleArn)
// Node groups
err = Paginator(func(nt2 *string) (*string, error) {
nodeGroups, err := svc.ListNodegroups(ctx.Context, &eks.ListNodegroupsInput{
ClusterName: &clusterName,
MaxResults: aws.Int32(100),
NextToken: nt2,
})
if err != nil {
return nil, fmt.Errorf("failed to list node groups for cluster %s: %w", clusterName, err)
}
for _, ngName := range nodeGroups.Nodegroups {
ngRes, err := svc.DescribeNodegroup(ctx.Context, &eks.DescribeNodegroupInput{
ClusterName: &clusterName,
NodegroupName: &ngName,
})
if err != nil {
return nil, fmt.Errorf("failed to describe node group %s for cluster %s: %w", ngName, clusterName, err)
}
ng := ngRes.Nodegroup
ngArn := arn.ParseP(ng.NodegroupArn)
ngResource := resource.New(ctx, resource.EksNodeGroup, ngArn.ResourceId, ng.NodegroupName, ng)
ngResource.AddRelation(resource.EksCluster, clusterName, "")
for _, sn := range ng.Subnets {
ngResource.AddRelation(resource.Ec2Subnet, sn, "")
}
rg.AddResource(ngResource)
}
return nodeGroups.NextToken, nil
})
if err != nil {
return nil, err
}
// Fargate profiles
err = Paginator(func(nt2 *string) (*string, error) {
profiles, err := svc.ListFargateProfiles(ctx.Context, &eks.ListFargateProfilesInput{
ClusterName: &clusterName,
NextToken: nt2,
})
if err != nil {
return nil, fmt.Errorf("failed to list fargate profiles for cluster %s: %w", clusterName, err)
}
for _, fpName := range profiles.FargateProfileNames {
fpRes, err := svc.DescribeFargateProfile(ctx.Context, &eks.DescribeFargateProfileInput{
ClusterName: &clusterName,
FargateProfileName: &fpName,
})
if err != nil {
return nil, fmt.Errorf("failed to describe fargate profile %s for cluster %s: %w", fpName, clusterName, err)
}
if fp := fpRes.FargateProfile; fp != nil {
fpResource := resource.New(ctx, resource.EksFargateProfile, fmt.Sprintf("%s-%s", clusterName, fpName), fp.FargateProfileName, fp)
for _, sn := range fp.Subnets {
fpResource.AddRelation(resource.Ec2Subnet, sn, "")
}
fpResource.AddARNRelation(resource.IamRole, fp.PodExecutionRoleArn)
fpResource.AddRelation(resource.EksCluster, clusterName, "")
rg.AddResource(fpResource)
}
}
return profiles.NextToken, nil
})
if err != nil {
return nil, err
}
rg.AddResource(r)
}
```
Leave a reaction on this issue to contribute to the project by classifying this instance as a **Bug** :-1:, **Mitigated** :+1:, or **Desirable Behavior** :rocket:
See the descriptions of the classifications [here](https://github.com/github-vet/rangeclosure-findings#how-can-i-help) for more information.
commit ID: 92e0054d69b0d5bd0c17536cb00404848a45f0b6
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.