mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	Make -o option working for rolling-update
Use simple message to show the result. If -o is specified, print updated rc.
This commit is contained in:
		@@ -28,6 +28,7 @@ import (
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
	"k8s.io/kubernetes/pkg/api"
 | 
			
		||||
	"k8s.io/kubernetes/pkg/api/errors"
 | 
			
		||||
	"k8s.io/kubernetes/pkg/api/meta"
 | 
			
		||||
	"k8s.io/kubernetes/pkg/api/v1"
 | 
			
		||||
	"k8s.io/kubernetes/pkg/kubectl"
 | 
			
		||||
	cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
 | 
			
		||||
@@ -138,6 +139,7 @@ func RunRollingUpdate(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, arg
 | 
			
		||||
	interval := cmdutil.GetFlagDuration(cmd, "poll-interval")
 | 
			
		||||
	timeout := cmdutil.GetFlagDuration(cmd, "timeout")
 | 
			
		||||
	dryrun := cmdutil.GetFlagBool(cmd, "dry-run")
 | 
			
		||||
	outputFormat := cmdutil.GetFlagString(cmd, "output")
 | 
			
		||||
 | 
			
		||||
	cmdNamespace, enforceNamespace, err := f.DefaultNamespace()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
@@ -263,13 +265,18 @@ func RunRollingUpdate(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, arg
 | 
			
		||||
	}
 | 
			
		||||
	if dryrun {
 | 
			
		||||
		oldRcData := &bytes.Buffer{}
 | 
			
		||||
		newRcData := &bytes.Buffer{}
 | 
			
		||||
		if outputFormat == "" {
 | 
			
		||||
			oldRcData.WriteString(oldRc.Name)
 | 
			
		||||
			newRcData.WriteString(newRc.Name)
 | 
			
		||||
		} else {
 | 
			
		||||
			if err := f.PrintObject(cmd, oldRc, oldRcData); err != nil {
 | 
			
		||||
				return err
 | 
			
		||||
			}
 | 
			
		||||
		newRcData := &bytes.Buffer{}
 | 
			
		||||
			if err := f.PrintObject(cmd, newRc, newRcData); err != nil {
 | 
			
		||||
				return err
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		fmt.Fprintf(out, "Rolling from:\n%s\nTo:\n%s\n", string(oldRcData.Bytes()), string(newRcData.Bytes()))
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
@@ -297,11 +304,25 @@ func RunRollingUpdate(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, arg
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	message := "rolling updated"
 | 
			
		||||
	if keepOldName {
 | 
			
		||||
		fmt.Fprintf(out, "%s\n", oldName)
 | 
			
		||||
		newRc.Name = oldName
 | 
			
		||||
	} else {
 | 
			
		||||
		fmt.Fprintf(out, "%s\n", newRc.Name)
 | 
			
		||||
		message = fmt.Sprintf("rolling updated to %q", newRc.Name)
 | 
			
		||||
	}
 | 
			
		||||
	newRc, err = client.ReplicationControllers(cmdNamespace).Get(newRc.Name)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	if outputFormat != "" {
 | 
			
		||||
		return f.PrintObject(cmd, newRc, out)
 | 
			
		||||
	}
 | 
			
		||||
	_, kind, err := api.Scheme.ObjectVersionAndKind(newRc)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	_, res := meta.KindToResource(kind, false)
 | 
			
		||||
	cmdutil.PrintSuccess(mapper, false, out, res, oldName, message)
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user