Added config support for daemon, made password configurable

This commit is contained in:
Roberto Alsina 2024-07-07 11:51:14 -03:00
parent 3e4c940479
commit 31ab54478a
7 changed files with 52 additions and 8 deletions

View File

@ -1,19 +1,17 @@
# This configuration file was generated by `ameba --gen-config` # This configuration file was generated by `ameba --gen-config`
# on 2024-07-03 18:18:32 UTC using Ameba version 1.6.1. # on 2024-07-07 14:44:11 UTC using Ameba version 1.6.1.
# The point is for the user to remove these configuration records # The point is for the user to remove these configuration records
# one by one as the reported problems are removed from the code base. # one by one as the reported problems are removed from the code base.
# Problems found: 6 # Problems found: 5
# Run `ameba --only Documentation/DocumentationAdmonition` for details # Run `ameba --only Documentation/DocumentationAdmonition` for details
Documentation/DocumentationAdmonition: Documentation/DocumentationAdmonition:
Description: Reports documentation admonitions Description: Reports documentation admonitions
Timezone: UTC Timezone: UTC
Excluded: Excluded:
- src/secrets.cr - src/secrets.cr
- src/daemon/main.cr
- src/daemon/secrets.cr - src/daemon/secrets.cr
- src/daemon/funko.cr - src/daemon/funko.cr
- src/funko.cr
- spec/faaso_spec.cr - spec/faaso_spec.cr
Admonitions: Admonitions:
- TODO - TODO
@ -22,6 +20,16 @@ Documentation/DocumentationAdmonition:
Enabled: true Enabled: true
Severity: Warning Severity: Warning
# Problems found: 1
# Run `ameba --only Lint/UselessAssign` for details
Lint/UselessAssign:
Description: Disallows useless variable assignments
ExcludeTypeDeclarations: false
Excluded:
- src/daemon/config.cr
Enabled: true
Severity: Warning
# Problems found: 3 # Problems found: 3
# Run `ameba --only Naming/BlockParameterName` for details # Run `ameba --only Naming/BlockParameterName` for details
Naming/BlockParameterName: Naming/BlockParameterName:

View File

@ -18,4 +18,11 @@ http://*:8888 {
handle_path /admin/* { handle_path /admin/* {
reverse_proxy /* http://127.0.0.1:3000 reverse_proxy /* http://127.0.0.1:3000
} }
} handle_path /faaso/exp/* {
reverse_proxy /* http://faaso-exp-6ne49v:3000 {
health_uri /ping
fail_duration 30s
}
}
}

1
config/faaso.yml Normal file
View File

@ -0,0 +1 @@
password: admin

View File

@ -4,6 +4,10 @@ shards:
git: https://github.com/sija/backtracer.cr.git git: https://github.com/sija/backtracer.cr.git
version: 1.2.2 version: 1.2.2
cr-config:
git: https://github.com/crystal-community/cr-config.git
version: 5.1.0+git.commit.5eae3dfbf97da7dfa7c6e64a2a508069948518d3
crest: crest:
git: https://github.com/mamantoha/crest.git git: https://github.com/mamantoha/crest.git
version: 1.3.13 version: 1.3.13

View File

@ -19,6 +19,8 @@ dependencies:
github: mamantoha/crest github: mamantoha/crest
crinja: crinja:
github: straight-shoota/crinja github: straight-shoota/crinja
cr-config:
github: crystal-community/cr-config
crystar: crystar:
github: naqvis/crystar github: naqvis/crystar
docopt: docopt:
@ -26,14 +28,14 @@ dependencies:
docr: docr:
github: ralsina/docr github: ralsina/docr
branch: add_exposed_ports branch: add_exposed_ports
inotify:
github: petoem/inotify.cr
kemal: kemal:
github: kemalcr/kemal github: kemalcr/kemal
kemal-basic-auth: kemal-basic-auth:
github: kemalcr/kemal-basic-auth github: kemalcr/kemal-basic-auth
rucksack: rucksack:
github: busyloop/rucksack github: busyloop/rucksack
inotify:
github: petoem/inotify.cr
scripts: scripts:
postinstall: cat .rucksack >> bin/faaso postinstall: cat .rucksack >> bin/faaso

19
src/daemon/config.cr Normal file
View File

@ -0,0 +1,19 @@
require "cr-config"
class Config
include CrConfig
option password : String, default: "admin"
def self.load
builder = Config.new_builder
builder.providers do
[
CrConfig::Providers::SimpleFileProvider.new("config/faaso.yml"),
CrConfig::Providers::EnvVarProvider.new,
]
end
config = builder.build
Config.set_instance config
end
end

View File

@ -1,3 +1,4 @@
require "./config.cr"
require "./funko.cr" require "./funko.cr"
require "./proxy.cr" require "./proxy.cr"
require "./secrets.cr" require "./secrets.cr"
@ -9,7 +10,9 @@ require "kemal-basic-auth"
require "kemal" require "kemal"
require "uuid" require "uuid"
basic_auth "admin", "admin" Config.load
basic_auth "admin", Config.instance.password
macro version macro version
"{{ `grep version shard.yml | cut -d: -f2` }}".strip() "{{ `grep version shard.yml | cut -d: -f2` }}".strip()