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

update to pull samples from devfile registry #10394

Merged
Merged
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
Expand Up @@ -14,7 +14,7 @@ Feature: Create Application from Devfile
Given user is at the Topology page
When user right clicks on topology empty graph
And user selects "Import from Git" option from Add to Project context menu
And user enters Git Repo URL as "https://github.com/redhat-developer/devfile-sample" in Import from Git form
And user enters Git Repo URL as "https://github.com/nodeshift-starters/devfile-sample" in Import from Git form
And user enters workload name as "node-bulletin-board-1"
And user clicks Create button on Add page
Then user will be redirected to Topology page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Feature: Create the different workloads from Add page
Given user is at the Topology page
When user right clicks on topology empty graph
And user selects "Import from Git" option from Add to Project context menu
And user enters Git Repo URL as "https://github.com/redhat-developer/devfile-sample" in Import from Git form
And user enters Git Repo URL as "https://github.com/nodeshift-starters/devfile-sample" in Import from Git form
And user enters workload name as "node-bulletin-board-1"
And user clicks Create button on Add page
Then user will be redirected to Topology page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,16 @@ export const loadedCatalogService: CatalogService = {
{
uid: 'nodejs-basic',
type: 'Sample',
name: 'Basic NodeJS',
description: 'A simple Hello world NodeJS application',
name: 'Basic Node.js',
description: 'A simple Hello World Node.js application',
tags: ['NodeJS', 'Express'],
cta: {
label: 'Create Devfile Sample',
href:
'/import?importType=devfile&formType=sample&devfileName=nodejs-basic&gitRepo=https://github.com/redhat-developer/devfile-sample.git',
'/import?importType=devfile&formType=sample&devfileName=nodejs-basic&gitRepo=https://github.com/nodeshift-starters/devfile-sample.git',
},
icon: {
url: 'data:image/png;base64,.....',
url: 'https://nodejs.org/static/images/logos/nodejs-new-pantone-black.svg',
},
},
{
Expand All @@ -200,10 +200,10 @@ export const loadedCatalogService: CatalogService = {
cta: {
label: 'Create Devfile Sample',
href:
'/import?importType=devfile&formType=sample&devfileName=python-basic&gitRepo=https://github.com/elsony/devfile-sample-python-basic.git',
'/import?importType=devfile&formType=sample&devfileName=python-basic&gitRepo=https://github.com/devfile-samples/devfile-sample-python-basic.git',
},
icon: {
url: 'data:image/png;base64,.....',
url: 'https://www.python.org/static/community_logos/python-logo-generic.svg',
},
},
{
Expand All @@ -215,10 +215,10 @@ export const loadedCatalogService: CatalogService = {
cta: {
label: 'Create Devfile Sample',
href:
'/import?importType=devfile&formType=sample&devfileName=code-with-quarkus&gitRepo=https://github.com/elsony/devfile-sample-code-with-quarkus.git',
'/import?importType=devfile&formType=sample&devfileName=code-with-quarkus&gitRepo=https://github.com/devfile-samples/devfile-sample-code-with-quarkus.git',
},
icon: {
url: 'data:image/png;base64,.....',
url: 'https://design.jboss.org/quarkus/logo/final/SVG/quarkus_icon_rgb_default.svg',
},
},
{
Expand All @@ -230,10 +230,10 @@ export const loadedCatalogService: CatalogService = {
cta: {
label: 'Create Devfile Sample',
href:
'/import?importType=devfile&formType=sample&devfileName=java-springboot-basic&gitRepo=https://github.com/elsony/devfile-sample-java-springboot-basic.git',
'/import?importType=devfile&formType=sample&devfileName=java-springboot-basic&gitRepo=https://github.com/devfile-samples/devfile-sample-java-springboot-basic.git',
},
icon: {
url: 'data:image/png;base64,.....',
url: 'https://spring.io/images/projects/spring-edf462fec682b9d48cf628eaf9e19521.svg',
},
},
{
Expand Down Expand Up @@ -411,16 +411,16 @@ export const loadedCatalogService: CatalogService = {
{
uid: 'nodejs-basic',
type: 'Sample',
name: 'Basic NodeJS',
description: 'A simple Hello world NodeJS application',
name: 'Basic Node.js ',
description: 'A simple Hello World Node.js application',
tags: ['NodeJS', 'Express'],
cta: {
label: 'Create Devfile Sample',
href:
'/import?importType=devfile&formType=sample&devfileName=nodejs-basic&gitRepo=https://github.com/redhat-developer/devfile-sample.git',
'/import?importType=devfile&formType=sample&devfileName=nodejs-basic&gitRepo=https://github.com/nodeshift-starters/devfile-sample.git',
},
icon: {
url: 'data:image/png;base64,.....',
url: 'https://nodejs.org/static/images/logos/nodejs-new-pantone-black.svg',
},
},
{
Expand All @@ -432,10 +432,10 @@ export const loadedCatalogService: CatalogService = {
cta: {
label: 'Create Devfile Sample',
href:
'/import?importType=devfile&formType=sample&devfileName=python-basic&gitRepo=https://github.com/elsony/devfile-sample-python-basic.git',
'/import?importType=devfile&formType=sample&devfileName=python-basic&gitRepo=https://github.com/devfile-samples/devfile-sample-python-basic.git',
},
icon: {
url: 'data:image/png;base64,.....',
url: 'https://www.python.org/static/community_logos/python-logo-generic.svg',
},
},
{
Expand All @@ -447,10 +447,10 @@ export const loadedCatalogService: CatalogService = {
cta: {
label: 'Create Devfile Sample',
href:
'/import?importType=devfile&formType=sample&devfileName=code-with-quarkus&gitRepo=https://github.com/elsony/devfile-sample-code-with-quarkus.git',
'/import?importType=devfile&formType=sample&devfileName=code-with-quarkus&gitRepo=https://github.com/devfile-samples/devfile-sample-code-with-quarkus.git',
},
icon: {
url: 'data:image/png;base64,.....',
url: 'https://design.jboss.org/quarkus/logo/final/SVG/quarkus_icon_rgb_default.svg',
},
},
{
Expand All @@ -462,10 +462,10 @@ export const loadedCatalogService: CatalogService = {
cta: {
label: 'Create Devfile Sample',
href:
'/import?importType=devfile&formType=sample&devfileName=java-springboot-basic&gitRepo=https://github.com/elsony/devfile-sample-java-springboot-basic.git',
'/import?importType=devfile&formType=sample&devfileName=java-springboot-basic&gitRepo=https://github.com/devfile-samples/devfile-sample-java-springboot-basic.git',
},
icon: {
url: 'data:image/png;base64,.....',
url: 'https://spring.io/images/projects/spring-edf462fec682b9d48cf628eaf9e19521.svg',
},
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ describe('SampleGettingStartedCard', () => {
id: 'code-with-quarkus',
title: 'Basic Quarkus',
href:
'/import?importType=devfile&formType=sample&devfileName=code-with-quarkus&gitRepo=https://github.com/elsony/devfile-sample-code-with-quarkus.git',
'/import?importType=devfile&formType=sample&devfileName=code-with-quarkus&gitRepo=https://github.com/devfile-samples/devfile-sample-code-with-quarkus.git',
},
{
id: 'java-springboot-basic',
title: 'Basic Spring Boot',
href:
'/import?importType=devfile&formType=sample&devfileName=java-springboot-basic&gitRepo=https://github.com/elsony/devfile-sample-java-springboot-basic.git',
'/import?importType=devfile&formType=sample&devfileName=java-springboot-basic&gitRepo=https://github.com/devfile-samples/devfile-sample-java-springboot-basic.git',
},
]);
expect(wrapper.find(GettingStartedCard).props().moreLink).toEqual({
Expand All @@ -118,9 +118,9 @@ describe('SampleGettingStartedCard', () => {
},
{
id: 'nodejs-basic',
title: 'Basic NodeJS',
title: 'Basic Node.js',
href:
'/import?importType=devfile&formType=sample&devfileName=nodejs-basic&gitRepo=https://github.com/redhat-developer/devfile-sample.git',
'/import?importType=devfile&formType=sample&devfileName=nodejs-basic&gitRepo=https://github.com/nodeshift-starters/devfile-sample.git',
},
]);
expect(wrapper.find(GettingStartedCard).props().moreLink).toEqual({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { DevfileSample } from '../../../import/devfile/devfile-types';
export const devfileSamples: DevfileSample[] = [
{
name: 'nodejs-basic',
displayName: 'Basic NodeJS',
description: 'A simple Hello world NodeJS application',
displayName: 'Basic Node.js',
description: 'A simple Hello World Node.js application',
icon: 'trimmed',
tags: ['NodeJS', 'Express'],
projectType: 'nodejs',
language: 'nodejs',
git: {
remotes: {
origin: 'https://github.com/redhat-developer/devfile-sample.git',
origin: 'https://github.com/nodeshift-starters/devfile-sample.git',
},
},
},
Expand All @@ -26,7 +26,7 @@ export const devfileSamples: DevfileSample[] = [
language: 'java',
git: {
remotes: {
origin: 'https://github.com/elsony/devfile-sample-code-with-quarkus.git',
origin: 'https://github.com/devfile-samples/devfile-sample-code-with-quarkus.git',
},
},
},
Expand All @@ -40,7 +40,7 @@ export const devfileSamples: DevfileSample[] = [
language: 'java',
git: {
remotes: {
origin: 'https://github.com/elsony/devfile-sample-java-springboot-basic.git',
origin: 'https://github.com/devfile-samples/devfile-sample-java-springboot-basic.git',
},
},
},
Expand All @@ -54,7 +54,7 @@ export const devfileSamples: DevfileSample[] = [
language: 'python',
git: {
remotes: {
origin: 'https://github.com/elsony/devfile-sample-python-basic.git',
origin: 'https://github.com/devfile-samples/devfile-sample-python-basic.git',
},
},
},
Expand All @@ -64,15 +64,15 @@ export const expectedCatalogItems: CatalogItem[] = [
{
uid: 'nodejs-basic',
type: 'Sample',
name: 'Basic NodeJS',
description: 'A simple Hello world NodeJS application',
name: 'Basic Node.js',
description: 'A simple Hello World Node.js application',
tags: ['NodeJS', 'Express'],
cta: {
label: 'Create Devfile Sample',
href:
'/import?importType=devfile&formType=sample&devfileName=nodejs-basic&gitRepo=https://github.com/redhat-developer/devfile-sample.git',
'/import?importType=devfile&formType=sample&devfileName=nodejs-basic&gitRepo=https://github.com/nodeshift-starters/devfile-sample.git',
},
icon: { url: 'data:image/png;base64,trimmed' },
icon: { url: 'trimmed' },
},
{
uid: 'code-with-quarkus',
Expand All @@ -83,9 +83,9 @@ export const expectedCatalogItems: CatalogItem[] = [
cta: {
label: 'Create Devfile Sample',
href:
'/import?importType=devfile&formType=sample&devfileName=code-with-quarkus&gitRepo=https://github.com/elsony/devfile-sample-code-with-quarkus.git',
'/import?importType=devfile&formType=sample&devfileName=code-with-quarkus&gitRepo=https://github.com/devfile-samples/devfile-sample-code-with-quarkus.git',
},
icon: { url: 'data:image/png;base64,trimmed' },
icon: { url: 'trimmed' },
},
{
uid: 'java-springboot-basic',
Expand All @@ -96,9 +96,9 @@ export const expectedCatalogItems: CatalogItem[] = [
cta: {
label: 'Create Devfile Sample',
href:
'/import?importType=devfile&formType=sample&devfileName=java-springboot-basic&gitRepo=https://github.com/elsony/devfile-sample-java-springboot-basic.git',
'/import?importType=devfile&formType=sample&devfileName=java-springboot-basic&gitRepo=https://github.com/devfile-samples/devfile-sample-java-springboot-basic.git',
},
icon: { url: 'data:image/png;base64,trimmed' },
icon: { url: 'trimmed' },
},
{
uid: 'python-basic',
Expand All @@ -109,8 +109,8 @@ export const expectedCatalogItems: CatalogItem[] = [
cta: {
label: 'Create Devfile Sample',
href:
'/import?importType=devfile&formType=sample&devfileName=python-basic&gitRepo=https://github.com/elsony/devfile-sample-python-basic.git',
'/import?importType=devfile&formType=sample&devfileName=python-basic&gitRepo=https://github.com/devfile-samples/devfile-sample-python-basic.git',
},
icon: { url: 'data:image/png;base64,trimmed' },
icon: { url: 'trimmed' },
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ describe('useDevfileSamples:', () => {
const { result } = testHook(() => useDevfileSamples({}));

expect(getMock).toHaveBeenCalledTimes(1);
expect(getMock).toHaveBeenLastCalledWith('/api/devfile/samples?registry=sample-placeholder');
expect(getMock).toHaveBeenLastCalledWith(
'/api/devfile/samples?registry=https://registry.devfile.io',
);

expect(result.current).toEqual([[], false, undefined]);

Expand All @@ -39,7 +41,9 @@ describe('useDevfileSamples:', () => {
const { result } = testHook(() => useDevfileSamples({}));

expect(getMock).toHaveBeenCalledTimes(1);
expect(getMock).toHaveBeenLastCalledWith('/api/devfile/samples?registry=sample-placeholder');
expect(getMock).toHaveBeenLastCalledWith(
'/api/devfile/samples?registry=https://registry.devfile.io',
);

expect(result.current).toEqual([[], false, undefined]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const normalizeDevfile = (devfileSamples: DevfileSample[], t: TFunction): Catalo
const normalizedDevfileSamples = devfileSamples?.map((sample) => {
const { name: uid, displayName, description, tags, git, icon } = sample;
const gitRepoUrl = Object.values(git.remotes)[0];
const iconUrl = icon ? `data:image/png;base64,${icon}` : '';
const href = `/import?importType=devfile&devfileName=${uid}&gitRepo=${gitRepoUrl}`;
const createLabel = t('devconsole~Create Application');
const type = 'Devfile';
Expand Down Expand Up @@ -41,7 +40,7 @@ const normalizeDevfile = (devfileSamples: DevfileSample[], t: TFunction): Catalo
label: createLabel,
href,
},
icon: { url: iconUrl },
icon: { url: icon },
details: {
properties: detailsProperties,
descriptions: detailsDescriptions,
Expand All @@ -61,7 +60,7 @@ const useDevfile: ExtensionHook<CatalogItem[]> = (): [CatalogItem[], boolean, an

React.useEffect(() => {
let mounted = true;
coFetchJSON('/api/devfile/samples?registry=sample-placeholder')
coFetchJSON('/api/devfile/samples?registry=https://registry.devfile.io')
.then((resp) => {
if (mounted) setDevfileSamples(resp);
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const normalizeDevfileSamples = (devfileSamples: DevfileSample[], t: TFunction):
const gitRepoUrl = Object.values(git.remotes)[0];
const label = t('devconsole~Create Devfile Sample');
const href = `/import?importType=devfile&formType=sample&devfileName=${uid}&gitRepo=${gitRepoUrl}`;
const iconUrl = icon ? `data:image/png;base64,${icon}` : '';
const iconUrl = icon || '';

const item: CatalogItem = {
uid,
Expand Down Expand Up @@ -40,8 +40,7 @@ const useDevfileSamples: ExtensionHook<CatalogItem[]> = (): [CatalogItem[], bool

React.useEffect(() => {
let mounted = true;

coFetchJSON('/api/devfile/samples?registry=sample-placeholder')
coFetchJSON('/api/devfile/samples?registry=https://registry.devfile.io')
.then((res) => {
if (mounted) setDevfileSamples(res);
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ export type DevfileInfoProps = {
const DevfileInfo: React.FC<DevfileInfoProps> = ({ devfileSample }) => {
const { t } = useTranslation();
const { icon, iconClass, displayName, description, git, tags } = devfileSample;
const iconUrl = iconClass
? getImageForIconClass(iconClass)
: icon
? `data:image/png;base64,${icon}`
: '';
const iconUrl = iconClass ? getImageForIconClass(iconClass) : icon || '';
const sampleRepo = git?.remotes ? Object.values(git.remotes)[0] : '';

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export const useSelectedDevfileSample = () => {
React.useEffect(() => {
let mounted = true;
const payload = {
registry: 'sample-placeholder',
registry: 'https://registry.devfile.io',
};
coFetchJSON
.put('/api/devfile/samples', payload)
Expand Down
12 changes: 7 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ go 1.16
require (
github.com/coreos/go-oidc v2.1.0+incompatible
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f
github.com/devfile/api/v2 v2.0.0-20210211160219-33a78aec06af
github.com/devfile/library v1.0.0-alpha.2
github.com/devfile/registry-support/index/generator v0.0.0-20210505173027-d06fe2bb3ee8
github.com/devfile/api/v2 v2.0.0-20211021164004-dabee4e633ed
github.com/devfile/library v1.2.1-0.20211104222135-49d635cb492f
github.com/devfile/registry-support/index/generator v0.0.0-20211012185733-0a73f866043f
github.com/devfile/registry-support/registry-library v0.0.0-20211026200306-cab748834109
github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32 // indirect
github.com/gorilla/websocket v1.4.2
github.com/graph-gophers/graphql-go v0.0.0-20200309224638-dae41bde9ef9
github.com/openshift/api v0.0.0-20211103080632-8981c8822dfa
Expand All @@ -22,13 +24,13 @@ require (
gopkg.in/yaml.v2 v2.4.0
helm.sh/helm/v3 v3.6.2
k8s.io/api v0.22.1
k8s.io/apiextensions-apiserver v0.21.1
k8s.io/apiextensions-apiserver v0.21.3
k8s.io/apimachinery v0.22.1
k8s.io/cli-runtime v0.21.0
k8s.io/client-go v0.22.1
k8s.io/klog v1.0.0
k8s.io/klog/v2 v2.9.0
sigs.k8s.io/controller-runtime v0.9.0
sigs.k8s.io/controller-runtime v0.9.5
sigs.k8s.io/yaml v1.2.0
)

Expand Down
Loading