diff --git a/.changeset/silly-lemons-dream.md b/.changeset/silly-lemons-dream.md
new file mode 100644
index 0000000000..a93be80597
--- /dev/null
+++ b/.changeset/silly-lemons-dream.md
@@ -0,0 +1,5 @@
+---
+'@backstage/plugin-catalog-import': patch
+---
+
+Allows the CodeOwnersProcessor to set the owner automatically within the catalog-import plugin. This adds an additional checkbox that overrides the group selector and will omit the owner option in the generated catalog file yaml.
diff --git a/plugins/catalog-import/src/components/ImportStepper/defaults.tsx b/plugins/catalog-import/src/components/ImportStepper/defaults.tsx
index 5252b0aeae..dff2136aaa 100644
--- a/plugins/catalog-import/src/components/ImportStepper/defaults.tsx
+++ b/plugins/catalog-import/src/components/ImportStepper/defaults.tsx
@@ -15,7 +15,15 @@
*/
import { ConfigApi } from '@backstage/core';
-import { Box, StepLabel, TextField, Typography } from '@material-ui/core';
+import {
+ Box,
+ Checkbox,
+ FormControlLabel,
+ FormHelperText,
+ StepLabel,
+ TextField,
+ Typography,
+} from '@material-ui/core';
import React from 'react';
import { BackButton } from '../Buttons';
import { StepFinishImportLocation } from '../StepFinishImportLocation';
@@ -167,6 +175,7 @@ export function defaultGenerateStepper(
defaultTitle={title}
defaultBody={body}
renderFormFields={({
+ values,
control,
errors,
groupsLoading,
@@ -219,22 +228,47 @@ export function defaultGenerateStepper(
required
/>
-
+ )}
+
+ {
+ if (value) {
+ control.setValue('owner', '');
+ }
+ }}
+ />
+ }
+ label={
+ <>
+ Use CODEOWNERS file as Entity Owner
+ >
+ }
/>
+
+ WARNING: This may fail is no CODEOWNERS file is found at
+ the target location.
+
>
)}
/>
diff --git a/plugins/catalog-import/src/components/StepPrepareCreatePullRequest/StepPrepareCreatePullRequest.tsx b/plugins/catalog-import/src/components/StepPrepareCreatePullRequest/StepPrepareCreatePullRequest.tsx
index 333df76026..c34d5f374b 100644
--- a/plugins/catalog-import/src/components/StepPrepareCreatePullRequest/StepPrepareCreatePullRequest.tsx
+++ b/plugins/catalog-import/src/components/StepPrepareCreatePullRequest/StepPrepareCreatePullRequest.tsx
@@ -23,7 +23,7 @@ import {
import { Box, FormHelperText, Grid, Typography } from '@material-ui/core';
import { makeStyles } from '@material-ui/core/styles';
import React, { useCallback, useState } from 'react';
-import { UseFormMethods } from 'react-hook-form';
+import { UnpackNestedValue, UseFormMethods } from 'react-hook-form';
import { useAsync } from 'react-use';
import YAML from 'yaml';
import { AnalyzeResult, catalogImportApiRef } from '../../api';
@@ -48,6 +48,7 @@ type FormData = {
body: string;
componentName: string;
owner: string;
+ useCodeowners: boolean;
};
type Props = {
@@ -63,6 +64,7 @@ type Props = {
renderFormFields: (
props: Pick, 'errors' | 'register' | 'control'> & {
+ values: UnpackNestedValue;
groups: string[];
groupsLoading: boolean;
},
@@ -72,7 +74,7 @@ type Props = {
export function generateEntities(
entities: PartialEntity[],
componentName: string,
- owner: string,
+ owner?: string,
): Entity[] {
return entities.map(e => ({
...e,
@@ -84,7 +86,7 @@ export function generateEntities(
},
spec: {
...e.spec,
- owner,
+ ...(owner ? { owner } : {}),
},
}));
}
@@ -189,10 +191,12 @@ export const StepPrepareCreatePullRequest = ({
(analyzeResult.generatedEntities[0]?.spec?.owner as string) || '',
componentName:
analyzeResult.generatedEntities[0]?.metadata?.name || '',
+ useCodeowners: false,
}}
render={({ values, errors, control, register }) => (
<>
{renderFormFields({
+ values,
errors,
register,
control,