mirror of
https://github.com/projectcapsule/capsule.git
synced 2026-08-25 16:07:24 +00:00
* Updating to controller-runtime v0.7.0-alpha.4 and k8s 0.19.3 * Implementing ingresses.networking.k8s.io/v1 * Aligning to latest zap signatures
42 lines
1.0 KiB
Go
42 lines
1.0 KiB
Go
/*
|
|
Copyright 2020 Clastix Labs.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
package indexer
|
|
|
|
import (
|
|
"context"
|
|
|
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
|
"sigs.k8s.io/controller-runtime/pkg/manager"
|
|
)
|
|
|
|
type CustomIndexer interface {
|
|
Object() client.Object
|
|
Field() string
|
|
Func() client.IndexerFunc
|
|
}
|
|
|
|
var AddToIndexerFuncs []CustomIndexer
|
|
|
|
func AddToManager(m manager.Manager) error {
|
|
for _, f := range AddToIndexerFuncs {
|
|
if err := m.GetFieldIndexer().IndexField(context.TODO(), f.Object(), f.Field(), f.Func()); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|