本文整理汇总了Golang中github.com/openshift/origin/pkg/deploy/reaper.NewDeploymentConfigReaper函数的典型用法代码示例。如果您正苦于以下问题:Golang NewDeploymentConfigReaper函数的具体用法?Golang NewDeploymentConfigReaper怎么用?Golang NewDeploymentConfigReaper使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewDeploymentConfigReaper函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: NewFactory
//.........这里部分代码省略.........
if err != nil {
return nil, fmt.Errorf("unable to load a client %s: %v", mapping.GroupVersionKind.Kind, err)
}
describer, ok := describe.DescriberFor(mapping.GroupVersionKind.GroupKind(), oClient, kClient, cfg.Host)
if !ok {
return nil, fmt.Errorf("no description has been implemented for %q", mapping.GroupVersionKind.Kind)
}
return describer, nil
}
return kDescriberFunc(mapping)
}
kScalerFunc := w.Factory.Scaler
w.Scaler = func(mapping *meta.RESTMapping) (kubectl.Scaler, error) {
oc, kc, err := w.Clients()
if err != nil {
return nil, err
}
if mapping.GroupVersionKind.GroupKind() == deployapi.Kind("DeploymentConfig") {
return deployscaler.NewDeploymentConfigScaler(oc, kc), nil
}
return kScalerFunc(mapping)
}
kReaperFunc := w.Factory.Reaper
w.Reaper = func(mapping *meta.RESTMapping) (kubectl.Reaper, error) {
oc, kc, err := w.Clients()
if err != nil {
return nil, err
}
switch mapping.GroupVersionKind.GroupKind() {
case deployapi.Kind("DeploymentConfig"):
return deployreaper.NewDeploymentConfigReaper(oc, kc), nil
case authorizationapi.Kind("Role"):
return authorizationreaper.NewRoleReaper(oc, oc), nil
case authorizationapi.Kind("ClusterRole"):
return authorizationreaper.NewClusterRoleReaper(oc, oc, oc), nil
case userapi.Kind("User"):
return authenticationreaper.NewUserReaper(
client.UsersInterface(oc),
client.GroupsInterface(oc),
client.ClusterRoleBindingsInterface(oc),
client.RoleBindingsNamespacer(oc),
kclient.SecurityContextConstraintsInterface(kc),
), nil
case userapi.Kind("Group"):
return authenticationreaper.NewGroupReaper(
client.GroupsInterface(oc),
client.ClusterRoleBindingsInterface(oc),
client.RoleBindingsNamespacer(oc),
kclient.SecurityContextConstraintsInterface(kc),
), nil
case buildapi.Kind("BuildConfig"):
return buildreaper.NewBuildConfigReaper(oc), nil
}
return kReaperFunc(mapping)
}
kGenerators := w.Factory.Generators
w.Generators = func(cmdName string) map[string]kubectl.Generator {
originGenerators := DefaultGenerators(cmdName)
kubeGenerators := kGenerators(cmdName)
ret := map[string]kubectl.Generator{}
for k, v := range kubeGenerators {
ret[k] = v
示例2: NewFactory
// NewFactory creates an object that holds common methods across all OpenShift commands
func NewFactory(clientConfig kclientcmd.ClientConfig) *Factory {
mapper := ShortcutExpander{RESTMapper: kubectl.ShortcutExpander{RESTMapper: latest.RESTMapper}}
clients := &clientCache{
clients: make(map[string]*client.Client),
configs: make(map[string]*kclient.Config),
loader: clientConfig,
}
generators := map[string]kubectl.Generator{
"route/v1": routegen.RouteGenerator{},
"run/v1": deploygen.BasicDeploymentConfigController{},
"run-controller/v1": kubectl.BasicReplicationController{},
}
w := &Factory{
Factory: cmdutil.NewFactory(clientConfig),
OpenShiftClientConfig: clientConfig,
clients: clients,
}
w.Object = func() (meta.RESTMapper, runtime.ObjectTyper) {
// Output using whatever version was negotiated in the client cache. The
// version we decode with may not be the same as what the server requires.
if cfg, err := clients.ClientConfigForVersion(""); err == nil {
return kubectl.OutputVersionMapper{RESTMapper: mapper, OutputVersion: cfg.Version}, api.Scheme
}
return mapper, api.Scheme
}
kRESTClient := w.Factory.RESTClient
w.RESTClient = func(mapping *meta.RESTMapping) (resource.RESTClient, error) {
if latest.OriginKind(mapping.Kind, mapping.APIVersion) {
client, err := clients.ClientForVersion(mapping.APIVersion)
if err != nil {
return nil, err
}
return client.RESTClient, nil
}
return kRESTClient(mapping)
}
// Save original Describer function
kDescriberFunc := w.Factory.Describer
w.Describer = func(mapping *meta.RESTMapping) (kubectl.Describer, error) {
if latest.OriginKind(mapping.Kind, mapping.APIVersion) {
oClient, kClient, err := w.Clients()
if err != nil {
return nil, fmt.Errorf("unable to create client %s: %v", mapping.Kind, err)
}
cfg, err := clients.ClientConfigForVersion(mapping.APIVersion)
if err != nil {
return nil, fmt.Errorf("unable to load a client %s: %v", mapping.Kind, err)
}
describer, ok := describe.DescriberFor(mapping.Kind, oClient, kClient, cfg.Host)
if !ok {
return nil, fmt.Errorf("no description has been implemented for %q", mapping.Kind)
}
return describer, nil
}
return kDescriberFunc(mapping)
}
kScalerFunc := w.Factory.Scaler
w.Scaler = func(mapping *meta.RESTMapping) (kubectl.Scaler, error) {
oc, kc, err := w.Clients()
if err != nil {
return nil, err
}
if mapping.Kind == "DeploymentConfig" {
return deployscaler.NewDeploymentConfigScaler(oc, kc), nil
}
return kScalerFunc(mapping)
}
kReaperFunc := w.Factory.Reaper
w.Reaper = func(mapping *meta.RESTMapping) (kubectl.Reaper, error) {
oc, kc, err := w.Clients()
if err != nil {
return nil, err
}
switch mapping.Kind {
case "DeploymentConfig":
return deployreaper.NewDeploymentConfigReaper(oc, kc), nil
case "Role":
return authorizationreaper.NewRoleReaper(oc, oc), nil
case "ClusterRole":
return authorizationreaper.NewClusterRoleReaper(oc, oc, oc), nil
case "User":
return authenticationreaper.NewUserReaper(
client.UsersInterface(oc),
client.GroupsInterface(oc),
client.ClusterRoleBindingsInterface(oc),
client.RoleBindingsNamespacer(oc),
kclient.SecurityContextConstraintsInterface(kc),
), nil
case "Group":
//.........这里部分代码省略.........
示例3: NewFactory
// NewFactory creates an object that holds common methods across all OpenShift commands
func NewFactory(clientConfig kclientcmd.ClientConfig) *Factory {
mapper := ShortcutExpander{kubectl.ShortcutExpander{latest.RESTMapper}}
clients := &clientCache{
clients: make(map[string]*client.Client),
loader: clientConfig,
}
generators := map[string]kubectl.Generator{
"route/v1": routegen.RouteGenerator{},
"run/v1": deploygen.BasicDeploymentConfigController{},
"run-controller/v1": kubectl.BasicReplicationController{},
}
w := &Factory{
Factory: cmdutil.NewFactory(clientConfig),
OpenShiftClientConfig: clientConfig,
clients: clients,
}
w.Object = func() (meta.RESTMapper, runtime.ObjectTyper) {
if cfg, err := clientConfig.ClientConfig(); err == nil {
return kubectl.OutputVersionMapper{mapper, cfg.Version}, api.Scheme
}
return mapper, api.Scheme
}
kRESTClient := w.Factory.RESTClient
w.RESTClient = func(mapping *meta.RESTMapping) (resource.RESTClient, error) {
if latest.OriginKind(mapping.Kind, mapping.APIVersion) {
client, err := clients.ClientForVersion(mapping.APIVersion)
if err != nil {
return nil, err
}
return client.RESTClient, nil
}
return kRESTClient(mapping)
}
// Save original Describer function
kDescriberFunc := w.Factory.Describer
w.Describer = func(mapping *meta.RESTMapping) (kubectl.Describer, error) {
if latest.OriginKind(mapping.Kind, mapping.APIVersion) {
oClient, kClient, err := w.Clients()
if err != nil {
return nil, fmt.Errorf("unable to create client %s: %v", mapping.Kind, err)
}
cfg, err := clients.ClientConfigForVersion(mapping.APIVersion)
if err != nil {
return nil, fmt.Errorf("unable to load a client %s: %v", mapping.Kind, err)
}
describer, ok := describe.DescriberFor(mapping.Kind, oClient, kClient, cfg.Host)
if !ok {
return nil, fmt.Errorf("no description has been implemented for %q", mapping.Kind)
}
return describer, nil
}
return kDescriberFunc(mapping)
}
kScalerFunc := w.Factory.Scaler
w.Scaler = func(mapping *meta.RESTMapping) (kubectl.Scaler, error) {
oc, kc, err := w.Clients()
if err != nil {
return nil, err
}
if mapping.Kind == "DeploymentConfig" {
return deployscaler.NewDeploymentConfigScaler(oc, kc), nil
}
return kScalerFunc(mapping)
}
kReaperFunc := w.Factory.Reaper
w.Reaper = func(mapping *meta.RESTMapping) (kubectl.Reaper, error) {
oc, kc, err := w.Clients()
if err != nil {
return nil, err
}
if mapping.Kind == "DeploymentConfig" {
return deployreaper.NewDeploymentConfigReaper(oc, kc), nil
}
return kReaperFunc(mapping)
}
kGeneratorFunc := w.Factory.Generator
w.Generator = func(name string) (kubectl.Generator, bool) {
if generator, ok := generators[name]; ok {
return generator, true
}
return kGeneratorFunc(name)
}
kPodSelectorForObjectFunc := w.Factory.PodSelectorForObject
w.PodSelectorForObject = func(object runtime.Object) (string, error) {
switch t := object.(type) {
case *deployapi.DeploymentConfig:
return kubectl.MakeLabels(t.Template.ControllerTemplate.Selector), nil
default:
return kPodSelectorForObjectFunc(object)
//.........这里部分代码省略.........
示例4: NewFactory
//.........这里部分代码省略.........
if err != nil {
return nil, fmt.Errorf("unable to load a client %s: %v", mapping.GroupVersionKind.Kind, err)
}
describer, ok := describe.DescriberFor(mapping.GroupVersionKind.GroupKind(), oClient, kClient, cfg.Host)
if !ok {
return nil, fmt.Errorf("no description has been implemented for %q", mapping.GroupVersionKind.Kind)
}
return describer, nil
}
return kDescriberFunc(mapping)
}
kScalerFunc := w.Factory.Scaler
w.Scaler = func(mapping *meta.RESTMapping) (kubectl.Scaler, error) {
oc, kc, err := w.Clients()
if err != nil {
return nil, err
}
if mapping.GroupVersionKind.GroupKind() == deployapi.Kind("DeploymentConfig") {
return deployscaler.NewDeploymentConfigScaler(oc, kc), nil
}
return kScalerFunc(mapping)
}
kReaperFunc := w.Factory.Reaper
w.Reaper = func(mapping *meta.RESTMapping) (kubectl.Reaper, error) {
oc, kc, err := w.Clients()
if err != nil {
return nil, err
}
switch mapping.GroupVersionKind.GroupKind() {
case deployapi.Kind("DeploymentConfig"):
return deployreaper.NewDeploymentConfigReaper(oc, kc), nil
case authorizationapi.Kind("Role"):
return authorizationreaper.NewRoleReaper(oc, oc), nil
case authorizationapi.Kind("ClusterRole"):
return authorizationreaper.NewClusterRoleReaper(oc, oc, oc), nil
case userapi.Kind("User"):
return authenticationreaper.NewUserReaper(
client.UsersInterface(oc),
client.GroupsInterface(oc),
client.ClusterRoleBindingsInterface(oc),
client.RoleBindingsNamespacer(oc),
kclient.SecurityContextConstraintsInterface(kc),
), nil
case userapi.Kind("Group"):
return authenticationreaper.NewGroupReaper(
client.GroupsInterface(oc),
client.ClusterRoleBindingsInterface(oc),
client.RoleBindingsNamespacer(oc),
kclient.SecurityContextConstraintsInterface(kc),
), nil
case buildapi.Kind("BuildConfig"):
return buildreaper.NewBuildConfigReaper(oc), nil
}
return kReaperFunc(mapping)
}
kGenerators := w.Factory.Generators
w.Generators = func(cmdName string) map[string]kubectl.Generator {
originGenerators := DefaultGenerators(cmdName)
kubeGenerators := kGenerators(cmdName)
ret := map[string]kubectl.Generator{}
for k, v := range kubeGenerators {
ret[k] = v
示例5: NewFactory
// NewFactory creates an object that holds common methods across all OpenShift commands
func NewFactory(clientConfig kclientcmd.ClientConfig) *Factory {
mapper := ShortcutExpander{RESTMapper: kubectl.ShortcutExpander{RESTMapper: latest.RESTMapper}}
clients := &clientCache{
clients: make(map[string]*client.Client),
configs: make(map[string]*kclient.Config),
loader: clientConfig,
}
generators := map[string]kubectl.Generator{
"route/v1": routegen.RouteGenerator{},
"run/v1": deploygen.BasicDeploymentConfigController{},
"run-controller/v1": kubectl.BasicReplicationController{},
}
w := &Factory{
Factory: cmdutil.NewFactory(clientConfig),
OpenShiftClientConfig: clientConfig,
clients: clients,
}
w.Object = func() (meta.RESTMapper, runtime.ObjectTyper) {
// Output using whatever version was negotiated in the client cache. The
// version we decode with may not be the same as what the server requires.
if cfg, err := clients.ClientConfigForVersion(""); err == nil {
return kubectl.OutputVersionMapper{RESTMapper: mapper, OutputVersion: cfg.Version}, api.Scheme
}
return mapper, api.Scheme
}
kRESTClient := w.Factory.RESTClient
w.RESTClient = func(mapping *meta.RESTMapping) (resource.RESTClient, error) {
if latest.OriginKind(mapping.Kind, mapping.APIVersion) {
client, err := clients.ClientForVersion(mapping.APIVersion)
if err != nil {
return nil, err
}
return client.RESTClient, nil
}
return kRESTClient(mapping)
}
// Save original Describer function
kDescriberFunc := w.Factory.Describer
w.Describer = func(mapping *meta.RESTMapping) (kubectl.Describer, error) {
if latest.OriginKind(mapping.Kind, mapping.APIVersion) {
oClient, kClient, err := w.Clients()
if err != nil {
return nil, fmt.Errorf("unable to create client %s: %v", mapping.Kind, err)
}
cfg, err := clients.ClientConfigForVersion(mapping.APIVersion)
if err != nil {
return nil, fmt.Errorf("unable to load a client %s: %v", mapping.Kind, err)
}
describer, ok := describe.DescriberFor(mapping.Kind, oClient, kClient, cfg.Host)
if !ok {
return nil, fmt.Errorf("no description has been implemented for %q", mapping.Kind)
}
return describer, nil
}
return kDescriberFunc(mapping)
}
kScalerFunc := w.Factory.Scaler
w.Scaler = func(mapping *meta.RESTMapping) (kubectl.Scaler, error) {
oc, kc, err := w.Clients()
if err != nil {
return nil, err
}
if mapping.Kind == "DeploymentConfig" {
return deployscaler.NewDeploymentConfigScaler(oc, kc), nil
}
return kScalerFunc(mapping)
}
kReaperFunc := w.Factory.Reaper
w.Reaper = func(mapping *meta.RESTMapping) (kubectl.Reaper, error) {
oc, kc, err := w.Clients()
if err != nil {
return nil, err
}
if mapping.Kind == "DeploymentConfig" {
return deployreaper.NewDeploymentConfigReaper(oc, kc), nil
}
return kReaperFunc(mapping)
}
kGeneratorFunc := w.Factory.Generator
w.Generator = func(name string) (kubectl.Generator, bool) {
if generator, ok := generators[name]; ok {
return generator, true
}
return kGeneratorFunc(name)
}
kPodSelectorForObjectFunc := w.Factory.PodSelectorForObject
w.PodSelectorForObject = func(object runtime.Object) (string, error) {
switch t := object.(type) {
case *deployapi.DeploymentConfig:
//.........这里部分代码省略.........