-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(marketplace-backend): Marketplace backend to use catalog client (#…
…172) * use catalog client to fetch the catalog entities * cleanup old metadata files * fix lint errors * clean types and update filenames
- Loading branch information
1 parent
5caf019
commit cb427cd
Showing
20 changed files
with
137 additions
and
210 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
workspaces/marketplace/plugins/marketplace-backend/src/services/MarketplaceCatalogService.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* Copyright 2024 The Backstage Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import { | ||
AuthService, | ||
LoggerService, | ||
RootConfigService, | ||
} from '@backstage/backend-plugin-api'; | ||
|
||
import { | ||
MarketplacePluginEntry, | ||
MarketplacePluginList, | ||
} from '@red-hat-developer-hub/backstage-plugin-marketplace-common'; | ||
|
||
import { MarketplaceService } from './MarketplaceService'; | ||
import { CatalogApi } from '@backstage/catalog-client'; | ||
|
||
export type Options = { | ||
logger: LoggerService; | ||
auth: AuthService; | ||
config?: RootConfigService; | ||
catalogApi: CatalogApi; | ||
}; | ||
|
||
export class MarketplaceCatalogService implements MarketplaceService { | ||
private readonly logger: LoggerService; | ||
private readonly catalog: CatalogApi; | ||
private readonly auth: AuthService; | ||
|
||
constructor(options: Options) { | ||
this.logger = options.logger; | ||
this.auth = options.auth; | ||
this.catalog = options.catalogApi; | ||
} | ||
|
||
async getPlugins(): Promise<MarketplacePluginEntry[]> { | ||
this.logger.info('getPlugins'); | ||
|
||
const token = await this.auth.getPluginRequestToken({ | ||
onBehalfOf: await this.auth.getOwnServiceCredentials(), | ||
targetPluginId: 'catalog', | ||
}); | ||
const result = await this.catalog.getEntities( | ||
{ | ||
filter: { | ||
kind: 'plugin', | ||
}, | ||
}, | ||
token, | ||
); | ||
|
||
return result.items as MarketplacePluginEntry[]; | ||
} | ||
|
||
async getPluginList(): Promise<MarketplacePluginList[]> { | ||
this.logger.info('getPluginList'); | ||
|
||
const token = await this.auth.getPluginRequestToken({ | ||
onBehalfOf: await this.auth.getOwnServiceCredentials(), | ||
targetPluginId: 'catalog', | ||
}); | ||
const result = await this.catalog.getEntities( | ||
{ | ||
filter: { | ||
kind: 'pluginList', | ||
}, | ||
}, | ||
token, | ||
); | ||
|
||
return result.items as MarketplacePluginList[]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 0 additions & 64 deletions
64
workspaces/marketplace/plugins/marketplace-backend/src/services/MarketplaceServiceFSImpl.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.