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 2 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 @@ -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 @@ -26,7 +26,7 @@ describe('useDevfileSamples:', () => {

expect(putMock).toHaveBeenCalledTimes(1);
expect(putMock).toHaveBeenLastCalledWith('/api/devfile/samples', {
registry: 'sample-placeholder',
registry: 'https://registry.devfile.io',
});

expect(result.current).toEqual([[], false, undefined]);
Expand All @@ -44,7 +44,7 @@ describe('useDevfileSamples:', () => {

expect(putMock).toHaveBeenCalledTimes(1);
expect(putMock).toHaveBeenLastCalledWith('/api/devfile/samples', {
registry: 'sample-placeholder',
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,7 @@ 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 iconUrl = icon || '';
Copy link
Member

Choose a reason for hiding this comment

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

Do we know if the icons will always be URLs instead of base64 encoded images?

Can we use icon directly and remove the iconUrl var now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. The icons from registry will always be URLs. I have removed iconUrl and use icon directly

const href = `/import?importType=devfile&devfileName=${uid}&gitRepo=${gitRepoUrl}`;
const createLabel = t('devconsole~Create Application');
const type = 'Devfile';
Expand Down Expand Up @@ -62,7 +62,7 @@ const useDevfile: ExtensionHook<CatalogItem[]> = (): [CatalogItem[], boolean, an
React.useEffect(() => {
let mounted = true;
const payload = {
registry: 'sample-placeholder',
registry: 'https://registry.devfile.io',
};
coFetchJSON
.put('/api/devfile/samples', payload)
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 @@ -41,7 +41,7 @@ const useDevfileSamples: ExtensionHook<CatalogItem[]> = (): [CatalogItem[], bool
React.useEffect(() => {
let mounted = true;
const payload = {
registry: 'sample-placeholder',
registry: 'https://registry.devfile.io',
};
coFetchJSON
.put('/api/devfile/samples', payload)
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
18 changes: 10 additions & 8 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-20210910153124-da620cd1a7a1
github.com/devfile/library v1.1.1-0.20210910214722-7c5ff63711ec
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-20210105115604-44119421ec6b
Expand All @@ -21,14 +23,14 @@ require (
gopkg.in/square/go-jose.v2 v2.4.1 // indirect
gopkg.in/yaml.v2 v2.4.0
helm.sh/helm/v3 v3.6.2
k8s.io/api v0.21.1
k8s.io/apiextensions-apiserver v0.21.1
k8s.io/apimachinery v0.21.1
k8s.io/api v0.21.3
k8s.io/apiextensions-apiserver v0.21.3
k8s.io/apimachinery v0.21.3
k8s.io/cli-runtime v0.21.0
k8s.io/client-go v0.21.1
k8s.io/client-go v0.21.3
k8s.io/klog v1.0.0
k8s.io/klog/v2 v2.8.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