-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16516 from deads2k/client-06-cmd-snips
Automatic merge from submit-queue remove legacy client usage Cleans up a bunch of different legacy client usage.
- Loading branch information
Showing
19 changed files
with
218 additions
and
298 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,56 @@ | ||
package v1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
extensionsv1beta1 "k8s.io/kubernetes/pkg/apis/extensions/v1beta1" | ||
kextensionsclient "k8s.io/kubernetes/pkg/client/clientset_generated/clientset/typed/extensions/v1beta1" | ||
|
||
appstypedclient "github.com/openshift/origin/pkg/apps/generated/clientset/typed/apps/v1" | ||
) | ||
|
||
type delegatingScaleInterface struct { | ||
dcs appstypedclient.DeploymentConfigInterface | ||
scales kextensionsclient.ScaleInterface | ||
} | ||
|
||
type delegatingScaleNamespacer struct { | ||
dcNS appstypedclient.DeploymentConfigsGetter | ||
scaleNS kextensionsclient.ScalesGetter | ||
} | ||
|
||
func (c *delegatingScaleNamespacer) Scales(namespace string) kextensionsclient.ScaleInterface { | ||
return &delegatingScaleInterface{ | ||
dcs: c.dcNS.DeploymentConfigs(namespace), | ||
scales: c.scaleNS.Scales(namespace), | ||
} | ||
} | ||
|
||
func NewDelegatingScaleNamespacer(dcNamespacer appstypedclient.DeploymentConfigsGetter, sNamespacer kextensionsclient.ScalesGetter) kextensionsclient.ScalesGetter { | ||
return &delegatingScaleNamespacer{ | ||
dcNS: dcNamespacer, | ||
scaleNS: sNamespacer, | ||
} | ||
} | ||
|
||
// Get takes the reference to scale subresource and returns the subresource or error, if one occurs. | ||
func (c *delegatingScaleInterface) Get(kind string, name string) (result *extensionsv1beta1.Scale, err error) { | ||
switch { | ||
case kind == "DeploymentConfig": | ||
return c.dcs.GetScale(name, metav1.GetOptions{}) | ||
// TODO: This is borked because the interface for Get is broken. Kind is insufficient. | ||
default: | ||
return c.scales.Get(kind, name) | ||
} | ||
} | ||
|
||
// Update takes a scale subresource object, updates the stored version to match it, and | ||
// returns the subresource or error, if one occurs. | ||
func (c *delegatingScaleInterface) Update(kind string, scale *extensionsv1beta1.Scale) (result *extensionsv1beta1.Scale, err error) { | ||
switch { | ||
case kind == "DeploymentConfig": | ||
return c.dcs.UpdateScale(scale.Name, scale) | ||
// TODO: This is borked because the interface for Update is broken. Kind is insufficient. | ||
default: | ||
return c.scales.Update(kind, scale) | ||
} | ||
} |
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 |
---|---|---|
@@ -1,24 +1,11 @@ | ||
package origin | ||
|
||
import ( | ||
"github.com/golang/glog" | ||
|
||
kapierror "k8s.io/apimachinery/pkg/api/errors" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
genericapiserver "k8s.io/apiserver/pkg/server" | ||
kapi "k8s.io/kubernetes/pkg/api" | ||
) | ||
|
||
// ensureOpenShiftSharedResourcesNamespace is called as part of global policy initialization to ensure shared namespace exists | ||
func (c *MasterConfig) ensureOpenShiftSharedResourcesNamespace(context genericapiserver.PostStartHookContext) error { | ||
if _, err := c.PrivilegedLoopbackKubernetesClientsetInternal.Core().Namespaces().Get(c.Options.PolicyConfig.OpenShiftSharedResourcesNamespace, metav1.GetOptions{}); kapierror.IsNotFound(err) { | ||
namespace, createErr := c.PrivilegedLoopbackKubernetesClientsetInternal.Core().Namespaces().Create(&kapi.Namespace{ObjectMeta: metav1.ObjectMeta{Name: c.Options.PolicyConfig.OpenShiftSharedResourcesNamespace}}) | ||
if createErr != nil { | ||
glog.Errorf("Error creating namespace: %v due to %v\n", c.Options.PolicyConfig.OpenShiftSharedResourcesNamespace, createErr) | ||
return nil | ||
} | ||
|
||
EnsureNamespaceServiceAccountRoleBindings(c.PrivilegedLoopbackKubernetesClientsetInternal, c.PrivilegedLoopbackOpenShiftClient, namespace) | ||
} | ||
ensureNamespaceServiceAccountRoleBindings(context, c.Options.PolicyConfig.OpenShiftSharedResourcesNamespace) | ||
return nil | ||
} |
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
Oops, something went wrong.