Skip to content

Commit

Permalink
chore: Fix formatting / docs
Browse files Browse the repository at this point in the history
  • Loading branch information
rhuss committed Jun 6, 2019
1 parent 0ec784a commit 4fa787d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
2 changes: 2 additions & 0 deletions docs/cmd/kn_service_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ kn service create NAME --image IMAGE [flags]
### Options

```
--async Don't wait for the service to become Ready.
-e, --env stringArray Environment variable to set. NAME=value; you may provide this flag any number of times to set multiple environment variables.
--force Create service forcefully, replaces existing service if any.
-h, --help help for create
Expand All @@ -45,6 +46,7 @@ kn service create NAME --image IMAGE [flags]
-n, --namespace string List the requested object(s) in given namespace.
--requests-cpu string The requested CPU (e.g., 250m).
--requests-memory string The requested CPU (e.g., 64Mi).
--wait-timeout int Wait for that many seconds before giving up when creating a service. (default 60)
```

### Options inherited from parent commands
Expand Down
2 changes: 1 addition & 1 deletion pkg/kn/commands/service/configuration_edit_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type ConfigurationEditFlags struct {
RequestsFlags, LimitsFlags ResourceFlags
ForceCreate bool
Async bool
WaitTimeout int
WaitTimeout int
}

type ResourceFlags struct {
Expand Down
12 changes: 5 additions & 7 deletions pkg/kn/commands/service/service_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)


func NewServiceCreateCommand(p *commands.KnParams) *cobra.Command {
var editFlags ConfigurationEditFlags

Expand Down Expand Up @@ -182,7 +181,7 @@ func constructService(cmd *cobra.Command, editFlags ConfigurationEditFlags, name
}

func showUrl(client serving_v1alpha1_client.ServingV1alpha1Interface, serviceName string, namespace string, out io.Writer) error {
service, err := client.Services(namespace).Get(serviceName,v1.GetOptions{})
service, err := client.Services(namespace).Get(serviceName, v1.GetOptions{})
if err != nil {
return fmt.Errorf("cannot fetch service %s in namespace %s for extracting the URL", serviceName, namespace)
}
Expand All @@ -205,7 +204,7 @@ func waitForService(client serving_v1alpha1_client.ServingV1alpha1Interface, ser
// timeout. We have our own timeout which fire after "timeout" seconds and stop the watch
var timeoutWatch int64 = int64(timeout + 30)
opts := v1.ListOptions{
FieldSelector: fields.OneTermEqualSelector("metadata.name", serviceName).String(),
FieldSelector: fields.OneTermEqualSelector("metadata.name", serviceName).String(),
TimeoutSeconds: &timeoutWatch,
}
watcher, err := client.Services(namespace).Watch(opts)
Expand All @@ -229,9 +228,9 @@ func waitForReadyCondition(watcher watch.Interface, timeout int) error {
defer watcher.Stop()
for {
select {
case <- time.After(time.Duration(timeout) * time.Second):
case <-time.After(time.Duration(timeout) * time.Second):
return fmt.Errorf("timeout: Service not ready after %d seconds", timeout)
case event, ok := <- watcher.ResultChan():
case event, ok := <-watcher.ResultChan():
if !ok || event.Object == nil {
return errors.New("timeout while waiting for service to become ready")
}
Expand All @@ -242,11 +241,10 @@ func waitForReadyCondition(watcher watch.Interface, timeout int) error {
case corev1.ConditionTrue:
return nil
case corev1.ConditionFalse:
return fmt.Errorf("%s: %s",cond.Reason,cond.Message)
return fmt.Errorf("%s: %s", cond.Reason, cond.Message)
}
}
}
}
}
}

18 changes: 9 additions & 9 deletions pkg/kn/commands/service/service_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func TestServiceCreateEnv(t *testing.T) {

func TestServiceCreateWithRequests(t *testing.T) {
action, created, _, err := fakeServiceCreate([]string{
"service", "create", "foo", "--image", "gcr.io/foo/bar:baz", "--requests-cpu", "250m", "--requests-memory", "64Mi","--async"}, false)
"service", "create", "foo", "--image", "gcr.io/foo/bar:baz", "--requests-cpu", "250m", "--requests-memory", "64Mi", "--async"}, false)

if err != nil {
t.Fatal(err)
Expand All @@ -146,7 +146,7 @@ func TestServiceCreateWithRequests(t *testing.T) {

func TestServiceCreateWithLimits(t *testing.T) {
action, created, _, err := fakeServiceCreate([]string{
"service", "create", "foo", "--image", "gcr.io/foo/bar:baz", "--limits-cpu", "1000m", "--limits-memory", "1024Mi","--async"}, false)
"service", "create", "foo", "--image", "gcr.io/foo/bar:baz", "--limits-cpu", "1000m", "--limits-memory", "1024Mi", "--async"}, false)

if err != nil {
t.Fatal(err)
Expand All @@ -172,7 +172,7 @@ func TestServiceCreateWithLimits(t *testing.T) {

func TestServiceCreateRequestsLimitsCPU(t *testing.T) {
action, created, _, err := fakeServiceCreate([]string{
"service", "create", "foo", "--image", "gcr.io/foo/bar:baz", "--requests-cpu", "250m", "--limits-cpu", "1000m","--async"}, false)
"service", "create", "foo", "--image", "gcr.io/foo/bar:baz", "--requests-cpu", "250m", "--limits-cpu", "1000m", "--async"}, false)

if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -209,7 +209,7 @@ func TestServiceCreateRequestsLimitsCPU(t *testing.T) {

func TestServiceCreateRequestsLimitsMemory(t *testing.T) {
action, created, _, err := fakeServiceCreate([]string{
"service", "create", "foo", "--image", "gcr.io/foo/bar:baz", "--requests-memory", "64Mi", "--limits-memory", "1024Mi","--async"}, false)
"service", "create", "foo", "--image", "gcr.io/foo/bar:baz", "--requests-memory", "64Mi", "--limits-memory", "1024Mi", "--async"}, false)

if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -248,7 +248,7 @@ func TestServiceCreateRequestsLimitsCPUMemory(t *testing.T) {
action, created, _, err := fakeServiceCreate([]string{
"service", "create", "foo", "--image", "gcr.io/foo/bar:baz",
"--requests-cpu", "250m", "--limits-cpu", "1000m",
"--requests-memory", "64Mi", "--limits-memory", "1024Mi","--async"}, false)
"--requests-memory", "64Mi", "--limits-memory", "1024Mi", "--async"}, false)

if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -295,12 +295,12 @@ func parseQuantity(t *testing.T, quantityString string) resource.Quantity {

func TestServiceCreateImageForce(t *testing.T) {
_, _, _, err := fakeServiceCreate([]string{
"service", "create", "foo", "--image", "gcr.io/foo/bar:v1","--async"}, false)
"service", "create", "foo", "--image", "gcr.io/foo/bar:v1", "--async"}, false)
if err != nil {
t.Fatal(err)
}
action, created, output, err := fakeServiceCreate([]string{
"service", "create", "foo", "--force", "--image", "gcr.io/foo/bar:v2","--async"}, false)
"service", "create", "foo", "--force", "--image", "gcr.io/foo/bar:v2", "--async"}, false)
if err != nil {
t.Fatal(err)
} else if !action.Matches("create", "services") {
Expand All @@ -318,12 +318,12 @@ func TestServiceCreateImageForce(t *testing.T) {

func TestServiceCreateEnvForce(t *testing.T) {
_, _, _, err := fakeServiceCreate([]string{
"service", "create", "foo", "--image", "gcr.io/foo/bar:v1", "-e", "A=DOGS", "--env", "B=WOLVES","--async"}, false)
"service", "create", "foo", "--image", "gcr.io/foo/bar:v1", "-e", "A=DOGS", "--env", "B=WOLVES", "--async"}, false)
if err != nil {
t.Fatal(err)
}
action, created, output, err := fakeServiceCreate([]string{
"service", "create", "foo", "--force", "--image", "gcr.io/foo/bar:v2", "-e", "A=CATS", "--env", "B=LIONS","--async"}, false)
"service", "create", "foo", "--force", "--image", "gcr.io/foo/bar:v2", "-e", "A=CATS", "--env", "B=LIONS", "--async"}, false)

if err != nil {
t.Fatal(err)
Expand Down

0 comments on commit 4fa787d

Please sign in to comment.