Add usage of SITE_REPO and akraino templates 62/462/1
authorYolanda Robla <yroblamo@redhat.com>
Tue, 12 Mar 2019 08:44:56 +0000 (09:44 +0100)
committerYolanda Robla <yroblamo@redhat.com>
Tue, 12 Mar 2019 08:50:30 +0000 (09:50 +0100)
Change-Id: I1783293a8386fc8725ac5c67967f0418025a0e83

Makefile
cmd/generate.go
pkg/generator/generator.go

index d322f7b..f1ad0cf 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -27,7 +27,7 @@ build:
 
 deploy:
        @echo "Launching cluster deployment bin/$(GONAME)"
-       @./bin/$(GONAME) generate --installer_path $(INSTALLER_PATH) --build_path $(BUILDDIR) --base_repository $(BASE_REPO) --base_path $(BASE_PATH) --secrets_repository $(CREDENTIALS) --settings_path $(SETTINGS)
+       @./bin/$(GONAME) generate --installer_path $(INSTALLER_PATH) --build_path $(BUILDDIR) --base_repository $(BASE_REPO) --base_path $(BASE_PATH) --secrets_repository $(CREDENTIALS) --site_repository $(SITE_REPO) --settings_path $(SETTINGS_PATH)
 
 clean:
        @echo "Destroying previous cluster"
index 97f703f..0e9565a 100644 (file)
@@ -34,6 +34,7 @@ var generateCmd = &cobra.Command{
                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
@@ -48,7 +49,7 @@ var generateCmd = &cobra.Command{
                }
 
                // start generation process
-               g := generator.New(baseRepo, basePath, installerPath, secretsRepository, settingsPath, buildPath)
+               g := generator.New(baseRepo, basePath, installerPath, secretsRepository, siteRepository, settingsPath, buildPath)
                g.GenerateManifests()
        },
 }
@@ -65,6 +66,9 @@ func init() {
 
        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")
 }
index fd3a40a..33789dd 100644 (file)
@@ -23,14 +23,15 @@ type Generator struct {
        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
 }
 
@@ -64,16 +65,6 @@ func (g Generator) DownloadArtifacts() {
        }
        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)
@@ -85,6 +76,14 @@ func (g Generator) DownloadArtifacts() {
                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
@@ -126,7 +125,8 @@ func (g Generator) GenerateInstallConfig() {
        }
 
        // 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)