Massive architectural rework

This commit massively overhauls the project's structure to simplify
development. Most parts are now correctly compartmentalized and
dependencies are passed in a sane way rather than global variables
galore xd.
This commit is contained in:
Zoe
2025-05-02 12:15:40 -05:00
parent f4bf2ff5a1
commit c891c24843
50 changed files with 2684 additions and 2410 deletions

10
pkg/API/app.go Normal file
View File

@@ -0,0 +1,10 @@
package API
import "github.com/google/uuid"
type App struct {
Id uuid.UUID `json:"id,omitempty"`
Name string `json:"name,omitempty"`
DeploymentID int64 `json:"deployment_id,omitempty"`
DeploymentStatus string `json:"deployment_status,omitempty"`
}

19
pkg/API/deploy.go Normal file
View File

@@ -0,0 +1,19 @@
package API
import (
"mime/multipart"
"github.com/google/uuid"
"github.com/juls0730/flux/pkg"
)
type DeployRequest struct {
Id uuid.UUID `form:"id"`
Config pkg.ProjectConfig `form:"config"`
Code multipart.File `form:"code"`
}
type DeploymentEvent struct {
Message any `json:"message"`
Stage string `json:"stage"`
}

8
pkg/API/info.go Normal file
View File

@@ -0,0 +1,8 @@
package API
type Info struct {
// an int between 0 and 9 that represents the compression level, 0 being no compression, 9 being maximum compression
CompressionLevel int `json:"compression_level"`
// the version of the daemon (see pkg/version.go)
Version string `json:"version"`
}

View File

@@ -27,3 +27,15 @@ type ProjectConfig struct {
// config for supplemental containersm
Containers []Container `json:"containers,omitempty"`
}
type DaemonConfig struct {
Builder string `json:"builder"`
DisableDeleteAll bool `json:"disable_delete_all"`
CompressionLevel int `json:"compression_level"`
DaemonHost string `json:"host"` // default is 0.0.0.0:5647
ProxyHost string `json:"proxy_host"` // default is 0.0.0.0:7465
}
type CLIConfig struct {
DaemonURL string `json:"daemon_url,omitempty"`
}

View File

@@ -1,25 +0,0 @@
package pkg
import "github.com/google/uuid"
type App struct {
Id uuid.UUID `json:"id,omitempty"`
Name string `json:"name,omitempty"`
DeploymentID int64 `json:"deployment_id,omitempty"`
DeploymentStatus string `json:"deployment_status,omitempty"`
}
// TODO: this should be flattened to an int, where 0 = disabled and any other number is the level
type Compression struct {
Enabled bool `json:"enabled"`
Level int `json:"level,omitempty"`
}
type Info struct {
Compression Compression `json:"compression"`
Version string `json:"version"`
}
type DeploymentEvent struct {
Message interface{} `json:"message"`
}

View File

@@ -1,30 +0,0 @@
package pkg
import "sync"
type TypedMap[K comparable, V any] struct {
internal sync.Map
}
func (m *TypedMap[K, V]) Load(key K) (V, bool) {
val, ok := m.internal.Load(key)
if !ok {
var zero V
return zero, false
}
return val.(V), true
}
func (m *TypedMap[K, V]) Store(key K, value V) {
m.internal.Store(key, value)
}
func (m *TypedMap[K, V]) Delete(key K) {
m.internal.Delete(key)
}
func (m *TypedMap[K, V]) Range(f func(key K, value V) bool) {
m.internal.Range(func(k, v any) bool {
return f(k.(K), v.(V))
})
}

View File

@@ -1,3 +1,3 @@
package pkg
const Version = "2025.04.13-10"
const Version = "2025.05.02-17"