File tree Expand file tree Collapse file tree 7 files changed +32
-14
lines changed Expand file tree Collapse file tree 7 files changed +32
-14
lines changed Original file line number Diff line number Diff line change @@ -471,7 +471,22 @@ func (c *colimaApp) Update() error {
471471		return  err 
472472	}
473473
474- 	return  container .Update (ctx )
474+ 	oldVersion  :=  container .Version (ctx )
475+ 
476+ 	updated , err  :=  container .Update (ctx )
477+ 	if  err  !=  nil  {
478+ 		return  err 
479+ 	}
480+ 
481+ 	if  updated  {
482+ 		fmt .Println ("previous version" )
483+ 		fmt .Println (oldVersion )
484+ 		fmt .Println ()
485+ 		fmt .Println ("current version" )
486+ 		fmt .Println (container .Version (ctx ))
487+ 	}
488+ 
489+ 	return  nil 
475490}
476491
477492func  generateSSHConfig (modifySSHConfig  bool ) error  {
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ type Container interface {
2323	// Teardown tears down/uninstall the container runtime. 
2424	Teardown (ctx  context.Context ) error 
2525	// Update the container runtime. 
26- 	Update (ctx  context.Context ) error 
26+ 	Update (ctx  context.Context ) ( bool ,  error ) 
2727	// Version returns the container runtime version. 
2828	Version (ctx  context.Context ) string 
2929	// Running returns if the container runtime is currently running. 
Original file line number Diff line number Diff line change @@ -103,6 +103,6 @@ func (c containerdRuntime) Version(ctx context.Context) string {
103103	return  version 
104104}
105105
106- func  (c  * containerdRuntime ) Update (ctx  context.Context ) error  {
107- 	return  fmt .Errorf ("update not supported for the %s runtime" , Name )
106+ func  (c  * containerdRuntime ) Update (ctx  context.Context ) ( bool ,  error )  {
107+ 	return  false ,  fmt .Errorf ("update not supported for the %s runtime" , Name )
108108}
Original file line number Diff line number Diff line change @@ -135,7 +135,7 @@ func (d dockerRuntime) Version(ctx context.Context) string {
135135	return  version 
136136}
137137
138- func  (d  * dockerRuntime ) Update (ctx  context.Context ) error  {
138+ func  (d  * dockerRuntime ) Update (ctx  context.Context ) ( bool ,  error )  {
139139	packages  :=  []string {
140140		"docker-ce" ,
141141		"docker-ce-cli" ,
Original file line number Diff line number Diff line change @@ -280,7 +280,7 @@ type networkInfo struct {
280280	Type     string  `json:"type"` 
281281}
282282
283- func  (c  * incusRuntime ) Update (ctx  context.Context ) error  {
283+ func  (c  * incusRuntime ) Update (ctx  context.Context ) ( bool ,  error )  {
284284	packages  :=  []string {
285285		"incus" ,
286286		"incus-base" ,
Original file line number Diff line number Diff line change @@ -264,7 +264,6 @@ func (c kubernetesRuntime) Version(context.Context) string {
264264	return  version 
265265}
266266
267- func  (c  * kubernetesRuntime ) Update (ctx  context.Context ) error  {
268- 	// update not supported 
269- 	return  nil 
267+ func  (c  * kubernetesRuntime ) Update (ctx  context.Context ) (bool , error ) {
268+ 	return  false , fmt .Errorf ("update not supported for the %s runtime" , Name )
270269}
Original file line number Diff line number Diff line change @@ -34,13 +34,14 @@ func UpdateRuntime(
3434	chain  cli.CommandChain ,
3535	runtime  string ,
3636	packageNames  ... string ,
37- ) error  {
37+ ) ( bool ,  error )  {
3838	a  :=  chain .Init (ctx )
3939	log  :=  a .Logger ()
4040
4141	packages  :=  packages (packageNames )
4242
43- 	updatesAvailable  :=  false 
43+ 	hasUpdates  :=  false 
44+ 	updated  :=  false 
4445
4546	a .Stage ("refreshing package manager" )
4647	a .Add (func () error  {
@@ -58,12 +59,12 @@ func UpdateRuntime(
5859			"-c" ,
5960			packages .Upgradable (),
6061		)
61- 		updatesAvailable  =  err  ==  nil 
62+ 		hasUpdates  =  err  ==  nil 
6263		return  nil 
6364	})
6465
6566	a .Add (func () (err  error ) {
66- 		if  ! updatesAvailable  {
67+ 		if  ! hasUpdates  {
6768			log .Warnf ("no updates available for %s runtime" , runtime )
6869			return 
6970		}
@@ -75,10 +76,13 @@ func UpdateRuntime(
7576			packages .Install (),
7677		)
7778		if  err  ==  nil  {
79+ 			updated  =  true 
7880			log .Println ("done" )
7981		}
8082		return 
8183	})
8284
83- 	return  a .Exec ()
85+ 	// it is necessary to execute the chain here to get the correct value for `updated`. 
86+ 	err  :=  a .Exec ()
87+ 	return  updated , err 
8488}
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments