Refonte de la config #57

Open
opened 2024-09-09 11:43:46 -04:00 by vlbeaudoin · 1 comment
Owner

objet config map 1:1 avec type Config struct

type Config struct {
	Client struct {
		API struct {
			Host     string `yaml:"host"`
			Key      string `yaml:"key"`
			Port     string `yaml:"port"`
			Protocol string `yaml:"protocol"`
		} `yaml:"api"`
	} `yaml:"client"`

	Server struct {
		API struct {
			Host string `yaml:"host"`
			Key  string `yaml:"key"`
			Port string `yaml:"port"`
			TLS  struct {
				Enabled  bool   `yaml:"enabled"`
				Certfile string `yaml:"certfile"`
				Keyfile  string `yaml:"keyfile"`
			} `yaml:"tls"`
		} `yaml:"api"`
		DB struct {
			Database string `yaml:"database"`
			Host     string `yaml:"host"`
			Password string `yaml:"password"`
			Port     int    `yaml:"port"`
			SSLMode  string `yaml:"sslmode"`
			User     string `yaml:"user"`
		} `yaml:"db"`
		Web struct {
			API struct {
				Host     string `yaml:"host"`
				Key      string `yaml:"key"`
				Port     string `yaml:"port"`
				Protocol string `yaml:"protocol"`
			} `yaml:"api"`
			Password string `yaml:"password"`
			Port     int    `yaml:"port"`
			TLS      struct {
				Enabled  bool   `yaml:"enabled"`
				Certfile string `yaml:"certfile"`
				Keyfile  string `yaml:"keyfile"`
			} `yaml:"tls"`
			User string `yaml:"user"`
		} `yaml:"web"`
	} `yaml:"server"`
}

Exemple de config

  client:
    api:
      host: 'api'
      key: 'bottin'
      port: 1312
      protocol: 'https'
  server:
    api:
      host: '' # empty = any
      key: 'bottin'
      port: 1312
      tls:
        enabled: true
        certfile: '/etc/bottin/cert.pem'
        keyfile: '/etc/bottin/key.pem'
    db:
      database: 'bottin'
      host: 'db'
      password: 'bottin'
      port: 5432
      sslmode: 'prefer'
      user: 'bottin'
    web:
      api:
        host: 'api'
        key: 'bottin'
        port: 1312
        protocol: 'http'
      password: 'bottin'
      port: 2312
      tls:
        enabled: true
        certfile: '/etc/bottin/cert.pem'
        keyfile: '/etc/bottin/key.pem'
      user: 'bottin'
objet `config` map 1:1 avec `type Config struct` ```go type Config struct { Client struct { API struct { Host string `yaml:"host"` Key string `yaml:"key"` Port string `yaml:"port"` Protocol string `yaml:"protocol"` } `yaml:"api"` } `yaml:"client"` Server struct { API struct { Host string `yaml:"host"` Key string `yaml:"key"` Port string `yaml:"port"` TLS struct { Enabled bool `yaml:"enabled"` Certfile string `yaml:"certfile"` Keyfile string `yaml:"keyfile"` } `yaml:"tls"` } `yaml:"api"` DB struct { Database string `yaml:"database"` Host string `yaml:"host"` Password string `yaml:"password"` Port int `yaml:"port"` SSLMode string `yaml:"sslmode"` User string `yaml:"user"` } `yaml:"db"` Web struct { API struct { Host string `yaml:"host"` Key string `yaml:"key"` Port string `yaml:"port"` Protocol string `yaml:"protocol"` } `yaml:"api"` Password string `yaml:"password"` Port int `yaml:"port"` TLS struct { Enabled bool `yaml:"enabled"` Certfile string `yaml:"certfile"` Keyfile string `yaml:"keyfile"` } `yaml:"tls"` User string `yaml:"user"` } `yaml:"web"` } `yaml:"server"` } ``` ### Exemple de config ```yaml client: api: host: 'api' key: 'bottin' port: 1312 protocol: 'https' server: api: host: '' # empty = any key: 'bottin' port: 1312 tls: enabled: true certfile: '/etc/bottin/cert.pem' keyfile: '/etc/bottin/key.pem' db: database: 'bottin' host: 'db' password: 'bottin' port: 5432 sslmode: 'prefer' user: 'bottin' web: api: host: 'api' key: 'bottin' port: 1312 protocol: 'http' password: 'bottin' port: 2312 tls: enabled: true certfile: '/etc/bottin/cert.pem' keyfile: '/etc/bottin/key.pem' user: 'bottin' ```
vlbeaudoin added the
refactor
label 2024-09-09 11:45:17 -04:00
Author
Owner

Closes #56

Closes #56
This repo is archived. You cannot comment on issues.
No milestone
No project
No assignees
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: agecem/bottin#57
No description provided.