diff --git a/pkg/daprrp/processors/pubsubbrokers/processor.go b/pkg/daprrp/processors/pubsubbrokers/processor.go index 597246d2c8..9e8982f8a7 100644 --- a/pkg/daprrp/processors/pubsubbrokers/processor.go +++ b/pkg/daprrp/processors/pubsubbrokers/processor.go @@ -62,9 +62,16 @@ func (p *Processor) Process(ctx context.Context, resource *datamodel.DaprPubSubB // If the resource is being provisioned manually then *we* are responsible for creating the Dapr Component. // Let's do this now. - applicationID, err := resources.ParseResource(resource.Properties.Application) - if err != nil && resource.Properties.Application != "" { - return err // This should already be validated by this point. + // DaprPubSubBroker resources may or may not be application scoped. + // Some Dapr Components can be specific to a single application, they would be application scoped and have + // resource.Properties.Application populated, while others could be shared across multiple applications and + // would not have resource.Properties.Application populated. + var applicationID resources.ID + if resource.Properties.Application != "" { + applicationID, err = resources.ParseResource(resource.Properties.Application) + if err != nil { + return err // This should already be validated by this point. + } } component, err := dapr.ConstructDaprGeneric( @@ -113,9 +120,17 @@ func (p *Processor) Delete(ctx context.Context, resource *datamodel.DaprPubSubBr return nil } - applicationID, err := resources.ParseResource(resource.Properties.Application) - if err != nil && resource.Properties.Application != "" { - return err // This should already be validated by this point. + // DaprPubSubBroker resources may or may not be application scoped. + // Some Dapr Components can be specific to a single application, they would be application scoped and have + // resource.Properties.Application populated, while others could be shared across multiple applications and + // would not have resource.Properties.Application populated. + var err error + var applicationID resources.ID + if resource.Properties.Application != "" { + applicationID, err = resources.ParseResource(resource.Properties.Application) + if err != nil { + return err + } } component := unstructured.Unstructured{ diff --git a/pkg/daprrp/processors/secretstores/processor.go b/pkg/daprrp/processors/secretstores/processor.go index a8ab999816..3a01e7c53a 100644 --- a/pkg/daprrp/processors/secretstores/processor.go +++ b/pkg/daprrp/processors/secretstores/processor.go @@ -59,9 +59,16 @@ func (p *Processor) Process(ctx context.Context, resource *datamodel.DaprSecretS // If the resource is being provisioned manually then *we* are responsible for creating the Dapr Component. // Let's do this now. - applicationID, err := resources.ParseResource(resource.Properties.Application) - if err != nil && resource.Properties.Application != "" { - return err // This should already be validated by this point. + // DaprSecretStore resources may or may not be application scoped. + // Some Dapr Components can be specific to a single application, they would be application scoped and have + // resource.Properties.Application populated, while others could be shared across multiple applications and + // would not have resource.Properties.Application populated. + var applicationID resources.ID + if resource.Properties.Application != "" { + applicationID, err = resources.ParseResource(resource.Properties.Application) + if err != nil { + return err // This should already be validated by this point. + } } component, err := dapr.ConstructDaprGeneric( @@ -110,9 +117,17 @@ func (p *Processor) Delete(ctx context.Context, resource *datamodel.DaprSecretSt return nil } - applicationID, err := resources.ParseResource(resource.Properties.Application) - if err != nil && resource.Properties.Application != "" { - return err // This should already be validated by this point. + // DaprSecretStore resources may or may not be application scoped. + // Some Dapr Components can be specific to a single application, they would be application scoped and have + // resource.Properties.Application populated, while others could be shared across multiple applications and + // would not have resource.Properties.Application populated. + var err error + var applicationID resources.ID + if resource.Properties.Application != "" { + applicationID, err = resources.ParseResource(resource.Properties.Application) + if err != nil { + return err + } } component := unstructured.Unstructured{ diff --git a/pkg/daprrp/processors/statestores/processor.go b/pkg/daprrp/processors/statestores/processor.go index 03fdaf391f..2a053a4694 100644 --- a/pkg/daprrp/processors/statestores/processor.go +++ b/pkg/daprrp/processors/statestores/processor.go @@ -62,9 +62,16 @@ func (p *Processor) Process(ctx context.Context, resource *datamodel.DaprStateSt // If the resource is being provisioned manually then *we* are responsible for creating the Dapr Component. // Let's do this now. - applicationID, err := resources.ParseResource(resource.Properties.Application) - if err != nil && resource.Properties.Application != "" { - return err // This should already be validated by this point. + // DaprStateStore resources may or may not be application scoped. + // Some Dapr Components can be specific to a single application, they would be application scoped and have + // resource.Properties.Application populated, while others could be shared across multiple applications and + // would not have resource.Properties.Application populated. + var applicationID resources.ID + if resource.Properties.Application != "" { + applicationID, err = resources.ParseResource(resource.Properties.Application) + if err != nil { + return err // This should already be validated by this point. + } } component, err := dapr.ConstructDaprGeneric( @@ -113,9 +120,17 @@ func (p *Processor) Delete(ctx context.Context, resource *datamodel.DaprStateSto return nil } - applicationID, err := resources.ParseResource(resource.Properties.Application) - if err != nil && resource.Properties.Application != "" { - return err // This should already be validated by this point. + // DaprStateStore resources may or may not be application scoped. + // Some Dapr Components can be specific to a single application, they would be application scoped and have + // resource.Properties.Application populated, while others could be shared across multiple applications and + // would not have resource.Properties.Application populated. + var err error + var applicationID resources.ID + if resource.Properties.Application != "" { + applicationID, err = resources.ParseResource(resource.Properties.Application) + if err != nil { + return err + } } component := unstructured.Unstructured{