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

Use map for runningIn instead of array in JSON output #6094

Merged
merged 4 commits into from
Sep 6, 2022

Conversation

feloy
Copy link
Contributor

@feloy feloy commented Sep 5, 2022

What type of PR is this:

/kind bug

What does this PR do / why we need it:

Which issue(s) this PR fixes:

Fixes #5999

PR acceptance criteria:

  • Unit test

  • Integration test

  • Documentation

How to test changes / Special notes to the reviewer:

@openshift-ci openshift-ci bot added the kind/bug Categorizes issue or PR as related to a bug. label Sep 5, 2022
@feloy feloy requested a review from rm3l September 5, 2022 11:34
@netlify
Copy link

netlify bot commented Sep 5, 2022

Deploy Preview for odo-docusaurus-preview canceled.

Name Link
🔨 Latest commit 820eddc
🔍 Latest deploy log https://app.netlify.com/sites/odo-docusaurus-preview/deploys/63175bd3f5b17c00088555da

@feloy feloy removed the request for review from anandrkskd September 5, 2022 11:34
@odo-robot
Copy link

odo-robot bot commented Sep 5, 2022

Unit Tests on commit 508a8e4 finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Sep 5, 2022

Validate Tests on commit 508a8e4 finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Sep 5, 2022

OpenShift Tests on commit 508a8e4 finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Sep 5, 2022

Kubernetes Tests on commit 508a8e4 finished successfully.
View logs: TXT HTML

helper.JsonPathContentContain(stdout, "components.0.runningIn.#", "1")
helper.JsonPathContentContain(stdout, "components.0.runningIn.0", "Dev")
helper.JsonPathContentContain(stdout, "components.0.runningIn.dev", "true")
helper.JsonPathContentContain(stdout, "components.0.runningIn.deploy", "")
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I find this check confusing. If the component is not running in Deploy mode, "deploy" will not appear in the list, why then check for it to be an empty string.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The JsonPathContentContain function is not able to make a difference between is the field is not defined or if the field is empty.

This test is used to check that the field is not defined

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Sep 6, 2022
@feloy feloy closed this Sep 6, 2022
@feloy feloy reopened this Sep 6, 2022
@feloy
Copy link
Contributor Author

feloy commented Sep 6, 2022

Re-run with new tests names

"strings"
)

type RunningMode string
type RunningModeList []RunningMode
type RunningModeList map[string]bool

const (
RunningModeDev RunningMode = "Dev"
Copy link
Member

Choose a reason for hiding this comment

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

I can see that those constants (and the RunningMode type) are no longer used and could be removed.

strs = append(strs, string(s))
for s, v := range o {
if v {
strs = append(strs, string(strings.Title(s)))
Copy link
Member

Choose a reason for hiding this comment

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

strings.Title already returns a string, so the additional type conversion does not seem needed.

@@ -157,7 +157,9 @@ odo describe component -o json
"containerPort": 3000
}
],
"runningIn": ["Dev"],
"runningIn": {
"dev": true
Copy link
Member

Choose a reason for hiding this comment

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

Feature-wise, I was expecting the list of possible running modes to be exposed, instead of just the current running mode.

From what I understand from this comment:

menu to start dev mode is enabled if devfile has dev support and if dev mode is not running for the component.

If devfile has dev support but dev mode is not running for the component, I think odo describe component -o json should have "dev": false reported in the running mode object, to help to parse that information. No?

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, you are right. Writing the doc, I was thinking it was due to the omitempty nature of the marshalling in Go, but it is not the case, because it is a map. I'll make the changes to add by default all the keys with a False value

@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Sep 6, 2022
@odo-robot
Copy link

odo-robot bot commented Sep 6, 2022

Windows Tests (OCP) on commit 508a8e4 finished successfully.
View logs: TXT HTML

pkg/api/component.go Outdated Show resolved Hide resolved
pkg/api/component.go Outdated Show resolved Hide resolved
@feloy
Copy link
Contributor Author

feloy commented Sep 6, 2022

Thanks @dharmit for your review

@feloy feloy requested a review from dharmit September 6, 2022 14:40
@sonarcloud
Copy link

sonarcloud bot commented Sep 6, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Member

@rm3l rm3l left a comment

Choose a reason for hiding this comment

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

Thanks for the changes!

/approve

@openshift-ci
Copy link

openshift-ci bot commented Sep 6, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rm3l

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. Required by Prow. label Sep 6, 2022
@dharmit
Copy link
Member

dharmit commented Sep 6, 2022

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Sep 6, 2022
@feloy
Copy link
Contributor Author

feloy commented Sep 6, 2022

/override ci/prow/v4.10-integration-e2e
Tests pass on IBM cloud

@openshift-ci
Copy link

openshift-ci bot commented Sep 6, 2022

@feloy: Overrode contexts on behalf of feloy: ci/prow/v4.10-integration-e2e

In response to this:

/override ci/prow/v4.10-integration-e2e
Tests pass on IBM cloud

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@feloy
Copy link
Contributor Author

feloy commented Sep 6, 2022

/override ci/prow/v4.10-integration-e2e
/override Kubernetes-Integration-Tests/Kubernetes-Integration-Tests
/override OpenShift-Integration-tests/OpenShift-Integration-tests
/override Unit-Tests/Unit-Tests

All tests passed, but not recognized by Github

Required status checks "Kubernetes-Integration-Tests/Kubernetes-Integration-Tests", "OpenShift-Integration-tests/OpenShift-Integration-tests", and "Unit-Tests/Unit-Tests" were not set by the expected GitHub apps.

@openshift-ci
Copy link

openshift-ci bot commented Sep 6, 2022

@feloy: Overrode contexts on behalf of feloy: Kubernetes-Integration-Tests/Kubernetes-Integration-Tests, OpenShift-Integration-tests/OpenShift-Integration-tests, Unit-Tests/Unit-Tests, ci/prow/v4.10-integration-e2e

In response to this:

/override ci/prow/v4.10-integration-e2e
/override Kubernetes-Integration-Tests/Kubernetes-Integration-Tests
/override OpenShift-Integration-tests/OpenShift-Integration-tests
/override Unit-Tests/Unit-Tests

Required status checks "Kubernetes-Integration-Tests/Kubernetes-Integration-Tests", "OpenShift-Integration-tests/OpenShift-Integration-tests", and "Unit-Tests/Unit-Tests" were not set by the expected GitHub apps.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@feloy feloy merged commit 9e39df3 into redhat-developer:main Sep 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. Required by Prow. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. Required by Prow.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

odo features reported in a inconsistent way
4 participants