Skip to content

Commit df2a363

Browse files
committed
Auto-updates marketplace items from the repo when they are installed.
1 parent 2abd39e commit df2a363

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

backend/internal/processes/bootstrap.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func BootstrapEnv(appconf *config.AppConfig) error {
122122
log.Infof("Setting Up Unity UI from Marketplace")
123123
err = installUnityUi(store, appconf)
124124
if err != nil {
125-
log.WithError(err).Error("Error installing unity-ui")
125+
log.WithError(err).Error("Error installing unity-portal")
126126
err = store.AddToAudit(application.Bootstrap_Unsuccessful, "test")
127127
if err != nil {
128128
log.WithError(err).Error("Problem writing to auditlog")
@@ -447,10 +447,10 @@ func installHealthStatusLambda(store database.Datastore, appConfig *config.AppCo
447447

448448
func installUnityUi(store database.Datastore, appConfig *config.AppConfig) error {
449449

450-
// Find the marketplace item for the unity-ui
450+
// Find the marketplace item for the unity-portal
451451
var name, version string
452452
for _, item := range appConfig.MarketplaceItems {
453-
if item.Name == "unity-ui" {
453+
if item.Name == "unity-portal" {
454454
name = item.Name
455455
version = item.Version
456456
break
@@ -462,8 +462,8 @@ func installUnityUi(store database.Datastore, appConfig *config.AppConfig) error
462462

463463
// If the item wasn't found, log an error and return
464464
if name == "" || version == "" {
465-
log.Error("unity-ui not found in MarketplaceItems")
466-
return fmt.Errorf("unity-ui not found in MarketplaceItems")
465+
log.Error("unity-portal not found in MarketplaceItems")
466+
return fmt.Errorf("unity-portal not found in MarketplaceItems")
467467
}
468468

469469
installParams := types.ApplicationInstallParams{

backend/internal/processes/marketplace.go

+20-1
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,30 @@ func gitClone(url string, basedir string) (string, error) {
9090
return "", err
9191
}
9292

93-
// If the repository already exists, open it
93+
// If the repository already exists, open it and pull the latest changes
9494
repo, err = git.PlainOpen(basedir)
9595
if err != nil {
9696
return "", err
9797
}
98+
99+
// Pull the latest changes
100+
log.Infof("Repository already exists, pulling latest changes in %s", basedir)
101+
w, err := repo.Worktree()
102+
if err != nil {
103+
log.Errorf("Couldn't get worktree: %v", err)
104+
return "", err
105+
}
106+
107+
err = w.Pull(&git.PullOptions{
108+
Progress: os.Stdout,
109+
})
110+
111+
if err != nil && err != git.NoErrAlreadyUpToDate {
112+
log.Errorf("Couldn't pull updates: %v", err)
113+
return "", err
114+
} else if err == git.NoErrAlreadyUpToDate {
115+
log.Infof("Repository already up to date")
116+
}
98117
}
99118

100119
// Checkout the specific SHA if provided

0 commit comments

Comments
 (0)