Reformatting changes

* Run gofmt on all changed files
    so they formatted properly now
pull/1648/head
Nikolay Mahotkin 8 years ago
parent 045b158c3d
commit ea6328c7ce

@ -206,8 +206,8 @@ message RollbackReleaseRequest {
bool disable_hooks = 3; bool disable_hooks = 3;
// Version is the version of the release to deploy. // Version is the version of the release to deploy.
int32 version = 4; int32 version = 4;
// Performs pods restart for resources if applicable // Performs pods restart for resources if applicable
bool restart = 5; bool restart = 5;
} }
// RollbackReleaseResponse is the response to an update request. // RollbackReleaseResponse is the response to an update request.

@ -35,7 +35,7 @@ type rollbackCmd struct {
name string name string
revision int32 revision int32
dryRun bool dryRun bool
restart bool restart bool
disableHooks bool disableHooks bool
out io.Writer out io.Writer
client helm.Interface client helm.Interface

@ -40,8 +40,8 @@ type options struct {
dryRun bool dryRun bool
// if set, re-use an existing name // if set, re-use an existing name
reuseName bool reuseName bool
// // if set, performs pod restart during upgrade/rollback
restart bool restart bool
// if set, skip running hooks // if set, skip running hooks
disableHooks bool disableHooks bool
// name of release // name of release

@ -28,22 +28,22 @@ import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/errors" "k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/apimachinery/registered" "k8s.io/kubernetes/pkg/apimachinery/registered"
"k8s.io/kubernetes/pkg/apis/apps/v1alpha1"
"k8s.io/kubernetes/pkg/apis/batch" "k8s.io/kubernetes/pkg/apis/batch"
"k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
"k8s.io/kubernetes/pkg/client/unversioned" "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/client/unversioned/clientcmd" "k8s.io/kubernetes/pkg/client/unversioned/clientcmd"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/kubectl" "k8s.io/kubernetes/pkg/kubectl"
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util" cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
"k8s.io/kubernetes/pkg/kubectl/resource" "k8s.io/kubernetes/pkg/kubectl/resource"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/runtime" "k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util/strategicpatch" "k8s.io/kubernetes/pkg/util/strategicpatch"
"k8s.io/kubernetes/pkg/util/yaml" "k8s.io/kubernetes/pkg/util/yaml"
"k8s.io/kubernetes/pkg/watch" "k8s.io/kubernetes/pkg/watch"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/apis/apps/v1alpha1"
"k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
) )
// ErrNoObjectsVisited indicates that during a visit operation, no matching objects were found. // ErrNoObjectsVisited indicates that during a visit operation, no matching objects were found.
@ -353,63 +353,61 @@ func updateResource(c *Client, target *resource.Info, currentObj runtime.Object,
helper := resource.NewHelper(target.Client, target.Mapping) helper := resource.NewHelper(target.Client, target.Mapping)
_, err = helper.Patch(target.Namespace, target.Name, api.StrategicMergePatchType, patch) _, err = helper.Patch(target.Namespace, target.Name, api.StrategicMergePatchType, patch)
if err != nil { if err != nil {
return err return err
} }
if restart { if restart {
kind := target.Mapping.GroupVersionKind.Kind kind := target.Mapping.GroupVersionKind.Kind
client, _ := c.Client() client, _ := c.Client()
switch kind { switch kind {
case "ReplicationController": case "ReplicationController":
rc := currentObj.(*v1.ReplicationController) rc := currentObj.(*v1.ReplicationController)
err = restartPods(client, target.Namespace, rc.Spec.Selector) err = restartPods(client, target.Namespace, rc.Spec.Selector)
case "DaemonSet": case "DaemonSet":
daemonSet := currentObj.(*v1beta1.DaemonSet) daemonSet := currentObj.(*v1beta1.DaemonSet)
err = restartPods(client, target.Namespace, daemonSet.Spec.Selector.MatchLabels) err = restartPods(client, target.Namespace, daemonSet.Spec.Selector.MatchLabels)
case "PetSet": case "PetSet":
petSet := currentObj.(*v1alpha1.PetSet) petSet := currentObj.(*v1alpha1.PetSet)
err = restartPods(client, target.Namespace, petSet.Spec.Selector.MatchLabels) err = restartPods(client, target.Namespace, petSet.Spec.Selector.MatchLabels)
case "ReplicaSet": case "ReplicaSet":
replicaSet := currentObj.(*v1beta1.ReplicaSet) replicaSet := currentObj.(*v1beta1.ReplicaSet)
err = restartPods(client, target.Namespace, replicaSet.Spec.Selector.MatchLabels) err = restartPods(client, target.Namespace, replicaSet.Spec.Selector.MatchLabels)
} }
} }
return err return err
} }
func restartPods(client *unversioned.Client, namespace string, selector map[string]string) error { func restartPods(client *unversioned.Client, namespace string, selector map[string]string) error {
pods, err := client.Pods(namespace).List(api.ListOptions{ pods, err := client.Pods(namespace).List(api.ListOptions{
FieldSelector: fields.Everything(), FieldSelector: fields.Everything(),
LabelSelector: labels.Set(selector).AsSelector(), LabelSelector: labels.Set(selector).AsSelector(),
}) })
if err != nil { if err != nil {
return err return err
} }
// Restart pods
for _, pod := range pods.Items {
log.Printf("Restarting pod: %v/%v", pod.Namespace, pod.Name)
// Delete each pod for get them restarted with changed spec.
err := client.Pods(pod.Namespace).Delete(pod.Name, &api.DeleteOptions{
Preconditions: &api.Preconditions{
UID: &pod.UID,
},
})
if err != nil {
return err
}
}
return nil
}
// Restart pods
for _, pod := range pods.Items {
log.Printf("Restarting pod: %v/%v", pod.Namespace, pod.Name)
// Delete each pod for get them restarted with changed spec.
err := client.Pods(pod.Namespace).Delete(pod.Name, &api.DeleteOptions{
Preconditions: &api.Preconditions{
UID: &pod.UID,
},
})
if err != nil {
return err
}
}
return nil
}
func watchUntilReady(info *resource.Info) error { func watchUntilReady(info *resource.Info) error {
w, err := resource.NewHelper(info.Client, info.Mapping).WatchSingle(info.Namespace, info.Name, info.ResourceVersion) w, err := resource.NewHelper(info.Client, info.Mapping).WatchSingle(info.Namespace, info.Name, info.ResourceVersion)

@ -246,8 +246,8 @@ type UpdateReleaseRequest struct {
DryRun bool `protobuf:"varint,4,opt,name=dry_run,json=dryRun" json:"dry_run,omitempty"` DryRun bool `protobuf:"varint,4,opt,name=dry_run,json=dryRun" json:"dry_run,omitempty"`
// DisableHooks causes the server to skip running any hooks for the upgrade. // DisableHooks causes the server to skip running any hooks for the upgrade.
DisableHooks bool `protobuf:"varint,5,opt,name=disable_hooks,json=disableHooks" json:"disable_hooks,omitempty"` DisableHooks bool `protobuf:"varint,5,opt,name=disable_hooks,json=disableHooks" json:"disable_hooks,omitempty"`
// Performs pods restart for resources if applicable // Performs pods restart for resources if applicable
Restart bool `protobuf:"varint,6,opt,name=restart,json=restart" json:"restart,omitempty"` Restart bool `protobuf:"varint,6,opt,name=restart,json=restart" json:"restart,omitempty"`
} }
func (m *UpdateReleaseRequest) Reset() { *m = UpdateReleaseRequest{} } func (m *UpdateReleaseRequest) Reset() { *m = UpdateReleaseRequest{} }
@ -296,7 +296,7 @@ type RollbackReleaseRequest struct {
// Version is the version of the release to deploy. // Version is the version of the release to deploy.
Version int32 `protobuf:"varint,4,opt,name=version" json:"version,omitempty"` Version int32 `protobuf:"varint,4,opt,name=version" json:"version,omitempty"`
// Performs pods restart for resources if applicable // Performs pods restart for resources if applicable
Restart bool `protobuf:"varint,5,opt,name=restart,json=restart" json:"restart,omitempty"` Restart bool `protobuf:"varint,5,opt,name=restart,json=restart" json:"restart,omitempty"`
} }
func (m *RollbackReleaseRequest) Reset() { *m = RollbackReleaseRequest{} } func (m *RollbackReleaseRequest) Reset() { *m = RollbackReleaseRequest{} }

Loading…
Cancel
Save