Leverage release as version

remove-cloud-prod
Malachi Soord 2023-11-19 22:33:54 +01:00
parent 8be566afb9
commit 03f7ac8468
No known key found for this signature in database
GPG Key ID: C61BEBD6CC542333
5 changed files with 201 additions and 257 deletions

View File

@ -9,25 +9,10 @@ GOOS := $(shell go env GOOS)
GOARCH := $(shell go env GOARCH)
build-all:
build-all: clean
GOOS=linux GOARCH=amd64 make build
GOOS=linux GOARCH=arm make build
build-prod:
GOOS=linux GOARCH=arm RELEASE=prod make build
build-cloud:
GOOS=linux GOARCH=amd64 RELEASE=cloud make build
build-arm64:
GOOS=linux GOARCH=arm64 RELEASE=prod make build
build-armhf:
GOOS=linux GOARCH=arm RELEASE=prod make build
build-amd64:
GOOS=linux GOARCH=amd64 RELEASE=prod make build
GOOS=linux GOARCH=arm64 make build
build:
@echo "Building ${GOOS}-${GOARCH}"
@ -57,11 +42,7 @@ install:
@echo "Edgeboxctl installed successfully"
@echo "To start edgeboxctl run: systemctl start edgeboxctl"
install-prod: build-prod install
install-cloud: build-cloud install
install-arm64: build-arm64 install
install-armhf: build-armhf install
install-amd64: build-amd64 install
build-install: build install
start:
systemctl start edgeboxctl

View File

@ -1,18 +1,5 @@
package diagnostics
type ReleaseVersion string
var Version string
var Commit string
var BuildDate string
const (
DEV_VERSION ReleaseVersion = "dev"
PROD_VERSION ReleaseVersion = "prod"
CLOUD_VERSION ReleaseVersion = "cloud"
OTHER_VERSION ReleaseVersion = "other"
)
func GetReleaseVersion() ReleaseVersion {
return ReleaseVersion(Version)
}

View File

@ -6,7 +6,6 @@ import (
"path/filepath"
"strings"
"github.com/edgebox-iot/edgeboxctl/internal/diagnostics"
"github.com/edgebox-iot/edgeboxctl/internal/utils"
"github.com/shirou/gopsutil/disk"
)
@ -75,20 +74,9 @@ const (
DISK_TYPE_VDA DeviceIdentifier = "vda"
)
func GetDeviceIdentifier(release_version diagnostics.ReleaseVersion) DeviceIdentifier {
switch release_version {
case diagnostics.CLOUD_VERSION:
return DISK_TYPE_VDA
case diagnostics.PROD_VERSION:
return DISK_TYPE_MCBLK
}
return DISK_TYPE_SDA
}
// GetDevices : Returns a list of all available sotrage devices in structs filled with information
func GetDevices(release_version diagnostics.ReleaseVersion) []Device {
// GetDevices : Returns a list of all available storage devices in structs filled with information
func GetDevices() []Device {
var devices []Device
cmdArgs := []string{"--raw", "--bytes", "--noheadings"}
@ -100,8 +88,6 @@ func GetDevices(release_version diagnostics.ReleaseVersion) []Device {
firstDevice := true
currentDeviceInUseFlag := false
mainDiskID := GetDeviceIdentifier(release_version)
for scanner.Scan() {
// 1 Device is represented here. Extract words in order for filling a Device struct
// Example deviceRawInfo: "mmcblk0 179:0 0 29.7G 0 disk"
@ -153,14 +139,9 @@ func GetDevices(release_version diagnostics.ReleaseVersion) []Device {
Status: DeviceStatus{ID: 1, Description: "healthy"},
}
if device.ID == mainDiskID {
device.MainDevice = true
}
currentDevice = device
} else if isPartition {
mountpoint := ""
if len(deviceRawInfo) >= 7 {
mountpoint = deviceRawInfo[6]

View File

@ -82,6 +82,7 @@ func SetupCloudOptions() {
if err != nil {
fmt.Println("Error loading .env file for cloud version setup")
return
}
if cloudEnv["NAME"] != "" {

View File

@ -164,9 +164,6 @@ func ExecuteTask(task Task) Task {
log.Fatal(err.Error())
}
if diagnostics.GetReleaseVersion() == diagnostics.DEV_VERSION {
log.Printf("Dev environemnt. Not executing tasks.")
} else {
log.Println("Task: " + task.Task)
log.Println("Args: " + task.Args.String)
switch task.Task {
@ -366,10 +363,8 @@ func ExecuteTask(task Task) Task {
log.Println("Disabling online access to Dashboard...")
taskResult := taskDisablePublicDashboard()
task.Result = sql.NullString{String: taskResult, Valid: true}
}
}
statement, err = db.Prepare("Update task SET status = ?, result = ?, updated = ? WHERE ID = ?;") // Prepare SQL Statement
if err != nil {
@ -427,10 +422,9 @@ func ExecuteSchedules(tick int) {
// })
// }
if diagnostics.GetReleaseVersion() == diagnostics.CLOUD_VERSION {
log.Println("Setting up cloud version options (name, email, api token)")
taskSetupCloudOptions()
}
// Executing on startup (first tick). Schedules run before tasks in the SystemIterator
uptime := taskGetSystemUptime()
@ -1196,7 +1190,7 @@ func taskGetSystemUptime() string {
func taskGetStorageDevices() string {
fmt.Println("Executing taskGetStorageDevices")
devices := storage.GetDevices(diagnostics.GetReleaseVersion())
devices := storage.GetDevices()
devicesJSON, _ := json.Marshal(devices)
utils.WriteOption("STORAGE_DEVICES_LIST", string(devicesJSON))