Skip to content

Commit

Permalink
Usable SOPS config (#378)
Browse files Browse the repository at this point in the history
* Statred on configurable sops config

* WIP

* WIP

* WIP

* WIP

* WIP

* WIP

* WIP

* WIP

* WIP

* En bruker kan nå komme i gang med SOPS og sette opp default RoS

* Delete plugins/ros/src/assets/pr.svg

* Delete plugins/ros/src/assets/branch.svg

* WIP

* WIP

* WIP usable SOPS config

* WIP

* yarn fix

* Refactor and add norwegian text

* Minor styling bug fix

* Styling fix

* Minor changes

* Fix unique key bud

* Prettier format

* Linter fixing

* Fix lint errors

* Add GCP project and age keys info in step 3

* Make step 2 clickable

* Adjusted for keys instead of projects

* Formatted code

* Fix lint problem

---------

Co-authored-by: Lars Sørensen <larssorensen98@hotmail.com>
Co-authored-by: Håkon Frøland <hakon.froland@gmail.com>
  • Loading branch information
3 people authored Dec 11, 2024
1 parent 1f654e2 commit f33e897
Show file tree
Hide file tree
Showing 17 changed files with 6,482 additions and 5,557 deletions.
92 changes: 57 additions & 35 deletions packages/app/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,50 @@
import React from 'react';
import {Route} from 'react-router-dom';
import {apiDocsPlugin, ApiExplorerPage} from '@backstage/plugin-api-docs';
import {CatalogEntityPage, CatalogIndexPage, catalogPlugin,} from '@backstage/plugin-catalog';
import {CatalogImportPage, catalogImportPlugin,} from '@backstage/plugin-catalog-import';
import {ScaffolderPage, scaffolderPlugin} from '@backstage/plugin-scaffolder';
import {orgPlugin} from '@backstage/plugin-org';
import {SearchPage} from '@backstage/plugin-search';
import {TechRadarPage} from '@backstage-community/plugin-tech-radar';
import {DefaultTechDocsHome, TechDocsIndexPage, techdocsPlugin, TechDocsReaderPage,} from '@backstage/plugin-techdocs';
import {TechDocsAddons} from '@backstage/plugin-techdocs-react';
import {ReportIssue} from '@backstage/plugin-techdocs-module-addons-contrib';
import {UserSettingsPage} from '@backstage/plugin-user-settings';
import {apis} from './apis';
import {entityPage} from './components/catalog/EntityPage';
import {searchPage} from './components/search/SearchPage';
import {Root} from './components/Root';
import {HomepageCompositionRoot, VisitListener} from '@backstage/plugin-home';
import {HomePage} from './components/home/HomePage';
import {AlertDisplay, OAuthRequestDialog, SignInPage} from '@backstage/core-components';
import {createApp} from '@backstage/app-defaults';
import {AppRouter, FlatRoutes} from '@backstage/core-app-api';
import {CatalogGraphPage} from '@backstage/plugin-catalog-graph';
import {RequirePermission} from '@backstage/plugin-permission-react';
import {catalogEntityCreatePermission} from '@backstage/plugin-catalog-common/alpha';
import {ExplorePage} from '@backstage-community/plugin-explore';
import {microsoftAuthApiRef} from "@backstage/core-plugin-api";
import {LighthousePage} from '@backstage-community/plugin-lighthouse';
import {DevToolsPage} from '@backstage/plugin-devtools';
import {pluginRiScNorwegianTranslation} from '@kartverket/backstage-plugin-risk-scorecard';
import {OpencostPage} from "@kartverket/backstage-plugin-opencost";
import { Route } from 'react-router-dom';
import { apiDocsPlugin, ApiExplorerPage } from '@backstage/plugin-api-docs';
import {
CatalogEntityPage,
CatalogIndexPage,
catalogPlugin,
} from '@backstage/plugin-catalog';
import {
CatalogImportPage,
catalogImportPlugin,
} from '@backstage/plugin-catalog-import';
import { ScaffolderPage, scaffolderPlugin } from '@backstage/plugin-scaffolder';
import { orgPlugin } from '@backstage/plugin-org';
import { SearchPage } from '@backstage/plugin-search';
import { TechRadarPage } from '@backstage-community/plugin-tech-radar';
import {
DefaultTechDocsHome,
TechDocsIndexPage,
techdocsPlugin,
TechDocsReaderPage,
} from '@backstage/plugin-techdocs';
import { TechDocsAddons } from '@backstage/plugin-techdocs-react';
import { ReportIssue } from '@backstage/plugin-techdocs-module-addons-contrib';
import { UserSettingsPage } from '@backstage/plugin-user-settings';
import { apis } from './apis';
import { entityPage } from './components/catalog/EntityPage';
import { searchPage } from './components/search/SearchPage';
import { Root } from './components/Root';
import { HomepageCompositionRoot, VisitListener } from '@backstage/plugin-home';
import { HomePage } from './components/home/HomePage';
import {
AlertDisplay,
OAuthRequestDialog,
SignInPage,
} from '@backstage/core-components';
import { createApp } from '@backstage/app-defaults';
import { AppRouter, FlatRoutes } from '@backstage/core-app-api';
import { CatalogGraphPage } from '@backstage/plugin-catalog-graph';
import { RequirePermission } from '@backstage/plugin-permission-react';
import { catalogEntityCreatePermission } from '@backstage/plugin-catalog-common/alpha';
import { ExplorePage } from '@backstage-community/plugin-explore';
import { microsoftAuthApiRef } from '@backstage/core-plugin-api';
import { LighthousePage } from '@backstage-community/plugin-lighthouse';
import { DevToolsPage } from '@backstage/plugin-devtools';
import { pluginRiScNorwegianTranslation } from '@kartverket/backstage-plugin-risk-scorecard';
import { OpencostPage } from '@kartverket/backstage-plugin-opencost';

const app = createApp({
__experimentalTranslations: {
Expand All @@ -40,12 +56,18 @@ const app = createApp({
// if (configApi.getOptionalString('auth.environment') != 'production') {
// return <SignInPage {...props} auto providers={['guest']} />;
// }
return <SignInPage {...props} auto provider={{
return (
<SignInPage
{...props}
auto
provider={{
id: 'microsoft-auth-provider',
title: 'Microsoft',
message: 'Sign in using Microsoft',
apiRef: microsoftAuthApiRef,
}} />;
}}
/>
);
},
},
apis,
Expand All @@ -65,7 +87,7 @@ const app = createApp({
bind(orgPlugin.externalRoutes, {
catalogIndex: catalogPlugin.routes.catalogIndex,
});
}
},
});

const routes = (
Expand All @@ -80,8 +102,8 @@ const routes = (
>
{entityPage}
</Route>
<Route path="/docs" element={<TechDocsIndexPage />} >
<DefaultTechDocsHome />
<Route path="/docs" element={<TechDocsIndexPage />}>
<DefaultTechDocsHome />
</Route>
<Route
path="/docs/:namespace/:kind/:name/*"
Expand Down
60 changes: 33 additions & 27 deletions packages/app/src/components/catalog/EntityPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,17 @@ import { ReportIssue } from '@backstage/plugin-techdocs-module-addons-contrib';
import { EntityLinguistCard } from '@backstage-community/plugin-linguist';
import { EntityLighthouseContent } from '@backstage-community/plugin-lighthouse';
import {
EntityKubernetesContent,
isKubernetesAvailable,
EntityKubernetesContent,
isKubernetesAvailable,
} from '@backstage/plugin-kubernetes';
import { EntityGrafanaAlertsCard, EntityGrafanaDashboardsCard, EntityOverviewDashboardViewer, isAlertSelectorAvailable, isDashboardSelectorAvailable, isOverviewDashboardAvailable } from '@k-phoen/backstage-plugin-grafana';
import {
EntityGrafanaAlertsCard,
EntityGrafanaDashboardsCard,
EntityOverviewDashboardViewer,
isAlertSelectorAvailable,
isDashboardSelectorAvailable,
isOverviewDashboardAvailable,
} from '@k-phoen/backstage-plugin-grafana';
import { RiScPage } from '@kartverket/backstage-plugin-risk-scorecard';

const techdocsContent = (
Expand All @@ -84,7 +91,9 @@ const grafanaContent = (
</EntitySwitch.Case>
</EntitySwitch>
<EntitySwitch>
<EntitySwitch.Case if={entity => Boolean(isDashboardSelectorAvailable(entity))}>
<EntitySwitch.Case
if={entity => Boolean(isDashboardSelectorAvailable(entity))}
>
<Grid item md={6}>
<EntityGrafanaDashboardsCard />
</Grid>
Expand Down Expand Up @@ -214,9 +223,8 @@ const serviceEntityPage = (
</EntityLayout.Route>

<EntityLayout.Route path="/risc" title="ROS">
<RiScPage />
<RiScPage />
</EntityLayout.Route>

</EntityLayout>
);

Expand Down Expand Up @@ -250,9 +258,8 @@ const websiteEntityPage = (
</EntityLayout.Route>

<EntityLayout.Route path="/risc" title="Risk Scorecard">
<RiScPage />
<RiScPage />
</EntityLayout.Route>

</EntityLayout>
);

Expand All @@ -273,13 +280,13 @@ const defaultEntityPage = (
{techdocsContent}
</EntityLayout.Route>

<EntityLayout.Route
path="/kubernetes"
title="Kubernetes"
if={isKubernetesAvailable}
>
<EntityKubernetesContent />
</EntityLayout.Route>
<EntityLayout.Route
path="/kubernetes"
title="Kubernetes"
if={isKubernetesAvailable}
>
<EntityKubernetesContent />
</EntityLayout.Route>
</EntityLayout>
);

Expand Down Expand Up @@ -358,19 +365,19 @@ const groupPage = (
</Grid>
<Grid item xs={12} md={6}>
<EntityOwnershipCard
variant="gridItem"
entityFilterKind={[
'Domain',
'System',
'Component',
'API',
'Template',
'Resource',
]}
variant="gridItem"
entityFilterKind={[
'Domain',
'System',
'Component',
'API',
'Template',
'Resource',
]}
/>
</Grid>
<Grid item xs={12}>
<EntityMembersListCard showAggregateMembersToggle={true} />
<EntityMembersListCard showAggregateMembersToggle />
</Grid>
</Grid>
</EntityLayout.Route>
Expand Down Expand Up @@ -423,9 +430,8 @@ const systemPage = (
</EntityLayout.Route>

<EntityLayout.Route path="/risc" title="ROS">
<RiScPage />
<RiScPage />
</EntityLayout.Route>

</EntityLayout>
);

Expand Down
4 changes: 4 additions & 0 deletions packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@
"@backstage/catalog-client": "^1.7.1",
"@backstage/catalog-model": "^1.7.0",
"@backstage/config": "^1.2.0",
"@backstage/errors": "^1.2.5",
"@backstage/plugin-app-backend": "^0.3.76",
"@backstage/plugin-auth-backend": "^0.23.1",
"@backstage/plugin-auth-backend-module-github-provider": "^0.2.2",
"@backstage/plugin-auth-backend-module-google-provider": "^0.2.2",
"@backstage/plugin-auth-backend-module-guest-provider": "^0.2.1",
"@backstage/plugin-auth-backend-module-microsoft-provider": "^0.2.2",
"@backstage/plugin-auth-node": "^0.5.3",
"@backstage/plugin-catalog-backend": "^1.27.1",
"@backstage/plugin-catalog-backend-module-github": "^0.7.6",
Expand Down
27 changes: 17 additions & 10 deletions packages/backend/src/plugins/transformers/msGraphTransformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,32 @@ export async function msGraphGroupTransformer(
if (group.displayName?.includes('_leads')) {
return undefined;
}
let groupType = group.displayName?.split(' - ')[2];
const groupType = group.displayName?.split(' - ')[2];

if (group.displayName?.toLowerCase().includes('aad - tf')) {
group.displayName = group.displayName.split(' - ').slice(3).join(' - ');
group.displayName = group.displayName.split(' - ').slice(3).join(' - ');
}

let groupEntity: GroupEntityV1alpha1 | undefined = await defaultGroupTransformer(group, groupPhoto);
const groupEntity: GroupEntityV1alpha1 | undefined =
await defaultGroupTransformer(group, groupPhoto);

if (groupEntity === undefined) {
return undefined;
return undefined;
}
if (groupType != undefined && groupType.toLowerCase().includes('role')) {
groupEntity.spec.type = 'role';
if (groupType !== undefined && groupType.toLowerCase().includes('role')) {
groupEntity.spec.type = 'role';
}
if (groupType != undefined && groupType.toLowerCase().includes('business unit')) {
groupEntity.spec.type = 'business unit';
if (
groupType !== undefined &&
groupType.toLowerCase().includes('business unit')
) {
groupEntity.spec.type = 'business unit';
}
if (groupType != undefined && groupType.toLowerCase().includes('product area')) {
groupEntity.spec.type = 'product area';
if (
groupType !== undefined &&
groupType.toLowerCase().includes('product area')
) {
groupEntity.spec.type = 'product area';
}

return groupEntity;
Expand Down
4 changes: 2 additions & 2 deletions plugins/ros/src/components/riScPlugin/RiScPlugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const RiScPlugin = () => {
selectRiSc,
isFetching,
sopsConfigs,
gcpProjectIds,
gcpCryptoKeys,
resetResponse,
resetRiScStatus,
response,
Expand Down Expand Up @@ -220,7 +220,7 @@ export const RiScPlugin = () => {
onClose={closeSopsConfigDialog}
showDialog={showSopsConfigDialog}
sopsConfigs={sopsConfigs}
gcpProjectIds={gcpProjectIds}
gcpCryptoKeys={gcpCryptoKeys}
hasOpenedGitBranchMenuOnce={
hasOpenedSopsConfigDialogGitBranchMenuOnce
}
Expand Down
Loading

0 comments on commit f33e897

Please sign in to comment.