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

odo add binding - Bind as files UI update #5817

Merged
merged 11 commits into from
Jun 14, 2022

Conversation

valaparthvi
Copy link
Contributor

@valaparthvi valaparthvi commented Jun 13, 2022

Signed-off-by: Parthvi Vala pvala@redhat.com

What type of PR is this:
/kind feature

What does this PR do / why we need it:
This PR adds a more understandable question when asking how to service should be bound to the component.

Which issue(s) this PR fixes:

Fixes #5770

PR acceptance criteria:

How to test changes / Special notes to the reviewer:

  1. mkdir /tmp/101; cd /tmp/101
  2. Setup a bindable operator and spawn a service. For example - https://operatorhub.io/operator/cloud-native-postgresql
  3. odo init --name restapi --devfile go --starter go-starter
  4. odo add binding

@openshift-ci openshift-ci bot added the kind/feature Categorizes issue as a feature request. For PRs, that means that the PR is the implementation label Jun 13, 2022
@openshift-ci openshift-ci bot requested review from cdrage and dharmit June 13, 2022 07:18
@netlify
Copy link

netlify bot commented Jun 13, 2022

Deploy Preview for odo-docusaurus-preview canceled.

Name Link
🔨 Latest commit c9601e6
🔍 Latest deploy log https://app.netlify.com/sites/odo-docusaurus-preview/deploys/62a8464533e56300092bb352

@odo-robot
Copy link

odo-robot bot commented Jun 13, 2022

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

@valaparthvi
Copy link
Contributor Author

/retest-required

@odo-robot
Copy link

odo-robot bot commented Jun 13, 2022

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

@odo-robot
Copy link

odo-robot bot commented Jun 13, 2022

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

@odo-robot
Copy link

odo-robot bot commented Jun 13, 2022

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

Signed-off-by: Parthvi Vala <pvala@redhat.com>
@odo-robot
Copy link

odo-robot bot commented Jun 13, 2022

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

return answer, nil

var bindAsFiles bool
if answer == "Bind as Files" {
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO, you should avoid testing the literal value directly. You could pass an int as AskOne to get the index of the result, and test on the index.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, I keep forgetting about using the index.

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 do not want to return the int value here, I want to evaluate the bindAsFiles's bool here. So, even if I use int to store the value of user's answer, I would rely on the options to maintain. Something like below -

func (o *Survey) AskBindAsFiles() (bool, error) {
	options := []string{"Bind as Files", "Bind as Environment Variables"}
	question := &survey.Select{
		Message: "How do you want to bind the service?",
		Options: options,
	}
	var answer int
	err := survey.AskOne(question, &answer)
	if err != nil {
		return true, err
	}

	var bindAsFiles bool
	if answer == 0 {
		bindAsFiles = true
	}
	return bindAsFiles, nil
}

This doesn't seem correct to me.
Is this what you were suggesting?

Copy link
Contributor

Choose a reason for hiding this comment

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

You are right, this solution now relies on the order of the options, and not anymore on the content, which can be equally error prone.

Or, in your first version, you could make a constant with "Bind as files", to be sure one is not changed without the other.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Const sounds like a better idea, will do that.

@feloy
Copy link
Contributor

feloy commented Jun 13, 2022

/approve

@openshift-ci
Copy link

openshift-ci bot commented Jun 13, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: feloy

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 Jun 13, 2022
@valaparthvi
Copy link
Contributor Author

/override ci/prow/v4.10-integration-e2e

@openshift-ci
Copy link

openshift-ci bot commented Jun 13, 2022

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

In response to this:

/override ci/prow/v4.10-integration-e2e

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.

Copy link
Member

@dharmit dharmit left a comment

Choose a reason for hiding this comment

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

Only doc review. Besides the requested/suggested changes, I feel that we should document the need to either have a running odo dev in a separate terminal, or execute odo dev after adding a binding if it's not running in a separate terminal.

valaparthvi and others added 2 commits June 14, 2022 12:18
…d-binding.md

Co-authored-by: Dharmit Shah <shahdharmit@gmail.com>
…d-binding.md

Co-authored-by: Dharmit Shah <shahdharmit@gmail.com>
Copy link
Member

@dharmit dharmit left a comment

Choose a reason for hiding this comment

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

Code review. Looks good, only minor suggestions.

pkg/binding/asker/survey_asker.go Outdated Show resolved Hide resolved
pkg/odo/cli/add/binding/binding.go Outdated Show resolved Hide resolved
// This is run before every Spec (It)
var _ = BeforeEach(func() {
if helper.IsKubernetesCluster() {
Skip("Operators have not been setup on Kubernetes cluster yet. Remove this once the issue has been fixed.")
Copy link
Member

Choose a reason for hiding this comment

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

Really? Why is that the case? I mean, what's blocking us from setting up Operators on k8s cluster?

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 have to take a jab at it again, but the last time we tried, we had some problem related to annotations' character limit with a certain OLM version. I work with a minikube cluster locally, so I can ascertain that it works well on a vanilla K8s cluster, but I'll have to take a look at test cluster again.

valaparthvi and others added 4 commits June 14, 2022 12:27
…d-binding.md

Co-authored-by: Dharmit Shah <shahdharmit@gmail.com>
…d-binding.md

Co-authored-by: Dharmit Shah <shahdharmit@gmail.com>
…d-binding.md

Co-authored-by: Dharmit Shah <shahdharmit@gmail.com>
Co-authored-by: Dharmit Shah <shahdharmit@gmail.com>
@dharmit
Copy link
Member

dharmit commented Jun 14, 2022

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Jun 14, 2022
…d-binding.md

Co-authored-by: Dharmit Shah <shahdharmit@gmail.com>
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Jun 14, 2022
…d-binding.md

Co-authored-by: Dharmit Shah <shahdharmit@gmail.com>
@valaparthvi
Copy link
Contributor Author

I feel that we should document the need to either have a running odo dev in a separate terminal, or execute odo dev after adding a binding if it's not running in a separate terminal.

I don't think that has to be the case. odo add binding does not require for the component to be pushed on the cluster, it simply adds data to the devfile, you can run odo dev later on to create it on the cluster. I think the suggestion you made in #5817 (comment) should suffice.

@sonarcloud
Copy link

sonarcloud bot commented Jun 14, 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 2 Code Smells

No Coverage information No Coverage information
0.5% 0.5% Duplication

@dharmit
Copy link
Member

dharmit commented Jun 14, 2022

/lgtm

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

/override ci/prow/v4.10-integration-e2e

@openshift-ci
Copy link

openshift-ci bot commented Jun 14, 2022

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

In response to this:

/override ci/prow/v4.10-integration-e2e

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.

@openshift-ci openshift-ci bot merged commit aa2d935 into redhat-developer:main Jun 14, 2022
cdrage pushed a commit to cdrage/odo that referenced this pull request Aug 31, 2022
* odo add binding - Bind as files UI update

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Philippe's review

* Update docs/website/versioned_docs/version-3.0.0/command-reference/add-binding.md

Co-authored-by: Dharmit Shah <shahdharmit@gmail.com>

* Update docs/website/versioned_docs/version-3.0.0/command-reference/add-binding.md

Co-authored-by: Dharmit Shah <shahdharmit@gmail.com>

* Update docs/website/versioned_docs/version-3.0.0/command-reference/add-binding.md

Co-authored-by: Dharmit Shah <shahdharmit@gmail.com>

* Update docs/website/versioned_docs/version-3.0.0/command-reference/add-binding.md

Co-authored-by: Dharmit Shah <shahdharmit@gmail.com>

* Update docs/website/versioned_docs/version-3.0.0/command-reference/add-binding.md

Co-authored-by: Dharmit Shah <shahdharmit@gmail.com>

* Update pkg/odo/cli/add/binding/binding.go

Co-authored-by: Dharmit Shah <shahdharmit@gmail.com>

* Update docs/website/versioned_docs/version-3.0.0/command-reference/add-binding.md

Co-authored-by: Dharmit Shah <shahdharmit@gmail.com>

* Update docs/website/versioned_docs/version-3.0.0/command-reference/add-binding.md

Co-authored-by: Dharmit Shah <shahdharmit@gmail.com>

* make consts private

Co-authored-by: Dharmit Shah <shahdharmit@gmail.com>
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.

odo add binding - Bind as files UI update
3 participants