Skip to content

Commit

Permalink
Output service name when creating Operator backed service (redhat-dev…
Browse files Browse the repository at this point in the history
…eloper#4336)

* Output service name when creating Operator backed service

* Check for service name in tests
  • Loading branch information
dharmit authored Jan 11, 2021
1 parent 9c129a3 commit f463d09
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 7 additions & 0 deletions pkg/odo/cli/service/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,13 @@ func (o *ServiceCreateOptions) Validate() (err error) {
// CRD is valid. We can use it further to create a service from it.
o.CustomResourceDefinition = d.OriginalCRD

if o.ServiceName == "" {
o.ServiceName, err = d.getServiceNameFromCRD()
if err != nil {
return err
}
}

return nil
} else {
// This block is executed only when user has neither provided a
Expand Down
5 changes: 3 additions & 2 deletions tests/integration/operatorhub/cmd_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ var _ = Describe("odo service command tests for OperatorHub", func() {
It("should be able to create, list and then delete EtcdCluster from its alm example", func() {
operators := helper.CmdShouldPass("odo", "catalog", "list", "services")
etcdOperator := regexp.MustCompile(`etcdoperator\.*[a-z][0-9]\.[0-9]\.[0-9]-clusterwide`).FindString(operators)
helper.CmdShouldPass("odo", "service", "create", fmt.Sprintf("%s/EtcdCluster", etcdOperator), "--project", project)
stdOut := helper.CmdShouldPass("odo", "service", "create", fmt.Sprintf("%s/EtcdCluster", etcdOperator), "--project", project)
Expect(stdOut).To(ContainSubstring("Service 'example' was created"))

// now verify if the pods for the operator have started
pods := helper.CmdShouldPass("oc", "get", "pods", "-n", project)
Expand All @@ -90,7 +91,7 @@ var _ = Describe("odo service command tests for OperatorHub", func() {
})

// now test listing of the service using odo
stdOut := helper.CmdShouldPass("odo", "service", "list")
stdOut = helper.CmdShouldPass("odo", "service", "list")
Expect(stdOut).To(ContainSubstring("EtcdCluster/example"))

// now test the deletion of the service using odo
Expand Down

0 comments on commit f463d09

Please sign in to comment.