Skip to content

Commit ddbb95b

Browse files
authored
feat: Better output of build/deploy/delete commands (#206)
Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>
1 parent 6110d50 commit ddbb95b

File tree

4 files changed

+21
-22
lines changed

4 files changed

+21
-22
lines changed

client.go

+11-17
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ type Lister interface {
7171
}
7272

7373
type ListItem struct {
74-
Name string `json:"name" yaml:"name"`
75-
Runtime string `json:"runtime" yaml:"runtime"`
76-
URL string `json:"url" yaml:"url"`
77-
KService string `json:"kservice" yaml:"kservice"`
78-
Ready string `json:"ready" yaml:"ready"`
74+
Name string `json:"name" yaml:"name"`
75+
Runtime string `json:"runtime" yaml:"runtime"`
76+
URL string `json:"url" yaml:"url"`
77+
KService string `json:"kservice" yaml:"kservice"`
78+
Ready string `json:"ready" yaml:"ready"`
7979
}
8080

8181
// ProgressListener is notified of task progress.
@@ -383,9 +383,8 @@ func (c *Client) Initialize(cfg Function) (err error) {
383383
// Build the Function at path. Errors if the Function is either unloadable or does
384384
// not contain a populated Image.
385385
func (c *Client) Build(path string) (err error) {
386-
if c.verbose {
387-
fmt.Println("Building Function image:")
388-
}
386+
387+
fmt.Println("Building function image")
389388

390389
f, err := NewFunction(path)
391390
if err != nil {
@@ -409,9 +408,8 @@ func (c *Client) Build(path string) (err error) {
409408

410409
// TODO: create a statu structure and return it here for optional
411410
// use by the cli for user echo (rather than rely on verbose mode here)
412-
if c.verbose {
413-
fmt.Printf("Function image has been built, image: %v\n", f.Image)
414-
}
411+
fmt.Printf("Function image has been built, image: %v\n", f.Image)
412+
415413
return
416414
}
417415

@@ -429,9 +427,7 @@ func (c *Client) Deploy(path string) (err error) {
429427
}
430428

431429
// Push the image for the named service to the configured registry
432-
if c.verbose {
433-
fmt.Println("\nPushing Function image to the registry:")
434-
}
430+
fmt.Println("Pushing function image to the registry")
435431
imageDigest, err := c.pusher.Push(f)
436432
if err != nil {
437433
return
@@ -444,9 +440,7 @@ func (c *Client) Deploy(path string) (err error) {
444440
}
445441

446442
// Deploy a new or Update the previously-deployed Function
447-
if c.verbose {
448-
fmt.Println("\nDeploying Function to cluster:")
449-
}
443+
fmt.Println("Deploying function to the cluster")
450444
return c.deployer.Deploy(f)
451445
}
452446

cmd/build.go

-2
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,6 @@ func newBuildConfig() buildConfig {
138138
func (c buildConfig) Prompt() buildConfig {
139139
imageName := deriveImage(c.Image, c.Registry, c.Path)
140140
if !interactiveTerminal() || !c.Confirm {
141-
// If --confirm false or non-interactive, just print the image name
142-
fmt.Printf("Building image: %v\n", imageName)
143141
return c
144142
}
145143
return buildConfig{

knative/deployer.go

+8
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,14 @@ func (d *Deployer) Deploy(f faas.Function) (err error) {
9191
err = fmt.Errorf("knative deployer failed to update the service: %v", err)
9292
return err
9393
}
94+
95+
route, err := client.GetRoute(serviceName)
96+
if err != nil {
97+
err = fmt.Errorf("knative deployer failed to get the route: %v", err)
98+
return err
99+
}
100+
101+
fmt.Println("Function updated at URL: " + route.Status.URL.String())
94102
}
95103

96104
return nil

knative/remover.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ func (remover *Remover) Remove(name string) (err error) {
3535
return
3636
}
3737

38-
if remover.Verbose {
39-
fmt.Printf("Removing Knative Service: %v\n", serviceName)
40-
}
38+
fmt.Printf("Removing Knative Service: %v\n", serviceName)
39+
4140
err = client.DeleteService(serviceName, time.Second*60)
4241
if err != nil {
4342
err = fmt.Errorf("knative remover failed to delete the service: %v", err)

0 commit comments

Comments
 (0)