mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 07:20:13 +00:00
kubeadm-upgrade: small improvements to diff
1) Store the io.Writer and pass it to sub-commands in upgrade.go 2) Check if the manifest path is an empty string in diff.go:runDiff() 3) Use the io.Writer that upgrade.go defines instead of writing to os.Stdout directly.
This commit is contained in:
parent
bf790f4467
commit
5adee74000
@ -17,8 +17,8 @@ limitations under the License.
|
||||
package upgrade
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"github.com/pmezard/go-difflib/difflib"
|
||||
@ -119,6 +119,9 @@ func runDiff(flags *diffFlags, args []string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if path == "" {
|
||||
return fmt.Errorf("empty manifest path")
|
||||
}
|
||||
existingManifest, err := ioutil.ReadFile(path)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -133,7 +136,7 @@ func runDiff(flags *diffFlags, args []string) error {
|
||||
Context: flags.contextLines,
|
||||
}
|
||||
|
||||
difflib.WriteUnifiedDiff(os.Stdout, diff)
|
||||
difflib.WriteUnifiedDiff(flags.parent.out, diff)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ type cmdUpgradeFlags struct {
|
||||
skipPreFlight bool
|
||||
ignorePreflightErrors []string
|
||||
ignorePreflightErrorsSet sets.String
|
||||
out io.Writer
|
||||
}
|
||||
|
||||
// NewCmdUpgrade returns the cobra command for `kubeadm upgrade`
|
||||
@ -50,6 +51,7 @@ func NewCmdUpgrade(out io.Writer) *cobra.Command {
|
||||
printConfig: false,
|
||||
skipPreFlight: false,
|
||||
ignorePreflightErrorsSet: sets.NewString(),
|
||||
out: out,
|
||||
}
|
||||
|
||||
cmd := &cobra.Command{
|
||||
|
Loading…
Reference in New Issue
Block a user