Skip to content

Commit

Permalink
Merge pull request #44 from unity-sds/auto-navbar-install
Browse files Browse the repository at this point in the history
added method needed for installing unity-ui during bootstrap
  • Loading branch information
jdrodjpl authored Nov 11, 2024
2 parents 5af8eb6 + a1eabaf commit e8c1e15
Showing 1 changed file with 53 additions and 3 deletions.
56 changes: 53 additions & 3 deletions backend/internal/processes/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@ package processes

import (
"fmt"

log "github.com/sirupsen/logrus"
"github.com/spf13/afero"

// "github.com/unity-sds/unity-cs-manager/marketplace"
"path/filepath"
"strings"

"github.com/unity-sds/unity-management-console/backend/internal/application"
"github.com/unity-sds/unity-management-console/backend/internal/application/config"
"github.com/unity-sds/unity-management-console/backend/internal/aws"
"github.com/unity-sds/unity-management-console/backend/internal/database"
"github.com/unity-sds/unity-management-console/backend/types"
"path/filepath"
"strings"
)

func BootstrapEnv(appconf *config.AppConfig) {
Expand Down Expand Up @@ -88,7 +91,7 @@ func BootstrapEnv(appconf *config.AppConfig) {

err = installHealthStatusLambda(store, appconf)
if err != nil {
log.WithError(err).Error("Error installing Health Status ")
log.WithError(err).Error("Error installing Health Status")
err = store.AddToAudit(application.Bootstrap_Unsuccessful, "test")
if err != nil {
log.WithError(err).Error("Problem writing to auditlog")
Expand All @@ -106,6 +109,16 @@ func BootstrapEnv(appconf *config.AppConfig) {
return
}

err = installUnityUi(store, appconf)
if err != nil {
log.WithError(err).Error("Error installing unity-ui")
err = store.AddToAudit(application.Bootstrap_Unsuccessful, "test")
if err != nil {
log.WithError(err).Error("Problem writing to auditlog")
}
return
}

err = store.AddToAudit(application.Bootstrap_Successful, "test")
if err != nil {
log.WithError(err).Error("Problem writing to auditlog")
Expand Down Expand Up @@ -410,3 +423,40 @@ func installHealthStatusLambda(store database.Datastore, appConfig *config.AppCo
}
return nil
}

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

// Find the marketplace item for the unity-ui
var name, version string
for _, item := range appConfig.MarketplaceItems {
if item.Name == "unity-ui" {
name = item.Name
version = item.Version
break
}
}

// Print the name and version
log.Infof("Found marketplace item - Name: %s, Version: %s", name, version)

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

installParams := types.ApplicationInstallParams{
Name: name,
Version: version,
Variables: nil,
DisplayName: "Unity Navbar UI",
DeploymentName: fmt.Sprintf("default-%s", name),
}

err := TriggerInstall(store, &installParams, appConfig, true)
if err != nil {
log.WithError(err).Error("Issue installing Unity Navbar UI")
return err
}
return nil
}

0 comments on commit e8c1e15

Please sign in to comment.