Skip to content

Commit

Permalink
feat: Better output of build/deploy/delete commands (#206)
Browse files Browse the repository at this point in the history
Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>
  • Loading branch information
zroubalik committed Nov 5, 2020
1 parent 6110d50 commit ddbb95b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 22 deletions.
28 changes: 11 additions & 17 deletions client.go
Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand All @@ -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
}

Expand All @@ -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
Expand All @@ -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)
}

Expand Down
2 changes: 0 additions & 2 deletions cmd/build.go
Expand Up @@ -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{
Expand Down
8 changes: 8 additions & 0 deletions knative/deployer.go
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions knative/remover.go
Expand Up @@ -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)
Expand Down

0 comments on commit ddbb95b

Please sign in to comment.