Skip to content

Commit

Permalink
Fixes resource category mapping
Browse files Browse the repository at this point in the history
Initially if a new category was added and if an exisiting resource
from the catalog already had that category, then resource-category
mapping was not done and hence the filter won't work on Hub UI

Hence, this patch fixes this by updating the catalog sha in the
database, which results in catalog refresh and all the resource-
category mapping is done

Signed-off-by: Puneet Punamiya ppunamiy@redhat.com
  • Loading branch information
PuneetPunamiya authored and tekton-robot committed Jan 12, 2023
1 parent 56ff1ce commit 8c77e13
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions api/pkg/db/initializer/initializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,26 @@ func (i *Initializer) Run(ctx context.Context) (*model.Config, error) {
return nil
}

// In order to map the existing resources with the updated config,
// catalog refresh needs to be done, hence deleting the sha will
// run the catalog refresh forcefully
logger.Info("Forcing Catalog Refresh by deleting the Catalog SHA")
updateCatalogSha := func(db *gorm.DB, log *log.Logger, data *app.Data) error {
for _, c := range data.Catalogs {
if err := db.Model(&model.Catalog{}).Where("name = ?", c.Name).Update("sha", "").Error; err != nil {
log.Error(err)
return err
}
}
return nil
}

if err := withTransaction(db, logger, data,
addCategories,
addCatalogs,
addUsers,
updateConfig,
updateCatalogSha,
); err != nil {
return nil, err
}
Expand Down

0 comments on commit 8c77e13

Please sign in to comment.