|
9 | 9 | "path/filepath"
|
10 | 10 | "testing"
|
11 | 11 |
|
12 |
| - "github.com/stretchr/testify/assert" |
13 | 12 | kusttest_test "sigs.k8s.io/kustomize/api/testutils/kusttest"
|
14 | 13 | )
|
15 | 14 |
|
@@ -580,139 +579,3 @@ valuesInline:
|
580 | 579 | `)
|
581 | 580 | th.AssertActualEqualsExpected(rm, "")
|
582 | 581 | }
|
583 |
| - |
584 |
| -func TestHelmChartInflationGeneratorWithSameChartMultipleVersions(t *testing.T) { |
585 |
| - th := kusttest_test.MakeEnhancedHarnessWithTmpRoot(t). |
586 |
| - PrepBuiltin("HelmChartInflationGenerator") |
587 |
| - defer th.Reset() |
588 |
| - if err := th.ErrIfNoHelm(); err != nil { |
589 |
| - t.Skip("skipping: " + err.Error()) |
590 |
| - } |
591 |
| - |
592 |
| - tests := []struct { |
593 |
| - name string |
594 |
| - chartName string |
595 |
| - repo string |
596 |
| - version string |
597 |
| - releaseName string |
598 |
| - }{ |
599 |
| - { |
600 |
| - name: "terraform chart with no version grabs latest", |
601 |
| - chartName: "terraform", |
602 |
| - repo: "https://helm.releases.hashicorp.com", |
603 |
| - version: "", |
604 |
| - releaseName: "terraform-latest", |
605 |
| - }, |
606 |
| - { |
607 |
| - name: "terraform chart with version 1.1.1", |
608 |
| - chartName: "terraform", |
609 |
| - repo: "https://helm.releases.hashicorp.com", |
610 |
| - version: "1.1.1", |
611 |
| - releaseName: "terraform-1.1.1", |
612 |
| - }, |
613 |
| - { |
614 |
| - name: "terraform chart with version 1.1.1 again", |
615 |
| - chartName: "terraform", |
616 |
| - repo: "https://helm.releases.hashicorp.com", |
617 |
| - version: "1.1.1", |
618 |
| - releaseName: "terraform-1.1.1-1", |
619 |
| - }, |
620 |
| - { |
621 |
| - name: "terraform chart with version 1.1.2", |
622 |
| - chartName: "terraform", |
623 |
| - repo: "https://helm.releases.hashicorp.com", |
624 |
| - version: "1.1.2", |
625 |
| - releaseName: "terraform-1.1.2", |
626 |
| - }, |
627 |
| - } |
628 |
| - |
629 |
| - for _, tt := range tests { |
630 |
| - t.Run(tt.name, func(t *testing.T) { |
631 |
| - config := fmt.Sprintf(` |
632 |
| -apiVersion: builtin |
633 |
| -kind: HelmChartInflationGenerator |
634 |
| -metadata: |
635 |
| - name: %s |
636 |
| -name: %s |
637 |
| -version: %s |
638 |
| -repo: %s |
639 |
| -releaseName: %s |
640 |
| -`, tt.chartName, tt.chartName, tt.version, tt.repo, tt.releaseName) |
641 |
| - |
642 |
| - rm := th.LoadAndRunGenerator(config) |
643 |
| - assert.True(t, len(rm.Resources()) > 0) |
644 |
| - |
645 |
| - var chartDir string |
646 |
| - if tt.version != "" { |
647 |
| - chartDir = fmt.Sprintf("charts/%s-%s/%s", tt.chartName, tt.version, tt.chartName) |
648 |
| - } else { |
649 |
| - chartDir = fmt.Sprintf("charts/%s", tt.chartName) |
650 |
| - } |
651 |
| - |
652 |
| - d, err := th.GetFSys().ReadFile(filepath.Join(th.GetRoot(), chartDir, "Chart.yaml")) |
653 |
| - if err != nil { |
654 |
| - t.Fatal(err) |
655 |
| - } |
656 |
| - |
657 |
| - assert.Contains(t, string(d), fmt.Sprintf("name: %s", tt.chartName)) |
658 |
| - if tt.version != "" { |
659 |
| - assert.Contains(t, string(d), fmt.Sprintf("version: %s", tt.version)) |
660 |
| - } |
661 |
| - }) |
662 |
| - } |
663 |
| -} |
664 |
| - |
665 |
| -// Test that verifies +1 instances of same chart with different versions |
666 |
| -// https://github.com/kubernetes-sigs/kustomize/issues/4813 |
667 |
| -func TestHelmChartInflationGeneratorWithMultipleInstancesSameChartDifferentVersions(t *testing.T) { |
668 |
| - th := kusttest_test.MakeEnhancedHarnessWithTmpRoot(t). |
669 |
| - PrepBuiltin("HelmChartInflationGenerator") |
670 |
| - defer th.Reset() |
671 |
| - if err := th.ErrIfNoHelm(); err != nil { |
672 |
| - t.Skip("skipping: " + err.Error()) |
673 |
| - } |
674 |
| - |
675 |
| - podinfo1 := th.LoadAndRunGenerator(` |
676 |
| -apiVersion: builtin |
677 |
| -kind: HelmChartInflationGenerator |
678 |
| -metadata: |
679 |
| - name: podinfo |
680 |
| -name: podinfo |
681 |
| -version: 6.2.1 |
682 |
| -repo: https://stefanprodan.github.io/podinfo |
683 |
| -releaseName: podinfo1 |
684 |
| -`) |
685 |
| - |
686 |
| - podinfo2 := th.LoadAndRunGenerator(` |
687 |
| -apiVersion: builtin |
688 |
| -kind: HelmChartInflationGenerator |
689 |
| -metadata: |
690 |
| - name: podinfo |
691 |
| -name: podinfo |
692 |
| -version: 6.1.8 |
693 |
| -repo: https://stefanprodan.github.io/podinfo |
694 |
| -releaseName: podinfo2 |
695 |
| -`) |
696 |
| - |
697 |
| - podinfo1Img, err := podinfo1.Resources()[1].GetFieldValue("spec.template.spec.containers.0.image") |
698 |
| - assert.NoError(t, err) |
699 |
| - assert.Equal(t, "ghcr.io/stefanprodan/podinfo:6.2.1", podinfo1Img) |
700 |
| - |
701 |
| - podinfo2Img, err := podinfo2.Resources()[1].GetFieldValue("spec.template.spec.containers.0.image") |
702 |
| - assert.NoError(t, err) |
703 |
| - assert.Equal(t, "ghcr.io/stefanprodan/podinfo:6.1.8", podinfo2Img) |
704 |
| - |
705 |
| - podinfo1ChartsDir := filepath.Join(th.GetRoot(), "charts/podinfo-6.2.1/podinfo") |
706 |
| - assert.True(t, th.GetFSys().Exists(podinfo1ChartsDir)) |
707 |
| - |
708 |
| - podinfo2ChartsDir := filepath.Join(th.GetRoot(), "charts/podinfo-6.1.8/podinfo") |
709 |
| - assert.True(t, th.GetFSys().Exists(podinfo2ChartsDir)) |
710 |
| - |
711 |
| - podinfo1ChartContents, err := th.GetFSys().ReadFile(filepath.Join(podinfo1ChartsDir, "Chart.yaml")) |
712 |
| - assert.NoError(t, err) |
713 |
| - assert.Contains(t, string(podinfo1ChartContents), "version: 6.2.1") |
714 |
| - |
715 |
| - podinfo2ChartContents, err := th.GetFSys().ReadFile(filepath.Join(podinfo2ChartsDir, "Chart.yaml")) |
716 |
| - assert.NoError(t, err) |
717 |
| - assert.Contains(t, string(podinfo2ChartContents), "version: 6.1.8") |
718 |
| -} |
0 commit comments