Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"packageRules": [
{
"description": "all Cost Management minor updates",
"matchFileNames": ["workspaces/cost-management/**"],
"extends": [
"github>redhat-developer/rhdh-plugins//.github/renovate-presets/base/rhdh-minor-presets(Cost Management)"
],
"addLabels": ["team/cost-management", "cost-management"]
},
{
"description": "all Cost Management patch updates",
"matchFileNames": ["workspaces/cost-management/**"],
"extends": [
"github>redhat-developer/rhdh-plugins//.github/renovate-presets/base/rhdh-patch-presets(Cost Management)"
],
"addLabels": ["team/cost-management", "cost-management"]
},
{
"description": "all Cost Management dev dependency updates",
"matchFileNames": ["workspaces/cost-management/**"],
"extends": [
"github>redhat-developer/rhdh-plugins//.github/renovate-presets/base/rhdh-devdependency-presets(Cost Management)"
],
"addLabels": ["team/cost-management", "cost-management"]
}
]
}

This file was deleted.

2 changes: 1 addition & 1 deletion .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"github>redhat-developer/rhdh-plugins//.github/renovate-presets/workspace/rhdh-orchestrator-presets",
"github>redhat-developer/rhdh-plugins//.github/renovate-presets/workspace/rhdh-sandbox-presets",
"github>redhat-developer/rhdh-plugins//.github/renovate-presets/workspace/rhdh-openshift-image-registry-presets",
"github>redhat-developer/rhdh-plugins//.github/renovate-presets/workspace/rhdh-redhat-resource-optimization-presets",
"github>redhat-developer/rhdh-plugins//.github/renovate-presets/workspace/rhdh-cost-management-presets",
"github>redhat-developer/rhdh-plugins//.github/renovate-presets/workspace/rhdh-quickstart-presets",
"github>redhat-developer/rhdh-plugins//.github/renovate-presets/workspace/rhdh-mcp-integrations-presets",
"github>redhat-developer/rhdh-plugins//.github/renovate-presets/workspace/rhdh-repo-tools-presets",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ This method requires vanilla backstage to be used:
credentials: dangerously-allow-unauthenticated

# Replace `${RHHCC_SA_CLIENT_ID}` and `${RHHCC_SA_CLIENT_SECRET}` with the service account credentials.
resourceOptimization:
costManagement:
clientId: ${RHHCC_SA_CLIENT_ID}
clientSecret: ${RHHCC_SA_CLIENT_SECRET}
optimizationWorkflowId: 'patch-k8s-resource'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,9 @@ catalog:
# target: https://github.com/backstage/backstage/blob/master/packages/catalog-model/examples/acme-corp.yaml
# rules:
# - allow: [User, Group]
# Cost Management plugin (optional). See plugins/redhat-resource-optimization README.
# costManagement:
# clientId: ${RHHCC_SA_CLIENT_ID}
# clientSecret: ${RHHCC_SA_CLIENT_SECRET}
# optimizationWorkflowId: 'patch-k8s-resource'
# optimizationsBaseUrl: 'https://console.redhat.com/api'
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ The procedure involves the following steps:
# replace the CLIENT_ID and CLIENT_SECRET which you have saved from the previous step from your service account
# with `Cost OpenShift Viewer` role

ROS_CLIENT_ID: # <as base64 string>
ROS_CLIENT_SECRET: # <as base64 string>
CM_CLIENT_ID: # <as base64 string>
CM_CLIENT_SECRET: # <as base64 string>
```

```yaml
Expand Down Expand Up @@ -57,8 +57,8 @@ The procedure involves the following steps:
target: https://console.redhat.com/api/cost-management/v1
allowedHeaders: ['Authorization']
credentials: dangerously-allow-unauthenticated
resourceOptimization:
clientId: ${ROS_CLIENT_ID}
clientSecret: ${ROS_CLIENT_SECRET}
costManagement:
clientId: ${CM_CLIENT_ID}
clientSecret: ${CM_CLIENT_SECRET}
optimizationWorkflowId: 'patch-k8s-resource'
```
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"repository": {
"type": "git",
"url": "https://github.com/redhat-developer/rhdh-plugins",
"directory": "workspaces/redhat-resource-optimization"
"directory": "workspaces/cost-management"
},
"devDependencies": {
"@backstage/cli": "^0.29.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"repository": {
"type": "git",
"url": "https://github.com/redhat-developer/rhdh-plugins",
"directory": "workspaces/redhat-resource-optimization/packages/app"
"directory": "workspaces/cost-management/packages/app"
},
"scripts": {
"start": "backstage-cli package start",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"repository": {
"type": "git",
"url": "https://github.com/redhat-developer/rhdh-plugins",
"directory": "workspaces/redhat-resource-optimization/packages/backend"
"directory": "workspaces/cost-management/packages/backend"
},
"scripts": {
"start": "backstage-cli package start",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ proxy:
target: https://console.redhat.com/api/cost-management/v1
allowedHeaders: ['Authorization']
credentials: dangerously-allow-unauthenticated
resourceOptimization:
clientId: ${ROS_CLIENT_ID}
clientSecret: ${ROS_CLIENT_SECRET}
costManagement:
clientId: ${CM_CLIENT_ID}
clientSecret: ${CM_CLIENT_SECRET}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

export interface Config {
resourceOptimization: {
costManagement: {
Copy link
Member

Choose a reason for hiding this comment

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

As I commented before, previously this was used without prefix, and after the refactor you introduced a prefix, is thsi expect? is this the config?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here the name is fine, but the nested values were incorrect.
Reverted.

/**
* @default "https://sso.redhat.com"
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"access": "public"
},
"repository": {
"directory": "workspaces/redhat-resource-optimization/plugins/redhat-resource-optimization-backend",
"directory": "workspaces/cost-management/plugins/redhat-resource-optimization-backend",
"type": "git",
"url": "https://github.com/redhat-developer/rhdh-plugins"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ export const getToken: (options: RouterOptions) => RequestHandler =
logger.info('Requesting new access token');

const ssoBaseUrl =
config.getOptionalString('resourceOptimization.ssoBaseUrl') ??
config.getOptionalString('costManagement.ssoBaseUrl') ??
DEFAULT_SSO_BASE_URL;
const params = {
tokenUrl: `${ssoBaseUrl}/auth/realms/redhat-external/protocol/openid-connect/token`,
clientId: config.getString('resourceOptimization.clientId'),
clientSecret: config.getString('resourceOptimization.clientSecret'),
clientId: config.getString('costManagement.clientId'),
clientSecret: config.getString('costManagement.clientSecret'),
scope: 'api.console',
grantType: 'client_credentials',
} as const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ export const getTokenFromApi = async (options: RouterOptions) => {
logger.info('Requesting new access token');

const ssoBaseUrl =
config.getOptionalString('resourceOptimization.ssoBaseUrl') ??
config.getOptionalString('costManagement.ssoBaseUrl') ??
DEFAULT_SSO_BASE_URL;
const params = {
tokenUrl: `${ssoBaseUrl}/auth/realms/redhat-external/protocol/openid-connect/token`,
clientId: config.getString('resourceOptimization.clientId'),
clientSecret: config.getString('resourceOptimization.clientSecret'),
clientId: config.getString('costManagement.clientId'),
clientSecret: config.getString('costManagement.clientSecret'),
scope: 'api.console',
grantType: 'client_credentials',
} as const;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Resource Optimization Common

Shared isomorphic code for the redhat-resource-optimization plugin.

## Generating the API client

The client is generated from the Optimizations (ROS) OpenAPI spec. The spec's `info.title` is set to `redhat-resource-optimization` (see [Generating API Clients](https://backstage.io/docs/openapi/generate-client/)). Run from the common package:

```sh
yarn generate-client
```

If a Cost Management reports API OpenAPI spec becomes available, the script in `scripts/generate_client.mjs` can be extended to fetch or merge it.

## Links

- [Resource Optimization front-end plugin](../redhat-resource-optimization/README.md)
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"access": "public"
},
"repository": {
"directory": "workspaces/redhat-resource-optimization/plugins/redhat-resource-optimization-common",
"directory": "workspaces/cost-management/plugins/redhat-resource-optimization-common",
"type": "git",
"url": "https://github.com/redhat-developer/rhdh-plugins"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
openapi: 3.0.0
info:
title: redhat-resource-optimization
title: cost-management
description: GO Echo API for Resource Optimization OCP Backend Service
version: v1
license:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ You can follow one of these options depending on your environment and how you ch
credentials: dangerously-allow-unauthenticated

# Replace `${RHHCC_SA_CLIENT_ID}` and `${RHHCC_SA_CLIENT_SECRET}` with the service account credentials.
resourceOptimization:
costManagement:
clientId: ${RHHCC_SA_CLIENT_ID}
clientSecret: ${RHHCC_SA_CLIENT_SECRET}
```
Expand Down Expand Up @@ -148,7 +148,7 @@ The procedure involves the following steps:
target: https://console.redhat.com/api/cost-management/v1
allowedHeaders: ['Authorization']
credentials: dangerously-allow-unauthenticated
resourceOptimization:
costManagement:
clientId: '${RHHCC_SA_CLIENT_ID}'
clientSecret: '${RHHCC_SA_CLIENT_SECRET}'
dynamicPlugins:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

export interface Config {
resourceOptimization?: {
costManagement?: {
/** @visibility frontend */
optimizationWorkflowId?: string;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"access": "public"
},
"repository": {
"directory": "workspaces/redhat-resource-optimization/plugins/redhat-resource-optimization",
"directory": "workspaces/cost-management/plugins/redhat-resource-optimization",
"type": "git",
"url": "https://github.com/redhat-developer/rhdh-plugins"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,7 @@ export const OptimizationsBreakdownPage = () => {
const { id } = useParams();
const configApi = useApi(configApiRef);
const workflowIdRef = useRef<string>(
configApi.getOptionalString(
'resourceOptimization.optimizationWorkflowId',
) ?? '',
configApi.getOptionalString('costManagement.optimizationWorkflowId') ?? '',
);
const workflowUnavailableReasonRef = useRef<
WorkflowUnavailableReason | undefined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export const getLegendData = (

const result: any = [];

series.map((s, index) => {
series.forEach((s, index) => {
Copy link
Member

Choose a reason for hiding this comment

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

Why is that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a Sonar Qube Issue fixed here.
CI fail here, unless we're changing the map to forEach.

if (s.legendItem) {
const data = {
childName: s.childName,
Expand Down

This file was deleted.

Loading