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:
volumeMounts:
- mountPath: /app
name: config-volume
env:
- name: STATUSLIST_DATABASE_PASSWORD
valueFrom:
secretKeyRef:
name: "{{- .Release.Name }}-postgresql"
key: postgres-password
{{- if .Values.resources }}
resources:
{{ toYaml .Values.resources | indent 10 }}
......
......@@ -33,6 +33,16 @@ config:
timeoutInSec: 10
queueGroup: statuslistservice
servingPort: 8083
databaseUrl: postgres://user:pass@localhost:5432/status
database:
username: user
password: pass
host: localhost
port: 5432
db: status
creationTopic: status
blockSizeInBytes: 125000
\ No newline at end of file
blockSizeInBytes: 125000
postgresql:
auth:
username: user
database: status
......@@ -8,9 +8,15 @@ import (
)
type statusListConfiguration struct {
LogLevel string `mapstructure:"logLevel"`
Port int `mapstructure:"servingPort"`
DatabaseUrl string `mapstructure:"databaseUrl"`
LogLevel string `mapstructure:"logLevel"`
Port int `mapstructure:"servingPort"`
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"`
BlockSizeInBytes int `mapstructure:"blockSizeInBytes"`
}
......
......@@ -19,7 +19,7 @@ type Database struct {
DbConnection
}
func New(databaseUrl string, blockSizeInBytes int) (*Database, error) {
dbConnection, err := newPostgresConnection(databaseUrl, blockSizeInBytes)
func New(username string, password string, host string, port int, db string, blockSizeInBytes int) (*Database, error) {
dbConnection, err := newPostgresConnection(username, password, host, port, db, blockSizeInBytes)
return &Database{DbConnection: dbConnection}, err
}
......@@ -17,8 +17,9 @@ type postgresConnection struct {
blockSizeInBytes int
}
func newPostgresConnection(url string, blockSizeInBytes int) (DbConnection, error) {
conn, err := pgxpool.New(context.Background(), url)
func newPostgresConnection(username string, password string, host string, port int, db string, blockSizeInBytes int) (DbConnection, error) {
connUrl := fmt.Sprintf("postgres://%s:%s@%s:%d/%s", username, password, host, port, db)
conn, err := pgxpool.New(context.Background(), connUrl)
if err != nil {
return nil, err
}
......
......@@ -13,7 +13,15 @@ func main() {
}
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 {
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