diff --git a/pkg/generator/appconfiguration/generator/app_configurations_generator.go b/pkg/generator/appconfiguration/generator/app_configurations_generator.go index 7f40f732..adf5fa4a 100644 --- a/pkg/generator/appconfiguration/generator/app_configurations_generator.go +++ b/pkg/generator/appconfiguration/generator/app_configurations_generator.go @@ -6,6 +6,7 @@ import ( "kusionstack.io/kusion/pkg/generator" "kusionstack.io/kusion/pkg/generator/appconfiguration" accessories "kusionstack.io/kusion/pkg/generator/appconfiguration/generator/accessories/database" + "kusionstack.io/kusion/pkg/generator/appconfiguration/generator/trait" "kusionstack.io/kusion/pkg/generator/appconfiguration/generator/workload" "kusionstack.io/kusion/pkg/models" appmodel "kusionstack.io/kusion/pkg/models/appconfiguration" @@ -93,6 +94,7 @@ func (g *appConfigurationGenerator) Generate(spec *models.Spec) error { NewNamespaceGeneratorFunc(g.project.Name), accessories.NewDatabaseGeneratorFunc(g.project, g.stack, g.appName, g.app.Workload, g.app.Database), workload.NewWorkloadGeneratorFunc(g.project, g.stack, g.appName, g.app.Workload, g.app.Monitoring, g.app.OpsRule), + trait.NewOpsRuleGeneratorFunc(g.project, g.stack, g.appName, g.app), NewMonitoringGeneratorFunc(g.project, g.app.Monitoring, g.appName), // The OrderedResourcesGenerator should be executed after all resources are generated. NewOrderedResourcesGeneratorFunc(), diff --git a/pkg/generator/appconfiguration/generator/trait/ops_rule_generator.go b/pkg/generator/appconfiguration/generator/trait/ops_rule_generator.go index ac4ecccf..6c85f8d4 100644 --- a/pkg/generator/appconfiguration/generator/trait/ops_rule_generator.go +++ b/pkg/generator/appconfiguration/generator/trait/ops_rule_generator.go @@ -45,6 +45,10 @@ func NewOpsRuleGeneratorFunc( } func (g *opsRuleGenerator) Generate(spec *models.Spec) error { + if g.app.OpsRule == nil { + return nil + } + if g.app.Workload.Header.Type != workload.TypeService { return nil }