forked from knative/client
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(service create): Added --no-wait and --wait-timeout
By default, `kn service create` blocks until the service is either created or an error occured during service creation. With the option --no-wait the behaviour can be switched to an async mode so that that kn returns immediately after the service is created without waiting for a successful Ready status condition. The timeout for how long to wait can be configured with --wait-timeout If a timeout occur, that doesn't mean that the service is not created, but the wait just returns. The default value is 60 seconds. In wait mode, print out the service URL as a last line (so that it can be used together with `tail -1`) to extract the service URL after the service is created. Fixes knative#54
- Loading branch information
Showing
9 changed files
with
603 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package service | ||
|
||
import ( | ||
"fmt" | ||
"github.com/knative/client/pkg/wait" | ||
"github.com/knative/pkg/apis" | ||
serving_v1alpha1_api "github.com/knative/serving/pkg/apis/serving/v1alpha1" | ||
serving_v1alpha1_client "github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
) | ||
|
||
// Create wait arguments for a Knative service which can be used to wait for | ||
// a create/update options to be finished | ||
// Can be used by `service_create` and `service_update`, hence this extra file | ||
func newServiceWaitForReady(client serving_v1alpha1_client.ServingV1alpha1Interface, namespace string) wait.WaitForReady { | ||
return wait.NewWaitForReady( | ||
"service", | ||
client.Services(namespace).Watch, | ||
serviceConditionExtractor) | ||
} | ||
|
||
func serviceConditionExtractor(obj runtime.Object) (apis.Conditions, error) { | ||
service, ok := obj.(*serving_v1alpha1_api.Service) | ||
if !ok { | ||
return nil, fmt.Errorf("%v is not a service", obj) | ||
} | ||
return apis.Conditions(service.Status.Conditions), nil | ||
} |
Oops, something went wrong.