Class: Manifest
- Inherits:
-
Object
- Object
- Manifest
- Defined in:
- lib/conan/manifest_builder.rb
Instance Method Summary collapse
- #appVersion(pipeline_id, app_id) ⇒ Object
- #bg_clean ⇒ Object
- #bg_configure ⇒ Object
- #bg_deploy ⇒ Object
- #bg_switch ⇒ Object
- #configure ⇒ Object
- #deploy ⇒ Object
- #environment(env_id, &block) ⇒ Object
-
#initialize(options, artifact_repo, output) ⇒ Manifest
constructor
A new instance of Manifest.
- #paas ⇒ Object
- #pipeline(pipeline_id, &block) ⇒ Object
- #provision ⇒ Object
-
#select(pipeline_id, env_id) ⇒ Object
select a pipeline and environment to do operations on.
- #validateThatEnvironmentIsSelected ⇒ Object
Constructor Details
#initialize(options, artifact_repo, output) ⇒ Manifest
Returns a new instance of Manifest.
30 31 32 33 34 35 36 |
# File 'lib/conan/manifest_builder.rb', line 30 def initialize(, artifact_repo, output) @pipelines = {} @environments = {} @options = @artifact_repo = artifact_repo @output = output end |
Instance Method Details
#appVersion(pipeline_id, app_id) ⇒ Object
63 64 65 |
# File 'lib/conan/manifest_builder.rb', line 63 def appVersion(pipeline_id, app_id) @pipelines[pipeline_id].appVersion(app_id) end |
#bg_clean ⇒ Object
129 130 131 132 133 134 |
# File 'lib/conan/manifest_builder.rb', line 129 def bg_clean validateThatEnvironmentIsSelected puts "Blue/green clean #{@current_environment.id} for #{@current_pipeline.id} pipeline" @current_pipeline.bg_clean(@current_environment, paas) end |
#bg_configure ⇒ Object
80 81 82 83 84 |
# File 'lib/conan/manifest_builder.rb', line 80 def bg_configure validateThatEnvironmentIsSelected puts "Blue/green configure #{@current_environment.id} manifest files for #{@current_pipeline.id} pipeline" @current_pipeline.configure(@current_environment, true) end |
#bg_deploy ⇒ Object
113 114 115 116 117 118 119 120 |
# File 'lib/conan/manifest_builder.rb', line 113 def bg_deploy validateThatEnvironmentIsSelected puts "Blue/green deploy #{@current_environment.id} for #{@current_pipeline.id} pipeline" force = @options[:'force-deploy'] || false @current_pipeline.bg_deploy(@current_environment, paas, force) end |
#bg_switch ⇒ Object
122 123 124 125 126 127 |
# File 'lib/conan/manifest_builder.rb', line 122 def bg_switch validateThatEnvironmentIsSelected puts "Blue/green switch #{@current_environment.id} for #{@current_pipeline.id} pipeline" @current_pipeline.bg_switch(@current_environment, paas) end |
#configure ⇒ Object
74 75 76 77 78 |
# File 'lib/conan/manifest_builder.rb', line 74 def configure validateThatEnvironmentIsSelected puts "Configure #{@current_environment.id} manifest files for #{@current_pipeline.id} pipeline" @current_pipeline.configure(@current_environment) end |
#deploy ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/conan/manifest_builder.rb', line 95 def deploy validateThatEnvironmentIsSelected puts "Deploy #{@current_environment.id} for #{@current_pipeline.id} pipeline" nr_api_key = @options[:'new-relic-api-key'] || ENV['NEWRELIC_API_KEY'] force = @options[:'force-deploy'] || false @current_pipeline.deploy(@current_environment, paas, force) { |app_name| if (nr_api_key) puts 'Reporting Deployment to New Relic' job = @options[:'job-url'] || 'nexus-app-manifest' NewRelic.alertDeployment(nr_api_key, app_name, "Deployed by #{job}") else puts "WARNING: Skipping New Relic alert. No API defined" end } end |
#environment(env_id, &block) ⇒ Object
56 57 58 59 60 61 |
# File 'lib/conan/manifest_builder.rb', line 56 def environment(env_id, &block) e = Environment.new(env_id) e.instance_eval(&block) @environments[env_id] = e e end |
#paas ⇒ Object
86 87 88 89 90 91 92 93 |
# File 'lib/conan/manifest_builder.rb', line 86 def paas paas_user = @options[:'paas-user'] || ENV['PAAS_USER'] paas_pwd = @options[:'paas-password'] || ENV['PAAS_PASSWORD'] dry_run = @options[:'dry-run'] || false trace = @options[:'verbose'] || false Stackato.new(paas_user, paas_pwd, trace, dry_run) end |
#pipeline(pipeline_id, &block) ⇒ Object
49 50 51 52 53 54 |
# File 'lib/conan/manifest_builder.rb', line 49 def pipeline(pipeline_id, &block) pl = Pipeline.new(pipeline_id, @artifact_repo, @output) pl.instance_eval(&block) @pipelines[pipeline_id] = pl pl end |
#provision ⇒ Object
67 68 69 70 71 72 |
# File 'lib/conan/manifest_builder.rb', line 67 def provision validateThatEnvironmentIsSelected # TODO banners puts "Update #{@current_environment.id} manifest files for #{@current_pipeline.id} pipeline" @current_pipeline.update(@current_environment, @environments[@current_environment.upstream_env]) end |
#select(pipeline_id, env_id) ⇒ Object
select a pipeline and environment to do operations on
39 40 41 42 43 44 45 46 47 |
# File 'lib/conan/manifest_builder.rb', line 39 def select(pipeline_id, env_id) env = @environments[env_id] raise ArgumentError.new "Invalid environment id: '#{env_id}'. Valid options are #{@environments.keys.join(", ")}" if env.nil? @current_environment = env pl = @pipelines[pipeline_id] raise ArgumentError.new "Invalid pipeline id: '#{pipeline_id}'. Valid options are #{@pipelines.keys.join(", ")}" if pl.nil? @current_pipeline = pl pl.load!(env, @options[:'deploy-shipcloud']) end |
#validateThatEnvironmentIsSelected ⇒ Object
136 137 138 139 140 |
# File 'lib/conan/manifest_builder.rb', line 136 def validateThatEnvironmentIsSelected unless @current_environment && @current_pipeline raise ScriptError, 'Environment and Pipeline must be selected' end end |