generated: run refactor
Kubernetes-commit: 3aa59f7f3077642592dc8a864fcef8ba98699894
This commit is contained in:
parent
f6a49de918
commit
71d8052cb0
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||
package autoscale
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
|
@ -262,7 +263,7 @@ func (o *AutoscaleOptions) Run() error {
|
|||
return err
|
||||
}
|
||||
|
||||
actualHPA, err := o.HPAClient.HorizontalPodAutoscalers(o.namespace).Create(hpa)
|
||||
actualHPA, err := o.HPAClient.HorizontalPodAutoscalers(o.namespace).Create(context.TODO(), hpa)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ func (o *ClusterInfoDumpOptions) Complete(f cmdutil.Factory, cmd *cobra.Command)
|
|||
}
|
||||
|
||||
func (o *ClusterInfoDumpOptions) Run() error {
|
||||
nodes, err := o.CoreClient.Nodes().List(metav1.ListOptions{})
|
||||
nodes, err := o.CoreClient.Nodes().List(context.TODO(), metav1.ListOptions{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -177,7 +177,7 @@ func (o *ClusterInfoDumpOptions) Run() error {
|
|||
|
||||
var namespaces []string
|
||||
if o.AllNamespaces {
|
||||
namespaceList, err := o.CoreClient.Namespaces().List(metav1.ListOptions{})
|
||||
namespaceList, err := o.CoreClient.Namespaces().List(context.TODO(), metav1.ListOptions{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -195,7 +195,7 @@ func (o *ClusterInfoDumpOptions) Run() error {
|
|||
for _, namespace := range namespaces {
|
||||
// TODO: this is repetitive in the extreme. Use reflection or
|
||||
// something to make this a for loop.
|
||||
events, err := o.CoreClient.Events(namespace).List(metav1.ListOptions{})
|
||||
events, err := o.CoreClient.Events(namespace).List(context.TODO(), metav1.ListOptions{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -203,7 +203,7 @@ func (o *ClusterInfoDumpOptions) Run() error {
|
|||
return err
|
||||
}
|
||||
|
||||
rcs, err := o.CoreClient.ReplicationControllers(namespace).List(metav1.ListOptions{})
|
||||
rcs, err := o.CoreClient.ReplicationControllers(namespace).List(context.TODO(), metav1.ListOptions{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -211,7 +211,7 @@ func (o *ClusterInfoDumpOptions) Run() error {
|
|||
return err
|
||||
}
|
||||
|
||||
svcs, err := o.CoreClient.Services(namespace).List(metav1.ListOptions{})
|
||||
svcs, err := o.CoreClient.Services(namespace).List(context.TODO(), metav1.ListOptions{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -219,7 +219,7 @@ func (o *ClusterInfoDumpOptions) Run() error {
|
|||
return err
|
||||
}
|
||||
|
||||
sets, err := o.AppsClient.DaemonSets(namespace).List(metav1.ListOptions{})
|
||||
sets, err := o.AppsClient.DaemonSets(namespace).List(context.TODO(), metav1.ListOptions{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -227,7 +227,7 @@ func (o *ClusterInfoDumpOptions) Run() error {
|
|||
return err
|
||||
}
|
||||
|
||||
deps, err := o.AppsClient.Deployments(namespace).List(metav1.ListOptions{})
|
||||
deps, err := o.AppsClient.Deployments(namespace).List(context.TODO(), metav1.ListOptions{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -235,7 +235,7 @@ func (o *ClusterInfoDumpOptions) Run() error {
|
|||
return err
|
||||
}
|
||||
|
||||
rps, err := o.AppsClient.ReplicaSets(namespace).List(metav1.ListOptions{})
|
||||
rps, err := o.AppsClient.ReplicaSets(namespace).List(context.TODO(), metav1.ListOptions{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -243,7 +243,7 @@ func (o *ClusterInfoDumpOptions) Run() error {
|
|||
return err
|
||||
}
|
||||
|
||||
pods, err := o.CoreClient.Pods(namespace).List(metav1.ListOptions{})
|
||||
pods, err := o.CoreClient.Pods(namespace).List(context.TODO(), metav1.ListOptions{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||
package create
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
|
|
@ -200,7 +201,7 @@ func (c *CreateClusterRoleOptions) RunCreateRole() error {
|
|||
|
||||
// Create ClusterRole.
|
||||
if !c.DryRun {
|
||||
clusterRole, err = c.Client.ClusterRoles().Create(clusterRole)
|
||||
clusterRole, err = c.Client.ClusterRoles().Create(context.TODO(), clusterRole)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||
package create
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
|
@ -164,7 +165,7 @@ func (o *CreateCronJobOptions) Run() error {
|
|||
|
||||
if !o.DryRun {
|
||||
var err error
|
||||
cronjob, err = o.Client.CronJobs(o.Namespace).Create(cronjob)
|
||||
cronjob, err = o.Client.CronJobs(o.Namespace).Create(context.TODO(), cronjob)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create cronjob: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||
package create
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
|
@ -192,7 +193,7 @@ func (o *CreateJobOptions) Run() error {
|
|||
}
|
||||
if !o.DryRun {
|
||||
var err error
|
||||
job, err = o.Client.Jobs(o.Namespace).Create(job)
|
||||
job, err = o.Client.Jobs(o.Namespace).Create(context.TODO(), job)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create job: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||
package create
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
|
|
@ -341,7 +342,7 @@ func (o *CreateRoleOptions) RunCreateRole() error {
|
|||
|
||||
// Create role.
|
||||
if !o.DryRun {
|
||||
role, err = o.Client.Roles(o.Namespace).Create(role)
|
||||
role, err = o.Client.Roles(o.Namespace).Create(context.TODO(), role)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||
package exec
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/url"
|
||||
|
|
@ -285,7 +286,7 @@ func (p *ExecOptions) Run() error {
|
|||
// since there are any other command run this function by providing Podname with PodsGetter
|
||||
// and without resource builder, eg: `kubectl cp`.
|
||||
if len(p.PodName) != 0 {
|
||||
p.Pod, err = p.PodClient.Pods(p.Namespace).Get(p.PodName, metav1.GetOptions{})
|
||||
p.Pod, err = p.PodClient.Pods(p.Namespace).Get(context.TODO(), p.PodName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||
package portforward
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
|
@ -311,7 +312,7 @@ func (o PortForwardOptions) Validate() error {
|
|||
|
||||
// RunPortForward implements all the necessary functionality for port-forward cmd.
|
||||
func (o PortForwardOptions) RunPortForward() error {
|
||||
pod, err := o.PodClient.Pods(o.Namespace).Get(o.PodName, metav1.GetOptions{})
|
||||
pod, err := o.PodClient.Pods(o.Namespace).Get(context.TODO(), o.PodName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||
package rollingupdate
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"strconv"
|
||||
|
|
@ -205,7 +206,7 @@ func (r *RollingUpdater) Update(config *RollingUpdaterConfig) error {
|
|||
// annotation if it doesn't yet exist.
|
||||
_, hasOriginalAnnotation := oldRc.Annotations[originalReplicasAnnotation]
|
||||
if !hasOriginalAnnotation {
|
||||
existing, err := r.rcClient.ReplicationControllers(oldRc.Namespace).Get(oldRc.Name, metav1.GetOptions{})
|
||||
existing, err := r.rcClient.ReplicationControllers(oldRc.Namespace).Get(context.TODO(), oldRc.Name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -415,7 +416,7 @@ func (r *RollingUpdater) scaleAndWaitWithScaler(rc *corev1.ReplicationController
|
|||
if err := scaler.Scale(rc.Namespace, rc.Name, uint(valOrZero(rc.Spec.Replicas)), &scale.ScalePrecondition{Size: -1, ResourceVersion: ""}, retry, wait, corev1.SchemeGroupVersion.WithResource("replicationcontrollers")); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return r.rcClient.ReplicationControllers(rc.Namespace).Get(rc.Name, metav1.GetOptions{})
|
||||
return r.rcClient.ReplicationControllers(rc.Namespace).Get(context.TODO(), rc.Name, metav1.GetOptions{})
|
||||
}
|
||||
|
||||
// readyPods returns the old and new ready counts for their pods.
|
||||
|
|
@ -433,7 +434,7 @@ func (r *RollingUpdater) readyPods(oldRc, newRc *corev1.ReplicationController, m
|
|||
controller := controllers[i]
|
||||
selector := labels.Set(controller.Spec.Selector).AsSelector()
|
||||
options := metav1.ListOptions{LabelSelector: selector.String()}
|
||||
pods, err := r.podClient.Pods(controller.Namespace).List(options)
|
||||
pods, err := r.podClient.Pods(controller.Namespace).List(context.TODO(), options)
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
|
|
@ -482,7 +483,7 @@ func (r *RollingUpdater) getOrCreateTargetControllerWithClient(controller *corev
|
|||
controller.Annotations[desiredReplicasAnnotation] = fmt.Sprintf("%d", valOrZero(controller.Spec.Replicas))
|
||||
controller.Annotations[sourceIDAnnotation] = sourceID
|
||||
controller.Spec.Replicas = utilpointer.Int32Ptr(0)
|
||||
newRc, err := r.rcClient.ReplicationControllers(r.ns).Create(controller)
|
||||
newRc, err := r.rcClient.ReplicationControllers(r.ns).Create(context.TODO(), controller)
|
||||
return newRc, false, err
|
||||
}
|
||||
// Validate and use the existing controller.
|
||||
|
|
@ -502,7 +503,7 @@ func (r *RollingUpdater) existingController(controller *corev1.ReplicationContro
|
|||
return nil, errors.NewNotFound(corev1.Resource("replicationcontrollers"), controller.Name)
|
||||
}
|
||||
// controller name is required to get rc back
|
||||
return r.rcClient.ReplicationControllers(controller.Namespace).Get(controller.Name, metav1.GetOptions{})
|
||||
return r.rcClient.ReplicationControllers(controller.Namespace).Get(context.TODO(), controller.Name, metav1.GetOptions{})
|
||||
}
|
||||
|
||||
// cleanupWithClients performs cleanup tasks after the rolling update. Update
|
||||
|
|
@ -511,7 +512,7 @@ func (r *RollingUpdater) existingController(controller *corev1.ReplicationContro
|
|||
func (r *RollingUpdater) cleanupWithClients(oldRc, newRc *corev1.ReplicationController, config *RollingUpdaterConfig) error {
|
||||
// Clean up annotations
|
||||
var err error
|
||||
newRc, err = r.rcClient.ReplicationControllers(r.ns).Get(newRc.Name, metav1.GetOptions{})
|
||||
newRc, err = r.rcClient.ReplicationControllers(r.ns).Get(context.TODO(), newRc.Name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -526,7 +527,7 @@ func (r *RollingUpdater) cleanupWithClients(oldRc, newRc *corev1.ReplicationCont
|
|||
if err = wait.Poll(config.Interval, config.Timeout, controllerHasDesiredReplicas(r.rcClient, newRc)); err != nil {
|
||||
return err
|
||||
}
|
||||
newRc, err = r.rcClient.ReplicationControllers(r.ns).Get(newRc.Name, metav1.GetOptions{})
|
||||
newRc, err = r.rcClient.ReplicationControllers(r.ns).Get(context.TODO(), newRc.Name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -535,11 +536,11 @@ func (r *RollingUpdater) cleanupWithClients(oldRc, newRc *corev1.ReplicationCont
|
|||
case DeleteRollingUpdateCleanupPolicy:
|
||||
// delete old rc
|
||||
fmt.Fprintf(config.Out, "Update succeeded. Deleting %s\n", oldRc.Name)
|
||||
return r.rcClient.ReplicationControllers(r.ns).Delete(oldRc.Name, nil)
|
||||
return r.rcClient.ReplicationControllers(r.ns).Delete(context.TODO(), oldRc.Name, nil)
|
||||
case RenameRollingUpdateCleanupPolicy:
|
||||
// delete old rc
|
||||
fmt.Fprintf(config.Out, "Update succeeded. Deleting old controller: %s\n", oldRc.Name)
|
||||
if err := r.rcClient.ReplicationControllers(r.ns).Delete(oldRc.Name, nil); err != nil {
|
||||
if err := r.rcClient.ReplicationControllers(r.ns).Delete(context.TODO(), oldRc.Name, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Fprintf(config.Out, "Renaming %s to %s\n", newRc.Name, oldRc.Name)
|
||||
|
|
@ -557,12 +558,12 @@ func Rename(c corev1client.ReplicationControllersGetter, rc *corev1.ReplicationC
|
|||
rc.ResourceVersion = ""
|
||||
// First delete the oldName RC and orphan its pods.
|
||||
policy := metav1.DeletePropagationOrphan
|
||||
err := c.ReplicationControllers(rc.Namespace).Delete(oldName, &metav1.DeleteOptions{PropagationPolicy: &policy})
|
||||
err := c.ReplicationControllers(rc.Namespace).Delete(context.TODO(), oldName, &metav1.DeleteOptions{PropagationPolicy: &policy})
|
||||
if err != nil && !errors.IsNotFound(err) {
|
||||
return err
|
||||
}
|
||||
err = wait.Poll(5*time.Second, 60*time.Second, func() (bool, error) {
|
||||
_, err := c.ReplicationControllers(rc.Namespace).Get(oldName, metav1.GetOptions{})
|
||||
_, err := c.ReplicationControllers(rc.Namespace).Get(context.TODO(), oldName, metav1.GetOptions{})
|
||||
if err == nil {
|
||||
return false, nil
|
||||
} else if errors.IsNotFound(err) {
|
||||
|
|
@ -575,7 +576,7 @@ func Rename(c corev1client.ReplicationControllersGetter, rc *corev1.ReplicationC
|
|||
return err
|
||||
}
|
||||
// Then create the same RC with the new name.
|
||||
_, err = c.ReplicationControllers(rc.Namespace).Create(rc)
|
||||
_, err = c.ReplicationControllers(rc.Namespace).Create(context.TODO(), rc)
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
@ -583,7 +584,7 @@ func LoadExistingNextReplicationController(c corev1client.ReplicationControllers
|
|||
if len(newName) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
newRc, err := c.ReplicationControllers(namespace).Get(newName, metav1.GetOptions{})
|
||||
newRc, err := c.ReplicationControllers(namespace).Get(context.TODO(), newName, metav1.GetOptions{})
|
||||
if err != nil && errors.IsNotFound(err) {
|
||||
return nil, nil
|
||||
}
|
||||
|
|
@ -602,7 +603,7 @@ type NewControllerConfig struct {
|
|||
func CreateNewControllerFromCurrentController(rcClient corev1client.ReplicationControllersGetter, codec runtime.Codec, cfg *NewControllerConfig) (*corev1.ReplicationController, error) {
|
||||
containerIndex := 0
|
||||
// load the old RC into the "new" RC
|
||||
newRc, err := rcClient.ReplicationControllers(cfg.Namespace).Get(cfg.OldName, metav1.GetOptions{})
|
||||
newRc, err := rcClient.ReplicationControllers(cfg.Namespace).Get(context.TODO(), cfg.OldName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -719,7 +720,7 @@ func AddDeploymentKeyToReplicationController(oldRc *corev1.ReplicationController
|
|||
// TODO: extract the code from the label command and re-use it here.
|
||||
selector := labels.SelectorFromSet(oldRc.Spec.Selector)
|
||||
options := metav1.ListOptions{LabelSelector: selector.String()}
|
||||
podList, err := podClient.Pods(namespace).List(options)
|
||||
podList, err := podClient.Pods(namespace).List(context.TODO(), options)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -755,13 +756,13 @@ func AddDeploymentKeyToReplicationController(oldRc *corev1.ReplicationController
|
|||
// we've finished re-adopting existing pods to the rc.
|
||||
selector = labels.SelectorFromSet(oldRc.Spec.Selector)
|
||||
options = metav1.ListOptions{LabelSelector: selector.String()}
|
||||
if podList, err = podClient.Pods(namespace).List(options); err != nil {
|
||||
if podList, err = podClient.Pods(namespace).List(context.TODO(), options); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for ix := range podList.Items {
|
||||
pod := &podList.Items[ix]
|
||||
if value, found := pod.Labels[deploymentKey]; !found || value != deploymentValue {
|
||||
if err := podClient.Pods(namespace).Delete(pod.Name, nil); err != nil {
|
||||
if err := podClient.Pods(namespace).Delete(context.TODO(), pod.Name, nil); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
|
@ -782,14 +783,14 @@ func updateRcWithRetries(rcClient corev1client.ReplicationControllersGetter, nam
|
|||
err := retry.RetryOnConflict(retry.DefaultBackoff, func() (e error) {
|
||||
// Apply the update, then attempt to push it to the apiserver.
|
||||
applyUpdate(rc)
|
||||
if rc, e = rcClient.ReplicationControllers(namespace).Update(rc); e == nil {
|
||||
if rc, e = rcClient.ReplicationControllers(namespace).Update(context.TODO(), rc); e == nil {
|
||||
// rc contains the latest controller post update
|
||||
return
|
||||
}
|
||||
updateErr := e
|
||||
// Update the controller with the latest resource version, if the update failed we
|
||||
// can't trust rc so use oldRc.Name.
|
||||
if rc, e = rcClient.ReplicationControllers(namespace).Get(oldRc.Name, metav1.GetOptions{}); e != nil {
|
||||
if rc, e = rcClient.ReplicationControllers(namespace).Get(context.TODO(), oldRc.Name, metav1.GetOptions{}); e != nil {
|
||||
// The Get failed: Value in rc cannot be trusted.
|
||||
rc = oldRc
|
||||
}
|
||||
|
|
@ -813,11 +814,11 @@ func updatePodWithRetries(podClient corev1client.PodsGetter, namespace string, p
|
|||
err := retry.RetryOnConflict(retry.DefaultBackoff, func() (e error) {
|
||||
// Apply the update, then attempt to push it to the apiserver.
|
||||
applyUpdate(pod)
|
||||
if pod, e = podClient.Pods(namespace).Update(pod); e == nil {
|
||||
if pod, e = podClient.Pods(namespace).Update(context.TODO(), pod); e == nil {
|
||||
return
|
||||
}
|
||||
updateErr := e
|
||||
if pod, e = podClient.Pods(namespace).Get(oldPod.Name, metav1.GetOptions{}); e != nil {
|
||||
if pod, e = podClient.Pods(namespace).Get(context.TODO(), oldPod.Name, metav1.GetOptions{}); e != nil {
|
||||
pod = oldPod
|
||||
}
|
||||
// Only return the error from update
|
||||
|
|
@ -829,7 +830,7 @@ func updatePodWithRetries(podClient corev1client.PodsGetter, namespace string, p
|
|||
}
|
||||
|
||||
func FindSourceController(r corev1client.ReplicationControllersGetter, namespace, name string) (*corev1.ReplicationController, error) {
|
||||
list, err := r.ReplicationControllers(namespace).List(metav1.ListOptions{})
|
||||
list, err := r.ReplicationControllers(namespace).List(context.TODO(), metav1.ListOptions{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -851,7 +852,7 @@ func controllerHasDesiredReplicas(rcClient corev1client.ReplicationControllersGe
|
|||
desiredGeneration := controller.Generation
|
||||
|
||||
return func() (bool, error) {
|
||||
ctrl, err := rcClient.ReplicationControllers(controller.Namespace).Get(controller.Name, metav1.GetOptions{})
|
||||
ctrl, err := rcClient.ReplicationControllers(controller.Namespace).Get(context.TODO(), controller.Name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ package rollingupdate
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
|
|
@ -248,7 +249,7 @@ func (o *RollingUpdateOptions) Run() error {
|
|||
|
||||
var newRc *corev1.ReplicationController
|
||||
// fetch rc
|
||||
oldRc, err := coreClient.ReplicationControllers(o.Namespace).Get(o.OldName, metav1.GetOptions{})
|
||||
oldRc, err := coreClient.ReplicationControllers(o.Namespace).Get(context.TODO(), o.OldName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
if !errors.IsNotFound(err) || len(o.Image) == 0 || !o.KeepOldName {
|
||||
return err
|
||||
|
|
@ -431,7 +432,7 @@ func (o *RollingUpdateOptions) Run() error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
coreClient.ReplicationControllers(config.NewRc.Namespace).Update(config.NewRc)
|
||||
coreClient.ReplicationControllers(config.NewRc.Namespace).Update(context.TODO(), config.NewRc)
|
||||
}
|
||||
err = updater.Update(config)
|
||||
if err != nil {
|
||||
|
|
@ -444,7 +445,7 @@ func (o *RollingUpdateOptions) Run() error {
|
|||
} else {
|
||||
message = fmt.Sprintf("rolling updated to %q", newRc.Name)
|
||||
}
|
||||
newRc, err = coreClient.ReplicationControllers(o.Namespace).Get(newRc.Name, metav1.GetOptions{})
|
||||
newRc, err = coreClient.ReplicationControllers(o.Namespace).Get(context.TODO(), newRc.Name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -474,11 +474,11 @@ func waitForPod(podClient corev1client.PodsGetter, ns, name string, exitConditio
|
|||
lw := &cache.ListWatch{
|
||||
ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
|
||||
options.FieldSelector = fieldSelector
|
||||
return podClient.Pods(ns).List(options)
|
||||
return podClient.Pods(ns).List(context.TODO(), options)
|
||||
},
|
||||
WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
|
||||
options.FieldSelector = fieldSelector
|
||||
return podClient.Pods(ns).Watch(options)
|
||||
return podClient.Pods(ns).Watch(context.TODO(), options)
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||
package env
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math"
|
||||
"strconv"
|
||||
|
|
@ -51,7 +52,7 @@ func getSecretRefValue(client kubernetes.Interface, namespace string, store *Res
|
|||
secret, ok := store.SecretStore[secretSelector.Name]
|
||||
if !ok {
|
||||
var err error
|
||||
secret, err = client.CoreV1().Secrets(namespace).Get(secretSelector.Name, metav1.GetOptions{})
|
||||
secret, err = client.CoreV1().Secrets(namespace).Get(context.TODO(), secretSelector.Name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
@ -69,7 +70,7 @@ func getConfigMapRefValue(client kubernetes.Interface, namespace string, store *
|
|||
configMap, ok := store.ConfigMapStore[configMapSelector.Name]
|
||||
if !ok {
|
||||
var err error
|
||||
configMap, err = client.CoreV1().ConfigMaps(namespace).Get(configMapSelector.Name, metav1.GetOptions{})
|
||||
configMap, err = client.CoreV1().ConfigMaps(namespace).Get(context.TODO(), configMapSelector.Name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||
package top
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
|
@ -199,13 +200,13 @@ func (o TopNodeOptions) RunTopNode() error {
|
|||
|
||||
var nodes []v1.Node
|
||||
if len(o.ResourceName) > 0 {
|
||||
node, err := o.NodeClient.Nodes().Get(o.ResourceName, metav1.GetOptions{})
|
||||
node, err := o.NodeClient.Nodes().Get(context.TODO(), o.ResourceName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
nodes = append(nodes, *node)
|
||||
} else {
|
||||
nodeList, err := o.NodeClient.Nodes().List(metav1.ListOptions{
|
||||
nodeList, err := o.NodeClient.Nodes().List(context.TODO(), metav1.ListOptions{
|
||||
LabelSelector: selector.String(),
|
||||
})
|
||||
if err != nil {
|
||||
|
|
@ -229,13 +230,13 @@ func getNodeMetricsFromMetricsAPI(metricsClient metricsclientset.Interface, reso
|
|||
mc := metricsClient.MetricsV1beta1()
|
||||
nm := mc.NodeMetricses()
|
||||
if resourceName != "" {
|
||||
m, err := nm.Get(resourceName, metav1.GetOptions{})
|
||||
m, err := nm.Get(context.TODO(), resourceName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
versionedMetrics.Items = []metricsV1beta1api.NodeMetrics{*m}
|
||||
} else {
|
||||
versionedMetrics, err = nm.List(metav1.ListOptions{LabelSelector: selector.String()})
|
||||
versionedMetrics, err = nm.List(context.TODO(), metav1.ListOptions{LabelSelector: selector.String()})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||
package top
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
|
@ -212,13 +213,13 @@ func getMetricsFromMetricsAPI(metricsClient metricsclientset.Interface, namespac
|
|||
}
|
||||
versionedMetrics := &metricsv1beta1api.PodMetricsList{}
|
||||
if resourceName != "" {
|
||||
m, err := metricsClient.MetricsV1beta1().PodMetricses(ns).Get(resourceName, metav1.GetOptions{})
|
||||
m, err := metricsClient.MetricsV1beta1().PodMetricses(ns).Get(context.TODO(), resourceName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
versionedMetrics.Items = []metricsv1beta1api.PodMetrics{*m}
|
||||
} else {
|
||||
versionedMetrics, err = metricsClient.MetricsV1beta1().PodMetricses(ns).List(metav1.ListOptions{LabelSelector: selector.String()})
|
||||
versionedMetrics, err = metricsClient.MetricsV1beta1().PodMetricses(ns).List(context.TODO(), metav1.ListOptions{LabelSelector: selector.String()})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -233,7 +234,7 @@ func getMetricsFromMetricsAPI(metricsClient metricsclientset.Interface, namespac
|
|||
|
||||
func verifyEmptyMetrics(o TopPodOptions, selector labels.Selector) error {
|
||||
if len(o.ResourceName) > 0 {
|
||||
pod, err := o.PodClient.Pods(o.Namespace).Get(o.ResourceName, metav1.GetOptions{})
|
||||
pod, err := o.PodClient.Pods(o.Namespace).Get(context.TODO(), o.ResourceName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -241,7 +242,7 @@ func verifyEmptyMetrics(o TopPodOptions, selector labels.Selector) error {
|
|||
return err
|
||||
}
|
||||
} else {
|
||||
pods, err := o.PodClient.Pods(o.Namespace).List(metav1.ListOptions{
|
||||
pods, err := o.PodClient.Pods(o.Namespace).List(context.TODO(), metav1.ListOptions{
|
||||
LabelSelector: selector.String(),
|
||||
})
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ package versioned
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/x509"
|
||||
"fmt"
|
||||
"io"
|
||||
|
|
@ -363,11 +364,11 @@ type NamespaceDescriber struct {
|
|||
}
|
||||
|
||||
func (d *NamespaceDescriber) Describe(namespace, name string, describerSettings describe.DescriberSettings) (string, error) {
|
||||
ns, err := d.CoreV1().Namespaces().Get(name, metav1.GetOptions{})
|
||||
ns, err := d.CoreV1().Namespaces().Get(context.TODO(), name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
resourceQuotaList, err := d.CoreV1().ResourceQuotas(name).List(metav1.ListOptions{})
|
||||
resourceQuotaList, err := d.CoreV1().ResourceQuotas(name).List(context.TODO(), metav1.ListOptions{})
|
||||
if err != nil {
|
||||
if errors.IsNotFound(err) {
|
||||
// Server does not support resource quotas.
|
||||
|
|
@ -377,7 +378,7 @@ func (d *NamespaceDescriber) Describe(namespace, name string, describerSettings
|
|||
return "", err
|
||||
}
|
||||
}
|
||||
limitRangeList, err := d.CoreV1().LimitRanges(name).List(metav1.ListOptions{})
|
||||
limitRangeList, err := d.CoreV1().LimitRanges(name).List(context.TODO(), metav1.ListOptions{})
|
||||
if err != nil {
|
||||
if errors.IsNotFound(err) {
|
||||
// Server does not support limit ranges.
|
||||
|
|
@ -538,7 +539,7 @@ type LimitRangeDescriber struct {
|
|||
func (d *LimitRangeDescriber) Describe(namespace, name string, describerSettings describe.DescriberSettings) (string, error) {
|
||||
lr := d.CoreV1().LimitRanges(namespace)
|
||||
|
||||
limitRange, err := lr.Get(name, metav1.GetOptions{})
|
||||
limitRange, err := lr.Get(context.TODO(), name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
@ -565,7 +566,7 @@ type ResourceQuotaDescriber struct {
|
|||
func (d *ResourceQuotaDescriber) Describe(namespace, name string, describerSettings describe.DescriberSettings) (string, error) {
|
||||
rq := d.CoreV1().ResourceQuotas(namespace)
|
||||
|
||||
resourceQuota, err := rq.Get(name, metav1.GetOptions{})
|
||||
resourceQuota, err := rq.Get(context.TODO(), name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
@ -633,13 +634,13 @@ type PodDescriber struct {
|
|||
}
|
||||
|
||||
func (d *PodDescriber) Describe(namespace, name string, describerSettings describe.DescriberSettings) (string, error) {
|
||||
pod, err := d.CoreV1().Pods(namespace).Get(name, metav1.GetOptions{})
|
||||
pod, err := d.CoreV1().Pods(namespace).Get(context.TODO(), name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
if describerSettings.ShowEvents {
|
||||
eventsInterface := d.CoreV1().Events(namespace)
|
||||
selector := eventsInterface.GetFieldSelector(&name, &namespace, nil, nil)
|
||||
options := metav1.ListOptions{FieldSelector: selector.String()}
|
||||
events, err2 := eventsInterface.List(options)
|
||||
events, err2 := eventsInterface.List(context.TODO(), options)
|
||||
if describerSettings.ShowEvents && err2 == nil && len(events.Items) > 0 {
|
||||
return tabbedString(func(out io.Writer) error {
|
||||
w := NewPrefixWriter(out)
|
||||
|
|
@ -1326,7 +1327,7 @@ type PersistentVolumeDescriber struct {
|
|||
func (d *PersistentVolumeDescriber) Describe(namespace, name string, describerSettings describe.DescriberSettings) (string, error) {
|
||||
c := d.CoreV1().PersistentVolumes()
|
||||
|
||||
pv, err := c.Get(name, metav1.GetOptions{})
|
||||
pv, err := c.Get(context.TODO(), name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
@ -1474,7 +1475,7 @@ type PersistentVolumeClaimDescriber struct {
|
|||
func (d *PersistentVolumeClaimDescriber) Describe(namespace, name string, describerSettings describe.DescriberSettings) (string, error) {
|
||||
c := d.CoreV1().PersistentVolumeClaims(namespace)
|
||||
|
||||
pvc, err := c.Get(name, metav1.GetOptions{})
|
||||
pvc, err := c.Get(context.TODO(), name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
@ -1492,7 +1493,7 @@ func (d *PersistentVolumeClaimDescriber) Describe(namespace, name string, descri
|
|||
}
|
||||
|
||||
func getMountPods(c corev1client.PodInterface, pvcName string) ([]corev1.Pod, error) {
|
||||
nsPods, err := c.List(metav1.ListOptions{})
|
||||
nsPods, err := c.List(context.TODO(), metav1.ListOptions{})
|
||||
if err != nil {
|
||||
return []corev1.Pod{}, err
|
||||
}
|
||||
|
|
@ -1948,7 +1949,7 @@ func (d *ReplicationControllerDescriber) Describe(namespace, name string, descri
|
|||
rc := d.CoreV1().ReplicationControllers(namespace)
|
||||
pc := d.CoreV1().Pods(namespace)
|
||||
|
||||
controller, err := rc.Get(name, metav1.GetOptions{})
|
||||
controller, err := rc.Get(context.TODO(), name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
@ -2023,7 +2024,7 @@ func (d *ReplicaSetDescriber) Describe(namespace, name string, describerSettings
|
|||
rsc := d.AppsV1().ReplicaSets(namespace)
|
||||
pc := d.CoreV1().Pods(namespace)
|
||||
|
||||
rs, err := rsc.Get(name, metav1.GetOptions{})
|
||||
rs, err := rsc.Get(context.TODO(), name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
@ -2082,7 +2083,7 @@ type JobDescriber struct {
|
|||
}
|
||||
|
||||
func (d *JobDescriber) Describe(namespace, name string, describerSettings describe.DescriberSettings) (string, error) {
|
||||
job, err := d.BatchV1().Jobs(namespace).Get(name, metav1.GetOptions{})
|
||||
job, err := d.BatchV1().Jobs(namespace).Get(context.TODO(), name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
@ -2143,7 +2144,7 @@ type CronJobDescriber struct {
|
|||
}
|
||||
|
||||
func (d *CronJobDescriber) Describe(namespace, name string, describerSettings describe.DescriberSettings) (string, error) {
|
||||
cronJob, err := d.client.BatchV1beta1().CronJobs(namespace).Get(name, metav1.GetOptions{})
|
||||
cronJob, err := d.client.BatchV1beta1().CronJobs(namespace).Get(context.TODO(), name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
@ -2245,7 +2246,7 @@ func (d *DaemonSetDescriber) Describe(namespace, name string, describerSettings
|
|||
dc := d.AppsV1().DaemonSets(namespace)
|
||||
pc := d.CoreV1().Pods(namespace)
|
||||
|
||||
daemon, err := dc.Get(name, metav1.GetOptions{})
|
||||
daemon, err := dc.Get(context.TODO(), name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
@ -2302,7 +2303,7 @@ type SecretDescriber struct {
|
|||
func (d *SecretDescriber) Describe(namespace, name string, describerSettings describe.DescriberSettings) (string, error) {
|
||||
c := d.CoreV1().Secrets(namespace)
|
||||
|
||||
secret, err := c.Get(name, metav1.GetOptions{})
|
||||
secret, err := c.Get(context.TODO(), name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
@ -2341,7 +2342,7 @@ type IngressDescriber struct {
|
|||
|
||||
func (i *IngressDescriber) Describe(namespace, name string, describerSettings describe.DescriberSettings) (string, error) {
|
||||
c := i.NetworkingV1beta1().Ingresses(namespace)
|
||||
ing, err := c.Get(name, metav1.GetOptions{})
|
||||
ing, err := c.Get(context.TODO(), name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
@ -2349,8 +2350,8 @@ func (i *IngressDescriber) Describe(namespace, name string, describerSettings de
|
|||
}
|
||||
|
||||
func (i *IngressDescriber) describeBackend(ns string, backend *networkingv1beta1.IngressBackend) string {
|
||||
endpoints, _ := i.CoreV1().Endpoints(ns).Get(backend.ServiceName, metav1.GetOptions{})
|
||||
service, _ := i.CoreV1().Services(ns).Get(backend.ServiceName, metav1.GetOptions{})
|
||||
endpoints, _ := i.CoreV1().Endpoints(ns).Get(context.TODO(), backend.ServiceName, metav1.GetOptions{})
|
||||
service, _ := i.CoreV1().Services(ns).Get(context.TODO(), backend.ServiceName, metav1.GetOptions{})
|
||||
spName := ""
|
||||
for i := range service.Spec.Ports {
|
||||
sp := &service.Spec.Ports[i]
|
||||
|
|
@ -2448,12 +2449,12 @@ type ServiceDescriber struct {
|
|||
func (d *ServiceDescriber) Describe(namespace, name string, describerSettings describe.DescriberSettings) (string, error) {
|
||||
c := d.CoreV1().Services(namespace)
|
||||
|
||||
service, err := c.Get(name, metav1.GetOptions{})
|
||||
service, err := c.Get(context.TODO(), name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
endpoints, _ := d.CoreV1().Endpoints(namespace).Get(name, metav1.GetOptions{})
|
||||
endpoints, _ := d.CoreV1().Endpoints(namespace).Get(context.TODO(), name, metav1.GetOptions{})
|
||||
var events *corev1.EventList
|
||||
if describerSettings.ShowEvents {
|
||||
events, _ = d.CoreV1().Events(namespace).Search(scheme.Scheme, service)
|
||||
|
|
@ -2551,7 +2552,7 @@ type EndpointsDescriber struct {
|
|||
func (d *EndpointsDescriber) Describe(namespace, name string, describerSettings describe.DescriberSettings) (string, error) {
|
||||
c := d.CoreV1().Endpoints(namespace)
|
||||
|
||||
ep, err := c.Get(name, metav1.GetOptions{})
|
||||
ep, err := c.Get(context.TODO(), name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
@ -2626,7 +2627,7 @@ type EndpointSliceDescriber struct {
|
|||
func (d *EndpointSliceDescriber) Describe(namespace, name string, describerSettings describe.DescriberSettings) (string, error) {
|
||||
c := d.DiscoveryV1beta1().EndpointSlices(namespace)
|
||||
|
||||
eps, err := c.Get(name, metav1.GetOptions{})
|
||||
eps, err := c.Get(context.TODO(), name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
@ -2719,7 +2720,7 @@ type ServiceAccountDescriber struct {
|
|||
func (d *ServiceAccountDescriber) Describe(namespace, name string, describerSettings describe.DescriberSettings) (string, error) {
|
||||
c := d.CoreV1().ServiceAccounts(namespace)
|
||||
|
||||
serviceAccount, err := c.Get(name, metav1.GetOptions{})
|
||||
serviceAccount, err := c.Get(context.TODO(), name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
@ -2729,7 +2730,7 @@ func (d *ServiceAccountDescriber) Describe(namespace, name string, describerSett
|
|||
// missingSecrets is the set of all secrets present in the
|
||||
// serviceAccount but not present in the set of existing secrets.
|
||||
missingSecrets := sets.NewString()
|
||||
secrets, err := d.CoreV1().Secrets(namespace).List(metav1.ListOptions{})
|
||||
secrets, err := d.CoreV1().Secrets(namespace).List(context.TODO(), metav1.ListOptions{})
|
||||
|
||||
// errors are tolerated here in order to describe the serviceAccount with all
|
||||
// of the secrets that it references, even if those secrets cannot be fetched.
|
||||
|
|
@ -2834,7 +2835,7 @@ type RoleDescriber struct {
|
|||
}
|
||||
|
||||
func (d *RoleDescriber) Describe(namespace, name string, describerSettings describe.DescriberSettings) (string, error) {
|
||||
role, err := d.RbacV1().Roles(namespace).Get(name, metav1.GetOptions{})
|
||||
role, err := d.RbacV1().Roles(namespace).Get(context.TODO(), name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
@ -2873,7 +2874,7 @@ type ClusterRoleDescriber struct {
|
|||
}
|
||||
|
||||
func (d *ClusterRoleDescriber) Describe(namespace, name string, describerSettings describe.DescriberSettings) (string, error) {
|
||||
role, err := d.RbacV1().ClusterRoles().Get(name, metav1.GetOptions{})
|
||||
role, err := d.RbacV1().ClusterRoles().Get(context.TODO(), name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
@ -2929,7 +2930,7 @@ type RoleBindingDescriber struct {
|
|||
}
|
||||
|
||||
func (d *RoleBindingDescriber) Describe(namespace, name string, describerSettings describe.DescriberSettings) (string, error) {
|
||||
binding, err := d.RbacV1().RoleBindings(namespace).Get(name, metav1.GetOptions{})
|
||||
binding, err := d.RbacV1().RoleBindings(namespace).Get(context.TODO(), name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
@ -2961,7 +2962,7 @@ type ClusterRoleBindingDescriber struct {
|
|||
}
|
||||
|
||||
func (d *ClusterRoleBindingDescriber) Describe(namespace, name string, describerSettings describe.DescriberSettings) (string, error) {
|
||||
binding, err := d.RbacV1().ClusterRoleBindings().Get(name, metav1.GetOptions{})
|
||||
binding, err := d.RbacV1().ClusterRoleBindings().Get(context.TODO(), name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
@ -2994,12 +2995,12 @@ type NodeDescriber struct {
|
|||
|
||||
func (d *NodeDescriber) Describe(namespace, name string, describerSettings describe.DescriberSettings) (string, error) {
|
||||
mc := d.CoreV1().Nodes()
|
||||
node, err := mc.Get(name, metav1.GetOptions{})
|
||||
node, err := mc.Get(context.TODO(), name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
lease, err := d.CoordinationV1().Leases(corev1.NamespaceNodeLease).Get(name, metav1.GetOptions{})
|
||||
lease, err := d.CoordinationV1().Leases(corev1.NamespaceNodeLease).Get(context.TODO(), name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
if !errors.IsNotFound(err) {
|
||||
return "", err
|
||||
|
|
@ -3015,7 +3016,7 @@ func (d *NodeDescriber) Describe(namespace, name string, describerSettings descr
|
|||
// in a policy aware setting, users may have access to a node, but not all pods
|
||||
// in that case, we note that the user does not have access to the pods
|
||||
canViewPods := true
|
||||
nodeNonTerminatedPodsList, err := d.CoreV1().Pods(namespace).List(metav1.ListOptions{FieldSelector: fieldSelector.String()})
|
||||
nodeNonTerminatedPodsList, err := d.CoreV1().Pods(namespace).List(context.TODO(), metav1.ListOptions{FieldSelector: fieldSelector.String()})
|
||||
if err != nil {
|
||||
if !errors.IsForbidden(err) {
|
||||
return "", err
|
||||
|
|
@ -3149,7 +3150,7 @@ type StatefulSetDescriber struct {
|
|||
}
|
||||
|
||||
func (p *StatefulSetDescriber) Describe(namespace, name string, describerSettings describe.DescriberSettings) (string, error) {
|
||||
ps, err := p.client.AppsV1().StatefulSets(namespace).Get(name, metav1.GetOptions{})
|
||||
ps, err := p.client.AppsV1().StatefulSets(namespace).Get(context.TODO(), name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
@ -3207,7 +3208,7 @@ type CertificateSigningRequestDescriber struct {
|
|||
}
|
||||
|
||||
func (p *CertificateSigningRequestDescriber) Describe(namespace, name string, describerSettings describe.DescriberSettings) (string, error) {
|
||||
csr, err := p.client.CertificatesV1beta1().CertificateSigningRequests().Get(name, metav1.GetOptions{})
|
||||
csr, err := p.client.CertificatesV1beta1().CertificateSigningRequests().Get(context.TODO(), name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
@ -3294,7 +3295,7 @@ func (d *HorizontalPodAutoscalerDescriber) Describe(namespace, name string, desc
|
|||
// autoscaling/v2beta2 is introduced since v1.12 and autoscaling/v1 does not have full backward compatibility
|
||||
// with autoscaling/v2beta2, so describer will try to get and describe hpa v2beta2 object firstly, if it fails,
|
||||
// describer will fall back to do with hpa v1 object
|
||||
hpaV2beta2, err := d.client.AutoscalingV2beta2().HorizontalPodAutoscalers(namespace).Get(name, metav1.GetOptions{})
|
||||
hpaV2beta2, err := d.client.AutoscalingV2beta2().HorizontalPodAutoscalers(namespace).Get(context.TODO(), name, metav1.GetOptions{})
|
||||
if err == nil {
|
||||
if describerSettings.ShowEvents {
|
||||
events, _ = d.client.CoreV1().Events(namespace).Search(scheme.Scheme, hpaV2beta2)
|
||||
|
|
@ -3302,7 +3303,7 @@ func (d *HorizontalPodAutoscalerDescriber) Describe(namespace, name string, desc
|
|||
return describeHorizontalPodAutoscalerV2beta2(hpaV2beta2, events, d)
|
||||
}
|
||||
|
||||
hpaV1, err := d.client.AutoscalingV1().HorizontalPodAutoscalers(namespace).Get(name, metav1.GetOptions{})
|
||||
hpaV1, err := d.client.AutoscalingV1().HorizontalPodAutoscalers(namespace).Get(context.TODO(), name, metav1.GetOptions{})
|
||||
if err == nil {
|
||||
if describerSettings.ShowEvents {
|
||||
events, _ = d.client.CoreV1().Events(namespace).Search(scheme.Scheme, hpaV1)
|
||||
|
|
@ -3598,7 +3599,7 @@ type DeploymentDescriber struct {
|
|||
}
|
||||
|
||||
func (dd *DeploymentDescriber) Describe(namespace, name string, describerSettings describe.DescriberSettings) (string, error) {
|
||||
d, err := dd.client.AppsV1().Deployments(namespace).Get(name, metav1.GetOptions{})
|
||||
d, err := dd.client.AppsV1().Deployments(namespace).Get(context.TODO(), name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
@ -3671,7 +3672,7 @@ func printReplicaSetsByLabels(matchingRSs []*appsv1.ReplicaSet) string {
|
|||
|
||||
func getPodStatusForController(c corev1client.PodInterface, selector labels.Selector, uid types.UID) (running, waiting, succeeded, failed int, err error) {
|
||||
options := metav1.ListOptions{LabelSelector: selector.String()}
|
||||
rcPods, err := c.List(options)
|
||||
rcPods, err := c.List(context.TODO(), options)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
@ -3703,7 +3704,7 @@ type ConfigMapDescriber struct {
|
|||
func (d *ConfigMapDescriber) Describe(namespace, name string, describerSettings describe.DescriberSettings) (string, error) {
|
||||
c := d.CoreV1().ConfigMaps(namespace)
|
||||
|
||||
configMap, err := c.Get(name, metav1.GetOptions{})
|
||||
configMap, err := c.Get(context.TODO(), name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
@ -3741,7 +3742,7 @@ type NetworkPolicyDescriber struct {
|
|||
func (d *NetworkPolicyDescriber) Describe(namespace, name string, describerSettings describe.DescriberSettings) (string, error) {
|
||||
c := d.NetworkingV1().NetworkPolicies(namespace)
|
||||
|
||||
networkPolicy, err := c.Get(name, metav1.GetOptions{})
|
||||
networkPolicy, err := c.Get(context.TODO(), name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
@ -3895,7 +3896,7 @@ type StorageClassDescriber struct {
|
|||
}
|
||||
|
||||
func (s *StorageClassDescriber) Describe(namespace, name string, describerSettings describe.DescriberSettings) (string, error) {
|
||||
sc, err := s.StorageV1().StorageClasses().Get(name, metav1.GetOptions{})
|
||||
sc, err := s.StorageV1().StorageClasses().Get(context.TODO(), name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
@ -3947,7 +3948,7 @@ type CSINodeDescriber struct {
|
|||
}
|
||||
|
||||
func (c *CSINodeDescriber) Describe(namespace, name string, describerSettings describe.DescriberSettings) (string, error) {
|
||||
csi, err := c.StorageV1().CSINodes().Get(name, metav1.GetOptions{})
|
||||
csi, err := c.StorageV1().CSINodes().Get(context.TODO(), name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
@ -4022,7 +4023,7 @@ type PodDisruptionBudgetDescriber struct {
|
|||
}
|
||||
|
||||
func (p *PodDisruptionBudgetDescriber) Describe(namespace, name string, describerSettings describe.DescriberSettings) (string, error) {
|
||||
pdb, err := p.PolicyV1beta1().PodDisruptionBudgets(namespace).Get(name, metav1.GetOptions{})
|
||||
pdb, err := p.PolicyV1beta1().PodDisruptionBudgets(namespace).Get(context.TODO(), name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
@ -4071,7 +4072,7 @@ type PriorityClassDescriber struct {
|
|||
}
|
||||
|
||||
func (s *PriorityClassDescriber) Describe(namespace, name string, describerSettings describe.DescriberSettings) (string, error) {
|
||||
pc, err := s.SchedulingV1().PriorityClasses().Get(name, metav1.GetOptions{})
|
||||
pc, err := s.SchedulingV1().PriorityClasses().Get(context.TODO(), name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
@ -4107,7 +4108,7 @@ type PodSecurityPolicyDescriber struct {
|
|||
}
|
||||
|
||||
func (d *PodSecurityPolicyDescriber) Describe(namespace, name string, describerSettings describe.DescriberSettings) (string, error) {
|
||||
psp, err := d.PolicyV1beta1().PodSecurityPolicies().Get(name, metav1.GetOptions{})
|
||||
psp, err := d.PolicyV1beta1().PodSecurityPolicies().Get(context.TODO(), name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||
package drain
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
|
|
@ -87,9 +88,9 @@ func (c *CordonHelper) PatchOrReplace(clientset kubernetes.Interface) (error, er
|
|||
|
||||
patchBytes, patchErr := strategicpatch.CreateTwoWayMergePatch(oldData, newData, c.node)
|
||||
if patchErr == nil {
|
||||
_, err = client.Patch(c.node.Name, types.StrategicMergePatchType, patchBytes)
|
||||
_, err = client.Patch(context.TODO(), c.node.Name, types.StrategicMergePatchType, patchBytes)
|
||||
} else {
|
||||
_, err = client.Update(c.node)
|
||||
_, err = client.Update(context.TODO(), c.node)
|
||||
}
|
||||
return err, patchErr
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ func (d *Helper) makeDeleteOptions() *metav1.DeleteOptions {
|
|||
|
||||
// DeletePod will delete the given pod, or return an error if it couldn't
|
||||
func (d *Helper) DeletePod(pod corev1.Pod) error {
|
||||
return d.Client.CoreV1().Pods(pod.Namespace).Delete(pod.Name, d.makeDeleteOptions())
|
||||
return d.Client.CoreV1().Pods(pod.Namespace).Delete(context.TODO(), pod.Name, d.makeDeleteOptions())
|
||||
}
|
||||
|
||||
// EvictPod will evict the give pod, or return an error if it couldn't
|
||||
|
|
@ -160,7 +160,7 @@ func (d *Helper) GetPodsForDeletion(nodeName string) (*podDeleteList, []error) {
|
|||
return nil, []error{err}
|
||||
}
|
||||
|
||||
podList, err := d.Client.CoreV1().Pods(metav1.NamespaceAll).List(metav1.ListOptions{
|
||||
podList, err := d.Client.CoreV1().Pods(metav1.NamespaceAll).List(context.TODO(), metav1.ListOptions{
|
||||
LabelSelector: labelSelector.String(),
|
||||
FieldSelector: fields.SelectorFromSet(fields.Set{"spec.nodeName": nodeName}).String()})
|
||||
if err != nil {
|
||||
|
|
@ -205,7 +205,7 @@ func (d *Helper) DeleteOrEvictPods(pods []corev1.Pod) error {
|
|||
|
||||
// TODO(justinsb): unnecessary?
|
||||
getPodFn := func(namespace, name string) (*corev1.Pod, error) {
|
||||
return d.Client.CoreV1().Pods(namespace).Get(name, metav1.GetOptions{})
|
||||
return d.Client.CoreV1().Pods(namespace).Get(context.TODO(), name, metav1.GetOptions{})
|
||||
}
|
||||
|
||||
if !d.DisableEviction {
|
||||
|
|
|
|||
|
|
@ -241,7 +241,7 @@ func addEvictionSupport(t *testing.T, k *fake.Clientset) {
|
|||
eviction := *action.(ktest.CreateAction).GetObject().(*policyv1beta1.Eviction)
|
||||
// Avoid the lock
|
||||
go func() {
|
||||
err := k.CoreV1().Pods(eviction.Namespace).Delete(eviction.Name, &metav1.DeleteOptions{})
|
||||
err := k.CoreV1().Pods(eviction.Namespace).Delete(context.TODO(), eviction.Name, &metav1.DeleteOptions{})
|
||||
if err != nil {
|
||||
// Errorf because we can't call Fatalf from another goroutine
|
||||
t.Errorf("failed to delete pod: %s/%s", eviction.Namespace, eviction.Name)
|
||||
|
|
@ -356,7 +356,7 @@ func TestDeleteOrEvict(t *testing.T) {
|
|||
// Test that other pods are still there
|
||||
var remainingPods []string
|
||||
{
|
||||
podList, err := k.CoreV1().Pods("").List(metav1.ListOptions{})
|
||||
podList, err := k.CoreV1().Pods("").List(context.TODO(), metav1.ListOptions{})
|
||||
if err != nil {
|
||||
t.Fatalf("error listing pods: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||
package drain
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
|
@ -172,7 +173,7 @@ func (d *Helper) daemonSetFilter(pod corev1.Pod) podDeleteStatus {
|
|||
return makePodDeleteStatusOkay()
|
||||
}
|
||||
|
||||
if _, err := d.Client.AppsV1().DaemonSets(pod.Namespace).Get(controllerRef.Name, metav1.GetOptions{}); err != nil {
|
||||
if _, err := d.Client.AppsV1().DaemonSets(pod.Namespace).Get(context.TODO(), controllerRef.Name, metav1.GetOptions{}); err != nil {
|
||||
// remove orphaned pods with a warning if --force is used
|
||||
if apierrors.IsNotFound(err) && d.Force {
|
||||
return makePodDeleteStatusWithWarning(true, err.Error())
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ import (
|
|||
func GetFirstPod(client coreclient.PodsGetter, namespace string, selector string, timeout time.Duration, sortBy func([]*corev1.Pod) sort.Interface) (*corev1.Pod, int, error) {
|
||||
options := metav1.ListOptions{LabelSelector: selector}
|
||||
|
||||
podList, err := client.Pods(namespace).List(options)
|
||||
podList, err := client.Pods(namespace).List(context.TODO(), options)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
|
@ -57,7 +57,7 @@ func GetFirstPod(client coreclient.PodsGetter, namespace string, selector string
|
|||
|
||||
// Watch until we observe a pod
|
||||
options.ResourceVersion = podList.ResourceVersion
|
||||
w, err := client.Pods(namespace).Watch(options)
|
||||
w, err := client.Pods(namespace).Watch(context.TODO(), options)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ package polymorphichelpers
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"text/tabwriter"
|
||||
|
|
@ -101,7 +102,7 @@ type DeploymentHistoryViewer struct {
|
|||
// TODO: this should be a describer
|
||||
func (h *DeploymentHistoryViewer) ViewHistory(namespace, name string, revision int64) (string, error) {
|
||||
versionedAppsClient := h.c.AppsV1()
|
||||
deployment, err := versionedAppsClient.Deployments(namespace).Get(name, metav1.GetOptions{})
|
||||
deployment, err := versionedAppsClient.Deployments(namespace).Get(context.TODO(), name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to retrieve deployment %s: %v", name, err)
|
||||
}
|
||||
|
|
@ -265,7 +266,7 @@ func controlledHistoryV1(
|
|||
selector labels.Selector,
|
||||
accessor metav1.Object) ([]*appsv1.ControllerRevision, error) {
|
||||
var result []*appsv1.ControllerRevision
|
||||
historyList, err := apps.ControllerRevisions(namespace).List(metav1.ListOptions{LabelSelector: selector.String()})
|
||||
historyList, err := apps.ControllerRevisions(namespace).List(context.TODO(), metav1.ListOptions{LabelSelector: selector.String()})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -286,7 +287,7 @@ func controlledHistory(
|
|||
selector labels.Selector,
|
||||
accessor metav1.Object) ([]*appsv1.ControllerRevision, error) {
|
||||
var result []*appsv1.ControllerRevision
|
||||
historyList, err := apps.ControllerRevisions(namespace).List(metav1.ListOptions{LabelSelector: selector.String()})
|
||||
historyList, err := apps.ControllerRevisions(namespace).List(context.TODO(), metav1.ListOptions{LabelSelector: selector.String()})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -304,7 +305,7 @@ func controlledHistory(
|
|||
func daemonSetHistory(
|
||||
apps clientappsv1.AppsV1Interface,
|
||||
namespace, name string) (*appsv1.DaemonSet, []*appsv1.ControllerRevision, error) {
|
||||
ds, err := apps.DaemonSets(namespace).Get(name, metav1.GetOptions{})
|
||||
ds, err := apps.DaemonSets(namespace).Get(context.TODO(), name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("failed to retrieve DaemonSet %s: %v", name, err)
|
||||
}
|
||||
|
|
@ -327,7 +328,7 @@ func daemonSetHistory(
|
|||
func statefulSetHistory(
|
||||
apps clientappsv1.AppsV1Interface,
|
||||
namespace, name string) (*appsv1.StatefulSet, []*appsv1.ControllerRevision, error) {
|
||||
sts, err := apps.StatefulSets(namespace).Get(name, metav1.GetOptions{})
|
||||
sts, err := apps.StatefulSets(namespace).Get(context.TODO(), name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("failed to retrieve Statefulset %s: %s", name, err.Error())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||
package polymorphichelpers
|
||||
|
||||
import (
|
||||
"context"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
|
|
@ -84,7 +85,7 @@ func TestViewHistory(t *testing.T) {
|
|||
)
|
||||
|
||||
fakeClientSet := fake.NewSimpleClientset(ssStub)
|
||||
_, err := fakeClientSet.AppsV1().ControllerRevisions("default").Create(ssStub1)
|
||||
_, err := fakeClientSet.AppsV1().ControllerRevisions("default").Create(context.TODO(), ssStub1)
|
||||
if err != nil {
|
||||
t.Fatalf("create controllerRevisions error %v occurred ", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ package polymorphichelpers
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"sort"
|
||||
|
||||
|
|
@ -109,7 +110,7 @@ func (r *DeploymentRollbacker) Rollback(obj runtime.Object, updatedAnnotations m
|
|||
// to the external appsv1 Deployment without round-tripping through an internal version of Deployment. We're
|
||||
// currently getting rid of all internal versions of resources. So we specifically request the appsv1 version
|
||||
// here. This follows the same pattern as for DaemonSet and StatefulSet.
|
||||
deployment, err := r.c.AppsV1().Deployments(namespace).Get(name, metav1.GetOptions{})
|
||||
deployment, err := r.c.AppsV1().Deployments(namespace).Get(context.TODO(), name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to retrieve Deployment %s: %v", name, err)
|
||||
}
|
||||
|
|
@ -153,7 +154,7 @@ func (r *DeploymentRollbacker) Rollback(obj runtime.Object, updatedAnnotations m
|
|||
}
|
||||
|
||||
// Restore revision
|
||||
if _, err = r.c.AppsV1().Deployments(namespace).Patch(name, patchType, patch); err != nil {
|
||||
if _, err = r.c.AppsV1().Deployments(namespace).Patch(context.TODO(), name, patchType, patch); err != nil {
|
||||
return "", fmt.Errorf("failed restoring revision %d: %v", toRevision, err)
|
||||
}
|
||||
return rollbackSuccess, nil
|
||||
|
|
@ -293,7 +294,7 @@ func (r *DaemonSetRollbacker) Rollback(obj runtime.Object, updatedAnnotations ma
|
|||
}
|
||||
|
||||
// Restore revision
|
||||
if _, err = r.c.AppsV1().DaemonSets(accessor.GetNamespace()).Patch(accessor.GetName(), types.StrategicMergePatchType, toHistory.Data.Raw); err != nil {
|
||||
if _, err = r.c.AppsV1().DaemonSets(accessor.GetNamespace()).Patch(context.TODO(), accessor.GetName(), types.StrategicMergePatchType, toHistory.Data.Raw); err != nil {
|
||||
return "", fmt.Errorf("failed restoring revision %d: %v", toRevision, err)
|
||||
}
|
||||
|
||||
|
|
@ -380,7 +381,7 @@ func (r *StatefulSetRollbacker) Rollback(obj runtime.Object, updatedAnnotations
|
|||
}
|
||||
|
||||
// Restore revision
|
||||
if _, err = r.c.AppsV1().StatefulSets(sts.Namespace).Patch(sts.Name, types.StrategicMergePatchType, toHistory.Data.Raw); err != nil {
|
||||
if _, err = r.c.AppsV1().StatefulSets(sts.Namespace).Patch(context.TODO(), sts.Name, types.StrategicMergePatchType, toHistory.Data.Raw); err != nil {
|
||||
return "", fmt.Errorf("failed restoring revision %d: %v", toRevision, err)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||
package deployment
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sort"
|
||||
"strconv"
|
||||
|
||||
|
|
@ -95,7 +96,7 @@ func GetAllReplicaSets(deployment *appsv1.Deployment, c appsclient.AppsV1Interfa
|
|||
// RsListFromClient returns an rsListFunc that wraps the given client.
|
||||
func rsListFromClient(c appsclient.AppsV1Interface) rsListFunc {
|
||||
return func(namespace string, options metav1.ListOptions) ([]*appsv1.ReplicaSet, error) {
|
||||
rsList, err := c.ReplicaSets(namespace).List(options)
|
||||
rsList, err := c.ReplicaSets(namespace).List(context.TODO(), options)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue