module Dalmatian
  class RdsDeployment
    include Deployable

    def initialize(
      rds:,
      env:,
      auto_approve: false,
      plan: false,
      destroy: false,
      verbose: false
    )
      @rds = rds
      @env = env
      @helper = Helper
      @logger = Logger
      @auto_approve = auto_approve
      @plan = plan
      @destroy = destroy
      @verbose = verbose
    end

    private

    attr_reader :rds, :env, :helper, :logger, :auto_approve, :plan, :destroy, :verbose

    def target_directory
      File.join(
        Infrastructure::APP_ROOT,
        Infrastructure::PATH,
        "rds"
      )
    end

    def env_config
      env_details.merge(
        "account_id" => rds.account_id,
        "infrastructure_name" => rds.cluster_id,
        "dalmatian_role" => dalmatian_role,
        "rds" => rds.to_params
      )
    end

    def checkout_revision_if_required
      false
    end

    def workspace_name
      [rds.cluster_id, rds.identifier, "rds", env_name].join("-")
    end
  end
end
