eclipse-archived / codewind

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

cwctl templates list returning no results or incorrect results #947

Closed eharris369 closed 4 years ago

eharris369 commented 4 years ago

I have only the appsody template source enabled (see below) but when I run cwctl templates list --showEnabledOnly true I get null and when I run cwctl templates list I get only the Codewind templates. I am on Windows 10 Enterprise using the latest Codewind (pulled down from git and built) and the latest cwctl build and appsody 0.4.8 release build.

Even if the list of templates is really empty shouldn't it return an empty array instead of null? Also the --json option is supposed to be universal but adding it to this command gives me an error. I want to be able to just add it to all commands in the IDE.

C:\tmp\test\windows>cwctl templates list --showEnabledOnly true
null
C:\tmp\test\windows>cwctl templates list
[
        {
                "label": "Go",
                "description": "Sample microservice for simple go app",
                "language": "go",
                "url": "https://github.com/microclimate-dev2ops/microclimateGoTemplate",
                "projectType": "docker"
        },
        {
                "label": "Lagom Java",
                "description": "Sample for building Lagom Reactive microservice in Java",
                "language": "java",
                "url": "https://github.com/microclimate-dev2ops/lagomJavaTemplate",
                "projectType": "docker"
        },
        ...
[
        {
                "description": "The default set of templates for new projects in Codewind.",
                "url": "https://raw.githubusercontent.com/kabanero-io/codewind-templates/master/devfiles/index.json",
                "name": "Default templates",
                "id": "",
                "enabled": false,
                "protected": true,
                "projectStyles": [
                        "Codewind"
                ]
        },
        {
                "description": "Kabanero Collections",
                "url": "https://github.com/kabanero-io/collections/releases/download/v0.1.2/kabanero-index.json",
                "name": "",
                "id": "",
                "enabled": false,
                "protected": true,
                "projectStyles": [
                        "Appsody"
                ]
        },
        {
                "description": "Appsody Stacks - appsodyhub",
                "url": "https://github.com/appsody/stacks/releases/latest/download/incubator-index.json",
                "name": "",
                "id": "",
                "enabled": true,
                "protected": true,
                "projectStyles": [
                        "Appsody"
                ]
        }
]
james-wallis commented 4 years ago

This looks like it is related to https://github.com/eclipse/codewind/issues/946

jagraj commented 4 years ago

I and Andrew investigated further on my machine and cwctl does not list all the enabled templates. We are able to get all the templates from the curl but not from cwctl. #946 issue did not fix this problem.

eharris369 commented 4 years ago

A further problem is that the source field is missing for the templates. This used to be in the result of the REST API call but is not there in cwctl templates list.

jopit commented 4 years ago

We're switching the eclipse plugin back to using the templates REST API for now. So while this needs to be fixed, it's no longer stopship

james-wallis commented 4 years ago

@tobespc I'll pick this up.

@jopit Just wondering, are you using the --json flag straight after the cwctl? It needs to be this way as it is a global flag, if you put it anywhere else it'll throw an error.

cwctl --json templates list --showEnabledOnly true
james-wallis commented 4 years ago

Looks like the CLI might be adding projectStyle=Codewind to the templates list command without specifying any options. The URL after the Query.adds is http://127.0.0.1:34077/api/v1/templates?projectStyle=Codewind&showEnabledOnly=false

james-wallis commented 4 years ago

When no value is given for projectStyle the CLI is defaulting to Codewind. https://github.com/eclipse/codewind-installer/blob/master/pkg/actions/commands.go#L279

I'll change this to not have a default value, for UX I'm also changing the showEnabledOnly flag to be a boolean so the user can either do --showEnabledOnly true as is implemented now or just --showEnabledOnly which has the same effect.

james-wallis commented 4 years ago

I've made the changes in this PR which just needs testing written for it and then can be accepted. https://github.com/eclipse/codewind-installer/pull/197

james-wallis commented 4 years ago

@eharris369 could you please retest with latest and close this issue if its resolved.