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

Print yaml definition of CR when asked for dry-run #2810

Merged
merged 2 commits into from Apr 15, 2020
Merged

Print yaml definition of CR when asked for dry-run #2810

merged 2 commits into from Apr 15, 2020

Conversation

dharmit
Copy link
Member

@dharmit dharmit commented Apr 3, 2020

What type of PR is this?

/kind feature

What does does this PR do / why we need it:
When user does odo service create <operator-name> --crd <crd-name> --dry-run,
it will print only the CR's yaml definition that will be used to bring up the
service.

This is needed because yaml definitions provided in the alm-examples are not
always complete. Sometimes they contain template data which needs to be
modified to be able to start the service. After this PR, we will have another
PR which will let the user specify file containing a yaml definition to bring
up the service. That's where this will yaml output in this PR will be really
helpful.

Which issue(s) this PR fixes:

Addresses first acceptance criteria of #2723.

How to test changes / Special notes to the reviewer:

  1. Make sure you have an operator installed on your cluster.
  2. Enable experimental mode export ODO_EXPERIMENTAL=true
  3. Execute following command:
    $ odo service create etcdoperator.v0.9.4 --crd EtcdCluster --dry-run
    Following definition will be used to create EtcdCluster:
    
    apiVersion: etcd.database.coreos.com/v1beta2
    kind: EtcdCluster
    metadata:
      name: example
    spec:
      size: 3
      version: 3.2.13

NOTE to reviewer & QE: The output generated by above command is likely to
change when the operator is upgrade by its developers. Hence, the integration
test for this PR only checks for the presence of the line Following definition will be used to create.

NOTE to approver: This PR is rebased on top of #2739 and hence that should
go in first.

@openshift-ci-robot openshift-ci-robot added the kind/feature Categorizes issue as a feature request. For PRs, that means that the PR is the implementation label Apr 3, 2020
Copy link
Contributor

@amitkrout amitkrout left a comment

Choose a reason for hiding this comment

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

@dharmit No UTs will be added because of #2739 (comment) including the the changes you made for cli packages pkg/odo/cli/service/create.go too, right ?

@amitkrout
Copy link
Contributor

/test v4.3-integration-e2e-benchmark

@codecov
Copy link

codecov bot commented Apr 5, 2020

Codecov Report

Merging #2810 into master will decrease coverage by 0.26%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2810      +/-   ##
==========================================
- Coverage   43.26%   43.00%   -0.27%     
==========================================
  Files          97       97              
  Lines        8878     8930      +52     
==========================================
- Hits         3841     3840       -1     
- Misses       4673     4726      +53     
  Partials      364      364              
Impacted Files Coverage Δ
pkg/odo/cli/service/create.go 13.26% <0.00%> (-0.95%) ⬇️
pkg/kclient/secrets.go 85.71% <0.00%> (-3.76%) ⬇️
pkg/url/url.go 26.66% <0.00%> (-1.41%) ⬇️
pkg/occlient/occlient.go 51.81% <0.00%> (-0.93%) ⬇️
...g/devfile/adapters/kubernetes/component/adapter.go 27.61% <0.00%> (-0.27%) ⬇️
pkg/watch/watch.go 69.41% <0.00%> (+2.35%) ⬆️

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 749739a...65dfbcd. Read the comment docs.

@openshift-ci-robot openshift-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. Required by Prow. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. Required by Prow. labels Apr 10, 2020
@dharmit
Copy link
Member Author

dharmit commented Apr 13, 2020

@dharmit No UTs will be added because of #2739 (comment) including the the changes you made for cli packages pkg/odo/cli/service/create.go too, right ?

Yes, that's right. The data is so dynamic that it's not possible to add much in terms of unit tests. But I'm really willing to discuss adding more integration tests if you or anyone thinks that we can add some scenario.

@girishramnani
Copy link
Contributor

/approve

@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: girishramnani

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 14, 2020
@adisky
Copy link
Contributor

adisky commented Apr 15, 2020

Looks good to me, just one suggestion, we should have some difference in formatting of message and yaml

$ odo service create nfd.4.3.10-202003311428 --crd NodeFeatureDiscovery --dry-run
Following definition will be used to create NodeFeatureDiscovery:

apiVersion: nfd.openshift.io/v1alpha1
kind: NodeFeatureDiscovery
metadata:
  name: nfd-master-server
spec:
  namespace: openshift-nfd

operators := helper.CmdShouldPass("odo", "catalog", "list", "services")
etcdOperator := regexp.MustCompile(`etcdoperator\.*[a-z][0-9]\.[0-9]\.[0-9]`).FindString(operators)

helper.CmdShouldPass("odo", "service", "create", etcdOperator, "--crd", "EtcdCluster", "--dry-run")
Copy link
Contributor

@adisky adisky Apr 15, 2020

Choose a reason for hiding this comment

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

can we verify that output contains apiVersion Kind strings? as now this Following definition will be used to create. is removed

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense to me. Done.

@adisky
Copy link
Contributor

adisky commented Apr 15, 2020

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Apr 15, 2020
@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit a8d0a17 into redhat-developer:master Apr 15, 2020
@dharmit dharmit deleted the fix-2723 branch May 15, 2020 04:44
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/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.

None yet

7 participants