Skip to content
Snippets Groups Projects
Commit a02bd208 authored by Michael Zigldrum's avatar Michael Zigldrum
Browse files

Merge branch 'main' into 'main'

enable database password via secret

See merge request eclipse/xfsc/organisational-credential-manager-w-stack/status-list-service!4
parents 9c534836 593bc3cf
No related branches found
No related tags found
No related merge requests found
...@@ -35,6 +35,12 @@ spec: ...@@ -35,6 +35,12 @@ spec:
volumeMounts: volumeMounts:
- mountPath: /app - mountPath: /app
name: config-volume name: config-volume
env:
- name: STATUSLIST_DATABASE_PASSWORD
valueFrom:
secretKeyRef:
name: "{{- .Release.Name }}-postgresql"
key: postgres-password
{{- if .Values.resources }} {{- if .Values.resources }}
resources: resources:
{{ toYaml .Values.resources | indent 10 }} {{ toYaml .Values.resources | indent 10 }}
......
...@@ -33,6 +33,16 @@ config: ...@@ -33,6 +33,16 @@ config:
timeoutInSec: 10 timeoutInSec: 10
queueGroup: statuslistservice queueGroup: statuslistservice
servingPort: 8083 servingPort: 8083
databaseUrl: postgres://user:pass@localhost:5432/status database:
username: user
password: pass
host: localhost
port: 5432
db: status
creationTopic: status creationTopic: status
blockSizeInBytes: 125000 blockSizeInBytes: 125000
\ No newline at end of file
postgresql:
auth:
username: user
database: status
...@@ -8,9 +8,15 @@ import ( ...@@ -8,9 +8,15 @@ import (
) )
type statusListConfiguration struct { type statusListConfiguration struct {
LogLevel string `mapstructure:"logLevel"` LogLevel string `mapstructure:"logLevel"`
Port int `mapstructure:"servingPort"` Port int `mapstructure:"servingPort"`
DatabaseUrl string `mapstructure:"databaseUrl"` Database struct {
Username string `mapstructure:"username"`
Password string `mapstructure:"password"`
Host string `mapstructure:"host"`
Port int `mapstructure:"port"`
Db string `mapstructure:"db"`
} `mapstructure:"database"`
CreationTopic string `mapstructure:"creationTopic"` CreationTopic string `mapstructure:"creationTopic"`
BlockSizeInBytes int `mapstructure:"blockSizeInBytes"` BlockSizeInBytes int `mapstructure:"blockSizeInBytes"`
} }
......
...@@ -19,7 +19,7 @@ type Database struct { ...@@ -19,7 +19,7 @@ type Database struct {
DbConnection DbConnection
} }
func New(databaseUrl string, blockSizeInBytes int) (*Database, error) { func New(username string, password string, host string, port int, db string, blockSizeInBytes int) (*Database, error) {
dbConnection, err := newPostgresConnection(databaseUrl, blockSizeInBytes) dbConnection, err := newPostgresConnection(username, password, host, port, db, blockSizeInBytes)
return &Database{DbConnection: dbConnection}, err return &Database{DbConnection: dbConnection}, err
} }
...@@ -17,8 +17,9 @@ type postgresConnection struct { ...@@ -17,8 +17,9 @@ type postgresConnection struct {
blockSizeInBytes int blockSizeInBytes int
} }
func newPostgresConnection(url string, blockSizeInBytes int) (DbConnection, error) { func newPostgresConnection(username string, password string, host string, port int, db string, blockSizeInBytes int) (DbConnection, error) {
conn, err := pgxpool.New(context.Background(), url) connUrl := fmt.Sprintf("postgres://%s:%s@%s:%d/%s", username, password, host, port, db)
conn, err := pgxpool.New(context.Background(), connUrl)
if err != nil { if err != nil {
return nil, err return nil, err
} }
......
...@@ -13,7 +13,15 @@ func main() { ...@@ -13,7 +13,15 @@ func main() {
} }
currentConf := &config.CurrentStatusListConfig currentConf := &config.CurrentStatusListConfig
db, err := database.New(currentConf.DatabaseUrl, currentConf.BlockSizeInBytes) dbConf := &currentConf.Database
db, err := database.New(
dbConf.Username,
dbConf.Password,
dbConf.Host,
dbConf.Port,
dbConf.Db,
currentConf.BlockSizeInBytes,
)
if err != nil { if err != nil {
log.Error(err) log.Error(err)
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment