@@ -2,7 +2,6 @@ package main
22
33import (
44 "fmt"
5- "io/ioutil"
65 "os"
76 "strings"
87
@@ -582,7 +581,7 @@ func validateRepo(c *cli.Context) {
582581 u := chartsScriptOptions .ValidateOptions .UpstreamOptions
583582 branch := chartsScriptOptions .ValidateOptions .Branch
584583 logrus .Infof ("Performing upstream validation against repository %s at branch %s" , u .URL , branch )
585- compareGeneratedAssetsResponse , err := validate .CompareGeneratedAssets (repoFs , u , branch , releaseOptions )
584+ compareGeneratedAssetsResponse , err := validate .CompareGeneratedAssets (repoRoot , repoFs , u , branch , releaseOptions )
586585 if err != nil {
587586 logrus .Fatal (err )
588587 }
@@ -634,17 +633,17 @@ func createOrUpdateTemplate(c *cli.Context) {
634633}
635634
636635func setupCache (c * cli.Context ) error {
637- return puller .InitRootCache (CacheMode , path .DefaultCachePath )
636+ return puller .InitRootCache (getRepoRoot (), CacheMode , path .DefaultCachePath )
638637}
639638
640639func cleanCache (c * cli.Context ) {
641- if err := puller .CleanRootCache (path .DefaultCachePath ); err != nil {
640+ if err := puller .CleanRootCache (getRepoRoot (), path .DefaultCachePath ); err != nil {
642641 logrus .Fatal (err )
643642 }
644643}
645644
646645func parseScriptOptions () * options.ChartsScriptOptions {
647- configYaml , err := ioutil .ReadFile (defaultChartsScriptOptionsFile )
646+ configYaml , err := os .ReadFile (ChartsScriptOptionsFile )
648647 if err != nil {
649648 logrus .Fatalf ("Unable to find configuration file: %s" , err )
650649 }
@@ -656,6 +655,13 @@ func parseScriptOptions() *options.ChartsScriptOptions {
656655}
657656
658657func getRepoRoot () string {
658+ var repoRoot string
659+ repoRoot = os .Getenv ("DEV_REPO_ROOT" )
660+ if repoRoot != "" {
661+ logrus .Debugf ("Using repo root : %s" , repoRoot )
662+ return repoRoot
663+ }
664+
659665 repoRoot , err := os .Getwd ()
660666 if err != nil {
661667 logrus .Fatalf ("Unable to get current working directory: %s" , err )
@@ -697,11 +703,12 @@ func checkImages(c *cli.Context) {
697703}
698704
699705func checkRCTagsAndVersions (c * cli.Context ) {
706+ repoRoot := getRepoRoot ()
700707 // Grab all images that contain RC tags
701- rcImageTagMap := images .CheckRCTags ()
708+ rcImageTagMap := images .CheckRCTags (repoRoot )
702709
703710 // Grab all chart versions that contain RC tags
704- rcChartVersionMap := charts .CheckRCCharts ()
711+ rcChartVersionMap := charts .CheckRCCharts (repoRoot )
705712
706713 // If there are any charts that contains RC version or images that contains RC tags
707714 // log them and return an error
@@ -717,8 +724,9 @@ func checkRCTagsAndVersions(c *cli.Context) {
717724func lifecycleStatus (c * cli.Context ) {
718725 // Initialize dependencies with branch-version and current chart
719726 logrus .Info ("Initializing dependencies for lifecycle-status" )
720- rootFs := filesystem .GetFilesystem (getRepoRoot ())
721- lifeCycleDep , err := lifecycle .InitDependencies (rootFs , c .String ("branch-version" ), CurrentChart )
727+ repoRoot := getRepoRoot ()
728+ rootFs := filesystem .GetFilesystem (repoRoot )
729+ lifeCycleDep , err := lifecycle .InitDependencies (repoRoot , rootFs , c .String ("branch-version" ), CurrentChart )
722730 if err != nil {
723731 logrus .Fatalf ("encountered error while initializing dependencies: %s" , err )
724732 }
@@ -738,8 +746,9 @@ func autoForwardPort(c *cli.Context) {
738746
739747 // Initialize dependencies with branch-version and current chart
740748 logrus .Info ("Initializing dependencies for auto-forward-port" )
741- rootFs := filesystem .GetFilesystem (getRepoRoot ())
742- lifeCycleDep , err := lifecycle .InitDependencies (rootFs , c .String ("branch-version" ), CurrentChart )
749+ repoRoot := getRepoRoot ()
750+ rootFs := filesystem .GetFilesystem (repoRoot )
751+ lifeCycleDep , err := lifecycle .InitDependencies (repoRoot , rootFs , c .String ("branch-version" ), CurrentChart )
743752 if err != nil {
744753 logrus .Fatalf ("encountered error while initializing dependencies: %v" , err )
745754 }
@@ -773,10 +782,10 @@ func release(c *cli.Context) {
773782 if CurrentChart == "" {
774783 logrus .Fatal ("CHART environment variable must be set to run release cmd" )
775784 }
785+ repoRoot := getRepoRoot ()
786+ rootFs := filesystem .GetFilesystem (repoRoot )
776787
777- rootFs := filesystem .GetFilesystem (getRepoRoot ())
778-
779- dependencies , err := lifecycle .InitDependencies (rootFs , c .String ("branch-version" ), CurrentChart )
788+ dependencies , err := lifecycle .InitDependencies (repoRoot , rootFs , c .String ("branch-version" ), CurrentChart )
780789 if err != nil {
781790 logrus .Fatalf ("encountered error while initializing dependencies: %v" , err )
782791 }
@@ -825,15 +834,15 @@ func validateRelease(c *cli.Context) {
825834 fmt .Println ("BRANCH environment variable must be set to run validate-release-charts" )
826835 os .Exit (1 )
827836 }
828-
829- rootFs := filesystem .GetFilesystem (getRepoRoot () )
837+ repoRoot := getRepoRoot ()
838+ rootFs := filesystem .GetFilesystem (repoRoot )
830839
831840 if ! strings .HasPrefix (Branch , "release-v" ) {
832841 fmt .Println ("Branch must be in the format release-v2.x" )
833842 os .Exit (1 )
834843 }
835844
836- dependencies , err := lifecycle .InitDependencies (rootFs , strings .TrimPrefix (Branch , "release-v" ), "" )
845+ dependencies , err := lifecycle .InitDependencies (repoRoot , rootFs , strings .TrimPrefix (Branch , "release-v" ), "" )
837846 if err != nil {
838847 fmt .Printf ("encountered error while initializing d: %v \n " , err )
839848 os .Exit (1 )
0 commit comments