func()

in internal/engine/environments/azure.go [83:124]


func (status *AzureDeploymentStatus) ConfigureMarkdownForDownload(
	markdown string,
	environmentVariables map[string]string,
	environment string,
) {
	if !IsAzureEnvironment(environment) {
		return
	}

	for key, value := range environmentVariables {
		exportRegex := patterns.ExportVariableRegex(key)

		matches := exportRegex.FindAllStringSubmatch(markdown, -1)

		if len(matches) != 0 {
			logging.GlobalLogger.Debugf(
				"Found %d matches for the environment variable %s, Replacing them in markdown source.",
				len(matches),
				key,
			)
		}

		for _, match := range matches {
			oldLine := match[0]
			oldValue := match[1]

			// Replace the old export with the new export statement
			newLine := strings.Replace(oldLine, oldValue, value+" ", 1)
			logging.GlobalLogger.Debugf("Replacing '%s' with '%s'", oldLine, newLine)

			// Update the code block with the new export statement
			markdown = strings.Replace(
				markdown,
				oldLine,
				newLine,
				1,
			)
		}
	}

	status.ConfiguredMarkdown = markdown
}