feat: Better output of build/deploy/delete commands (#206)

Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>
This commit is contained in:
Zbynek Roubalik 2020-11-05 16:46:21 +01:00 committed by GitHub
parent 6110d50b6b
commit ddbb95b075
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 22 deletions

View File

@ -71,11 +71,11 @@ type Lister interface {
}
type ListItem struct {
Name string `json:"name" yaml:"name"`
Runtime string `json:"runtime" yaml:"runtime"`
URL string `json:"url" yaml:"url"`
KService string `json:"kservice" yaml:"kservice"`
Ready string `json:"ready" yaml:"ready"`
Name string `json:"name" yaml:"name"`
Runtime string `json:"runtime" yaml:"runtime"`
URL string `json:"url" yaml:"url"`
KService string `json:"kservice" yaml:"kservice"`
Ready string `json:"ready" yaml:"ready"`
}
// ProgressListener is notified of task progress.
@ -383,9 +383,8 @@ func (c *Client) Initialize(cfg Function) (err error) {
// Build the Function at path. Errors if the Function is either unloadable or does
// not contain a populated Image.
func (c *Client) Build(path string) (err error) {
if c.verbose {
fmt.Println("Building Function image:")
}
fmt.Println("Building function image")
f, err := NewFunction(path)
if err != nil {
@ -409,9 +408,8 @@ func (c *Client) Build(path string) (err error) {
// TODO: create a statu structure and return it here for optional
// use by the cli for user echo (rather than rely on verbose mode here)
if c.verbose {
fmt.Printf("Function image has been built, image: %v\n", f.Image)
}
fmt.Printf("Function image has been built, image: %v\n", f.Image)
return
}
@ -429,9 +427,7 @@ func (c *Client) Deploy(path string) (err error) {
}
// Push the image for the named service to the configured registry
if c.verbose {
fmt.Println("\nPushing Function image to the registry:")
}
fmt.Println("Pushing function image to the registry")
imageDigest, err := c.pusher.Push(f)
if err != nil {
return
@ -444,9 +440,7 @@ func (c *Client) Deploy(path string) (err error) {
}
// Deploy a new or Update the previously-deployed Function
if c.verbose {
fmt.Println("\nDeploying Function to cluster:")
}
fmt.Println("Deploying function to the cluster")
return c.deployer.Deploy(f)
}

View File

@ -138,8 +138,6 @@ func newBuildConfig() buildConfig {
func (c buildConfig) Prompt() buildConfig {
imageName := deriveImage(c.Image, c.Registry, c.Path)
if !interactiveTerminal() || !c.Confirm {
// If --confirm false or non-interactive, just print the image name
fmt.Printf("Building image: %v\n", imageName)
return c
}
return buildConfig{

View File

@ -91,6 +91,14 @@ func (d *Deployer) Deploy(f faas.Function) (err error) {
err = fmt.Errorf("knative deployer failed to update the service: %v", err)
return err
}
route, err := client.GetRoute(serviceName)
if err != nil {
err = fmt.Errorf("knative deployer failed to get the route: %v", err)
return err
}
fmt.Println("Function updated at URL: " + route.Status.URL.String())
}
return nil

View File

@ -35,9 +35,8 @@ func (remover *Remover) Remove(name string) (err error) {
return
}
if remover.Verbose {
fmt.Printf("Removing Knative Service: %v\n", serviceName)
}
fmt.Printf("Removing Knative Service: %v\n", serviceName)
err = client.DeleteService(serviceName, time.Second*60)
if err != nil {
err = fmt.Errorf("knative remover failed to delete the service: %v", err)