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

Function Example_noMergingOnExplicitPaths

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

Source from the content-addressed store, hash-verified

577}
578
579func Example_noMergingOnExplicitPaths() {
580 commandLineFile, _ := ioutil.TempFile("", "")
581 defer os.Remove(commandLineFile.Name())
582 envVarFile, _ := ioutil.TempFile("", "")
583 defer os.Remove(envVarFile.Name())
584
585 WriteToFile(testConfigAlfa, commandLineFile.Name())
586 WriteToFile(testConfigConflictAlfa, envVarFile.Name())
587
588 loadingRules := ClientConfigLoadingRules{
589 ExplicitPath: commandLineFile.Name(),
590 Precedence: []string{envVarFile.Name()},
591 }
592
593 mergedConfig, err := loadingRules.Load()
594
595 json, err := runtime.Encode(clientcmdlatest.Codec, mergedConfig)
596 if err != nil {
597 fmt.Printf("Unexpected error: %v", err)
598 }
599 output, err := yaml.JSONToYAML(json)
600 if err != nil {
601 fmt.Printf("Unexpected error: %v", err)
602 }
603
604 fmt.Printf("%v", string(output))
605 // Output:
606 // apiVersion: v1
607 // clusters:
608 // - cluster:
609 // server: http://cow.org:8080
610 // name: cow-cluster
611 // contexts:
612 // - context:
613 // cluster: cow-cluster
614 // namespace: hammer-ns
615 // user: red-user
616 // name: federal-context
617 // current-context: ""
618 // kind: Config
619 // preferences: {}
620 // users:
621 // - name: red-user
622 // user:
623 // token: red-token
624}
625
626func Example_mergingSomeWithConflict() {
627 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