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

Adding machine output to component create #2532

Merged

Conversation

mohammedzee1000
Copy link
Contributor

@mohammedzee1000 mohammedzee1000 commented Jan 27, 2020

  • Cleaning machine output
  • Changing as needed to affected packages
  • Adding machine output to component create

What type of PR is this?

/kind bug

Which issue(s) this PR fixes:

Fixes #2309

How to test changes / Special notes to the reviewer:

❯ odo create -o json nodejs
{
    "kind": "Component",
    "apiVersion": "odo.openshift.io/v1alpha1",
    "metadata": {
        "name": "nodejs-nodejs-ex-2-quxc",
        "namespace": "myproject",
        "creationTimestamp": null
    },
    "spec": {
        "app": "app",
        "type": "nodejs",
        "source": "file://./",
        "ports": [
            "8080/TCP"
        ]
    },
    "status": {
        "state": "Not Pushed"
    }
}

❯ odo create python --now -o json
{
    "kind": "Component",
    "apiVersion": "odo.openshift.io/v1alpha1",
    "metadata": {
        "name": "python-python-bveb",
        "namespace": "myproject",
        "creationTimestamp": null
    },
    "spec": {
        "app": "app",
        "type": "python",
        "source": "file://./",
        "env": [
            {
                "name": "DEBUG_PORT",
                "value": "5858"
            }
        ]
    },
    "status": {
        "state": "Pushed"
    }
}


return err
}
if log.IsJSON() {
componentDesc, err := component.GetComponent(po.Context.Client, po.Context.Component(), po.Context.Application, po.Context.Project)
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if outputting component description is what we want for odo push -o json output.
I would skip JSON output for the push for now as we are not sure how it should look like. This PR was supposed to just about create command.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, skipped

Copy link
Member

@kadel kadel left a comment

Choose a reason for hiding this comment

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

The output was supposed to be for odo create command, not odo push :-(

▶ odo component create java -o json
 ✗  Machine readable output is not yet implemented for this command

@mohammedzee1000
Copy link
Contributor Author

@kadel fixed

@kadel
Copy link
Member

kadel commented Jan 30, 2020

@mohammedzee1000 :-(
you are not checking error, and odo list is panicking :-(

golangci-lint run ./... --timeout 5m
pkg/odo/cli/component/create.go:502:35: SA4006: this value of `err` is never used (staticcheck)
		co.Context, co.localConfigInfo, err = genericclioptions.UpdatedContext(co.Context)
odo component list --app app --project hfksemmieq]

[odo] panic: runtime error: invalid memory address or nil pointer dereference
[odo] [signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x13c71d5]
[odo] 
[odo] goroutine 1 [running]:
[odo] github.com/openshift/odo/pkg/component.List(0xc00072f040, 0x7ffd6a39e598, 0x3, 0xc000a22cd0, 0xc000946e60, 0x18f55a8, 0x14, 0x18e43e7, 0x2, 0x1516b11)
[odo] 	/go/src/github.com/openshift/odo/pkg/component/component.go:907 +0x4f5
[odo] github.com/openshift/odo/pkg/odo/cli/component.(*ListOptions).Run(0xc000841aa0, 0x0, 0x0)
[odo] 	/go/src/github.com/openshift/odo/pkg/odo/cli/component/list.go:113 +0xc7d
[odo] github.com/openshift/odo/pkg/odo/genericclioptions.GenericRun(0x1b205e0, 0xc000841aa0, 0xc0007bb8c0, 0xc0004d93c0, 0x0, 0x4)
[odo] 	/go/src/github.com/openshift/odo/pkg/odo/genericclioptions/runnable.go:31 +0x13c
[odo] github.com/openshift/odo/pkg/odo/cli/component.NewCmdList.func1(0xc0007bb8c0, 0xc0004d93c0, 0x0, 0x4)
[odo] 	/go/src/github.com/openshift/odo/pkg/odo/cli/component/list.go:149 +0x5e
[odo] github.com/openshift/odo/vendor/github.com/spf13/cobra.(*Command).execute(0xc0007bb8c0, 0xc0004d9380, 0x4, 0x4, 0xc0007bb8c0, 0xc0004d9380)
[odo] 	/go/src/github.com/openshift/odo/vendor/github.com/spf13/cobra/command.go:702 +0x2d3
[odo] github.com/openshift/odo/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc000817b00, 0x8, 0xc000000300, 0x15012d0)
[odo] 	/go/src/github.com/openshift/odo/vendor/github.com/spf13/cobra/command.go:783 +0x2dc
[odo] github.com/openshift/odo/vendor/github.com/spf13/cobra.(*Command).Execute(0xc000817b00, 0x19e8e78, 0xc0007a2420)
[odo] 	/go/src/github.com/openshift/odo/vendor/github.com/spf13/cobra/command.go:736 +0x2b
[odo] main.main()
[odo] 	/go/src/github.com/openshift/odo/cmd/odo/odo.go:72 +0x3fe

@girishramnani
Copy link
Contributor

any update on this PR @mohammedzee1000

@mohammedzee1000
Copy link
Contributor Author

I am looking at what broke

@girishramnani
Copy link
Contributor

@mohammedzee1000 :-(
you are not checking error, and odo list is panicking :-(

golangci-lint run ./... --timeout 5m
pkg/odo/cli/component/create.go:502:35: SA4006: this value of `err` is never used (staticcheck)
		co.Context, co.localConfigInfo, err = genericclioptions.UpdatedContext(co.Context)
odo component list --app app --project hfksemmieq]

[odo] panic: runtime error: invalid memory address or nil pointer dereference
[odo] [signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x13c71d5]
[odo] 
[odo] goroutine 1 [running]:
[odo] github.com/openshift/odo/pkg/component.List(0xc00072f040, 0x7ffd6a39e598, 0x3, 0xc000a22cd0, 0xc000946e60, 0x18f55a8, 0x14, 0x18e43e7, 0x2, 0x1516b11)
[odo] 	/go/src/github.com/openshift/odo/pkg/component/component.go:907 +0x4f5
[odo] github.com/openshift/odo/pkg/odo/cli/component.(*ListOptions).Run(0xc000841aa0, 0x0, 0x0)
[odo] 	/go/src/github.com/openshift/odo/pkg/odo/cli/component/list.go:113 +0xc7d
[odo] github.com/openshift/odo/pkg/odo/genericclioptions.GenericRun(0x1b205e0, 0xc000841aa0, 0xc0007bb8c0, 0xc0004d93c0, 0x0, 0x4)
[odo] 	/go/src/github.com/openshift/odo/pkg/odo/genericclioptions/runnable.go:31 +0x13c
[odo] github.com/openshift/odo/pkg/odo/cli/component.NewCmdList.func1(0xc0007bb8c0, 0xc0004d93c0, 0x0, 0x4)
[odo] 	/go/src/github.com/openshift/odo/pkg/odo/cli/component/list.go:149 +0x5e
[odo] github.com/openshift/odo/vendor/github.com/spf13/cobra.(*Command).execute(0xc0007bb8c0, 0xc0004d9380, 0x4, 0x4, 0xc0007bb8c0, 0xc0004d9380)
[odo] 	/go/src/github.com/openshift/odo/vendor/github.com/spf13/cobra/command.go:702 +0x2d3
[odo] github.com/openshift/odo/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc000817b00, 0x8, 0xc000000300, 0x15012d0)
[odo] 	/go/src/github.com/openshift/odo/vendor/github.com/spf13/cobra/command.go:783 +0x2dc
[odo] github.com/openshift/odo/vendor/github.com/spf13/cobra.(*Command).Execute(0xc000817b00, 0x19e8e78, 0xc0007a2420)
[odo] 	/go/src/github.com/openshift/odo/vendor/github.com/spf13/cobra/command.go:736 +0x2b
[odo] main.main()
[odo] 	/go/src/github.com/openshift/odo/cmd/odo/odo.go:72 +0x3fe

please address @kadel comments too

@mohammedzee1000 mohammedzee1000 force-pushed the cmp_create_json branch 2 times, most recently from 64ca790 to e773574 Compare February 5, 2020 11:18
@codecov
Copy link

codecov bot commented Feb 5, 2020

Codecov Report

Merging #2532 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2532   +/-   ##
=======================================
  Coverage   43.39%   43.39%           
=======================================
  Files          91       91           
  Lines        8312     8312           
=======================================
  Hits         3607     3607           
  Misses       4352     4352           
  Partials      353      353

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 791be7f...2f56a8b. Read the comment docs.

@mohammedzee1000
Copy link
Contributor Author

Due to less amount of time, I am removing the changes i had implemented to json output itself. I am recording it #2573.

I will push smaller PR with only machine-readable output for component creation shortly.

@cdrage
Copy link
Member

cdrage commented Feb 12, 2020

Looks like only this is currently implemented:

~/nodejs-ex  master ✔                                                                                                                                                          16d  ⍉
▶ odo create nodejs -o json
{
    "metadata": {
        "creationTimestamp": null
    },
    "spec": {},
    "status": {
        "state": ""
    }
}

However.. this should match odo describe..

{
    "kind": "Component",
    "apiVersion": "odo.openshift.io/v1alpha1",
    "metadata": {
        "name": "nodejs-nodejs-ex-wila",
        "namespace": "default",
        "creationTimestamp": null
    },
    "spec": {
        "app": "app",
        "type": "nodejs",
        "source": "file://./",
        "ports": [
            "8080/TCP"
        ]
    },
    "status": {
        "state": "Not Pushed"
    }
}

So I'm going to fix that 👍

@kadel
Copy link
Member

kadel commented Mar 10, 2020

@mohammedzee1000 How is this progressing? Any blockers?

@@ -236,6 +236,24 @@ func componentTests(args ...string) {
helper.CmdShouldPass("odo", append(args, "delete", "-f", "--all", "--context", context)...)
})

It("should describe not pushed component when it is created with json output", func() {
cmpDescribeJSON, err := helper.Unindented(helper.CmdShouldPass("odo", append(args, "create", "nodejs", "cmp-git", "--project", project, "--git", "https://github.com/openshift/nodejs-ex", "--context", context, "--app", "testing", "-o", "json")...))
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you use nodejs local source (less time consuming) instead of git source.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

})

It("should describe pushed component when it is created with json output", func() {
cmpDescribeJSON, err := helper.Unindented(helper.CmdShouldPass("odo", append(args, "create", "nodejs", "cmp-git", "--project", project, "--git", "https://github.com/openshift/nodejs-ex", "--context", context, "--app", "testing", "-o", "json", "--now")...))
Copy link
Contributor

Choose a reason for hiding this comment

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

Use local nodejs source to save few minutes of CI time

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@mohammedzee1000
Copy link
Contributor Author

@amitkrout done

@mohammedzee1000
Copy link
Contributor Author

/retest

1 similar comment
@mohammedzee1000
Copy link
Contributor Author

/retest

@openshift-ci-robot openshift-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Apr 2, 2020
@amitkrout
Copy link
Contributor

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Apr 2, 2020
return err
}
}
componentDesc.Spec.Ports = co.LocalConfigInfo.GetPorts()
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this needed to be done, shouldn’t the port be populated in the spec?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I took what is there in odo describe logic. Must be a reason why its there

Copy link
Member

@cdrage cdrage left a comment

Choose a reason for hiding this comment

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

Changes look great!

/approve

@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cdrage

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-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. Required by Prow. label Apr 7, 2020
@openshift-merge-robot openshift-merge-robot merged commit 2995990 into redhat-developer:master Apr 7, 2020
@mohammedzee1000 mohammedzee1000 deleted the cmp_create_json branch April 8, 2020 05:49
@rm3l rm3l added the estimated-size/M (10-20) Rough sizing for Epics. About 1 sprint of work for one person label Jun 18, 2023
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. estimated-size/M (10-20) Rough sizing for Epics. About 1 sprint of work for one person kind/bug Categorizes issue or PR as related to a bug. kind/feature Categorizes issue as a feature request. For PRs, that means that the PR is the implementation 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.

No message is generated for component create command with -o json flag
8 participants