diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index a67e9d070..eda9aebe1 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -21,6 +21,10 @@ | Add channel sink prefix | https://github.com/knative/client/pull/1092[#1092] +| 🐣 +| Drop deprecated --async flag support +| https://github.com/knative/client/pull/1094[#1094] + | 🐣 | Uniform multiple writeSink to DescribeSink | https://github.com/knative/client/pull/1075[#1075] diff --git a/docs/cmd/kn_broker_delete.md b/docs/cmd/kn_broker_delete.md index 551fff502..a7b16fd6b 100644 --- a/docs/cmd/kn_broker_delete.md +++ b/docs/cmd/kn_broker_delete.md @@ -24,7 +24,6 @@ kn broker delete NAME ### Options ``` - --async DEPRECATED: please use --no-wait instead. Do not wait for 'broker delete' operation to be completed. (default true) -h, --help help for delete -n, --namespace string Specify the namespace to operate in. --no-wait Do not wait for 'broker delete' operation to be completed. (default true) diff --git a/docs/cmd/kn_revision_delete.md b/docs/cmd/kn_revision_delete.md index 8f4776498..6f310f8e9 100644 --- a/docs/cmd/kn_revision_delete.md +++ b/docs/cmd/kn_revision_delete.md @@ -21,7 +21,6 @@ kn revision delete NAME [NAME ...] ### Options ``` - --async DEPRECATED: please use --no-wait instead. Do not wait for 'revision delete' operation to be completed. (default true) -h, --help help for delete -n, --namespace string Specify the namespace to operate in. --no-wait Do not wait for 'revision delete' operation to be completed. (default true) diff --git a/docs/cmd/kn_service_apply.md b/docs/cmd/kn_service_apply.md index 8aa6c4cc5..ef4e99a5f 100644 --- a/docs/cmd/kn_service_apply.md +++ b/docs/cmd/kn_service_apply.md @@ -37,7 +37,6 @@ kn service apply s0 --filename my-svc.yml --annotation-revision stringArray Revision annotation to set. name=value; you may provide this flag any number of times to set multiple annotations. To unset, specify the annotation name followed by a "-" (e.g., name-). This flag takes precedence over the "annotation" flag. --annotation-service stringArray Service annotation to set. name=value; you may provide this flag any number of times to set multiple annotations. To unset, specify the annotation name followed by a "-" (e.g., name-). This flag takes precedence over the "annotation" flag. --arg stringArray Add argument to the container command. Example: --arg myArg1 --arg --myArg2 --arg myArg3=3. You can use this flag multiple times. - --async DEPRECATED: please use --no-wait instead. Do not wait for 'service apply' operation to be completed. --autoscale-window string Duration to look back for making auto-scaling decisions. The service is scaled to zero if no request was received in during that time. (eg: 10s) --cluster-local Specify that the service be private. (--no-cluster-local will make the service publicly available) --cmd string Specify command to be used as entrypoint instead of default one. Example: --cmd /app/start or --cmd /app/start --arg myArg to pass additional arguments. diff --git a/docs/cmd/kn_service_create.md b/docs/cmd/kn_service_create.md index a27963a57..e55945677 100644 --- a/docs/cmd/kn_service_create.md +++ b/docs/cmd/kn_service_create.md @@ -57,7 +57,6 @@ kn service create NAME --image IMAGE --annotation-revision stringArray Revision annotation to set. name=value; you may provide this flag any number of times to set multiple annotations. To unset, specify the annotation name followed by a "-" (e.g., name-). This flag takes precedence over the "annotation" flag. --annotation-service stringArray Service annotation to set. name=value; you may provide this flag any number of times to set multiple annotations. To unset, specify the annotation name followed by a "-" (e.g., name-). This flag takes precedence over the "annotation" flag. --arg stringArray Add argument to the container command. Example: --arg myArg1 --arg --myArg2 --arg myArg3=3. You can use this flag multiple times. - --async DEPRECATED: please use --no-wait instead. Do not wait for 'service create' operation to be completed. --autoscale-window string Duration to look back for making auto-scaling decisions. The service is scaled to zero if no request was received in during that time. (eg: 10s) --cluster-local Specify that the service be private. (--no-cluster-local will make the service publicly available) --cmd string Specify command to be used as entrypoint instead of default one. Example: --cmd /app/start or --cmd /app/start --arg myArg to pass additional arguments. diff --git a/docs/cmd/kn_service_delete.md b/docs/cmd/kn_service_delete.md index aa492868e..f94046c4a 100644 --- a/docs/cmd/kn_service_delete.md +++ b/docs/cmd/kn_service_delete.md @@ -28,7 +28,6 @@ kn service delete NAME [NAME ...] ``` --all Delete all services in a namespace. - --async DEPRECATED: please use --no-wait instead. Do not wait for 'service delete' operation to be completed. (default true) -h, --help help for delete -n, --namespace string Specify the namespace to operate in. --no-wait Do not wait for 'service delete' operation to be completed. (default true) diff --git a/docs/cmd/kn_service_update.md b/docs/cmd/kn_service_update.md index 39e8f1691..b12521993 100644 --- a/docs/cmd/kn_service_update.md +++ b/docs/cmd/kn_service_update.md @@ -42,7 +42,6 @@ kn service update NAME --annotation-revision stringArray Revision annotation to set. name=value; you may provide this flag any number of times to set multiple annotations. To unset, specify the annotation name followed by a "-" (e.g., name-). This flag takes precedence over the "annotation" flag. --annotation-service stringArray Service annotation to set. name=value; you may provide this flag any number of times to set multiple annotations. To unset, specify the annotation name followed by a "-" (e.g., name-). This flag takes precedence over the "annotation" flag. --arg stringArray Add argument to the container command. Example: --arg myArg1 --arg --myArg2 --arg myArg3=3. You can use this flag multiple times. - --async DEPRECATED: please use --no-wait instead. Do not wait for 'service update' operation to be completed. --autoscale-window string Duration to look back for making auto-scaling decisions. The service is scaled to zero if no request was received in during that time. (eg: 10s) --cluster-local Specify that the service be private. (--no-cluster-local will make the service publicly available) --cmd string Specify command to be used as entrypoint instead of default one. Example: --cmd /app/start or --cmd /app/start --arg myArg to pass additional arguments. diff --git a/pkg/kn/commands/service/create.go b/pkg/kn/commands/service/create.go index 74c66b9da..befa33714 100644 --- a/pkg/kn/commands/service/create.go +++ b/pkg/kn/commands/service/create.go @@ -157,12 +157,6 @@ func replaceService(client clientservingv1.KnServingClient, service *servingv1.S } func waitIfRequested(client clientservingv1.KnServingClient, serviceName string, waitFlags commands.WaitFlags, verbDoing string, verbDone string, out io.Writer) error { - //TODO: deprecated condition should be removed with --async flag - if waitFlags.Async { - fmt.Fprintf(out, "\nWARNING: flag --async is deprecated and going to be removed in future release, please use --no-wait instead.\n\n") - fmt.Fprintf(out, "Service '%s' %s in namespace '%s'.\n", serviceName, verbDone, client.Namespace()) - return nil - } if !waitFlags.Wait { fmt.Fprintf(out, "Service '%s' %s in namespace '%s'.\n", serviceName, verbDone, client.Namespace()) return nil diff --git a/pkg/kn/commands/service/update.go b/pkg/kn/commands/service/update.go index 9c53cbc36..4e4214167 100644 --- a/pkg/kn/commands/service/update.go +++ b/pkg/kn/commands/service/update.go @@ -109,8 +109,7 @@ func NewServiceUpdateCommand(p *commands.KnParams) *cobra.Command { } out := cmd.OutOrStdout() - //TODO: deprecated condition should be once --async is gone - if !waitFlags.Async && waitFlags.Wait { + if waitFlags.Wait { fmt.Fprintf(out, "Updating Service '%s' in namespace '%s':\n", args[0], namespace) fmt.Fprintln(out, "") err := waitForService(client, name, out, waitFlags.TimeoutInSeconds) @@ -120,9 +119,6 @@ func NewServiceUpdateCommand(p *commands.KnParams) *cobra.Command { fmt.Fprintln(out, "") return showUrl(client, name, latestRevisionBeforeUpdate, "updated", out) } else { - if waitFlags.Async { - fmt.Fprintf(out, "\nWARNING: flag --async is deprecated and going to be removed in future release, please use --no-wait instead.\n\n") - } fmt.Fprintf(out, "Service '%s' updated in namespace '%s'.\n", args[0], namespace) } diff --git a/pkg/kn/commands/wait_flags.go b/pkg/kn/commands/wait_flags.go index 32e0e07c0..ce4c7d133 100644 --- a/pkg/kn/commands/wait_flags.go +++ b/pkg/kn/commands/wait_flags.go @@ -33,11 +33,9 @@ type WaitFlags struct { TimeoutInSeconds int // If set then apply resources and wait for completion Wait bool - //TODO: deprecated variable should be removed with --async flag - Async bool } -// Add flags which influence the sync/async behaviour when creating or updating +// Add flags which influence the wait/no-wait behaviour when creating or updating // resources. Set `waitDefault` argument if the default behaviour is synchronous. // Use `what` for describing what is waited for. func (p *WaitFlags) AddConditionWaitFlags(command *cobra.Command, waitTimeoutDefault int, action, what, until string) { @@ -48,8 +46,6 @@ func (p *WaitFlags) AddConditionWaitFlags(command *cobra.Command, waitTimeoutDef waitDefault = false } - //TODO: deprecated flag should be removed in next release - command.Flags().BoolVar(&p.Async, "async", !waitDefault, "DEPRECATED: please use --no-wait instead. "+knflags.InvertUsage(waitUsage)) knflags.AddBothBoolFlagsUnhidden(command.Flags(), &p.Wait, "wait", "", waitDefault, waitUsage) timeoutUsage := fmt.Sprintf("Seconds to wait before giving up on waiting for %s to be %s.", what, until) command.Flags().IntVar(&p.TimeoutInSeconds, "wait-timeout", waitTimeoutDefault, timeoutUsage) diff --git a/pkg/kn/commands/wait_flags_test.go b/pkg/kn/commands/wait_flags_test.go index 923c0d882..7d7a80737 100644 --- a/pkg/kn/commands/wait_flags_test.go +++ b/pkg/kn/commands/wait_flags_test.go @@ -32,14 +32,13 @@ type waitTestCase struct { isParseErrorExpected bool } -//TODO: deprecated test should be removed with --async flag func TestAddWaitForReadyDeprecatedFlags(t *testing.T) { for i, tc := range []waitTestCase{ - {[]string{"--async"}, 60, false, false}, + {[]string{"--no-wait"}, 60, false, false}, {[]string{}, 60, true, false}, {[]string{"--wait-timeout=120"}, 120, true, false}, // Can't be easily prevented, the timeout is just ignored in this case: - {[]string{"--async", "--wait-timeout=120"}, 120, false, false}, + {[]string{"--no-wait", "--wait-timeout=120"}, 120, false, false}, {[]string{"--wait-timeout=bla"}, 0, true, true}, } { @@ -58,12 +57,12 @@ func TestAddWaitForReadyDeprecatedFlags(t *testing.T) { continue } - // reconcile to ensure wait, no-wait and async behaves as expected + // reconcile to ensure wait, no-wait behave as expected err = knflags.ReconcileBoolFlags(cmd.Flags()) assert.NilError(t, err) - if flags.Async == tc.isWaitExpected { - t.Errorf("%d: wrong async mode detected: %t (expected) != %t (actual)", i, tc.isWaitExpected, flags.Async) + if flags.Wait != tc.isWaitExpected { + t.Errorf("%d: wrong wait mode detected: %t (expected) != %t (actual)", i, tc.isWaitExpected, flags.Wait) } if flags.TimeoutInSeconds != tc.timeoutExpected { t.Errorf("%d: Invalid timeout set. %d (expected) != %d (actual)", i, tc.timeoutExpected, flags.TimeoutInSeconds) @@ -95,7 +94,7 @@ func TestAddWaitForReadyFlags(t *testing.T) { continue } - // reconcile to ensure wait, no-wait and async behaves as expected + // reconcile to ensure wait, no-wait behave as expected err = knflags.ReconcileBoolFlags(cmd.Flags()) assert.NilError(t, err) fmt.Println("wait value") diff --git a/pkg/kn/flags/bool.go b/pkg/kn/flags/bool.go index 03e0827b9..feca0b2af 100644 --- a/pkg/kn/flags/bool.go +++ b/pkg/kn/flags/bool.go @@ -68,19 +68,6 @@ func ReconcileBoolFlags(f *pflag.FlagSet) error { return } - // handle async flag - if flag.Name == "async" && flag.Changed { - if f.Lookup("wait").Changed || f.Lookup("no-wait").Changed { - err = fmt.Errorf("only one of (DEPRECATED) --async, --wait and --no-wait may be specified") - return - } - err = checkExplicitFalse(flag, "wait") - if err != nil { - return - } - f.Lookup("no-wait").Value.Set("true") - } - // Walk the "no-" versions of the flags. Make sure we didn't set // both, and set the positive value to the opposite of the "no-" // value if it exists. diff --git a/pkg/kn/flags/bool_test.go b/pkg/kn/flags/bool_test.go index 870bea2df..955486be1 100644 --- a/pkg/kn/flags/bool_test.go +++ b/pkg/kn/flags/bool_test.go @@ -29,13 +29,6 @@ type boolPairTestCase struct { expectedErrText string } -type boolPairTestCaseDeprecated struct { - waitDefaultVal bool - flags []string - expectedResult bool - expectedErrText string -} - func TestBooleanPair(t *testing.T) { cases := []*boolPairTestCase{ {"foo", true, []string{}, true, ""}, @@ -76,27 +69,3 @@ func TestBooleanPair(t *testing.T) { } } } - -func TestBooleanPairWithDeprecatedSyncFlag(t *testing.T) { - cases := []*boolPairTestCaseDeprecated{ - {true, []string{}, false, ""}, - {true, []string{"--async"}, true, ""}, - {true, []string{"--async", "--no-wait"}, false, "only one of (DEPRECATED) --async, --wait and --no-wait may be specified"}, - // delete operation - {false, []string{""}, true, ""}, - {false, []string{"--async=false"}, false, "use --wait instead of providing \"false\" to --async"}, - } - for _, c := range cases { - var result, wait bool - f := &pflag.FlagSet{} - AddBothBoolFlags(f, &wait, "wait", "", c.waitDefaultVal, "set wait") - f.BoolVar(&result, "async", !c.waitDefaultVal, "DEPRECATED: set async") - f.Parse(c.flags) - err := ReconcileBoolFlags(f) - if c.expectedErrText != "" { - assert.ErrorContains(t, err, c.expectedErrText) - } else { - assert.Equal(t, result, c.expectedResult) - } - } -}