Use Base class for default config assignment

This commit is contained in:
David Heinemeier Hansson
2023-01-07 21:29:33 +01:00
parent 517c23f37b
commit 55c5875321
5 changed files with 11 additions and 10 deletions

View File

@@ -1,4 +1,11 @@
module Mrsk::Commands
class Base
attr_accessor :config
def initialize(config)
@config = config
end
end
end
require "mrsk/commands/app"

View File

@@ -1,10 +1,4 @@
class Mrsk::Commands::App
attr_accessor :config
def initialize(config)
@config = config
end
class Mrsk::Commands::App < Mrsk::Commands::Base
def push
# TODO: Run 'docker buildx create --use' when needed
"docker buildx build --push --platform=linux/amd64,linux/arm64 -t #{config.image_with_version} ."

View File

@@ -1,4 +1,4 @@
class Mrsk::Commands::Registry
class Mrsk::Commands::Registry < Mrsk::Commands::Base
def login
if (user = ENV["DOCKER_USER"]).present? && (password = ENV["DOCKER_PASSWORD"]).present?
# FIXME: Find a way to hide PW so it's not shown on terminal

View File

@@ -1,4 +1,4 @@
class Mrsk::Commands::Traefik
class Mrsk::Commands::Traefik < Mrsk::Commands::Base
def start
"docker run --name traefik " +
"--rm -d " +

View File

@@ -1,6 +1,6 @@
require_relative "setup"
traefik = Mrsk::Commands::Traefik.new
traefik = Mrsk::Commands::Traefik.new(MRSK_CONFIG)
namespace :mrsk do
namespace :traefik do