Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for subscriptions to data sources #5271

Merged

Conversation

eleftherias
Copy link
Contributor

Summary

This is the first PR for adding subscriptions to data sources, allowing them to be part of a bundle.
This PR focuses on the database operations and service layer.
A followup PR will add the functions to import data sources from the bundle, and additional validation.

Change Type

Mark the type of change your PR introduces:

  • Bug fix (resolves an issue without affecting existing features)
  • Feature (adds new functionality without breaking changes)
  • Breaking change (may impact existing functionalities or require documentation updates)
  • Documentation (updates or additions to documentation)
  • Refactoring or test improvements (no bug fixes or new functionality)

Testing

Outline how the changes were tested, including steps to reproduce and any relevant configurations.
Attach screenshots if helpful.

Review Checklist:

  • Reviewed my own code for quality and clarity.
  • Added comments to complex or tricky code sections.
  • Updated any affected documentation.
  • Included tests that validate the fix or feature.
  • Checked that related changes are merged.

@eleftherias eleftherias requested a review from a team as a code owner January 9, 2025 10:20
@@ -36,7 +36,7 @@ func (s *Server) CreateDataSource(ctx context.Context,
}

// Process the request
ret, err := s.dataSourcesService.Create(ctx, dsReq, nil)
ret, err := s.dataSourcesService.Create(ctx, uuid.Nil, dsReq, nil)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we leave a TODO about verifying the subscription before doing an update?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we already do that in the service, I've tagged you in a comment below to verify

Comment on lines +253 to +262
// Validate the subscription ID if present
existingDS, err := getDataSourceFromDb(ctx, projectID, ReadBuilder().WithTransaction(tx), tx,
func(ctx context.Context, tx db.ExtendQuerier, projs []uuid.UUID) (db.DataSource, error) {
return getByNameQuery(ctx, tx, projs, ds.GetName())
})
if err != nil {
return nil, fmt.Errorf("failed to get existing data source: %w", err)
return nil, fmt.Errorf("failed to get existing data source from DB: %w", err)
}
if err = namespaces.DoesSubscriptionIDMatch(subscriptionID, existingDS.SubscriptionID); err != nil {
return nil, fmt.Errorf("failed to update data source: %w", err)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JAORMX Is this what you mean?

@eleftherias eleftherias merged commit 4b34fb3 into mindersec:main Jan 9, 2025
26 checks passed
@eleftherias eleftherias deleted the data-source-subscription-id branch January 9, 2025 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants