@@ -141,14 +141,18 @@ func (g *appConfigurationGenerator) Generate(spec *v1.Spec) error {
141141 namespace := g .getNamespaceName ()
142142 gfs := []modules.NewGeneratorFunc {
143143 NewNamespaceGeneratorFunc (namespace ),
144+ }
145+
146+ if g .app .Workload != nil {
144147 // todo: refactor secret into a module
145- secret .NewSecretGeneratorFunc (& secret.GeneratorRequest {
148+ gfs = append ( gfs , secret .NewSecretGeneratorFunc (& secret.GeneratorRequest {
146149 Project : g .project .Name ,
147150 Namespace : namespace ,
148151 Workload : g .app .Workload ,
149152 SecretStore : g .ws .SecretStore ,
150- }),
153+ }))
151154 }
155+
152156 if err = modules .CallGenerators (spec , gfs ... ); err != nil {
153157 return err
154158 }
@@ -160,7 +164,9 @@ func (g *appConfigurationGenerator) Generate(spec *v1.Spec) error {
160164 }
161165
162166 // append the generated resources to the spec
163- spec .Resources = append (spec .Resources , * wl )
167+ if wl != nil {
168+ spec .Resources = append (spec .Resources , * wl )
169+ }
164170 spec .Resources = append (spec .Resources , resources ... )
165171
166172 // patch workload with resource patchers
@@ -246,6 +252,11 @@ func PatchWorkload(workload *v1.Resource, patcher *v1.Patcher) error {
246252 return nil
247253 }
248254
255+ if workload == nil {
256+ log .Info ("workload is nil, return" )
257+ return nil
258+ }
259+
249260 un := & unstructured.Unstructured {}
250261 attributes := workload .Attributes
251262
@@ -500,7 +511,9 @@ func (g *appConfigurationGenerator) buildModuleConfigIndex(platformModuleConfigs
500511 for k , v := range g .app .Accessories {
501512 tempMap [k ] = v
502513 }
503- tempMap ["workload" ] = g .app .Workload
514+ if g .app .Workload != nil {
515+ tempMap ["workload" ] = g .app .Workload
516+ }
504517
505518 for accName , accessory := range tempMap {
506519 // parse accessory module key
@@ -525,6 +538,11 @@ func (g *appConfigurationGenerator) buildModuleConfigIndex(platformModuleConfigs
525538// parseModuleKey returns the module key of the accessory in format of "org/module@version"
526539// example: "kusionstack/[email protected] " 527540func parseModuleKey (accessory v1.Accessory , dependencies * pkg.Dependencies ) (string , error ) {
541+ if accessory == nil {
542+ log .Info ("accessory is nil, return empty module key" )
543+ return "" , nil
544+ }
545+
528546 moduleName , err := getModuleName (accessory )
529547 if err != nil {
530548 return "" , err
0 commit comments