forked from ManageIQ/manageiq-providers-embedded_terraform
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ManageIQ#2 from Adam-Grare/add_configuration_scrip…
…t_source_and_payload Add configuration script source and payload
- Loading branch information
Showing
4 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
.../manageiq/providers/embedded_terraform/automation_manager/configuration_script_payload.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class ManageIQ::Providers::EmbeddedTerraform::AutomationManager::ConfigurationScriptPayload < ManageIQ::Providers::EmbeddedAutomationManager::ConfigurationScriptPayload | ||
has_many :jobs, :class_name => 'OrchestrationStack', :foreign_key => :configuration_script_base_id | ||
|
||
def run(vars = {}, _userid = nil) | ||
end | ||
end |
36 changes: 36 additions & 0 deletions
36
...s/manageiq/providers/embedded_terraform/automation_manager/configuration_script_source.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
class ManageIQ::Providers::EmbeddedTerraform::AutomationManager::ConfigurationScriptSource < ManageIQ::Providers::EmbeddedAutomationManager::ConfigurationScriptSource | ||
FRIENDLY_NAME = "Embedded Terraform Repository".freeze | ||
|
||
def self.display_name(number = 1) | ||
n_('Repository (Embedded Terraform)', 'Repositories (Embedded Terraform)', number) | ||
end | ||
|
||
def sync | ||
update!(:status => "running") | ||
|
||
transaction do | ||
current = configuration_script_payloads.index_by(&:name) | ||
|
||
git_repository.update_repo | ||
git_repository.with_worktree do |worktree| | ||
worktree.ref = scm_branch | ||
worktree.blob_list.each do |filename| | ||
next if filename.start_with?(".") || !filename.end_with?(".tf") | ||
|
||
payload = worktree.read_file(filename) | ||
found = current.delete(filename) || self.class.module_parent::ConfigurationScriptPayload.new(:configuration_script_source_id => id) | ||
|
||
found.update!(:name => filename, :manager_id => manager_id, :payload => payload, :payload_type => "json") | ||
end | ||
end | ||
|
||
current.values.each(&:destroy) | ||
configuration_script_payloads.reload | ||
end | ||
|
||
update!(:status => "successful", :last_updated_on => Time.zone.now, :last_update_error => nil) | ||
rescue => error | ||
update!(:status => "error", :last_updated_on => Time.zone.now, :last_update_error => error) | ||
raise error | ||
end | ||
end |
2 changes: 2 additions & 0 deletions
2
app/models/manageiq/providers/embedded_terraform/automation_manager/credential.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class ManageIQ::Providers::EmbeddedTerraform::AutomationManager::Credential < ManageIQ::Providers::EmbeddedAutomationManager::Authentication | ||
end |
5 changes: 5 additions & 0 deletions
5
app/models/manageiq/providers/embedded_terraform/automation_manager/scm_credential.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class ManageIQ::Providers::EmbeddedTerraform::AutomationManager::ScmCredential < ManageIQ::Providers::EmbeddedTerraform::AutomationManager::Credential | ||
include ManageIQ::Providers::EmbeddedAutomationManager::ScmCredentialMixin | ||
|
||
FRIENDLY_NAME = "Embedded Terraform SCM Credential".freeze | ||
end |