Skip to content

Commit

Permalink
Allow for Custom Accessory Service Name
Browse files Browse the repository at this point in the history
  • Loading branch information
rience committed Sep 30, 2023
1 parent 83a2d52 commit 89e5bcc
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/kamal/configuration/accessory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def initialize(name, config:)
end

def service_name
"#{config.service}-#{name}"
specifics['service'] || "#{config.service}-#{name}"
end

def image
Expand Down
3 changes: 2 additions & 1 deletion test/commands/accessory_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class CommandsAccessoryTest < ActiveSupport::TestCase
]
},
"busybox" => {
"service" => "custom-busybox",
"image" => "busybox:latest",
"host" => "1.1.1.7"
}
Expand All @@ -57,7 +58,7 @@ class CommandsAccessoryTest < ActiveSupport::TestCase
new_command(:redis).run.join(" ")

assert_equal \
"docker run --name app-busybox --detach --restart unless-stopped --log-opt max-size=\"10m\" --env-file .kamal/env/accessories/app-busybox.env --label service=\"app-busybox\" busybox:latest",
"docker run --name custom-busybox --detach --restart unless-stopped --log-opt max-size=\"10m\" --env-file .kamal/env/accessories/custom-busybox.env --label service=\"custom-busybox\" busybox:latest",
new_command(:busybox).run.join(" ")
end

Expand Down
2 changes: 2 additions & 0 deletions test/configuration/accessory_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class ConfigurationAccessoryTest < ActiveSupport::TestCase
}
},
"monitoring" => {
"service" => "custom-monitoring",
"image" => "monitoring:latest",
"roles" => [ "web" ],
"port" => "4321:4321",
Expand All @@ -72,6 +73,7 @@ class ConfigurationAccessoryTest < ActiveSupport::TestCase
test "service name" do
assert_equal "app-mysql", @config.accessory(:mysql).service_name
assert_equal "app-redis", @config.accessory(:redis).service_name
assert_equal "custom-monitoring", @config.accessory(:monitoring).service_name
end

test "port" do
Expand Down
1 change: 1 addition & 0 deletions test/integration/docker/deployer/app/config/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ traefik:
image: registry:4443/traefik:v2.9
accessories:
busybox:
service: custom-busybox
image: registry:4443/busybox:1.36.0
cmd: sh -c 'echo "Starting busybox..."; trap exit term; while true; do sleep 1; done'
roles:
Expand Down

0 comments on commit 89e5bcc

Please sign in to comment.