Class: ActivePostgres::DeploymentFlow

Inherits:
Object
  • Object
show all
Includes:
ComponentResolver
Defined in:
lib/active_postgres/deployment_flow.rb

Direct Known Subclasses

ClusterDeploymentFlow, StandbyDeploymentFlow

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ComponentResolver

#component_class_for

Constructor Details

#initialize(config, ssh_executor:, secrets:, logger:, rollback_manager:, skip_validation: false) ⇒ DeploymentFlow

Returns a new instance of DeploymentFlow.



7
8
9
10
11
12
13
14
# File 'lib/active_postgres/deployment_flow.rb', line 7

def initialize(config, ssh_executor:, secrets:, logger:, rollback_manager:, skip_validation: false)
  @config = config
  @ssh_executor = ssh_executor
  @secrets = secrets
  @logger = logger
  @rollback_manager = rollback_manager
  @skip_validation = skip_validation
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



5
6
7
# File 'lib/active_postgres/deployment_flow.rb', line 5

def config
  @config
end

#loggerObject (readonly)

Returns the value of attribute logger.



5
6
7
# File 'lib/active_postgres/deployment_flow.rb', line 5

def logger
  @logger
end

#rollback_managerObject (readonly)

Returns the value of attribute rollback_manager.



5
6
7
# File 'lib/active_postgres/deployment_flow.rb', line 5

def rollback_manager
  @rollback_manager
end

#secretsObject (readonly)

Returns the value of attribute secrets.



5
6
7
# File 'lib/active_postgres/deployment_flow.rb', line 5

def secrets
  @secrets
end

#skip_validationObject (readonly)

Returns the value of attribute skip_validation.



5
6
7
# File 'lib/active_postgres/deployment_flow.rb', line 5

def skip_validation
  @skip_validation
end

#ssh_executorObject (readonly)

Returns the value of attribute ssh_executor.



5
6
7
# File 'lib/active_postgres/deployment_flow.rb', line 5

def ssh_executor
  @ssh_executor
end

Instance Method Details

#executeObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/active_postgres/deployment_flow.rb', line 16

def execute
  ErrorHandler.with_handling(context: { operation: operation_name }) do
    print_header
    validate_prerequisites
    run_preflight_checks unless skip_validation
    print_deployment_plan
    return unless confirm_deployment

    rollback_manager.with_rollback(description: operation_name) do
      deploy_components
    end

    print_success_message
  end
end