From: Yolanda Robla Date: Wed, 28 Aug 2019 14:11:44 +0000 (+0200) Subject: Download the blueprint on apply_workloads X-Git-Tag: akraino_r2~28 X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F81%2F1481%2F1;p=kni%2Finstaller.git Download the blueprint on apply_workloads If we assume that apply_workloads can run from anywhere, there is no need for blueprint to be present. So download it as we do for prepare_manifests Signed-off-by: Yolanda Robla Change-Id: I93578ec1fb1bc2837a07d9648eefa5b8f35c899a --- diff --git a/pkg/site/site.go b/pkg/site/site.go index 0cb95b3..0400627 100644 --- a/pkg/site/site.go +++ b/pkg/site/site.go @@ -225,21 +225,12 @@ func (s Site) WriteEnvFile() { } } -// using the downloaded site content, prepares the manifests for it -func (s Site) PrepareManifests() { - sitePath := fmt.Sprintf("%s/%s", s.buildPath, s.siteName) - log.Println(fmt.Sprintf("Preparing manifests for %s", s.siteName)) - - // do the initial validation of pre-requisites - utils.ValidateRequirements(s.buildPath, s.siteName) - binariesPath := fmt.Sprintf("%s/requirements", sitePath) - - // retrieve profile path and clone the repo - _, profileLayerPath, profileRef := s.GetProfileFromSite() - +// given a site, download the repo dependencies +func (s Site) DownloadRepo(sitePath string, profileLayerPath string, profileRef string) { var blueprintRepo string var absoluteBlueprintRepo string var downloadRepo string + // check if we have a file or git if strings.HasPrefix(profileLayerPath, "file://") { blueprintRepo = profileLayerPath @@ -288,7 +279,7 @@ func (s Site) PrepareManifests() { var envVars []string utils.ExecuteCommand("", envVars, true, false, "cp", "-R", fmt.Sprintf("%s/site", sitePath), fmt.Sprintf("%s/blueprint/sites/site", sitePath)) - err := filepath.Walk(fmt.Sprintf("%s/blueprint/sites/site", sitePath), func(path string, info os.FileInfo, err error) error { + filepath.Walk(fmt.Sprintf("%s/blueprint/sites/site", sitePath), func(path string, info os.FileInfo, err error) error { if err == nil { if info.Name() == "kustomization.yaml" { readKustomization, err := ioutil.ReadFile(path) @@ -317,6 +308,20 @@ func (s Site) PrepareManifests() { return nil }) +} + +// using the downloaded site content, prepares the manifests for it +func (s Site) PrepareManifests() { + sitePath := fmt.Sprintf("%s/%s", s.buildPath, s.siteName) + log.Println(fmt.Sprintf("Preparing manifests for %s", s.siteName)) + + // do the initial validation of pre-requisites + utils.ValidateRequirements(s.buildPath, s.siteName) + binariesPath := fmt.Sprintf("%s/requirements", sitePath) + + // retrieve profile path and clone the repo + _, profileLayerPath, profileRef := s.GetProfileFromSite() + s.DownloadRepo(sitePath, profileLayerPath, profileRef) // generate openshift-install manifests based on phase 00_install-config assetsPath := fmt.Sprintf("%s/generated_assets", sitePath) @@ -338,6 +343,7 @@ func (s Site) PrepareManifests() { } // now generate the manifests + var envVars []string utils.ExecuteCommand("", envVars, true, true, fmt.Sprintf("%s/openshift-install", binariesPath), "create", "manifests", fmt.Sprintf("--dir=%s", assetsPath), "--log-level", "debug") // iterate over all the generated files and create a kustomization file f, err := os.Create(fmt.Sprintf("%s/kustomization.yaml", assetsPath)) @@ -401,6 +407,10 @@ func (s Site) ApplyWorkloads(kubeconfigFile string) { } binariesPath := fmt.Sprintf("%s/requirements", siteBuildPath) + // retrieve profile path and clone the repo + _, profileLayerPath, profileRef := s.GetProfileFromSite() + s.DownloadRepo(siteBuildPath, profileLayerPath, profileRef) + log.Println(fmt.Sprintf("Applying workloads from %s/blueprint/sites/site/02_cluster-addons", siteBuildPath)) out := utils.ApplyKustomize(fmt.Sprintf("%s/kustomize", binariesPath), fmt.Sprintf("%s/blueprint/sites/site/02_cluster-addons", siteBuildPath)) if string(out) != "" {