Skip to content

Commit

Permalink
Return odo analyze result as an array (redhat-developer#5799)
Browse files Browse the repository at this point in the history
  • Loading branch information
feloy authored and cdrage committed Aug 31, 2022
1 parent 5a63a8f commit e7e8cb3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,19 @@ The structures used to return information using JSON output are defined in [the

## odo analyze -o json

The `analyze` command analyzes the files in the current directory to select the best devfile to use,
The `analyze` command analyzes the files in the current directory to select the best devfiles to use,
from the devfiles in the registries defined in the list of preferred registries with the command `odo preference registry`.

The output of this command contains a devfile name and a registry name:
The output of this command contains a list of devfile name and registry name:

```bash
$ odo analyze -o json
{
"devfile": "nodejs",
"devfileRegistry": "DefaultDevfileRegistry"
}
[
{
"devfile": "nodejs",
"devfileRegistry": "DefaultDevfileRegistry"
}
]
$ echo $?
0
```
Expand Down
3 changes: 2 additions & 1 deletion pkg/odo/cli/alizer/alizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"os"

"github.com/redhat-developer/odo/pkg/alizer"
"github.com/redhat-developer/odo/pkg/api"
"github.com/redhat-developer/odo/pkg/machineoutput"
"github.com/redhat-developer/odo/pkg/odo/cmdline"
"github.com/redhat-developer/odo/pkg/odo/genericclioptions"
Expand Down Expand Up @@ -53,7 +54,7 @@ func (o *AlizerOptions) RunForJsonOutput(ctx context.Context) (out interface{},
return nil, err
}
result := alizer.GetDevfileLocationFromDetection(df, reg)
return result, nil
return []api.DevfileLocation{*result}, nil
}

func NewCmdAlizer(name, fullName string) *cobra.Command {
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/devfile/cmd_analyze_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ var _ = Describe("odo analyze command tests", func() {
stdout, stderr := res.Out(), res.Err()
Expect(stderr).To(BeEmpty())
Expect(helper.IsJSON(stdout)).To(BeTrue())
helper.JsonPathContentIs(stdout, "devfile", "nodejs")
helper.JsonPathContentIs(stdout, "devfileRegistry", "DefaultDevfileRegistry")
helper.JsonPathContentIs(stdout, "0.devfile", "nodejs")
helper.JsonPathContentIs(stdout, "0.devfileRegistry", "DefaultDevfileRegistry")
})
})

Expand Down

0 comments on commit e7e8cb3

Please sign in to comment.