diff --git a/controllers/helpers.go b/controllers/helpers.go index 4efe8a521e..f404792692 100644 --- a/controllers/helpers.go +++ b/controllers/helpers.go @@ -200,8 +200,7 @@ func GetPEUUID(ctx context.Context, client *prismclientv3.Client, peName, peUUID } return *peIntentResponse.Metadata.UUID, nil } else if peName != nil && *peName != "" { - filter := getFilterForName(*peName) - responsePEs, err := client.V3.ListAllCluster(ctx, filter) + responsePEs, err := client.V3.ListAllCluster(ctx, "") if err != nil { return "", err } @@ -209,7 +208,7 @@ func GetPEUUID(ctx context.Context, client *prismclientv3.Client, peName, peUUID foundPEs := make([]*prismclientv3.ClusterIntentResponse, 0) for _, s := range responsePEs.Entities { peSpec := s.Spec - if *peSpec.Name == *peName && hasPEClusterServiceEnabled(s, serviceNamePECluster) { + if strings.EqualFold(*peSpec.Name, *peName) && hasPEClusterServiceEnabled(s, serviceNamePECluster) { foundPEs = append(foundPEs, s) } } @@ -261,10 +260,9 @@ func GetSubnetUUID(ctx context.Context, client *prismclientv3.Client, peUUID str } } foundSubnetUUID = *subnetIntentResponse.Metadata.UUID - } else if subnetName != nil { - filter := getFilterForName(*subnetName) + } else { // else search by name // Not using additional filtering since we want to list overlay and vlan subnets - responseSubnets, err := client.V3.ListAllSubnet(ctx, filter, nil) + responseSubnets, err := client.V3.ListAllSubnet(ctx, "", nil) if err != nil { return "", err } @@ -274,7 +272,7 @@ func GetSubnetUUID(ctx context.Context, client *prismclientv3.Client, peUUID str if subnet == nil || subnet.Spec == nil || subnet.Spec.Name == nil || subnet.Spec.Resources == nil || subnet.Spec.Resources.SubnetType == nil { continue } - if *subnet.Spec.Name == *subnetName { + if strings.EqualFold(*subnet.Spec.Name, *subnetName) { if *subnet.Spec.Resources.SubnetType == subnetTypeOverlay { // Overlay subnets are present on all PEs managed by PC. foundSubnets = append(foundSubnets, subnet) @@ -315,9 +313,8 @@ func GetImageUUID(ctx context.Context, client *prismclientv3.Client, imageName, } } foundImageUUID = *imageIntentResponse.Metadata.UUID - } else if imageName != nil { - filter := getFilterForName(*imageName) - responseImages, err := client.V3.ListAllImage(ctx, filter) + } else { // else search by name + responseImages, err := client.V3.ListAllImage(ctx, "") if err != nil { return "", err } @@ -325,7 +322,7 @@ func GetImageUUID(ctx context.Context, client *prismclientv3.Client, imageName, foundImages := make([]*prismclientv3.ImageIntentResponse, 0) for _, s := range responseImages.Entities { imageSpec := s.Spec - if *imageSpec.Name == *imageName { + if strings.EqualFold(*imageSpec.Name, *imageName) { foundImages = append(foundImages, s) } } @@ -636,16 +633,15 @@ func GetProjectUUID(ctx context.Context, client *prismclientv3.Client, projectNa } } foundProjectUUID = *projectIntentResponse.Metadata.UUID - } else if projectName != nil { - filter := getFilterForName(*projectName) - responseProjects, err := client.V3.ListAllProject(ctx, filter) + } else { // else search by name + responseProjects, err := client.V3.ListAllProject(ctx, "") if err != nil { return "", err } foundProjects := make([]*prismclientv3.Project, 0) for _, s := range responseProjects.Entities { projectSpec := s.Spec - if projectSpec.Name == *projectName { + if strings.EqualFold(projectSpec.Name, *projectName) { foundProjects = append(foundProjects, s) } } @@ -663,10 +659,6 @@ func GetProjectUUID(ctx context.Context, client *prismclientv3.Client, projectNa return foundProjectUUID, nil } -func getFilterForName(name string) string { - return fmt.Sprintf("name==%s", name) -} - func hasPEClusterServiceEnabled(peCluster *prismclientv3.ClusterIntentResponse, serviceName string) bool { if peCluster.Status == nil || peCluster.Status.Resources == nil ||