basePath, _ := cmd.Flags().GetString("base_path")
installerPath, _ := cmd.Flags().GetString("installer_path")
secretsRepository, _ := cmd.Flags().GetString("secrets_repository")
+ siteRepository, _ := cmd.Flags().GetString("site_repository")
settingsPath, _ := cmd.Flags().GetString("settings_path")
// Check if build path exists, create if not
}
// start generation process
- g := generator.New(baseRepo, basePath, installerPath, secretsRepository, settingsPath, buildPath)
+ g := generator.New(baseRepo, basePath, installerPath, secretsRepository, siteRepository, settingsPath, buildPath)
g.GenerateManifests()
},
}
generateCmd.Flags().StringP("secrets_repository", "", "", "Path to repository that contains secrets")
generateCmd.MarkFlagRequired("secrets_repository")
- generateCmd.Flags().StringP("settings_path", "", "", "Path to repository that contains settings.yaml with definitions for the site")
+
+ generateCmd.Flags().StringP("site_repository", "", "", "Url for the specific site github repository")
+ generateCmd.MarkFlagRequired("site_repository")
+ generateCmd.Flags().StringP("settings_path", "", "", "Path to settings.yaml with specific config for the site")
generateCmd.MarkFlagRequired("settings_path")
}
basePath string
installerPath string
secretsRepo string
+ siteRepo string
settingsPath string
buildPath string
secrets map[string]string
}
// New constructor for the generator
-func New(baseRepo string, basePath string, installerPath string, secretsRepo string, settingsPath string, buildPath string) Generator {
- g := Generator{baseRepo, basePath, installerPath, secretsRepo, settingsPath, buildPath, make(map[string]string)}
+func New(baseRepo string, basePath string, installerPath string, secretsRepo string, siteRepo string, settingsPath string, buildPath string) Generator {
+ g := Generator{baseRepo, basePath, installerPath, secretsRepo, siteRepo, settingsPath, buildPath, make(map[string]string)}
return g
}
}
os.Chmod(secretsPath, 0700)
- // Download the settings.yaml and place it on build directory
- log.Println("Download settings file")
- settingsBuildPath := fmt.Sprintf("%s/settings.yaml", g.buildPath)
- client = &getter.Client{Src: g.settingsPath, Dst: settingsBuildPath, Mode: getter.ClientModeFile}
- err = client.Get()
- if err != nil {
- log.Fatal(fmt.Sprintf("Error downloading settings.yaml: %s", err))
- os.Exit(1)
- }
-
// Clone the base repository with base manifests
log.Println("Cloning the base repository with base manifests")
baseBuildPath := fmt.Sprintf("%s/base_manifests", g.buildPath)
os.Exit(1)
}
+ // Clone the site repository with settings.yaml
+ log.Println("Cloning the site repository with settings")
+ siteBuildPath := fmt.Sprintf("%s/site", g.buildPath)
+ client = &getter.Client{Src: g.siteRepo, Dst: siteBuildPath, Mode: getter.ClientModeAny}
+ err = client.Get()
+ if err != nil {
+ log.Fatal(fmt.Sprintf("Error cloning site repository: %s", err))
+ }
}
// ReadSecretFiles will traverse secrets directory and read content
}
// parse settings file
- yamlContent, err := ioutil.ReadFile(fmt.Sprintf("%s/settings.yaml", g.buildPath))
+ settingsPath := fmt.Sprintf("%s/site/%s", g.buildPath, g.settingsPath)
+ yamlContent, err := ioutil.ReadFile(settingsPath)
if err != nil {
log.Fatal(fmt.Sprintf("Error reading settings file: %s", err))
os.Exit(1)