-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use config-file on CDK for kurtosis e2e tests (#99)
- The e2e test for CDK use a local configuration template instead of the one on kurtosis branch: to allow to develop changes on config file is more easy if we are able to use the config file on CDK repo. After that we can update config file and cdk image on kurtosis repo - The local configuration for run on vscode use the same template (`test/config/kurtosis-cdk-node-config.toml.template`) as the e2e test - Fix error on CI `test-e2e.yml` with the duplicated `ref` key
- Loading branch information
1 parent
ba2b077
commit 8167397
Showing
7 changed files
with
467 additions
and
209 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"os" | ||
"regexp" | ||
"strings" | ||
"text/template" | ||
) | ||
|
||
func main() { | ||
tmpl := template.New("t1") | ||
content, err := readFile(os.Args[1]) | ||
if err != nil { | ||
log.Fatalf("Error loading template: %v", err) | ||
} | ||
content = replaceDotsInTemplateVariables(content) | ||
tmpl = template.Must(tmpl.Parse(content)) | ||
|
||
if err := tmpl.Execute(os.Stdout, environmentToMap()); err != nil { | ||
log.Fatalf("Error executing template: %v", err) | ||
} | ||
} | ||
func replaceDotsInTemplateVariables(template string) string { | ||
re := regexp.MustCompile(`{{\s*\.([^{}]*)\s*}}`) | ||
result := re.ReplaceAllStringFunc(template, func(match string) string { | ||
match = strings.ReplaceAll(match[3:], ".", "_") | ||
return "{{." + match | ||
}) | ||
return result | ||
} | ||
|
||
func readFile(filename string) (string, error) { | ||
content, err := os.ReadFile(filename) | ||
if err != nil { | ||
return "", err | ||
} | ||
return string(content), nil | ||
} | ||
|
||
func environmentToMap() map[string]any { | ||
envVars := make(map[string]any) | ||
for _, e := range os.Environ() { | ||
pair := splitAtFirst(e, '=') | ||
fmt.Printf("zzzz env=%s pair=%v\n", e, pair) | ||
envVars[pair[0]] = pair[1] | ||
} | ||
envVars["aggregator_db"] = map[string]string{ | ||
"user": "user", | ||
"name": "Name", | ||
} | ||
return envVars | ||
} | ||
|
||
func splitAtFirst(s string, sep rune) [2]string { | ||
for i, c := range s { | ||
if c == sep { | ||
return [2]string{s[:i], s[i+1:]} | ||
} | ||
} | ||
return [2]string{s, ""} | ||
} |
Oops, something went wrong.