Skip to content

Commit

Permalink
✨ Add config struct (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
tosone committed Jul 26, 2023
1 parent c9a95d0 commit 28b51a6
Show file tree
Hide file tree
Showing 5 changed files with 543 additions and 13 deletions.
4 changes: 3 additions & 1 deletion build/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/sh

if [ "$(yq ".redis.type" < /etc/sigma/config.yaml)" = "internal" ]; then
REDIS_TYPE=${REDIS_TYPE:-$(yq ".redis.type" < /etc/sigma/config.yaml)}

if [ "$REDIS_TYPE" = "internal" ]; then
if [ ! -d /var/lib/sigma/redis/ ]; then
mkdir -p /var/lib/sigma/redis/
fi
Expand Down
14 changes: 5 additions & 9 deletions conf/config-full.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,27 @@ database:
dbname: ximager
sslmode: disable

# deploy avaliable: single, replica
# deploy available: single, replica
# replica should use external redis
deploy: single

redis:
# redis type avaliable: internal, external
# redis type available: internal, external
type: internal
url: redis://:sigma@localhost:6379/0

cache:
# the cache type avaliable is: redis
# the cache type available is: redis
type: redis
# please attation in multi
inmemory: {}
redis: {}

workqueue:
# the workqueue type avaliable: redis
# the workqueue type available: redis
type: redis
redis: {}

namespace:
# push image to registry, if namespace not exist, it will be created automatically
autoCreate: false
# the automatic created namespace visibility, avaliable: public, private
# the automatic created namespace visibility, available: public, private
visibility: public

http:
Expand Down
74 changes: 74 additions & 0 deletions pkg/configs/configuration.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package configs

import "github.com/go-sigma/sigma/pkg/types/enums"

// ConfigurationLog ...
type ConfigurationLog struct {
Level enums.LogLevel
ProxyLevel enums.LogLevel
}

// ConfigurationDatabaseSqlite3 ...
type ConfigurationDatabaseSqlite3 struct {
Path string
}

// ConfigurationDatabaseMysql ...
type ConfigurationDatabaseMysql struct {
Host string
Port int
User string
Password string
DBName string
}

// ConfigurationDatabase ...
type ConfigurationDatabasePostgresql struct {
Host string
Port int
User string
Password string
DBName string
SslMode bool
}

// ConfigurationDatabase ...
type ConfigurationDatabase struct {
Type enums.Database
Sqlite3 ConfigurationDatabaseSqlite3
Mysql ConfigurationDatabaseMysql
Postgresql ConfigurationDatabasePostgresql
}

// ConfigurationRedis ...
type ConfigurationRedis struct {
Type enums.RedisType
Url string
}

// ConfigurationCache ...
type ConfigurationCache struct {
Type enums.CacheType
}

// ConfigurationWorkQueue ...
type ConfigurationWorkQueue struct {
Type enums.WorkQueueType
}

// ConfigurationNamespace ...
type ConfigurationNamespace struct {
AutoCreate bool
Visibility enums.Visibility
}

// Configuration ...
type Configuration struct {
Log ConfigurationLog
Database ConfigurationDatabase
Deploy enums.Deploy
Redis ConfigurationRedis
Cache ConfigurationCache
WorkQueue ConfigurationWorkQueue
Namespace ConfigurationNamespace
}
34 changes: 34 additions & 0 deletions pkg/types/enums/enums.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,23 @@ package enums

//go:generate go-enum --sql --mustparse

// LogLevel x ENUM(
// trace,
// debug,
// info,
// warn,
// error,
// fatal,
// panic,
// )
type LogLevel string

// Deploy x ENUM(
// single,
// replica,
// )
type Deploy string

// TaskCommonStatus x ENUM(
// Pending,
// Doing,
Expand All @@ -31,6 +48,23 @@ type TaskCommonStatus string
// )
type Database string

// RedisType x ENUM(
// internal,
// external,
// )
type RedisType string

// CacheType x ENUM(
// memory,
// redis,
// )
type CacheType string

// CacheKey x ENUM(
// redis,
// )
type WorkQueueType string

// Daemon x ENUM(
// Vulnerability,
// Sbom,
Expand Down
Loading

0 comments on commit 28b51a6

Please sign in to comment.