Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(bug): Remove FIQL based filters from list calls #485

Merged
merged 2 commits into from
Oct 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 11 additions & 19 deletions controllers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,16 +200,15 @@
}
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, "")

Check warning on line 203 in controllers/helpers.go

View check run for this annotation

Codecov / codecov/patch

controllers/helpers.go#L203

Added line #L203 was not covered by tests
if err != nil {
return "", err
}
// Validate filtered PEs
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) {

Check warning on line 211 in controllers/helpers.go

View check run for this annotation

Codecov / codecov/patch

controllers/helpers.go#L211

Added line #L211 was not covered by tests
foundPEs = append(foundPEs, s)
}
}
Expand Down Expand Up @@ -261,10 +260,9 @@
}
}
foundSubnetUUID = *subnetIntentResponse.Metadata.UUID
} else if subnetName != nil {
filter := getFilterForName(*subnetName)
} else { // else search by name

Check warning on line 263 in controllers/helpers.go

View check run for this annotation

Codecov / codecov/patch

controllers/helpers.go#L263

Added line #L263 was not covered by tests
// 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)

Check warning on line 265 in controllers/helpers.go

View check run for this annotation

Codecov / codecov/patch

controllers/helpers.go#L265

Added line #L265 was not covered by tests
if err != nil {
return "", err
}
Expand All @@ -274,7 +272,7 @@
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) {

Check warning on line 275 in controllers/helpers.go

View check run for this annotation

Codecov / codecov/patch

controllers/helpers.go#L275

Added line #L275 was not covered by tests
if *subnet.Spec.Resources.SubnetType == subnetTypeOverlay {
// Overlay subnets are present on all PEs managed by PC.
foundSubnets = append(foundSubnets, subnet)
Expand Down Expand Up @@ -315,17 +313,16 @@
}
}
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, "")

Check warning on line 317 in controllers/helpers.go

View check run for this annotation

Codecov / codecov/patch

controllers/helpers.go#L316-L317

Added lines #L316 - L317 were not covered by tests
if err != nil {
return "", err
}
// Validate filtered Images
foundImages := make([]*prismclientv3.ImageIntentResponse, 0)
for _, s := range responseImages.Entities {
imageSpec := s.Spec
if *imageSpec.Name == *imageName {
if strings.EqualFold(*imageSpec.Name, *imageName) {

Check warning on line 325 in controllers/helpers.go

View check run for this annotation

Codecov / codecov/patch

controllers/helpers.go#L325

Added line #L325 was not covered by tests
foundImages = append(foundImages, s)
}
}
Expand Down Expand Up @@ -636,16 +633,15 @@
}
}
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, "")

Check warning on line 637 in controllers/helpers.go

View check run for this annotation

Codecov / codecov/patch

controllers/helpers.go#L636-L637

Added lines #L636 - L637 were not covered by tests
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) {

Check warning on line 644 in controllers/helpers.go

View check run for this annotation

Codecov / codecov/patch

controllers/helpers.go#L644

Added line #L644 was not covered by tests
foundProjects = append(foundProjects, s)
}
}
Expand All @@ -663,10 +659,6 @@
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 ||
Expand Down
Loading