diff --git a/.ameba.yml b/.ameba.yml index ce61d04..58066a6 100644 --- a/.ameba.yml +++ b/.ameba.yml @@ -1,19 +1,17 @@ # 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 # 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 Documentation/DocumentationAdmonition: Description: Reports documentation admonitions Timezone: UTC Excluded: - src/secrets.cr - - src/daemon/main.cr - src/daemon/secrets.cr - src/daemon/funko.cr - - src/funko.cr - spec/faaso_spec.cr Admonitions: - TODO @@ -22,6 +20,16 @@ Documentation/DocumentationAdmonition: Enabled: true 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 # Run `ameba --only Naming/BlockParameterName` for details Naming/BlockParameterName: diff --git a/config/Caddyfile b/config/Caddyfile index 10e2a6b..1ebaa3e 100644 --- a/config/Caddyfile +++ b/config/Caddyfile @@ -18,4 +18,11 @@ http://*:8888 { handle_path /admin/* { 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 + } + } + +} \ No newline at end of file diff --git a/config/faaso.yml b/config/faaso.yml new file mode 100644 index 0000000..2f89fe7 --- /dev/null +++ b/config/faaso.yml @@ -0,0 +1 @@ +password: admin diff --git a/shard.lock b/shard.lock index cda5233..9353b2d 100644 --- a/shard.lock +++ b/shard.lock @@ -4,6 +4,10 @@ shards: git: https://github.com/sija/backtracer.cr.git version: 1.2.2 + cr-config: + git: https://github.com/crystal-community/cr-config.git + version: 5.1.0+git.commit.5eae3dfbf97da7dfa7c6e64a2a508069948518d3 + crest: git: https://github.com/mamantoha/crest.git version: 1.3.13 diff --git a/shard.yml b/shard.yml index 0d8c123..aa215a7 100644 --- a/shard.yml +++ b/shard.yml @@ -19,6 +19,8 @@ dependencies: github: mamantoha/crest crinja: github: straight-shoota/crinja + cr-config: + github: crystal-community/cr-config crystar: github: naqvis/crystar docopt: @@ -26,14 +28,14 @@ dependencies: docr: github: ralsina/docr branch: add_exposed_ports + inotify: + github: petoem/inotify.cr kemal: github: kemalcr/kemal kemal-basic-auth: github: kemalcr/kemal-basic-auth rucksack: github: busyloop/rucksack - inotify: - github: petoem/inotify.cr scripts: postinstall: cat .rucksack >> bin/faaso diff --git a/src/daemon/config.cr b/src/daemon/config.cr new file mode 100644 index 0000000..baedb86 --- /dev/null +++ b/src/daemon/config.cr @@ -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 diff --git a/src/daemon/main.cr b/src/daemon/main.cr index af15829..57e5df4 100644 --- a/src/daemon/main.cr +++ b/src/daemon/main.cr @@ -1,3 +1,4 @@ +require "./config.cr" require "./funko.cr" require "./proxy.cr" require "./secrets.cr" @@ -9,7 +10,9 @@ require "kemal-basic-auth" require "kemal" require "uuid" -basic_auth "admin", "admin" +Config.load + +basic_auth "admin", Config.instance.password macro version "{{ `grep version shard.yml | cut -d: -f2` }}".strip()