Skip to content

Commit

Permalink
Added config support for daemon, made password configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
ralsina committed Jul 7, 2024
1 parent 3e4c940 commit 31ab544
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 8 deletions.
16 changes: 12 additions & 4 deletions .ameba.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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:
Expand Down
9 changes: 8 additions & 1 deletion config/Caddyfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

}
1 change: 1 addition & 0 deletions config/faaso.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
password: admin
4 changes: 4 additions & 0 deletions shard.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions shard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,23 @@ dependencies:
github: mamantoha/crest
crinja:
github: straight-shoota/crinja
cr-config:
github: crystal-community/cr-config
crystar:
github: naqvis/crystar
docopt:
github: chenkovsky/docopt.cr
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
19 changes: 19 additions & 0 deletions src/daemon/config.cr
Original file line number Diff line number Diff line change
@@ -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
5 changes: 4 additions & 1 deletion src/daemon/main.cr
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require "./config.cr"
require "./funko.cr"
require "./proxy.cr"
require "./secrets.cr"
Expand All @@ -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()
Expand Down

0 comments on commit 31ab544

Please sign in to comment.