MCPcopy
hub / github.com/kubernetes/client-go / Example_mergingSomeWithConflict

Function Example_mergingSomeWithConflict

tools/clientcmd/loader_test.go:626–677  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

624}
625
626func Example_mergingSomeWithConflict() {
627 commandLineFile, _ := ioutil.TempFile("", "")
628 defer os.Remove(commandLineFile.Name())
629 envVarFile, _ := ioutil.TempFile("", "")
630 defer os.Remove(envVarFile.Name())
631
632 WriteToFile(testConfigAlfa, commandLineFile.Name())
633 WriteToFile(testConfigConflictAlfa, envVarFile.Name())
634
635 loadingRules := ClientConfigLoadingRules{
636 Precedence: []string{commandLineFile.Name(), envVarFile.Name()},
637 }
638
639 mergedConfig, err := loadingRules.Load()
640
641 json, err := runtime.Encode(clientcmdlatest.Codec, mergedConfig)
642 if err != nil {
643 fmt.Printf("Unexpected error: %v", err)
644 }
645 output, err := yaml.JSONToYAML(json)
646 if err != nil {
647 fmt.Printf("Unexpected error: %v", err)
648 }
649
650 fmt.Printf("%v", string(output))
651 // Output:
652 // apiVersion: v1
653 // clusters:
654 // - cluster:
655 // server: http://cow.org:8080
656 // name: cow-cluster
657 // - cluster:
658 // insecure-skip-tls-verify: true
659 // server: http://donkey.org:8080
660 // name: donkey-cluster
661 // contexts:
662 // - context:
663 // cluster: cow-cluster
664 // namespace: hammer-ns
665 // user: red-user
666 // name: federal-context
667 // current-context: federal-context
668 // kind: Config
669 // preferences: {}
670 // users:
671 // - name: red-user
672 // user:
673 // token: red-token
674 // - name: yellow-user
675 // user:
676 // token: yellow-token
677}
678
679func Example_mergingEverythingNoConflicts() {
680 commandLineFile, _ := ioutil.TempFile("", "")

Callers

nothing calls this directly

Calls 4

LoadMethod · 0.95
WriteToFileFunction · 0.85
NameMethod · 0.45
EncodeMethod · 0.45

Tested by

no test coverage detected