Skip to content

Commit

Permalink
maybe now I understand api group conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
louiseschmidtgen committed Jun 20, 2024
1 parent 164fb97 commit 854f205
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions src/k8s/pkg/k8sd/features/contour/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,28 +49,22 @@ func waitForRequiredContourCommonCRDs(ctx context.Context, snap snap.Snap) error
}

return control.WaitUntilReady(ctx, func() (bool, error) {
resourcesV1Alpha, err := client.ListResourcesForGroupVersion("projectcontour.io/v1alpha1")
resources, err := client.ListResourcesForGroupVersion("projectcontour.io")
if err != nil {
// This error is expected if the group version is not yet deployed.
return false, nil
}
resourcesV1, err := client.ListResourcesForGroupVersion("projectcontour.io/v1")
if err != nil {
// This error is expected if the group version is not yet deployed.
return false, nil
}
combinedAPIResources := append(resourcesV1Alpha.APIResources, resourcesV1.APIResources...)

requiredCRDs := map[string]bool{
"projectcontour.io/v1alpha1:contourconfigurations.projectcontour.io": true,
"projectcontour.io/v1alpha1:contourdeployments.projectcontour.io": true,
"projectcontour.io/v1alpha1:extensionservices.projectcontour.io": true,
"projectcontour.io/v1:tlscertificatedelegations.projectcontour.io": true,
"projectcontour.io/v1:httpproxies.projectcontour.io": true,
"contourconfigurations": true,
"contourdeployments": true,
"extensionservices": true,
"tlscertificatedelegations": true,
"httpproxies": true,
}

requiredCount := len(requiredCRDs)
for _, resource := range combinedAPIResources {
for _, resource := range resources.APIResources {
if _, exists := requiredCRDs[fmt.Sprintf("%s:%s", resource.Group, resource.Name)]; exists {
requiredCount--
}
Expand Down

0 comments on commit 854f205

Please sign in to comment.