vcloud-converter 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 50c056b64637d0413f577fa846893d270b6c89e4
4
+ data.tar.gz: 292b1fe920a962276b3f98ac9de8027371b454d6
5
+ SHA512:
6
+ metadata.gz: 9ae395e8fcaf1ca3f02101c2a7c6d12043afc8245dec6fef8d23f54c834812632f9dc4fd3cf7a728c02be4d864b55eccd5fd8fab6f63e8fed4679a4242c3a41d
7
+ data.tar.gz: 608969659e357fb4b6ca1df777759dfa76345968e76d0b8df22b2c7b089ddc5c96603b11c89d27f8e557f4594d59bc267aed7d1b2f8b0d1d4110a09f3a7a63a7
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1 @@
1
+ 2.4.0
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.0
5
+ before_install: gem install bundler -v 1.15.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in vcloud-converter.gemspec
4
+ gemspec
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env groovy
2
+
3
+ node {
4
+ def govuk = load '/var/lib/jenkins/groovy_scripts/govuk_jenkinslib.groovy'
5
+ govuk.buildProject()
6
+ }
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Laura Martin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,42 @@
1
+ # vCloud Converter
2
+
3
+ vCloud Converter turns your vCloud Tools manifests files into [Terraform](https://www.terraform.io/).
4
+
5
+ [vCloud Tools](https://github.com/gds-operations/vcloud-tools) is now considered feature complete
6
+ and so it is recommended to migrate to a newer tool for infrastructure deployment.
7
+
8
+ vCloud Converter strives to help make this change easier.
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'vcloud-converter'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install vcloud-converter
25
+
26
+ ## Usage
27
+
28
+ TODO: Write usage instructions here
29
+
30
+ ## Development
31
+
32
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
33
+
34
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
35
+
36
+ ## Contributing
37
+
38
+ Bug reports and pull requests are welcome on GitHub at https://github.com/surminus/vcloud-converter.
39
+
40
+ ## License
41
+
42
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "vcloud/converter"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "vcloud/converter"
5
+ require "optparse"
6
+
7
+ ARGV << '-h' if ARGV.empty?
8
+ options = {}
9
+ OptionParser.new do |opts|
10
+ opts.banner = "Usage: ./bin/convert -t vcloud-net_launcher -p path/to/file.yaml"
11
+
12
+ opts.on('-t', '--type TYPE', 'Type of YAML file for conversion.') { |v| options[:type] = v }
13
+ opts.on('-p', '--path PATH', 'Path to YAML file for conversion.') { |v| options[:path] = v }
14
+
15
+ opts.on_tail("-h", "--help", "Show this help message.") do
16
+ puts opts
17
+ exit
18
+ end
19
+ end.parse!
20
+
21
+ if File.exists?(File.expand_path(options[:path]))
22
+ Vcloud::Converter.convert(options[:type], options[:path])
23
+ else
24
+ puts "The file you specified - #{options[:path]} - doesn't exist."
25
+ exit
26
+ end
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,39 @@
1
+ require "vcloud/converter/version"
2
+ require "yaml"
3
+ require "erb"
4
+
5
+ module Vcloud
6
+ module Converter
7
+ def self.convert(conversion_type, file_path)
8
+ if conversion_type == "vcloud-net_launcher"
9
+ convert_vcloud_net_launcher(file_path)
10
+ end
11
+ end
12
+
13
+ def self.convert_vcloud_net_launcher(file_path)
14
+ begin
15
+ vcloud_config = YAML.load_file(file_path)
16
+ rescue Psych::SyntaxError
17
+ puts "Your YAML file had a syntax error!"
18
+ exit
19
+ else
20
+ name = vcloud_config.first.first
21
+
22
+ vcloud_config[name].each do |machine|
23
+ vdc_name = machine["vdc_name"]
24
+ edge_gateway = machine["edge_gateway"]
25
+ gateway = machine["gateway"]
26
+ netmask = machine["netmask"]
27
+ dns1 = machine["dns1"]
28
+ dns2 = machine["dns2"]
29
+ dns_suffix = machine["dns_suffix"]
30
+
31
+ start_address = machine["ip_ranges"][0]["start_address"]
32
+ end_address = machine["ip_ranges"][0]["end_address"]
33
+
34
+ puts ERB.new(File.read("./templates/vcd_networks.tf.erb")).result(binding)
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,5 @@
1
+ module Vcloud
2
+ module Converter
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,14 @@
1
+ resource "vcd_network" "<%= name %>" {
2
+ name = "<%= vdc_name %>"
3
+ edge_gateway = "<%= edge_gateway %>"
4
+ gateway = "<%= gateway %>"
5
+ netmask = "<%= netmask %>"
6
+ dns1 = "<%= dns1 %>"
7
+ dns2 = "<%= dns2 %>"
8
+ dns_suffix = "<%= dns_suffix %>"
9
+
10
+ static_ip_pool {
11
+ start_address = "<%= start_address %>"
12
+ end_address = "<%= end_address %>"
13
+ }
14
+ }
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "vcloud/converter/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "vcloud-converter"
8
+ spec.version = Vcloud::Converter::VERSION
9
+ spec.authors = ["GOV.UK Infrastructure"]
10
+ spec.email = ["vcloud-tools@digital.cabinet-office.gov.uk"]
11
+ spec.summary = 'Convert your vCloud Tools manifests to Terraform'
12
+ spec.description = 'Convert your vCloud Tools manifests to Terraform'
13
+ spec.homepage = 'http://github.com/alphagov/vcloud-converter'
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = "bin/"
20
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.15"
24
+ spec.add_development_dependency "rake", "~> 12.0"
25
+ spec.add_development_dependency "rspec", "~> 3.6"
26
+ end
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vcloud-converter
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - GOV.UK Infrastructure
8
+ autorequire:
9
+ bindir: bin/
10
+ cert_chain: []
11
+ date: 2017-08-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.15'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.15'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '12.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '12.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.6'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.6'
55
+ description: Convert your vCloud Tools manifests to Terraform
56
+ email:
57
+ - vcloud-tools@digital.cabinet-office.gov.uk
58
+ executables:
59
+ - console
60
+ - convert
61
+ - setup
62
+ extensions: []
63
+ extra_rdoc_files: []
64
+ files:
65
+ - ".gitignore"
66
+ - ".rspec"
67
+ - ".ruby-version"
68
+ - ".travis.yml"
69
+ - Gemfile
70
+ - Jenkinsfile
71
+ - LICENSE.txt
72
+ - README.md
73
+ - Rakefile
74
+ - bin/console
75
+ - bin/convert
76
+ - bin/setup
77
+ - lib/vcloud/converter.rb
78
+ - lib/vcloud/converter/version.rb
79
+ - templates/vcd_networks.tf.erb
80
+ - vcloud-converter.gemspec
81
+ homepage: http://github.com/alphagov/vcloud-converter
82
+ licenses:
83
+ - MIT
84
+ metadata: {}
85
+ post_install_message:
86
+ rdoc_options: []
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ requirements: []
100
+ rubyforge_project:
101
+ rubygems_version: 2.6.8
102
+ signing_key:
103
+ specification_version: 4
104
+ summary: Convert your vCloud Tools manifests to Terraform
105
+ test_files: []