Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Devel #77

Merged
merged 111 commits into from
Oct 10, 2024
Merged
Changes from 4 commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
fe05789
add: config path for docker container and mount point
HilkopterBob Aug 23, 2024
44592b9
ci: move binary into app dir
HilkopterBob Aug 26, 2024
9f66f44
chore: changed dependencies
HilkopterBob Aug 26, 2024
3d75de1
add: docker compose & usage to readme
HilkopterBob Aug 26, 2024
7b5de3f
add: mongo-db config options & generate command for initial admin user
HilkopterBob Sep 5, 2024
478ffbb
chore: add mongo db development container
HilkopterBob Sep 5, 2024
d96bd89
refactor: generate RSA Certificate
HilkopterBob Sep 5, 2024
b1e80c4
add: mongodb to initConfig()
HilkopterBob Sep 5, 2024
4f154a0
add: new User & ApiKey Structs
HilkopterBob Sep 5, 2024
4ac0f1d
add: db-connector, db module & db.Client, db.DB to globals
HilkopterBob Sep 5, 2024
02b22ac
fix: get Users from DB, add new JWT to user.apiKeys[]
HilkopterBob Sep 5, 2024
83889ba
ci: fix docker-compose file
HilkopterBob Sep 5, 2024
6accc76
add: mongodb
HilkopterBob Sep 5, 2024
a49347b
chore: comments
HilkopterBob Sep 5, 2024
8acd29b
chore: add test data generator for mongo db
HilkopterBob Sep 6, 2024
9adf160
chore: update dependencies
HilkopterBob Sep 6, 2024
35878af
feat: Package struct
HilkopterBob Sep 6, 2024
3c07ed6
rem: static synthetic data
HilkopterBob Sep 6, 2024
d61b259
refactor: move to mongodb
HilkopterBob Sep 6, 2024
61fe918
refactor: move to mongo db
HilkopterBob Sep 6, 2024
3080a82
refactor: move to mongo db
HilkopterBob Sep 6, 2024
97d5bae
refactor: move to mongo db
HilkopterBob Sep 6, 2024
056e6b6
rem: debug prints
HilkopterBob Sep 6, 2024
cd4ee60
fix: naming convention
HilkopterBob Sep 13, 2024
e2880a0
chore: update generate testuser cmd
HilkopterBob Sep 13, 2024
4b187b5
Extended Structs with more Informations
Kartoffel096 Oct 1, 2024
35636a8
Edited structs to support multiple network interfaces
Kartoffel096 Oct 1, 2024
617a240
Edited Structs to fit Pascal_Case and removed Domain from Interface
Kartoffel096 Oct 1, 2024
014f244
linting: conv to pascal case
HilkopterBob Oct 1, 2024
29e7b7a
Fixed Linting Workflow
Kartoffel096 Oct 1, 2024
ea5bd38
Merge pull request #48 from HilkopterBob/ExtendedStructs
HilkopterBob Oct 1, 2024
d13b480
Added Workflow for Unit Testing
Kartoffel096 Oct 1, 2024
b3415ba
Changed readme to include more Badges
Kartoffel096 Oct 1, 2024
ef5a08a
Added test-build workflow
Kartoffel096 Oct 1, 2024
50681ba
Merge pull request #50 from HilkopterBob/Readme-changes
HilkopterBob Oct 1, 2024
d7a6e5f
rem: old mongo connector file
HilkopterBob Oct 2, 2024
80cc622
add: Surreal DB connector file && global var `db.DB` for db-access
HilkopterBob Oct 2, 2024
406500e
ref: migrate to surrealDB
HilkopterBob Oct 2, 2024
75fff80
ref: add surrealDB json annotations
HilkopterBob Oct 2, 2024
186df27
ref: migrate Agents to surrealdb
HilkopterBob Oct 2, 2024
69e28a8
add: db.Select for whole-table selection in one line
HilkopterBob Oct 4, 2024
f121ec6
ref: migrate to surrealdb
HilkopterBob Oct 4, 2024
f82db2e
ref: switch to surrealdb
HilkopterBob Oct 4, 2024
88ff57d
add: pp, surrealdb, packagelock/db module
HilkopterBob Oct 4, 2024
58903a5
add: logging notice
HilkopterBob Oct 4, 2024
592f71a
add: comments
HilkopterBob Oct 4, 2024
729f7b8
feat: generate admin creates admin user
HilkopterBob Oct 4, 2024
c18b1a7
add dependencies
HilkopterBob Oct 4, 2024
b0085d2
REAMDE
HilkopterBob Oct 4, 2024
7a4513e
change: default config to reflect surrealdb default values
HilkopterBob Oct 4, 2024
82ead71
ref: use config for db connection details
HilkopterBob Oct 4, 2024
5dc3834
ref: move initConfig away from cobra Init. queue
HilkopterBob Oct 4, 2024
18e702a
Merge pull request #54 from HilkopterBob/db-refactor-surreal
HilkopterBob Oct 4, 2024
19ee2d4
rem: devel tools
HilkopterBob Oct 4, 2024
6f7c94b
Merge branch 'devel' into db-integration
HilkopterBob Oct 4, 2024
5a3b5b9
chore: various cleanups
HilkopterBob Oct 4, 2024
d7ea1fd
add: print help for common db connection errors
HilkopterBob Oct 4, 2024
9846d74
add: INFO
HilkopterBob Oct 7, 2024
a2973a8
fix: linting
HilkopterBob Oct 7, 2024
e22d4eb
ci: create docker container with right mounts, add surrealdb
HilkopterBob Oct 7, 2024
e756cce
Merge pull request #55 from HilkopterBob/db-integration
HilkopterBob Oct 7, 2024
6d14b4d
Merge pull request #57 from HilkopterBob/devel
Kartoffel096 Oct 7, 2024
5ca55b7
feat: logging
HilkopterBob Oct 7, 2024
326c97d
feat: logging
HilkopterBob Oct 8, 2024
83bb277
feat: logging
HilkopterBob Oct 8, 2024
cd13f0a
feat: logger & global var logger.Logger
HilkopterBob Oct 8, 2024
9b16074
feat: logging & error handling
HilkopterBob Oct 8, 2024
d93eb34
feat: logging
HilkopterBob Oct 8, 2024
9070460
feat: logging
HilkopterBob Oct 8, 2024
288ec5e
chore: rem old files
HilkopterBob Oct 8, 2024
c1b15af
feat: logging
HilkopterBob Oct 8, 2024
209148d
chore: fix naming
HilkopterBob Oct 8, 2024
4b592bc
chore: fix naming
HilkopterBob Oct 8, 2024
ea25449
Merge pull request #60 from HilkopterBob/logging
HilkopterBob Oct 8, 2024
1445407
Merge branch 'devel' into fix-naming
HilkopterBob Oct 8, 2024
54ede0b
Merge pull request #61 from HilkopterBob/fix-naming
HilkopterBob Oct 8, 2024
100b8e4
API: Switched to Fields and renamed routes
Kartoffel096 Oct 8, 2024
45ebcf6
refactor: changed id to suit namingscheme in structs
Kartoffel096 Oct 8, 2024
cb6a1f7
Merge pull request #62 from HilkopterBob/API-Fields
HilkopterBob Oct 8, 2024
2c13e1c
fix: create logs directory if non existent, close #63
HilkopterBob Oct 8, 2024
d50046b
fix: consistent error return for 'agent not found', close #64
HilkopterBob Oct 8, 2024
64bfa10
Merge pull request #65 from HilkopterBob/fix-#63
HilkopterBob Oct 8, 2024
b666056
Merge pull request #66 from HilkopterBob/fix-#64
HilkopterBob Oct 8, 2024
a344727
add: workflow for releasing on a new tag
Kartoffel096 Oct 8, 2024
751ac35
fix: missing folder path
Kartoffel096 Oct 9, 2024
70e4d83
fix: changed folder creation to happen earlier
Kartoffel096 Oct 9, 2024
20e1bfd
change: changed folder path
Kartoffel096 Oct 9, 2024
3c22f4a
change: changed folder to use github env
Kartoffel096 Oct 9, 2024
909e24b
fix: made copy recursive
Kartoffel096 Oct 9, 2024
b51f10f
change: changed upload of files
Kartoffel096 Oct 9, 2024
66ed301
add: testfile to test workflow on push
Kartoffel096 Oct 9, 2024
abf5a12
change: changed the release workflow
Kartoffel096 Oct 9, 2024
5550237
change: changed how the release upload url is read
Kartoffel096 Oct 9, 2024
9a44b0b
fix: changed pathing
Kartoffel096 Oct 9, 2024
e01253e
fix: fixed missing path
Kartoffel096 Oct 9, 2024
064be82
add: added debug lines
Kartoffel096 Oct 9, 2024
e6f40b3
change: changed debug lines
Kartoffel096 Oct 9, 2024
765b2b4
add: more debug lines
Kartoffel096 Oct 9, 2024
f5c3ba3
fix: permissions
Kartoffel096 Oct 9, 2024
70a698b
Change: Removed Debug Lines; Changed Tag Regex and added Checksum
Kartoffel096 Oct 9, 2024
fbb3085
Fix: Removed Filename from MD5 Sum
Kartoffel096 Oct 9, 2024
b8a0110
fix+feat: correct init chain + add setup.
HilkopterBob Oct 10, 2024
f432068
feat: unit file generation in setup
HilkopterBob Oct 10, 2024
ad08ed7
Merge pull request #71 from HilkopterBob/fix-init-chain
HilkopterBob Oct 10, 2024
1159b10
Merge pull request #72 from HilkopterBob/generate-systemd-unit-file
HilkopterBob Oct 10, 2024
f582cdc
Merge pull request #73 from HilkopterBob/GitHub-Actions
HilkopterBob Oct 10, 2024
934fdf5
REM: Removed old release workflow
Kartoffel096 Oct 10, 2024
1a47183
fix: run initServer before startServer, close #74
HilkopterBob Oct 10, 2024
ba40ea1
fix: wrong place for code
HilkopterBob Oct 10, 2024
14abd25
Merge pull request #75 from HilkopterBob/fix-#74
HilkopterBob Oct 10, 2024
d6a334d
Merge pull request #76 from HilkopterBob/GitHub-Actions
HilkopterBob Oct 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions config/conf-init.go
Original file line number Diff line number Diff line change
@@ -42,9 +42,9 @@ func StartViper(config ConfigProvider) ConfigProvider {
if err := config.ReadInConfig(); err != nil {
if _, ok := err.(viper.ConfigFileNotFoundError); ok {
CreateDefaultConfig(config)
new_config := StartViper(config)
newConfig := StartViper(config)
logger.Logger.Info("No Config found, created default Config.")
return new_config
return newConfig
} else {
logger.Logger.Panicf("Cannot create default config, got: %s", err)
}
@@ -79,8 +79,8 @@ network:
logger.Logger.Panicf("Incompatible Default Config! Got: %s", err)
}

err_write := config.WriteConfigAs("./config.yaml")
if err_write != nil {
logger.Logger.Panicf("Cannot write config file, got: %s", err)
errWrite := config.WriteConfigAs("./config.yaml")
if errWrite != nil {
logger.Logger.Panicf("Cannot write config file, got: %s", errWrite)
}
}
19 changes: 10 additions & 9 deletions main.go
Original file line number Diff line number Diff line change
@@ -145,14 +145,14 @@ func generateAdmin() error {
}

// Insert Admin
AdminInsertionData, err := db.DB.Create("user", TemporalAdmin)
adminInsertionData, err := db.DB.Create("user", TemporalAdmin)
if err != nil {
logger.Logger.Panicf("Got error while inserting Default Admin into DB: %s", err)
}

// Unmarshal data
var createdUser structs.User
err = surrealdb.Unmarshal(AdminInsertionData, &createdUser)
err = surrealdb.Unmarshal(adminInsertionData, &createdUser)
if err != nil {
logger.Logger.Panicf("Got error while querring Default Admin: %s", err)
}
@@ -201,7 +201,7 @@ func startServer() {
// Start the server in a goroutine
go func() {
for {
router := server.AddRoutes(config.Config)
Router := server.AddRoutes(config.Config)

// Setup server address from config
serverAddr := config.Config.GetString("network.fqdn") + ":" + config.Config.GetString("network.port")
@@ -213,18 +213,17 @@ func startServer() {
logger.Logger.Infof("Starting Fiber HTTPS server at https://%s...\n", serverAddr)

err := server.ListenAndServeTLS(
router.Router,
Router.Router,
config.Config.GetString("network.ssl-config.certificatepath"),
config.Config.GetString("network.ssl-config.privatekeypath"),
serverAddr)
if err != nil {
logger.Logger.Panicf("Server error: %s\n", err)
}
} else {

logger.Logger.Infof("Starting Fiber server at %s...\n", serverAddr)

if err := router.Router.Listen(serverAddr); err != nil {
if err := Router.Router.Listen(serverAddr); err != nil {
logger.Logger.Panicf("Server error: %s\n", err)
}
}
@@ -239,14 +238,15 @@ func startServer() {

_, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
if err := router.Router.Shutdown(); err != nil {

if err := Router.Router.Shutdown(); err != nil {
logger.Logger.Warnf("Server shutdown failed: %v\n", err)
} else {

// TODO: add Reason for restart/Stoping
fmt.Println("Server stopped.")
logger.Logger.Info("Server stopped.")
}

startServer()

case <-quitChan:
@@ -256,7 +256,8 @@ func startServer() {
logger.Logger.Info("Shutting down Fiber server...")
_, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
if err := router.Router.Shutdown(); err != nil {

if err := Router.Router.Shutdown(); err != nil {
logger.Logger.Warnf("Server shutdown failed: %v\n", err)
} else {
fmt.Println("Server stopped gracefully.")