@@ -78,37 +78,56 @@ func init() {
7878}
7979
8080func generateAllDevelopersWithProgress () {
81- // Step 1: Discover all developers
81+ // Step 1: Load global config once
82+ globalConfig , err := config .LoadGlobalConfig (configDir )
83+ if err != nil {
84+ fmt .Fprintf (os .Stderr , "Error loading global config in %s: %v\n " , configDir , err )
85+ os .Exit (1 )
86+ }
87+
88+ if verbose {
89+ fmt .Printf ("Generating system manifests in %s\n " , outputDir )
90+ }
91+
92+ // Step 2: Generate system manifests once
93+ if ! dryRun {
94+ if err := generateSystemManifests (globalConfig , outputDir ); err != nil {
95+ fmt .Fprintf (os .Stderr , "Error generating system manifests: %v\n " , err )
96+ os .Exit (1 )
97+ }
98+ }
99+
100+ // Step 3: Discover all developers
82101 developers , err := findAllDevelopers (configDir )
83102 if err != nil {
84103 fmt .Fprintf (os .Stderr , "Error discovering developers: %v\n " , err )
85104 os .Exit (1 )
86105 }
87106
88107 if len (developers ) == 0 {
89- fmt .Printf ("No deveolopers found in %s\n " , configDir )
108+ fmt .Printf ("No developers found in %s\n " , configDir )
90109 return
91110 }
92111
93112 fmt .Printf ("Found %d developers to process.\n " , len (developers ))
94113
95- // Step 2 : Set up channels for worker communication
114+ // Step 4 : Set up channels for worker communication
96115 const numWorkers = 4
97116 jobs := make (chan DeveloperJob , len (developers ))
98117 results := make (chan ProcessingResult , len (developers ))
99118
100- // Step 3 : Start worker goroutines
119+ // Step 5 : Start worker goroutines
101120 for i := 0 ; i < numWorkers ; i ++ {
102- go developerWorker (jobs , results )
121+ go developerWorker (jobs , results , globalConfig )
103122 }
104123
105- // Step 4 : Send all jobs to workers
124+ // Step 6 : Send all jobs to workers
106125 for _ , dev := range developers {
107126 jobs <- DeveloperJob {Name : dev }
108127 }
109128 close (jobs )
110129
111- // Step 5 : Collect results
130+ // Step 7 : Collect results
112131 var successCount , failureCount int
113132 var failures []ProcessingResult
114133
@@ -126,7 +145,7 @@ func generateAllDevelopersWithProgress() {
126145 }
127146 }
128147
129- // Step 6 : Print final summary
148+ // Step 8 : Print final summary
130149 fmt .Printf ("\n 🎉 Batch processing complete!\n " )
131150 fmt .Printf ("✅ Successful: %d\n " , successCount )
132151 if failureCount > 0 {
@@ -142,10 +161,10 @@ func generateAllDevelopersWithProgress() {
142161 }
143162}
144163
145- func developerWorker (jobs <- chan DeveloperJob , results chan <- ProcessingResult ) {
164+ func developerWorker (jobs <- chan DeveloperJob , results chan <- ProcessingResult , globalConfig * config. BaseConfig ) {
146165 for job := range jobs {
147166 startTime := time .Now ()
148- err := processSingleDeveloperForBatchWithError (job .Name )
167+ err := processSingleDeveloperForBatchWithError (job .Name , globalConfig )
149168
150169 results <- ProcessingResult {
151170 Developer : job .Name ,
@@ -157,12 +176,12 @@ func developerWorker(jobs <-chan DeveloperJob, results chan<- ProcessingResult)
157176}
158177
159178// processSingleDeveloperForBatchWithError processes a single developer for batch mode
160- func processSingleDeveloperForBatchWithError (developerName string ) error {
179+ func processSingleDeveloperForBatchWithError (developerName string , globalConfig * config. BaseConfig ) error {
161180 if verbose {
162181 fmt .Printf ("Processing developer: %s\n " , developerName )
163182 }
164183
165- cfg , err := config .LoadDeveloperConfigWithGlobalDefaults (configDir , developerName )
184+ cfg , err := config .LoadDeveloperConfigWithBaseConfig (configDir , developerName , globalConfig )
166185 if err != nil {
167186 return fmt .Errorf ("failed to load config: %w" , err )
168187 }
@@ -171,7 +190,7 @@ func processSingleDeveloperForBatchWithError(developerName string) error {
171190 userOutputDir := filepath .Join (outputDir , developerName )
172191
173192 if ! dryRun {
174- if err := generateManifests (cfg , userOutputDir ); err != nil {
193+ if err := generateDeveloperManifests (cfg , userOutputDir ); err != nil {
175194 return fmt .Errorf ("failed to generate manifests: %w" , err )
176195 }
177196 }
@@ -212,7 +231,18 @@ func generateSingleDeveloper(developerName string) {
212231
213232 userOutputDir := filepath .Join (outputDir , developerName )
214233
215- cfg , err := config .LoadDeveloperConfigWithGlobalDefaults (configDir , developerName )
234+ globalConfig , err := config .LoadGlobalConfig (configDir )
235+ if err != nil {
236+ fmt .Fprintf (os .Stderr , "Error loading global config in %s: %v\n " , configDir , err )
237+ os .Exit (1 )
238+ }
239+
240+ if err := generateSystemManifests (globalConfig , outputDir ); err != nil {
241+ fmt .Fprintf (os .Stderr , "Error generating system manifests: %v\n " , err )
242+ os .Exit (1 )
243+ }
244+
245+ cfg , err := config .LoadDeveloperConfigWithBaseConfig (configDir , developerName , globalConfig )
216246 if err != nil {
217247 fmt .Fprintf (os .Stderr , "Error loading config for developer %s: %v\n " , developerName , err )
218248 os .Exit (1 )
@@ -225,7 +255,7 @@ func generateSingleDeveloper(developerName string) {
225255 }
226256
227257 if ! dryRun {
228- if err := generateManifests (cfg , userOutputDir ); err != nil {
258+ if err := generateDeveloperManifests (cfg , userOutputDir ); err != nil {
229259 fmt .Fprintf (os .Stderr , "Error generating manifests: %v\n " , err )
230260 os .Exit (1 )
231261 }
@@ -234,10 +264,24 @@ func generateSingleDeveloper(developerName string) {
234264 }
235265}
236266
237- // generateManifests creates Kubernetes manifests for a developer
238- func generateManifests (cfg * config.DevEnvConfig , outputDir string ) error {
267+ func generateSystemManifests (cfg * config.BaseConfig , outputDir string ) error {
268+ // Create template renderer
269+ renderer := templates .NewSystemRenderer (outputDir )
270+
271+ // Render all main templates
272+ if err := renderer .RenderAll (cfg ); err != nil {
273+ return fmt .Errorf ("failed to render templates: %w" , err )
274+ }
275+
276+ fmt .Printf ("🎉 Successfully generated system manifests\n " )
277+
278+ return nil
279+ }
280+
281+ // generateDeveloperManifests creates Kubernetes manifests for a developer
282+ func generateDeveloperManifests (cfg * config.DevEnvConfig , outputDir string ) error {
239283 // Create template renderer
240- renderer := templates .NewRenderer (outputDir )
284+ renderer := templates .NewDevRenderer (outputDir )
241285
242286 // Render all main templates
243287 if err := renderer .RenderAll (cfg ); err != nil {
0 commit comments