Skip to content

Commit

Permalink
Address comments for better easy to read syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
harshshahsumo committed Jul 11, 2024
1 parent ccf82d2 commit cd83f9d
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions tests/helm/goldenfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,18 +133,24 @@ func runGoldenFileTest(t *testing.T, valuesFileName string, outputFileName strin
// expected templates
func fixupRenderedYaml(yaml string, chartVersion string) string {
checksumRegex := regexp.MustCompile("checksum/config: [a-z0-9]{64}")
replacements := map[string]string{
fmt.Sprintf("app.kubernetes.io/version: \"%s\"", chartVersion): "app.kubernetes.io/version: \"%CURRENT_CHART_VERSION%\"",
fmt.Sprintf("chart: \"sumologic-%s\"", chartVersion): "chart: \"sumologic-%CURRENT_CHART_VERSION%\"",
fmt.Sprintf("chart: sumologic-%s", chartVersion): "chart: sumologic-%CURRENT_CHART_VERSION%",
fmt.Sprintf("client: k8s_%s", chartVersion): "client: k8s_%CURRENT_CHART_VERSION%",
fmt.Sprintf("value: \"%s\"", chartVersion): "value: \"%CURRENT_CHART_VERSION%\"",
// replacements := map[string]string{
// fmt.Sprintf("app.kubernetes.io/version: \"%s\"", chartVersion): "app.kubernetes.io/version: \"%CURRENT_CHART_VERSION%\"",
// fmt.Sprintf("chart: \"sumologic-%s\"", chartVersion): "chart: \"sumologic-%CURRENT_CHART_VERSION%\"",
// fmt.Sprintf("chart: sumologic-%s", chartVersion): "chart: sumologic-%CURRENT_CHART_VERSION%",
// fmt.Sprintf("client: k8s_%s", chartVersion): "client: k8s_%CURRENT_CHART_VERSION%",
// fmt.Sprintf("value: \"%s\"", chartVersion): "value: \"%CURRENT_CHART_VERSION%\"",
// }
replacements := []string{
"app.kubernetes.io/version: \"%s\"",
"chart: \"sumologic-%s\"",
"chart: sumologic-%s",
"client: k8s_%s",
"value: \"%s\"",
}

output := yaml
output = strings.ReplaceAll(output, releaseName, "RELEASE-NAME")
for oldString, newString := range replacements {
output = strings.ReplaceAll(output, oldString, newString)
for _, r := range replacements {
output = strings.ReplaceAll(output, fmt.Sprintf(r, chartVersion), fmt.Sprintf(r, "%CURRENT_CHART_VERSION%"))
}
output = checksumRegex.ReplaceAllLiteralString(output, "checksum/config: '%CONFIG_CHECKSUM%'")
output = strings.TrimSuffix(output, "\n")
Expand Down

0 comments on commit cd83f9d

Please sign in to comment.