Skip to content

When in IndexField to return keys or not #2915

Closed Answered by camilamacedo86
antonincms asked this question in Support
Discussion options

You must be logged in to vote

Hi @antonincms,

The purpose of indexing in the cache is to allow quick lookups based on certain fields' values. An indexed field will have a mapping from values of that field to the objects that have those values.

Considering your two scenarios:

Returning nil when ConfigMap is empty:

if err := mgr.GetFieldIndexer().IndexField(context.Background(), &appsv1.ConfigDeployment{}, configMapField, func(rawObj client.Object) []string {
    // Extract the ConfigMap name from the ConfigDeployment Spec, if one is provided
    configDeployment := rawObj.(*appsv1.ConfigDeployment)
    if configDeployment.Spec.ConfigMap == "" {
        return nil
    }
    return []string{configDeployment.Spec.ConfigMap}…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
3 replies
@antonincms
Comment options

@camilamacedo86
Comment options

Answer selected by camilamacedo86
@antonincms
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Support
Labels
None yet
2 participants