Class: Clusters::Migration::CreateService
- Inherits:
-
Object
- Object
- Clusters::Migration::CreateService
- Defined in:
- app/services/clusters/migration/create_service.rb
Instance Attribute Summary collapse
-
#agent_name ⇒ Object
readonly
Returns the value of attribute agent_name.
-
#cluster ⇒ Object
readonly
Returns the value of attribute cluster.
-
#clusterable ⇒ Object
readonly
Returns the value of attribute clusterable.
-
#configuration_project ⇒ Object
readonly
Returns the value of attribute configuration_project.
-
#current_user ⇒ Object
readonly
Returns the value of attribute current_user.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(cluster, current_user:, configuration_project_id:, agent_name:) ⇒ CreateService
constructor
A new instance of CreateService.
Constructor Details
#initialize(cluster, current_user:, configuration_project_id:, agent_name:) ⇒ CreateService
Returns a new instance of CreateService.
8 9 10 11 12 13 14 |
# File 'app/services/clusters/migration/create_service.rb', line 8 def initialize(cluster, current_user:, configuration_project_id:, agent_name:) @cluster = cluster @clusterable = cluster.clusterable @current_user = current_user @configuration_project = find_configuration_project(configuration_project_id) @agent_name = agent_name end |
Instance Attribute Details
#agent_name ⇒ Object (readonly)
Returns the value of attribute agent_name.
6 7 8 |
# File 'app/services/clusters/migration/create_service.rb', line 6 def agent_name @agent_name end |
#cluster ⇒ Object (readonly)
Returns the value of attribute cluster.
6 7 8 |
# File 'app/services/clusters/migration/create_service.rb', line 6 def cluster @cluster end |
#clusterable ⇒ Object (readonly)
Returns the value of attribute clusterable.
6 7 8 |
# File 'app/services/clusters/migration/create_service.rb', line 6 def clusterable @clusterable end |
#configuration_project ⇒ Object (readonly)
Returns the value of attribute configuration_project.
6 7 8 |
# File 'app/services/clusters/migration/create_service.rb', line 6 def configuration_project @configuration_project end |
#current_user ⇒ Object (readonly)
Returns the value of attribute current_user.
6 7 8 |
# File 'app/services/clusters/migration/create_service.rb', line 6 def current_user @current_user end |
Instance Method Details
#execute ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/services/clusters/migration/create_service.rb', line 16 def execute validation_error = validate_inputs return validation_error if validation_error.present? agent_creation_response = agent_creation_service.execute return agent_creation_response unless agent_creation_response.success? agent = agent_creation_response[:cluster_agent] token_creation_response = token_creation_service(agent).execute return token_creation_response unless token_creation_response.success? migration = Clusters::AgentMigration.new( cluster: cluster, agent: agent, project: configuration_project, agent_name: agent_name ) if migration.save Clusters::Migration::InstallAgentWorker.perform_async(migration.id) ServiceResponse.success else error_response(message: migration.errors.) end end |