Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converge Import from Git/Devfile/Dockerfile flows #9832

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 1 addition & 39 deletions frontend/packages/dev-console/console-extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"id": "import-from-git",
"groupId": "git-repository",
"href": "/import/ns/:namespace",
"label": "%devconsole~From Git%",
"label": "%devconsole~Import from Git%",
"description": "%devconsole~Import code from your Git repository to be built and deployed%",
"icon": { "$codeRef": "icons.gitIconSVG" },
"accessReview": [
Expand All @@ -80,25 +80,6 @@
]
}
},
{
"type": "dev-console.add/action",
"properties": {
"id": "import-from-devfile",
"groupId": "git-repository",
"href": "/import/ns/:namespace?importType=devfile",
"label": "%devconsole~From Devfile%",
"description": "%devconsole~Import your Devfile from your Git repository to be built and deployed%",
"icon": { "$codeRef": "icons.devfileIconSVG" },
"accessReview": [
{ "group": "build.openshift.io", "resource": "buildconfigs", "verb": "create" },
{ "group": "image.openshift.io", "resource": "imagestreams", "verb": "create" },
{ "group": "apps", "resource": "deployments", "verb": "create" },
{ "group": "", "resource": "secrets", "verb": "create" },
{ "group": "route.openshift.io", "resource": "routes", "verb": "create" },
{ "group": "", "resource": "services", "verb": "create" }
]
}
},
{
"type": "dev-console.add/action",
"properties": {
Expand All @@ -119,25 +100,6 @@
]
}
},
{
"type": "dev-console.add/action",
"properties": {
"id": "import-from-dockerfile",
"groupId": "git-repository",
"href": "/import/ns/:namespace?importType=docker",
"label": "%devconsole~From Dockerfile%",
"description": "%devconsole~Import your Dockerfile from your Git repository to be built and deployed%",
"icon": { "$codeRef": "icons.dockerfileIconSVG" },
"accessReview": [
{ "group": "build.openshift.io", "resource": "buildconfigs", "verb": "create" },
{ "group": "image.openshift.io", "resource": "imagestreams", "verb": "create" },
{ "group": "apps.openshift.io", "resource": "deploymentconfigs", "verb": "create" },
{ "group": "", "resource": "secrets", "verb": "create" },
{ "group": "route.openshift.io", "resource": "routes", "verb": "create" },
{ "group": "", "resource": "services", "verb": "create" }
]
}
},
{
"type": "dev-console.add/action",
"properties": {
Expand Down
40 changes: 22 additions & 18 deletions frontend/packages/dev-console/locales/en/devconsole.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@
"From Local Machine": "From Local Machine",
"Samples": "Samples",
"Create an Application from a code sample": "Create an Application from a code sample",
"From Git": "From Git",
"Import from Git": "Import from Git",
"Import code from your Git repository to be built and deployed": "Import code from your Git repository to be built and deployed",
"From Devfile": "From Devfile",
"Import your Devfile from your Git repository to be built and deployed": "Import your Devfile from your Git repository to be built and deployed",
"Deploy an existing Image from an Image registry or Image stream tag": "Deploy an existing Image from an Image registry or Image stream tag",
"From Dockerfile": "From Dockerfile",
"Import your Dockerfile from your Git repository to be built and deployed": "Import your Dockerfile from your Git repository to be built and deployed",
"Import YAML": "Import YAML",
"Create resources from their YAML or JSON definitions": "Create resources from their YAML or JSON definitions",
"All services": "All services",
Expand All @@ -38,6 +34,7 @@
"Project": "Project",
"Builds": "Builds",
"Create Service Binding": "Create Service Binding",
"From Git": "From Git",
"Container Image": "Container Image",
"From Catalog": "From Catalog",
"Helm Charts": "Helm Charts",
Expand Down Expand Up @@ -99,7 +96,6 @@
"Create Devfile Sample": "Create Devfile Sample",
"Instantiate Template": "Instantiate Template",
"Select Secret name": "Select Secret name",
"Import from Git": "Import from Git",
"Import from Dockerfile": "Import from Dockerfile",
"Deploy Image": "Deploy Image",
"Save": "Save",
Expand Down Expand Up @@ -320,34 +316,30 @@
"There are no supported pipelines available for {{builderImage}}. Changing to this builder image will disconnect your associated Pipeline.": "There are no supported pipelines available for {{builderImage}}. Changing to this builder image will disconnect your associated Pipeline.",
"Builder Image": "Builder Image",
"Detecting recommended Builder Images...": "Detecting recommended Builder Images...",
"Builder Image(s) detected.": "Builder Image(s) detected.",
"Recommended Builder Images are represented by <2></2> icon.": "Recommended Builder Images are represented by <2></2> icon.",
"Unable to detect the Builder Image.": "Unable to detect the Builder Image.",
"Select the most appropriate one from the list to continue.": "Select the most appropriate one from the list to continue.",
"Builder Image version": "Builder Image version",
"Builder": "Builder",
"Sample repository:": "Sample repository:",
"Create": "Create",
"The Devfile in your Git repository is invalid.": "The Devfile in your Git repository is invalid.",
"Validated": "Validated",
"Devfile not detected": "Devfile not detected",
"Allows the builds to use a different path to locate your Devfile, relative to the Context Dir field": "Allows the builds to use a different path to locate your Devfile, relative to the Context Dir field",
"Import is not possible.": "Import is not possible.",
"Git repo URL": "Git repo URL",
"Devfile Path": "Devfile Path",
"Hide advanced Git options": "Hide advanced Git options",
"Show advanced Git options": "Show advanced Git options",
"Git reference": "Git reference",
"Optional branch, tag, or commit.": "Optional branch, tag, or commit.",
"Context dir": "Context dir",
"Optional subdirectory for the Application source code, used as a context directory for build.": "Optional subdirectory for the Application source code, used as a context directory for build.",
"Dockerfile": "Dockerfile",
"Dockerfile path": "Dockerfile path",
"Dockerfile not detected": "Dockerfile not detected",
"Allows the builds to use a different path to locate your Dockerfile, relative to the Context Dir field.": "Allows the builds to use a different path to locate your Dockerfile, relative to the Context Dir field.",
"Dockerfile path": "Dockerfile path",
"Dockerfile": "Dockerfile",
"Validating": "Validating",
"Validated": "Validated",
"Rate limit exceeded": "Rate limit exceeded",
"URL is valid but cannot be reached. If this is a private repository, enter a source Secret in advanced Git options": "URL is valid but cannot be reached. If this is a private repository, enter a source Secret in advanced Git options",
"No Devfile present, unable to continue.": "No Devfile present, unable to continue.",
"Repository URL to build and deploy your code from source.": "Repository URL to build and deploy your code from source.",
"Repository URL to build and deploy your code from a Dockerfile.": "Repository URL to build and deploy your code from a Dockerfile.",
"Repository URL to build and deploy your code from a Devfile.": "Repository URL to build and deploy your code from a Devfile.",
"Git": "Git",
"Git Repo URL": "Git Repo URL",
"Git type": "Git type",
Expand Down Expand Up @@ -378,9 +370,21 @@
"Cannot update Devfile resources": "Cannot update Devfile resources",
"Serverless Deployment": "Serverless Deployment",
"no application group": "no application group",
"Import from Devfile": "Import from Devfile",
"Create Source-to-Image Application": "Create Source-to-Image Application",
"Git repo URL": "Git repo URL",
"Create Sample Application": "Create Sample Application",
"The Devfile at {{filePath}} is recommended.": "The Devfile at {{filePath}} is recommended.",
"The Dockerfile at {{filePath}} is recommended.": "The Dockerfile at {{filePath}} is recommended.",
"A Builder Image is recommended.": "A Builder Image is recommended.",
"Multiple import strategies detected": "Multiple import strategies detected",
"{{strategy}} detected.": "{{strategy}} detected.",
"Import strategy changed to {{strategy}}": "Import strategy changed to {{strategy}}",
"Unable to detect import strategy": "Unable to detect import strategy",
"Error: {{loadError}}": "Error: {{loadError}}",
"Select from the options below.": "Select from the options below.",
"Edit Import Strategy": "Edit Import Strategy",
"Revert to recommended": "Revert to recommended",
"Import Strategy": "Import Strategy",
"JAR": "JAR",
"JAR file": "JAR file",
"Drag a file here or browse to upload": "Drag a file here or browse to upload",
Expand Down
38 changes: 2 additions & 36 deletions frontend/packages/dev-console/src/actions/add-resources.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import {
GitAltIcon,
OsImageIcon,
CatalogIcon,
CubeIcon,
LayerGroupIcon,
DatabaseIcon,
LaptopCodeIcon,
BoltIcon,
Expand All @@ -24,7 +22,7 @@ export const fromGit: AddActionItem = {
id: 'import-from-git',
action: createKebabAction(
// t('devconsole~From Git')
'devconsole~From Git',
'devconsole~Import from Git',
<GitAltIcon />,
ImportOptions.GIT,
allImportResourceAccess,
Expand Down Expand Up @@ -52,28 +50,6 @@ export const fromCatalog: AddActionItem = {
),
};

export const fromDockerfile: AddActionItem = {
id: 'import-from-dockerfile',
action: createKebabAction(
// t('devconsole~From Dockerfile')
'devconsole~From Dockerfile',
<CubeIcon />,
ImportOptions.DOCKERFILE,
allImportResourceAccess,
),
};

export const fromDevfile: AddActionItem = {
id: 'import-from-devfile',
action: createKebabAction(
// t('devconsole~From Devfile')
'devconsole~From Devfile',
<LayerGroupIcon />,
ImportOptions.DEVFILE,
allImportResourceAccess,
),
};

export const fromDatabaseCatalog: AddActionItem = {
id: 'dev-catalog-databases',
action: createKebabAction(
Expand Down Expand Up @@ -133,8 +109,6 @@ export const addResourceMenu: KebabAction[] = [
fromSamples,
fromGit,
containerImage,
fromDockerfile,
fromDevfile,
fromCatalog,
fromDatabaseCatalog,
fromOperatorBacked,
Expand All @@ -144,21 +118,13 @@ export const addResourceMenu: KebabAction[] = [
.filter(disabledFilter)
.map(actionMapper);

export const addGroupResourceMenu: KebabAction[] = [
fromGit,
containerImage,
fromDockerfile,
fromDevfile,
uploadJarFile,
]
export const addGroupResourceMenu: KebabAction[] = [fromGit, containerImage, uploadJarFile]
.filter(disabledFilter)
.map(actionMapper);

export const addResourceMenuWithoutCatalog: KebabAction[] = [
fromGit,
containerImage,
fromDockerfile,
fromDevfile,
fromOperatorBacked,
uploadJarFile,
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as React from 'react';
import { FormikProps, FormikValues } from 'formik';
import * as _ from 'lodash';
import { useTranslation } from 'react-i18next';
import { BuildStrategyType } from '@console/internal/components/build';
import { PageHeading } from '@console/internal/components/utils';
import PipelineSection from '@console/pipelines-plugin/src/components/import/pipeline/PipelineSection';
import { FormFooter, FlexForm, FormBody } from '@console/shared';
Expand Down Expand Up @@ -44,22 +43,17 @@ const EditApplicationForm: React.FC<FormikProps<FormikValues> & EditApplicationF
<PageHeading title={t(getFlowTypePageTitle(flowType))} />
<FlexForm onSubmit={handleSubmit}>
<FormBody flexLayout>
{flowType === ApplicationFlowType.Git && (
<GitSection buildStrategy={BuildStrategyType.Source} builderImages={builderImages} />
)}
{flowType === ApplicationFlowType.Git && <GitSection builderImages={builderImages} />}
{flowType === ApplicationFlowType.Dockerfile && (
<GitSection buildStrategy={BuildStrategyType.Docker} builderImages={builderImages} />
<GitSection builderImages={builderImages} />
)}
{flowType === ApplicationFlowType.Git && (
<BuilderSection
image={values.image}
builderImages={builderImages}
existingPipeline={appResources?.pipeline?.data}
/>
)}
{flowType === ApplicationFlowType.Dockerfile && (
<DockerSection buildStrategy={values.build.strategy} />
)}
{flowType === ApplicationFlowType.Dockerfile && <DockerSection />}
divyanshiGupta marked this conversation as resolved.
Show resolved Hide resolved
{flowType === ApplicationFlowType.JarUpload && <JarSection />}
{flowType === ApplicationFlowType.Container && <ImageSearchSection />}
{(flowType === ApplicationFlowType.Container ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,9 @@ export const gitImportInitialValues: GitImportFormData = {
strategy: 'Source',
},
healthChecks: healthChecksProbeInitialData,
import: {
showEditImportStrategy: true,
},
};

export const externalImageValues: DeployImageFormData = {
Expand Down Expand Up @@ -630,6 +633,9 @@ export const externalImageValues: DeployImageFormData = {
build: { env: [], triggers: {}, strategy: '' },
isSearchingForImage: false,
healthChecks: healthChecksProbeInitialData,
import: {
showEditImportStrategy: true,
},
divyanshiGupta marked this conversation as resolved.
Show resolved Hide resolved
};

export const internalImageValues: DeployImageFormData = {
Expand Down Expand Up @@ -700,6 +706,9 @@ export const internalImageValues: DeployImageFormData = {
build: { env: [], triggers: {}, strategy: '' },
isSearchingForImage: false,
healthChecks: healthChecksProbeInitialData,
import: {
showEditImportStrategy: true,
},
};

export const knAppResources: AppResources = {
Expand Down Expand Up @@ -781,9 +790,15 @@ export const knExternalImageValues: DeployImageFormData = {
allowInsecureRegistry: false,
serverless: serverlessInitialValues,
healthChecks: healthChecksProbeInitialData,
import: {
showEditImportStrategy: true,
},
};

export const gitImportInitialValuesWithHealthChecksEnabled: GitImportFormData = {
...gitImportInitialValues,
healthChecks: healthChecksData,
import: {
showEditImportStrategy: true,
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,9 @@ export const getCommonInitialValues = (
labels: getUserLabels(editAppResource),
limits: getLimitsDataFromResource(editAppResource),
healthChecks: getHealthChecksData(editAppResource),
import: {
showEditImportStrategy: true,
},
};
return commonInitialValues;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import * as React from 'react';
import { ValidatedOptions } from '@patternfly/react-core';
import { FormikProps, FormikValues } from 'formik';
import * as _ from 'lodash';
import { useTranslation } from 'react-i18next';
import { ImportStrategy } from '@console/git-service/src';
import PipelineSection from '@console/pipelines-plugin/src/components/import/pipeline/PipelineSection';
import { FormBody, FormFooter } from '@console/shared/src/components/form-utils';
import AdvancedSection from './advanced/AdvancedSection';
import AppSection from './app/AppSection';
import BuilderSection from './builder/BuilderSection';
import DockerSection from './git/DockerSection';
import GitSection from './git/GitSection';
import { GitImportFormProps } from './import-types';
import { GitImportFormProps, GitTypes } from './import-types';
import ImportStrategySection from './ImportStrategySection';
import ResourceSection from './section/ResourceSection';

const GitImportForm: React.FC<FormikProps<FormikValues> & GitImportFormProps> = ({
Expand All @@ -24,19 +25,40 @@ const GitImportForm: React.FC<FormikProps<FormikValues> & GitImportFormProps> =
projects,
}) => {
const { t } = useTranslation();
const searchParams = new URLSearchParams(window.location.search);
const gitRepoUrl = searchParams.get('gitRepo');
const formType = searchParams.get('formType');
const {
git: { validated, gitType },
} = values;
return (
<form onSubmit={handleSubmit} data-test-id="import-git-form">
<FormBody>
<GitSection buildStrategy={values.build.strategy} builderImages={builderImages} />
<BuilderSection image={values.image} builderImages={builderImages} />
<DockerSection buildStrategy={values.build.strategy} />
<AppSection
project={values.project}
noProjectsAvailable={projects.loaded && _.isEmpty(projects.data)}
<GitSection
builderImages={builderImages}
defaultSample={
gitRepoUrl && {
url: gitRepoUrl,
}
}
formType={formType}
/>
<ResourceSection />
<PipelineSection builderImages={builderImages} />
<AdvancedSection values={values} />
{validated !== ValidatedOptions.default && gitType !== GitTypes.invalid && (
<>
<ImportStrategySection builderImages={builderImages} />
<AppSection
project={values.project}
noProjectsAvailable={projects.loaded && _.isEmpty(projects.data)}
/>
{values.import.selectedStrategy.type !== ImportStrategy.DEVFILE && (
<>
<ResourceSection />
<PipelineSection builderImages={builderImages} />
<AdvancedSection values={values} />
</>
)}
</>
)}
</FormBody>
<FormFooter
handleReset={handleReset}
Expand Down