-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* #230: Improvements to the image update process. * Add a test for changes in #230 * remove dead code to ensure validation checks pass
- Loading branch information
1 parent
a998a6a
commit cd15155
Showing
5 changed files
with
52 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,9 @@ | ||
package library | ||
|
||
import ( | ||
"fmt" | ||
"github.com/fubarhouse/pygmy-go/service/interface" | ||
) | ||
|
||
// Pull is an alias function for Update. | ||
// It is here for the sake of user experience. | ||
func Pull(c Config) { | ||
|
||
Setup(&c) | ||
|
||
for _, Service := range c.Services { | ||
|
||
_, e := model.DockerPull(Service.Config.Image) | ||
if e != nil { | ||
fmt.Print(e) | ||
} | ||
Update(c) | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,47 @@ | ||
package library | ||
|
||
import "github.com/fubarhouse/pygmy-go/service/amazee" | ||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
// Update will update the Amazee images | ||
model "github.com/fubarhouse/pygmy-go/service/interface" | ||
) | ||
|
||
// Update will update the the images for all configured services. | ||
func Update(c Config) { | ||
amazee.AmazeeImagePull() | ||
|
||
// Import the configuration. | ||
Setup(&c) | ||
|
||
// Loop over services. | ||
for s := range c.Services { | ||
|
||
// Pull the image. | ||
service := c.Services[s] | ||
purpose, _ := service.GetFieldString("purpose") | ||
var result string | ||
var err error | ||
if purpose == "" || purpose == "sshagent" { | ||
result, err = model.DockerPull(service.Config.Image) | ||
if err == nil { | ||
fmt.Println(result) | ||
} | ||
} | ||
|
||
// If the service is running, restart it. | ||
if s, _ := service.Status(); s && !strings.Contains(result, "is up to date") { | ||
var e error | ||
e = service.Stop() | ||
if e != nil { | ||
fmt.Println(e) | ||
} | ||
if s, _ := service.Status(); !s { | ||
_, e = service.Start() | ||
if e != nil { | ||
fmt.Println(e) | ||
} | ||
} | ||
} | ||
} | ||
|
||
} |