Class: Kitsune::Kit::Workflows::EjectCompose
- Inherits:
-
Object
- Object
- Kitsune::Kit::Workflows::EjectCompose
- Defined in:
- lib/kitsune/kit/workflows/eject_compose.rb
Constant Summary collapse
- TYPES =
%w[postgres redis].freeze
Instance Method Summary collapse
- #call(force: false) ⇒ Object
-
#initialize(root:, config:, type:, config_path: nil) ⇒ EjectCompose
constructor
A new instance of EjectCompose.
Constructor Details
#initialize(root:, config:, type:, config_path: nil) ⇒ EjectCompose
Returns a new instance of EjectCompose.
16 17 18 19 20 21 |
# File 'lib/kitsune/kit/workflows/eject_compose.rb', line 16 def initialize(root:, config:, type:, config_path: nil) @root = Pathname(root). @config = config @type = type.to_s @config_path = config_path ? Pathname(config_path).(@root) : @root.join(".kitsune/config.yml") end |
Instance Method Details
#call(force: false) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/kitsune/kit/workflows/eject_compose.rb', line 23 def call(force: false) @backup_created = false validate_target!(force) content = ServiceCompose.new(config: config, type: type, service: service).generated_content FileUtils.mkdir_p(output_path.dirname, mode: 0o700) FileUtils.cp(config_path, backup_path) @backup_created = true write_atomic(output_path, content, 0o644) update_configuration { compose_file: output_path.to_s, config_file: config_path.to_s, backup_file: backup_path.to_s } rescue StandardError FileUtils.cp(backup_path, config_path) if @backup_created && backup_path.file? raise end |