mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Revert "fix kubectl config view to respect serialization formats"
This commit is contained in:
		@@ -18,7 +18,6 @@ package config
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"bytes"
 | 
						"bytes"
 | 
				
			||||||
	"fmt"
 | 
					 | 
				
			||||||
	"io/ioutil"
 | 
						"io/ioutil"
 | 
				
			||||||
	"os"
 | 
						"os"
 | 
				
			||||||
	"reflect"
 | 
						"reflect"
 | 
				
			||||||
@@ -48,36 +47,6 @@ type configCommandTest struct {
 | 
				
			|||||||
	expectedOutputs []string
 | 
						expectedOutputs []string
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func ExampleView() {
 | 
					 | 
				
			||||||
	expectedConfig := newRedFederalCowHammerConfig()
 | 
					 | 
				
			||||||
	test := configCommandTest{
 | 
					 | 
				
			||||||
		args:           []string{"view"},
 | 
					 | 
				
			||||||
		startingConfig: newRedFederalCowHammerConfig(),
 | 
					 | 
				
			||||||
		expectedConfig: expectedConfig,
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	output := test.run(nil)
 | 
					 | 
				
			||||||
	fmt.Printf("%v", output)
 | 
					 | 
				
			||||||
	// Output:
 | 
					 | 
				
			||||||
	// apiVersion: v1
 | 
					 | 
				
			||||||
	// clusters:
 | 
					 | 
				
			||||||
	// - cluster:
 | 
					 | 
				
			||||||
	//     server: http://cow.org:8080
 | 
					 | 
				
			||||||
	//   name: cow-cluster
 | 
					 | 
				
			||||||
	// contexts:
 | 
					 | 
				
			||||||
	// - context:
 | 
					 | 
				
			||||||
	//     cluster: cow-cluster
 | 
					 | 
				
			||||||
	//     user: red-user
 | 
					 | 
				
			||||||
	//   name: federal-context
 | 
					 | 
				
			||||||
	// current-context: ""
 | 
					 | 
				
			||||||
	// kind: Config
 | 
					 | 
				
			||||||
	// preferences: {}
 | 
					 | 
				
			||||||
	// users:
 | 
					 | 
				
			||||||
	// - name: red-user
 | 
					 | 
				
			||||||
	//   user:
 | 
					 | 
				
			||||||
	//     token: red-token
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func TestSetCurrentContext(t *testing.T) {
 | 
					func TestSetCurrentContext(t *testing.T) {
 | 
				
			||||||
	expectedConfig := newRedFederalCowHammerConfig()
 | 
						expectedConfig := newRedFederalCowHammerConfig()
 | 
				
			||||||
	expectedConfig.CurrentContext = "the-new-context"
 | 
						expectedConfig.CurrentContext = "the-new-context"
 | 
				
			||||||
@@ -571,7 +540,7 @@ func testConfigCommand(args []string, startingConfig clientcmdapi.Config) (strin
 | 
				
			|||||||
	return buf.String(), *config
 | 
						return buf.String(), *config
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (test configCommandTest) run(t *testing.T) string {
 | 
					func (test configCommandTest) run(t *testing.T) {
 | 
				
			||||||
	out, actualConfig := testConfigCommand(test.args, test.startingConfig)
 | 
						out, actualConfig := testConfigCommand(test.args, test.startingConfig)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	testSetNilMapsToEmpties(reflect.ValueOf(&test.expectedConfig))
 | 
						testSetNilMapsToEmpties(reflect.ValueOf(&test.expectedConfig))
 | 
				
			||||||
@@ -587,8 +556,6 @@ func (test configCommandTest) run(t *testing.T) string {
 | 
				
			|||||||
			t.Errorf("expected '%s' in output, got '%s'", expectedOutput, out)
 | 
								t.Errorf("expected '%s' in output, got '%s'", expectedOutput, out)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					 | 
				
			||||||
	return out
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
func testSetNilMapsToEmpties(curr reflect.Value) {
 | 
					func testSetNilMapsToEmpties(curr reflect.Value) {
 | 
				
			||||||
	actualCurrValue := curr
 | 
						actualCurrValue := curr
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -26,8 +26,6 @@ import (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	"github.com/GoogleCloudPlatform/kubernetes/pkg/client/clientcmd"
 | 
						"github.com/GoogleCloudPlatform/kubernetes/pkg/client/clientcmd"
 | 
				
			||||||
	clientcmdapi "github.com/GoogleCloudPlatform/kubernetes/pkg/client/clientcmd/api"
 | 
						clientcmdapi "github.com/GoogleCloudPlatform/kubernetes/pkg/client/clientcmd/api"
 | 
				
			||||||
	"github.com/GoogleCloudPlatform/kubernetes/pkg/client/clientcmd/api/latest"
 | 
					 | 
				
			||||||
	"github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl"
 | 
					 | 
				
			||||||
	cmdutil "github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl/cmd/util"
 | 
						cmdutil "github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl/cmd/util"
 | 
				
			||||||
	"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
 | 
						"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
@@ -52,20 +50,14 @@ $ kubectl config view --local`,
 | 
				
			|||||||
		Run: func(cmd *cobra.Command, args []string) {
 | 
							Run: func(cmd *cobra.Command, args []string) {
 | 
				
			||||||
			options.complete()
 | 
								options.complete()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			printer, generic, err := cmdutil.PrinterForCommand(cmd)
 | 
								printer, _, err := cmdutil.PrinterForCommand(cmd)
 | 
				
			||||||
			if err != nil {
 | 
								if err != nil {
 | 
				
			||||||
				glog.FatalDepth(1, err)
 | 
									glog.FatalDepth(1, err)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			if generic {
 | 
					 | 
				
			||||||
				version := cmdutil.OutputVersion(cmd, latest.Version)
 | 
					 | 
				
			||||||
				printer = kubectl.NewVersionedPrinter(printer, clientcmdapi.Scheme, version)
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			config, err := options.loadConfig()
 | 
								config, err := options.loadConfig()
 | 
				
			||||||
			if err != nil {
 | 
								if err != nil {
 | 
				
			||||||
				glog.FatalDepth(1, err)
 | 
									glog.FatalDepth(1, err)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					 | 
				
			||||||
			err = printer.PrintObj(config, out)
 | 
								err = printer.PrintObj(config, out)
 | 
				
			||||||
			if err != nil {
 | 
								if err != nil {
 | 
				
			||||||
				glog.FatalDepth(1, err)
 | 
									glog.FatalDepth(1, err)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user