Merge pull request #9 from edgebox-iot/edgeapp_description_support

Added support for adding EDGEAPP_DESCRIPTION env var to edgebox.env
pull/10/head
Paulo Truta 2021-06-01 16:51:48 +02:00 committed by GitHub
commit 5d69a9fb22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 6 deletions

View File

@ -16,6 +16,7 @@ import (
type EdgeApp struct { type EdgeApp struct {
ID string `json:"id"` ID string `json:"id"`
Name string `json:"name"` Name string `json:"name"`
Description string `json:"description"`
Status EdgeAppStatus `json:"status"` Status EdgeAppStatus `json:"status"`
Services []EdgeAppService `json:"services"` Services []EdgeAppService `json:"services"`
InternetAccessible bool `json:"internet_accessible"` InternetAccessible bool `json:"internet_accessible"`
@ -60,6 +61,7 @@ func GetEdgeApp(ID string) MaybeEdgeApp {
// File exists. Start digging! // File exists. Start digging!
edgeAppName := ID edgeAppName := ID
edgeAppDescription := ""
edgeAppEnv, err := godotenv.Read(utils.GetPath("edgeAppsPath") + ID + envFilename) edgeAppEnv, err := godotenv.Read(utils.GetPath("edgeAppsPath") + ID + envFilename)
@ -69,6 +71,9 @@ func GetEdgeApp(ID string) MaybeEdgeApp {
if edgeAppEnv["EDGEAPP_NAME"] != "" { if edgeAppEnv["EDGEAPP_NAME"] != "" {
edgeAppName = edgeAppEnv["EDGEAPP_NAME"] edgeAppName = edgeAppEnv["EDGEAPP_NAME"]
} }
if edgeAppEnv["EDGEAPP_DESCRIPTION"] != "" {
edgeAppDescription = edgeAppEnv["EDGEAPP_DESCRIPTION"]
}
} }
edgeAppInternetAccessible := false edgeAppInternetAccessible := false
@ -88,6 +93,7 @@ func GetEdgeApp(ID string) MaybeEdgeApp {
EdgeApp: EdgeApp{ EdgeApp: EdgeApp{
ID: ID, ID: ID,
Name: edgeAppName, Name: edgeAppName,
Description: edgeAppDescription,
Status: GetEdgeAppStatus(ID), Status: GetEdgeAppStatus(ID),
Services: GetEdgeAppServices(ID), Services: GetEdgeAppServices(ID),
InternetAccessible: edgeAppInternetAccessible, InternetAccessible: edgeAppInternetAccessible,
@ -123,7 +129,6 @@ func SetEdgeAppInstalled(ID string) bool {
_, err := os.Stat(utils.GetPath("edgeAppsPath") + ID + runnableFilename) _, err := os.Stat(utils.GetPath("edgeAppsPath") + ID + runnableFilename)
if os.IsNotExist(err) { if os.IsNotExist(err) {
_, err := os.Create(utils.GetPath("edgeAppsPath") + ID + runnableFilename) _, err := os.Create(utils.GetPath("edgeAppsPath") + ID + runnableFilename)
result = true result = true
@ -134,7 +139,6 @@ func SetEdgeAppInstalled(ID string) bool {
buildFrameworkContainers() buildFrameworkContainers()
} else { } else {
// Is already installed. // Is already installed.