eclipse-archived / codewind

The official repository of the Eclipse Codewind project
https://codewind.dev
Eclipse Public License 2.0
114 stars 44 forks source link

Templates API sometimes returning templates from disabled sources with showEnabledOnly=true #2472

Closed tetchel closed 4 years ago

tetchel commented 4 years ago

Master branch

When I GET http://localhost:10000/api/v1/templates?showEnabledOnly=true I get all the templates, even the ones from disabled sources. I see the same behaviour using the cwctl templates commands (the kabanero source is disabled, but its templates are still listed).

This means the user gets prompted with the entire list of templates every time they want to create a project, and disabling a source in the Source Manager has no effect.

[ /programs/codewind-vscode/dev ] 28 (testsInJenkins) $ cwctl templates repos ls
[
        {
                "description": "Codewind project templates help you create containerized projects for various runtimes.",
                "url": "https://raw.githubusercontent.com/codewind-resources/codewind-templates/master/devfiles/index.json",
                "name": "Default templates",
                "id": "",
                "enabled": true,
                "protected": true,
                "projectStyles": [
                        "Codewind"
                ]
        },
        {
                "description": "Kabanero, an open source project, brings together open source technologies into a microservices-based framework. Kabanero builds cloud native applications ready for deployment onto Kubernetes and Knative.",
                "url": "https://github.com/kabanero-io/collections/releases/latest/download/kabanero-index.json",
                "name": "Kabanero Collections",
                "id": "",
                "enabled": false,
                "protected": true,
                "projectStyles": [
                        "Appsody"
                ]
        },
        {
                "description": "Use Appsody in Codewind to develop applications with sharable technology stacks.",
                "url": "https://github.com/appsody/stacks/releases/latest/download/incubator-index.json",
                "name": "Appsody Stacks - incubator",
                "id": "incubator",
                "enabled": true,
                "protected": true,
                "projectStyles": [
                        "Appsody"
                ]
        }
]
[ /programs/codewind-vscode/dev ] 28 (testsInJenkins) $ cwctl templates ls --showEnabledOnly
[
        {
                "label": "Appsody Eclipse MicroProfile® template",
                "description": "Eclipse MicroProfile on Open Liberty \u0026 OpenJ9 using Maven",
                "language": "java",
                "url": "https://github.com/appsody/stacks/releases/download/java-microprofile-v0.2.24/incubator.java-microprofile.v0.2.24.templates.default.tar.gz",
                "projectType": "appsodyExtension",
                "projectStyle": "Appsody",
                "source": "Appsody Stacks - incubator",
                "sourceId": "incubator"
        },
        {
                "label": "Appsody Kitura template",
                "description": "Runtime for Kitura applications",
                "language": "swift",
                "url": "https://github.com/appsody/stacks/releases/download/kitura-v0.2.5/incubator.kitura.v0.2.5.templates.default.tar.gz",
                "projectType": "appsodyExtension",
                "projectStyle": "Appsody",
                "source": "Appsody Stacks - incubator",
                "sourceId": "incubator"
        },
        {
                "label": "Appsody LoopBack 4 template",
                "description": "LoopBack 4 API Framework for Node.js",
                "language": "nodejs",
                "url": "https://github.com/appsody/stacks/releases/download/nodejs-loopback-v0.2.2/incubator.nodejs-loopback.v0.2.2.templates.scaffold.tar.gz",
                "projectType": "appsodyExtension",
                "projectStyle": "Appsody",
                "source": "Appsody Stacks - incubator",
                "sourceId": "incubator"
        },
        {
                "label": "Appsody Node-RED template",
                "description": "Node-RED runtime for running flows",
                "language": "nodejs",
                "url": "https://github.com/appsody/stacks/releases/download/node-red-v0.1.1/incubator.node-red.v0.1.1.templates.simple.tar.gz",
                "projectType": "appsodyExtension",
                "projectStyle": "Appsody",
                "source": "Appsody Stacks - incubator",
                "sourceId": "incubator"
        },
        {
                "label": "Appsody Node.js Express scaffold template",
                "description": "Express web framework for Node.js",
                "language": "nodejs",
                "url": "https://github.com/appsody/stacks/releases/download/nodejs-express-v0.4.5/incubator.nodejs-express.v0.4.5.templates.scaffold.tar.gz",
                "projectType": "appsodyExtension",
                "projectStyle": "Appsody",
                "source": "Appsody Stacks - incubator",
                "sourceId": "incubator"
        },
        {
                "label": "Appsody Node.js Express simple template",
                "description": "Express web framework for Node.js",
                "language": "nodejs",
                "url": "https://github.com/appsody/stacks/releases/download/nodejs-express-v0.4.5/incubator.nodejs-express.v0.4.5.templates.simple.tar.gz",
                "projectType": "appsodyExtension",
                "projectStyle": "Appsody",
                "source": "Appsody Stacks - incubator",
                "sourceId": "incubator"
        },
        {
                "label": "Appsody Node.js template",
                "description": "Runtime for Node.js applications",
                "language": "nodejs",
                "url": "https://github.com/appsody/stacks/releases/download/nodejs-v0.3.5/incubator.nodejs.v0.3.5.templates.simple.tar.gz",
                "projectType": "appsodyExtension",
                "projectStyle": "Appsody",
                "source": "Appsody Stacks - incubator",
                "sourceId": "incubator"
        },
        {
                "label": "Appsody Open Liberty template",
                "description": "Open Liberty \u0026 OpenJ9 using Maven",
                "language": "java",
                "url": "https://github.com/appsody/stacks/releases/download/java-openliberty-v0.2.3/incubator.java-openliberty.v0.2.3.templates.default.tar.gz",
                "projectType": "appsodyExtension",
                "projectStyle": "Appsody",
                "source": "Appsody Stacks - incubator",
                "sourceId": "incubator"
        },
        {
                "label": "Appsody Python Flask template",
                "description": "Flask web Framework for Python",
                "language": "python",
                "url": "https://github.com/appsody/stacks/releases/download/python-flask-v0.2.2/incubator.python-flask.v0.2.2.templates.simple.tar.gz",
                "projectType": "appsodyExtension",
                "projectStyle": "Appsody",
                "source": "Appsody Stacks - incubator",
                "sourceId": "incubator"
        },
        {
                "label": "Appsody Spring Boot® default template",
                "description": "Spring Boot using OpenJ9 and Maven",
                "language": "java",
                "url": "https://github.com/appsody/stacks/releases/download/java-spring-boot2-v0.3.27/incubator.java-spring-boot2.v0.3.27.templates.default.tar.gz",
                "projectType": "appsodyExtension",
                "projectStyle": "Appsody",
                "source": "Appsody Stacks - incubator",
                "sourceId": "incubator"
        },
        {
                "label": "Appsody Spring Boot® kotlin template",
                "description": "Spring Boot using OpenJ9 and Maven",
                "language": "java",
                "url": "https://github.com/appsody/stacks/releases/download/java-spring-boot2-v0.3.27/incubator.java-spring-boot2.v0.3.27.templates.kotlin.tar.gz",
                "projectType": "appsodyExtension",
                "projectStyle": "Appsody",
                "source": "Appsody Stacks - incubator",
                "sourceId": "incubator"
        },
        {
                "label": "Appsody Starter Sample template",
                "description": "Runnable starter stack, copy to create a new stack",
                "language": "bash",
                "url": "https://github.com/appsody/stacks/releases/download/starter-v0.1.2/incubator.starter.v0.1.2.templates.simple.tar.gz",
                "projectType": "appsodyExtension",
                "projectStyle": "Appsody",
                "source": "Appsody Stacks - incubator",
                "sourceId": "incubator"
        },
        {
                "label": "Appsody Swift template",
                "description": "Appsody runtime for Swift applications",
                "language": "swift",
                "url": "https://github.com/appsody/stacks/releases/download/swift-v0.2.5/incubator.swift.v0.2.5.templates.simple.tar.gz",
                "projectType": "appsodyExtension",
                "projectStyle": "Appsody",
                "source": "Appsody Stacks - incubator",
                "sourceId": "incubator"
        },
        {
                "label": "Go",
                "description": "Eclipse Codewind Go sample application",
                "language": "go",
                "url": "https://github.com/codewind-resources/goTemplate",
                "projectType": "docker",
                "source": "Default templates"
        },
        {
                "label": "Lagom Java",
                "description": "Eclipse Codewind Lagom Reactive microservice in Java",
                "language": "java",
                "url": "https://github.com/codewind-resources/lagomJavaTemplate",
                "projectType": "docker",
                "source": "Default templates"
        },
        {
                "label": "Node.js Express",
                "description": "Eclipse Codewind Express sample application",
                "language": "nodejs",
                "url": "https://github.com/codewind-resources/nodeExpressTemplate",
                "projectType": "nodejs",
                "source": "Default templates"
        },
        {
                "label": "Open Liberty",
                "description": "Eclipse Codewind Open Liberty sample application in Java",
                "language": "java",
                "url": "https://github.com/codewind-resources/openLibertyTemplate",
                "projectType": "docker",
                "source": "Default templates"
        },
        {
                "label": "Python",
                "description": "Eclipse Codewind Python sample application",
                "language": "python",
                "url": "https://github.com/codewind-resources/pythonTemplate",
                "projectType": "docker",
                "source": "Default templates"
        },
        {
                "label": "Spring Boot®",
                "description": "Eclipse Codewind Spring Boot® sample application",
                "language": "java",
                "url": "https://github.com/codewind-resources/springJavaTemplate",
                "projectType": "spring",
                "source": "Default templates"
        },
        {
                "label": "Swift",
                "description": "Eclipse Codewind Swift sample application",
                "language": "swift",
                "url": "https://github.com/codewind-resources/swiftTemplate",
                "projectType": "swift",
                "source": "Default templates"
        },
        {
                "label": "WebSphere Liberty MicroProfile®",
                "description": "Eclipse MicroProfile® on Websphere Liberty",
                "language": "java",
                "url": "https://github.com/codewind-resources/javaMicroProfileTemplate",
                "projectType": "liberty",
                "source": "Default templates"
        },
        {
                "label": "Kabanero Eclipse MicroProfile® template",
                "description": "Eclipse MicroProfile on Open Liberty \u0026 OpenJ9 using Maven",
                "language": "java",
                "url": "https://github.com/kabanero-io/collections/releases/download/0.6.3/java-microprofile.v0.2.26.templates.default.tar.gz",
                "projectType": "appsodyExtension",
                "projectStyle": "Appsody",
                "source": "Kabanero Collections"
        },
        {
                "label": "Kabanero Node.js Express scaffold template",
                "description": "Express web framework for Node.js",
                "language": "nodejs",
                "url": "https://github.com/kabanero-io/collections/releases/download/0.6.3/nodejs-express.v0.2.10.templates.scaffold.tar.gz",
                "projectType": "appsodyExtension",
                "projectStyle": "Appsody",
                "source": "Kabanero Collections"
        },
        {
                "label": "Kabanero Node.js Express simple template",
                "description": "Express web framework for Node.js",
                "language": "nodejs",
                "url": "https://github.com/kabanero-io/collections/releases/download/0.6.3/nodejs-express.v0.2.10.templates.simple.tar.gz",
                "projectType": "appsodyExtension",
                "projectStyle": "Appsody",
                "source": "Kabanero Collections"
        },
        {
                "label": "Kabanero Node.js template",
                "description": "Runtime for Node.js applications",
                "language": "nodejs",
                "url": "https://github.com/kabanero-io/collections/releases/download/0.6.3/nodejs.v0.3.3.templates.simple.tar.gz",
                "projectType": "appsodyExtension",
                "projectStyle": "Appsody",
                "source": "Kabanero Collections"
        },
        {
                "label": "Kabanero Open Liberty template",
                "description": "Open Liberty \u0026 OpenJ9 using Maven",
                "language": "java",
                "url": "https://github.com/kabanero-io/collections/releases/download/0.6.3/java-openliberty.v0.2.3.templates.default.tar.gz",
                "projectType": "appsodyExtension",
                "projectStyle": "Appsody",
                "source": "Kabanero Collections"
        },
        {
                "label": "Kabanero Spring Boot® default template",
                "description": "Spring Boot using OpenJ9 and Maven",
                "language": "java",
                "url": "https://github.com/kabanero-io/collections/releases/download/0.6.3/java-spring-boot2.v0.3.24.templates.default.tar.gz",
                "projectType": "appsodyExtension",
                "projectStyle": "Appsody",
                "source": "Kabanero Collections"
        },
        {
                "label": "Kabanero Spring Boot® kotlin template",
                "description": "Spring Boot using OpenJ9 and Maven",
                "language": "java",
                "url": "https://github.com/kabanero-io/collections/releases/download/0.6.3/java-spring-boot2.v0.3.24.templates.kotlin.tar.gz",
                "projectType": "appsodyExtension",
                "projectStyle": "Appsody",
                "source": "Kabanero Collections"
        }
]
[ /programs/codewind-vscode/dev ] 28 (testsInJenkins) $ 
stalleyj commented 4 years ago

I'm unable to recreate this issue so far, continuing to investigate. I may need to add some extra debug lines to help track down the problem.

stalleyj commented 4 years ago

I've found the initial problem that was in the POST /api/v1/templates/repositories api. Writing a specific test for this has led me to another issue though, in that we are not accepting the 'enabled' option to the API which my test requires. Hope to deliver a fix for both tomorrow.

tetchel commented 4 years ago

It looks like there's still a bug with this. Newly added sources initially report they are enabled, but the templates don't show up when the templates list is requested. If you disable the source and then enable it, then the templates show up as expected.

tetchel commented 4 years ago

The original bug is fixed so i'll close this and opened https://github.com/eclipse/codewind/issues/2641