-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make namespace parsing and creating informers pluggable
- Loading branch information
1 parent
4c9ac06
commit a4c30dc
Showing
8 changed files
with
150 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package options | ||
|
||
import ( | ||
mpijobclientset "github.com/kubeflow/mpi-operator/pkg/client/clientset/versioned" | ||
informers "github.com/kubeflow/mpi-operator/pkg/client/informers/externalversions" | ||
kubeinformers "k8s.io/client-go/informers" | ||
kubeclientset "k8s.io/client-go/kubernetes" | ||
schedclientset "sigs.k8s.io/scheduler-plugins/pkg/generated/clientset/versioned" | ||
schedinformers "sigs.k8s.io/scheduler-plugins/pkg/generated/informers/externalversions" | ||
volcanoclient "volcano.sh/apis/pkg/client/clientset/versioned" | ||
volcanoinformers "volcano.sh/apis/pkg/client/informers/externalversions" | ||
) | ||
|
||
type NamespaceParserFunc func(namespace string, kubeClient kubeclientset.Interface) ([]string, error) | ||
|
||
type NamespaceOptions struct { | ||
Namespaces NamespaceParserFunc | ||
} | ||
|
||
func DefaultNamespaceParser(namespace string, kubeClient kubeclientset.Interface) ([]string, error) { | ||
return []string{namespace}, nil | ||
} | ||
|
||
type KubeInformerFunc func(namespaces []string, kubeClient kubeclientset.Interface) kubeinformers.SharedInformerFactory | ||
type MpiJobInformerFunc func(namespaces []string, mpiJobClient mpijobclientset.Interface) informers.SharedInformerFactory | ||
type VolcanoInformerFunc func(namespaces []string, volcanoClient volcanoclient.Interface) volcanoinformers.SharedInformerFactory | ||
type SchedulerPluginsInformerFunc func(namespaces []string, schedClient schedclientset.Interface) schedinformers.SharedInformerFactory | ||
|
||
type InformerOptions struct { | ||
KubeInformer KubeInformerFunc | ||
MpiJobInformer MpiJobInformerFunc | ||
VolcanoInformer VolcanoInformerFunc | ||
SchedulerPluginsInformer SchedulerPluginsInformerFunc | ||
} | ||
type AdditionalOptions struct { | ||
NamespaceOptions | ||
InformerOptions | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package informers | ||
|
||
import ( | ||
mpijobclientset "github.com/kubeflow/mpi-operator/pkg/client/clientset/versioned" | ||
informers "github.com/kubeflow/mpi-operator/pkg/client/informers/externalversions" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
kubeinformers "k8s.io/client-go/informers" | ||
kubeclientset "k8s.io/client-go/kubernetes" | ||
schedclientset "sigs.k8s.io/scheduler-plugins/pkg/generated/clientset/versioned" | ||
schedinformers "sigs.k8s.io/scheduler-plugins/pkg/generated/informers/externalversions" | ||
volcanoclient "volcano.sh/apis/pkg/client/clientset/versioned" | ||
volcanoinformers "volcano.sh/apis/pkg/client/informers/externalversions" | ||
) | ||
|
||
func DefaultKubeInformer(namespaces []string, kubeClient kubeclientset.Interface) kubeinformers.SharedInformerFactory { | ||
var kubeInformerFactoryOpts []kubeinformers.SharedInformerOption | ||
if namespaces[0] != metav1.NamespaceAll { | ||
kubeInformerFactoryOpts = append(kubeInformerFactoryOpts, kubeinformers.WithNamespace(namespaces[0])) | ||
} | ||
|
||
return kubeinformers.NewSharedInformerFactoryWithOptions(kubeClient, 0, kubeInformerFactoryOpts...) | ||
} | ||
|
||
func DefaultMpiJobInformer(namespaces []string, mpiJobClient mpijobclientset.Interface) informers.SharedInformerFactory { | ||
var kubeflowInformerFactoryOpts []informers.SharedInformerOption | ||
if namespaces[0] != metav1.NamespaceAll { | ||
kubeflowInformerFactoryOpts = append(kubeflowInformerFactoryOpts, informers.WithNamespace(namespaces[0])) | ||
} | ||
|
||
return informers.NewSharedInformerFactoryWithOptions(mpiJobClient, 0, kubeflowInformerFactoryOpts...) | ||
} | ||
|
||
func DefaultVolcanoInformer(namespaces []string, volcanoClient volcanoclient.Interface) volcanoinformers.SharedInformerFactory { | ||
var informerFactoryOpts []volcanoinformers.SharedInformerOption | ||
if namespaces[0] != metav1.NamespaceAll { | ||
informerFactoryOpts = append(informerFactoryOpts, volcanoinformers.WithNamespace(namespaces[0])) | ||
} | ||
return volcanoinformers.NewSharedInformerFactoryWithOptions(volcanoClient, 0, informerFactoryOpts...) | ||
} | ||
|
||
func DefaultSchedulerPluginsInformer(namespaces []string, schedClient schedclientset.Interface) schedinformers.SharedInformerFactory { | ||
var informerFactoryOpts []schedinformers.SharedInformerOption | ||
if namespaces[0] != metav1.NamespaceAll { | ||
informerFactoryOpts = append(informerFactoryOpts, schedinformers.WithNamespace(namespaces[0])) | ||
} | ||
return schedinformers.NewSharedInformerFactoryWithOptions(schedClient, 0, informerFactoryOpts...) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters