Skip to content

Commit

Permalink
fix: adapt the local-dev scripts to rendered workflow (#1210)
Browse files Browse the repository at this point in the history
  • Loading branch information
tommartensen authored Mar 7, 2024
1 parent d0d69e0 commit fee0053
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 11 deletions.
48 changes: 40 additions & 8 deletions scripts/local-dev/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ import (
"gopkg.in/yaml.v2"
)

var localConfigurationDir = "configuration/"
var (
localConfigurationDir = "configuration/"
chartPath = "chart/infra-server/Chart.yaml"
staticPath = "chart/infra-server/static"
valuesPath = "chart/infra-server/configuration/development-values-from-files.yaml"
)

func createLocalConfigurationDir() error {
// remove previous configurations
Expand Down Expand Up @@ -64,7 +69,7 @@ func determineValues() (map[string]interface{}, error) {
}

data := make(map[string]interface{})
fileContent, err := os.ReadFile("chart/infra-server/Chart.yaml")
fileContent, err := os.ReadFile(chartPath)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -121,13 +126,33 @@ func renderFile(path, content string, decodeString bool) error {
return nil
}

func renderFlavors() error {
path := "flavors.yaml"
fileContent, err := os.ReadFile(fmt.Sprintf("chart/infra-server/static/%s", path))
func renderFlavorList() error {
file := "flavors.yaml"
fileContent, err := os.ReadFile(fmt.Sprintf("%s/%s", staticPath, file))
if err != nil {
return err
}
return renderFile(path, string(fileContent), false)
return renderFile(file, string(fileContent), false)
}

func renderWorkflows() error {
files, err := os.ReadDir(staticPath)
if err != nil {
return fmt.Errorf("error while looking for workflow files: %v", err)
}
for _, file := range files {
fileName := file.Name()
if (strings.HasPrefix(fileName, "test-") || strings.HasPrefix(fileName, "workflow-")) && strings.HasSuffix(fileName, ".yaml") {
fileContent, err := os.ReadFile(fmt.Sprintf("%s/%s", staticPath, fileName))
if err != nil {
return err
}
if err := renderFile(fileName, string(fileContent), false); err != nil {
return err
}
}
}
return nil
}

func main() {
Expand All @@ -136,7 +161,7 @@ func main() {
return
}

data, err := readFileToMap("chart/infra-server/configuration/development-values-from-files.yaml")
data, err := readFileToMap(valuesPath)
if err != nil {
fmt.Printf("Error: %v\n", err)
return
Expand All @@ -153,10 +178,17 @@ func main() {
}
}

if err := renderFlavors(); err != nil {
if err := renderFlavorList(); err != nil {
fmt.Printf("Error: %v\n", err)
return
} else {
fmt.Println("Created flavors.yaml")
}

if err := renderWorkflows(); err != nil {
fmt.Printf("Error: %v\n", err)
return
} else {
fmt.Println("Rendered workflows")
}
}
3 changes: 0 additions & 3 deletions scripts/local-dev/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ sed -i 's/configuration\//..\/..\/configuration\//g' configuration/flavors.yaml
echo "INFO: Replace /etc/infra/static -> ../../ui/build in infra.yaml"
sed -i 's/\/etc\/infra\/static/..\/..\/ui\/build/g' configuration/infra.yaml

echo "INFO: Copy workflow templates in place"
cp chart/infra-server/static/{test,workflow}-*.yaml configuration/

echo "Prepare UI + CLI (for downloads)"
make -C ui
make cli
Expand Down

0 comments on commit fee0053

Please sign in to comment.