Skip to content

(feat): Multi resource catalog item and instance#11

Open
jenniferubah wants to merge 1 commit into
dcm-project:mainfrom
jenniferubah:catalog/composite-resolution
Open

(feat): Multi resource catalog item and instance#11
jenniferubah wants to merge 1 commit into
dcm-project:mainfrom
jenniferubah:catalog/composite-resolution

Conversation

@jenniferubah

@jenniferubah jenniferubah commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Add catalog item and and catalog instance resolution for multiple resource within a single request
Enhancement: dcm-project/enhancements#55
Note: Creation and Deletion for multi resource placement and rehydration are out of scope for this PR. These will be in a follow up PR and are marked as TODO in this PR.

@jenniferubah jenniferubah force-pushed the catalog/composite-resolution branch 11 times, most recently from 67d0d55 to 98af244 Compare June 25, 2026 21:10
Assisted-By: Cursor AI

Signed-off-by: Jennifer Ubah <cju.cipher@gmail.com>
@jenniferubah jenniferubah force-pushed the catalog/composite-resolution branch from 98af244 to 88da51a Compare June 25, 2026 21:28
@jenniferubah jenniferubah changed the title Composite catalog item component (feat): Multi resource catalog item and instance Jun 25, 2026
@jenniferubah jenniferubah marked this pull request as ready for review June 25, 2026 21:35
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

Comment on lines +184 to +196
inst, err := s.Get(ctx, id)
if err != nil {
if errors.Is(err, ErrCatalogItemInstanceNotFound) {
return nil, ErrCatalogItemInstanceNotFound
}
return nil, fmt.Errorf("failed to get catalog item instance: %w", err)
}
if len(inst.Spec.ResourceIDs) == 0 || inst.Spec.ResourceIDs[0] != expectedResourceID {
return nil, ErrCatalogItemInstanceConflict
}

inst.Spec.ResourceIDs[0] = newResourceID
result := s.db.WithContext(ctx).Model(&inst).Where("id = ?", id).Select("spec").Updates(&inst)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

the DB entry should be locked during this to avoid having potential race here where 2 requests race each other: we get the data from the DB, then some checks are performed on the app and only then the entry is updated in the DB. So during the time the checks are performed, some other changes may be applied to the DB.

So we should either block any change (or at least update) to be applied to the resource or do the update in 1 call as it was done previously

}

// TODO: Rehydrate for multi-resources
oldResourceID := instance.Spec.ResourceIDs[0]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

is it possible that Spec.ResourceIDs[0] is empty so this access would panic?

Comment on lines +113 to +114
if err := validateUserValuesForCatalogItem(catalogItem.Spec, req.Spec.UserValues); err != nil {
return nil, err

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

this is called by BuildResourceGraph which is called by createInstance so I guess this call is duplicated

WHERE json_extract(resource.value, '$.service_type') = ?
)`, serviceType)
default:
return query

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

so no filter is the DB is neither PSQL or sqlite? SHould we at least log a warning?

return nil
}

func sameStringSlice(a, b []string) bool {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think we can use slices.Equal from the std lib instead

if !ok {
return false
}
return strings.Contains(str, "${")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

this is to broad IMO. We should match for the whole pattern that we defined celReferencePattern

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.

3 participants