harness / backstage-plugins

Backstage Plugins for Harness Modules
Other
32 stars 22 forks source link

[Feat]: Add Search Collator for Harness resources #66

Open stephanschielke opened 1 year ago

stephanschielke commented 1 year ago

🔖 Feature description

Add a search collator that is able to index all projects, pipelines, services, and other resources available in Harness.

🎤 Context

The search feature of Backstage can be extended with new search index items. Users frequently use the search in Harness to find pipelines or services etc. but struggle to find items if they don't exactly know where they are stored in Harness. It would be beneficial if the backstage search could find those items.

✌️ Possible Implementation

Search collators should be implemented in a backstage backend plugin. However, no backend plugin yet exists. It could be named harness-backend-common

plugins/harness-backend-common/src/search/HarnessCollatorFactory.ts

class HarnessCollatorFactory implements DocumentCollatorFactory {

  async getCollator() {
    return Readable.from(this.execute());
  }

}

packages/backend/src/plugins/search.ts

import { HarnessCollatorFactory } from '@harnessio/backstage-plugin-backend-commong';
...
    indexBuilder.addCollator({
      schedule,
      factory: HarnessCollatorFactory.fromConfig(env.config, {
        logger: env.logger,
        discovery: env.discovery
      }),
    });

packages/app/src/components/search/SearchPage.tsx

          <Grid item xs={3}>
            <SearchType.Accordion
              name="Result Type"
              defaultValue=""
              types={[
                {
                  value: 'harness',
                  name: 'Harness',
                  icon: <DocsIcon/>,
                },
              ]}
            />
...
                      case 'harness':
                        return (
                          <HarnessResultListItem
                            key={document.location}
                            result={document}
                            highlight={highlight}
                            rank={rank}
                          />
                        );

I'm happy to work on this, though don't know how to best add a new backend plugin to this repo.

Debanitrkl commented 1 year ago

Hi @stephanschielke thanks for your interest regarding the search collator enhancement, feel free to open a PR , you could take help of our contributing guide to understand more on the same.

OrkoHunter commented 1 year ago

This is amazing! Thanks for the suggestion. We can start with just a simple collator to have pipelines searchable.

@stephanschielke As per your question, I think let's use yarn backstage-cli create and choose a common package and start adding the collator piece in there. You can fork this repo and clone your fork locally to do this. Some bits are also described in the contributing guide @Debanitrkl has shared. :)

Screenshot 2023-01-11 at 1 31 51 PM