()
| 577 | } |
| 578 | |
| 579 | func 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 | |
| 626 | func Example_mergingSomeWithConflict() { |
| 627 | commandLineFile, _ := ioutil.TempFile("", "") |
nothing calls this directly
no test coverage detected