Skip to content

Commit

Permalink
Add --wait switch on riff function create
Browse files Browse the repository at this point in the history
  • Loading branch information
glyn committed Aug 23, 2018
1 parent 567cf51 commit aa25bdf
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
8 changes: 8 additions & 0 deletions cmd/commands/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ From then on you can use the sub-commands for the 'service' command to interact
}
} else {
printSuccessfulCompletion(cmd)
fmt.Fprintf(cmd.OutOrStdout(), "Issue `riff service status %s` to see the status of the function\n", fnName)
}

return nil
Expand Down Expand Up @@ -188,6 +189,13 @@ From then on you can use the sub-commands for the 'service' command to interact
"verbose", "v", verboseUsage,
).NoOptDefVal = "true"

command.Flags().VarPF(
BroadcastBoolValue(false,
&createFunctionOptions.Wait,
),
"wait", "w", waitUsage,
).NoOptDefVal = "true"

command.Flags().Var(
BroadcastStringValue("",
&createInputChannelOptions.Bus,
Expand Down
1 change: 1 addition & 0 deletions cmd/commands/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ or 'secretKeyRef' to select a key from a Secret. The following formats are suppo
--env-from configMapKeyRef:{config-map-name}:{key-to-select}
--env-from secretKeyRef:{secret-name}:{key-to-select}`
verboseUsage = "print details of command progress"
waitUsage = "wait until the created resource reaches either a successful or an error state (automatic with --verbose)"
)
1 change: 1 addition & 0 deletions docs/riff_function_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ riff function create [flags]
-n, --namespace namespace the namespace of the subscription, channel, and function
-o, --output channel name of the function's output channel, if any
-v, --verbose print details of command progress
-w, --wait wait until the created resource reaches either a successful or an error state (automatic with --verbose)
```

### Options inherited from parent commands
Expand Down
6 changes: 4 additions & 2 deletions pkg/core/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,12 @@ func (c *client) CreateFunction(options CreateFunctionOptions, log io.Writer) (*
return nil, err
}

if options.Verbose {
if options.Verbose || options.Wait {
stopChan := make(chan struct{})
errChan := make(chan error)
go c.displayFunctionCreationProgress(ns, s.Name, log, stopChan, errChan)
if options.Verbose {
go c.displayFunctionCreationProgress(ns, s.Name, log, stopChan, errChan)
}
err := c.waitForSuccessOrFailure(ns, s.Name, stopChan, errChan)
if err != nil {
return nil, err
Expand Down
1 change: 1 addition & 0 deletions pkg/core/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type CreateServiceOptions struct {
EnvFrom []string
DryRun bool
Verbose bool
Wait bool
}

func (c *client) CreateService(options CreateServiceOptions) (*v1alpha1.Service, error) {
Expand Down

0 comments on commit aa25bdf

Please sign in to comment.