Repository: knative/client
Pull request #919 (2020-07-07 17:09:58)

Fixed the error message for min/max scale tests
## Description

Fixed an error message in the create_test.go file

## Changes

* Changed 1000 to 100 to match the value used in the test. 





knative-prow-robot: [APPROVALNOTIFIER] This PR is **NOT APPROVED**

This pull-request has been approved by: *<a href="https://github.com/knative/client/pull/919#" title="Author self-approved">mpetason</a>*
To complete the [pull request process](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process), please assign **rhuss**
You can assign the PR to them by writing `/assign @rhuss` in a comment when ready.

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=knative%2Fclient).

<details open>
Needs approval from an approver in each of these files:

- **[OWNERS](https://github.com/knative/client/blob/master/OWNERS)**

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":["rhuss"]} -->
knative-prow-robot: @mpetason: The following test **failed**, say `/retest` to rerun all failed tests:

Test name | Commit | Details | Rerun command
--- | --- | --- | ---
pull-knative-client-integration-tests | 76bcfb78e12f9692ef34d3c296268575b979ef04 | [link](https://prow.knative.dev/view/gcs/knative-prow/pr-logs/pull/knative_client/919/pull-knative-client-integration-tests/1280550538957557761) | `/test pull-knative-client-integration-tests`

[Full PR test history](https://gubernator.knative.dev/pr/knative_client/919). [Your PR dashboard](https://gubernator.knative.dev/pr/mpetason).

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
mpetason: /retest
knative-prow-robot: @mpetason: The following test **failed**, say `/retest` to rerun all failed tests:

Test name | Commit | Details | Rerun command
--- | --- | --- | ---
pull-knative-client-integration-tests | 76bcfb78e12f9692ef34d3c296268575b979ef04 | [link](https://prow.knative.dev/view/gcs/knative-prow/pr-logs/pull/knative_client/919/pull-knative-client-integration-tests/1280559598364790784) | `/test pull-knative-client-integration-tests`

[Full PR test history](https://gubernator.knative.dev/pr/knative_client/919). [Your PR dashboard](https://gubernator.knative.dev/pr/mpetason).

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
mpetason: I'm not sure why the test if failing, i only updated two values in an error message. 
knative-prow-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/knative/client/pull/919#" title="Author self-approved">mpetason</a>*, *<a href="https://github.com/knative/client/pull/919#pullrequestreview-444173331" title="Approved">navidshaikh</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=knative%2Fclient).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/knative/client/blob/master/OWNERS)~~ [navidshaikh]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->

Patch:
diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc
index d3b9d70b..491ffc7e 100644
--- a/CHANGELOG.adoc
+++ b/CHANGELOG.adoc
@@ -18,6 +18,10 @@
 |===
 | | Description | PR
 
+| 🎁
+| Add "url" output format to return service url in service describe
+| https://github.com/knative/client/pull/916[#916]
+
 | 🐛
 | Fix panic for `kn source apiserver` and `kn source binding` describe with Sink URI
 | https://github.com/knative/client/pull/901[#901]
diff --git a/docs/cmd/kn_service_describe.md b/docs/cmd/kn_service_describe.md
index 4f9d274a..41f81ecc 100644
--- a/docs/cmd/kn_service_describe.md
+++ b/docs/cmd/kn_service_describe.md
@@ -10,13 +10,27 @@ Show details of a service
 kn service describe NAME
 ```
 
+### Examples
+
+```
+
+  # Describe service 'svc' in human friendly format
+  kn service describe svc
+
+  # Describe service 'svc' in YAML format
+  kn service describe svc -o yaml
+
+  # Print only service URL
+  kn service describe svc -o url
+```
+
 ### Options
 
 ```
       --allow-missing-template-keys   If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. (default true)
   -h, --help                          help for describe
   -n, --namespace string              Specify the namespace to operate in.
-  -o, --output string                 Output format. One of: json|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|jsonpath-file.
+  -o, --output string                 Output format. One of: json|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|jsonpath-file|url.
       --template string               Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
   -v, --verbose                       More output.
 ```
diff --git a/pkg/kn/commands/service/describe.go b/pkg/kn/commands/service/describe.go
index f8191520..ea62cf36 100644
--- a/pkg/kn/commands/service/describe.go
+++ b/pkg/kn/commands/service/describe.go
@@ -20,6 +20,7 @@ import (
 	"io"
 	"sort"
 	"strconv"
+	"strings"
 
 	"k8s.io/apimachinery/pkg/util/sets"
 	"k8s.io/cli-runtime/pkg/genericclioptions"
@@ -70,6 +71,16 @@ type revisionDesc struct {
 // As this command does not do any writes/updates, it's just a matter of fallbacks.
 // [/REMOVE COMMENT WHEN MOVING TO 0.7.0]
 
+var describe_example = `
+  # Describe service 'svc' in human friendly format
+  kn service describe svc
+
+  # Describe service 'svc' in YAML format
+  kn service describe svc -o yaml
+
+  # Print only service URL
+  kn service describe svc -o url`
+
 // NewServiceDescribeCommand returns a new command for describing a service.
 func NewServiceDescribeCommand(p *commands.KnParams) *cobra.Command {
 
@@ -77,8 +88,9 @@ func NewServiceDescribeCommand(p *commands.KnParams) *cobra.Command {
 	machineReadablePrintFlags := genericclioptions.NewPrintFlags("")
 
 	command := &cobra.Command{
-		Use:   "describe NAME",
-		Short: "Show details of a service",
+		Use:     "describe NAME",
+		Short:   "Show details of a service",
+		Example: describe_example,
 		RunE: func(cmd *cobra.Command, args []string) error {
 			if len(args) != 1 {
 				return errors.New("'service describe' requires the service name given as single argument")
@@ -102,11 +114,16 @@ func NewServiceDescribeCommand(p *commands.KnParams) *cobra.Command {
 
 			// Print out machine readable output if requested
 			if machineReadablePrintFlags.OutputFlagSpecified() {
+				out := cmd.OutOrStdout()
+				if strings.ToLower(*machineReadablePrintFlags.OutputFormat) == "url" {
+					fmt.Fprintf(out, "%s\n", extractURL(service))
+					return nil
+				}
 				printer, err := machineReadablePrintFlags.ToPrinter()
 				if err != nil {
 					return err
 				}
-				return printer.PrintObj(service, cmd.OutOrStdout())
+				return printer.PrintObj(service, out)
 			}
 
 			printDetails, err = cmd.Flags().GetBool("verbose")
@@ -126,6 +143,7 @@ func NewServiceDescribeCommand(p *commands.KnParams) *cobra.Command {
 	commands.AddNamespaceFlags(flags, false)
 	flags.BoolP("verbose", "v", false, "More output.")
 	machineReadablePrintFlags.AddFlags(command)
+	command.Flag("output").Usage = fmt.Sprintf("Output format. One of: %s.", strings.Join(append(machineReadablePrintFlags.AllowedFormats(), "url"), "|"))
 	return command
 }
 


Test patch:
diff --git a/pkg/kn/commands/service/create_test.go b/pkg/kn/commands/service/create_test.go
index d31ec821..f056267c 100644
--- a/pkg/kn/commands/service/create_test.go
+++ b/pkg/kn/commands/service/create_test.go
@@ -540,7 +540,7 @@ func TestServiceCreateMaxMinScale(t *testing.T) {
 	}
 
 	if *template.Spec.ContainerConcurrency != int64(100) {
-		t.Fatalf("container concurrency not set to given value 1000")
+		t.Fatalf("container concurrency not set to given value 100")
 	}
 }
 
diff --git a/pkg/kn/commands/service/describe_test.go b/pkg/kn/commands/service/describe_test.go
index e86d36bd..381365ab 100644
--- a/pkg/kn/commands/service/describe_test.go
+++ b/pkg/kn/commands/service/describe_test.go
@@ -506,6 +506,23 @@ func TestServiceDescribeMachineReadable(t *testing.T) {
 	r.Validate()
 }
 
+func TestServiceDescribeURL(t *testing.T) {
+	client := knclient.NewMockKnServiceClient(t)
+
+	// Recording:
+	r := client.Recorder()
+
+	// Prepare service
+	expectedService := createTestService("foo", []string{"rev1", "rev2"}, goodConditions())
+	r.GetService("foo", &expectedService, nil)
+
+	output, err := executeServiceCommand(client, "describe", "foo", "-o", "url")
+	assert.NilError(t, err)
+	assert.Assert(t, util.ContainsAll(output, "foo.default.example.com"))
+
+	r.Validate()
+}
+
 func validateServiceOutput(t *testing.T, service string, output string) {
 	assert.Assert(t, cmp.Regexp("Name:\\s+"+service, output))
 	assert.Assert(t, cmp.Regexp("Namespace:\\s+default", output))
diff --git a/pkg/kn/commands/service/update_test.go b/pkg/kn/commands/service/update_test.go
index 6b7ee027..832fb0ee 100644
--- a/pkg/kn/commands/service/update_test.go
+++ b/pkg/kn/commands/service/update_test.go
@@ -350,7 +350,7 @@ func TestServiceUpdateMaxMinScale(t *testing.T) {
 	}
 
 	if *template.Spec.ContainerConcurrency != int64(100) {
-		t.Fatalf("container concurrency not set to given value 1000")
+		t.Fatalf("container concurrency not set to given value 100")
 	}
 
 }
diff --git a/test/common.sh b/test/common.sh
index b0c8f4d3..02ba4e77 100644
--- a/test/common.sh
+++ b/test/common.sh
@@ -36,6 +36,11 @@ function knative_setup() {
 
   if [ "${eventing_version}" = "latest" ]; then
     start_latest_knative_eventing
+
+    # install the sugar controller
+    kubectl apply --filename https://storage.googleapis.com/knative-nightly/eventing/latest/eventing-sugar-controller.yaml
+    wait_until_pods_running knative-eventing || return 1
+
   else
     start_release_knative_eventing "${eventing_version}"
   fi