terraspace_ci_codebuild 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 34396907944621238c65ce5b7bc8f6b992d5148cbb0985a60159b57b854a66ad
4
+ data.tar.gz: f5e64f7acea913e8a15d66e60fd9bf1c21b4853e12dccb6f188ae7eadbe78903
5
+ SHA512:
6
+ metadata.gz: 07ca580b7b4517241d1cdcfe4e9b4e0864432a4583367440cce3b7dbd3a9cf904f7bbffebaf22d8771daa7bd857376f413b11919f9ea734c1b81ae040f272c4c
7
+ data.tar.gz: bfe4b4bed48703f51bbefdaaa7a713aae2f294bff45636254b0f2c3370023ccd4f205be743ce91dc325fe8baee3a30bf8cca3691dc8088abc0f18effbceb2504
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ This project *tries* to adhere to [Semantic Versioning](http://semver.org/).
5
+
6
+ ## [0.1.0] - 2022-06-10
7
+
8
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in gemspec
6
+ gemspec
7
+
8
+ gem "rake"
9
+ gem "rspec"
10
+ gem "rubocop"
11
+
12
+ group :development, :test do
13
+ gem "terraspace"
14
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Tung Nguyen
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.
data/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # terraspace_ci_codebuild
2
+
3
+ Provides Terraspace CI support for AWS CodeBuild.
4
+
5
+ ## Installation
6
+
7
+ Add gem to your Terraspace project
8
+
9
+ Gemfile
10
+
11
+ gem terraspace_ci_codebuild
12
+
13
+ Then to install run
14
+
15
+ bundle
16
+
17
+ ## Contributing
18
+
19
+ Bug reports and pull requests are welcome on GitHub at https://github.com/boltops-tools/terraspace_ci_codebuild/
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -0,0 +1,11 @@
1
+ #!/bin/bash
2
+ # install terraform
3
+ git clone https://github.com/tfutils/tfenv.git ~/.tfenv
4
+ export PATH="$HOME/.tfenv/bin:$PATH"
5
+ tfenv install latest
6
+ tfenv use latest
7
+ terraform --version
8
+ # install terraspace
9
+ bundle
10
+ bundle exec terraspace new shim
11
+ export PATH="/usr/local/bin:$PATH"
@@ -0,0 +1,5 @@
1
+ #!/bin/bash
2
+ export PATH="$HOME/.tfenv/bin:$PATH"
3
+ type terraform
4
+ export PATH="/usr/local/bin:$PATH"
5
+ exec terraspace "$@"
@@ -0,0 +1,23 @@
1
+ require "zeitwerk"
2
+
3
+ module TerraspaceCiCodebuild
4
+ class Autoloader
5
+ class Inflector < Zeitwerk::Inflector
6
+ def camelize(basename, _abspath)
7
+ map = { version: "VERSION" }
8
+ map[basename.to_sym] || super
9
+ end
10
+ end
11
+
12
+ class << self
13
+ def setup
14
+ loader = Zeitwerk::Loader.new
15
+ loader.inflector = Inflector.new
16
+ loader.push_dir(File.dirname(__dir__)) # lib
17
+ loader.log! if ENV["TERRASPACE_CI_CODEBUILD_AUTOLOAD_LOG"]
18
+ loader.setup
19
+ end
20
+ end
21
+ end
22
+ end
23
+
@@ -0,0 +1,8 @@
1
+ module TerraspaceCiCodebuild
2
+ class Interface
3
+ # required interface
4
+ def vars
5
+ Vars.new.data
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,43 @@
1
+ require "uri"
2
+
3
+ module TerraspaceCiCodebuild
4
+ class Vars
5
+ # Interface method. Hash of properties to be stored
6
+ # Usually available from env vars.
7
+ # Provide as many CI system as possible.
8
+ def data
9
+ {
10
+ build_system: "codebuild",
11
+ host: host,
12
+ full_repo: full_repo,
13
+ branch_name: ENV['CODEBUILD_SOURCE_VERSION'],
14
+ # urls
15
+ build_url: ENV['CODEBUILD_BUILD_URL'],
16
+ build_id: ENV['CODEBUILD_BUILD_ID'],
17
+ build_number: ENV['CODEBUILD_BUILD_NUMBER'],
18
+ build_type: "push", # not available from env var. hard coded and really only type supported
19
+ sha: ENV['CODEBUILD_RESOLVED_SOURCE_VERSION'],
20
+ # commit_message: ENV['REPLACE_ME'],
21
+ # pr_url: ENV['REPLACE_ME'],
22
+ # pr_number: ENV['REPLACE_ME'],
23
+ }
24
+ end
25
+
26
+ def host
27
+ uri = URI(ENV['CODEBUILD_SOURCE_REPO_URL']) # https://github.com/ORG/REPO
28
+ "#{uri.scheme}://#{uri.host}"
29
+ end
30
+
31
+ # ORG/REPO
32
+ def full_repo
33
+ uri = URI(repo_url)
34
+ uri.path.sub(/^\//,'')
35
+ end
36
+
37
+ # https://github.com/ORG/REPO
38
+ def repo_url
39
+ # https://github.com/ORG/REPO.git
40
+ ENV['CODEBUILD_SOURCE_REPO_URL'].sub('.git','')
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TerraspaceCiCodebuild
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "terraspace_ci_codebuild/autoloader"
4
+ TerraspaceCiCodebuild::Autoloader.setup
5
+
6
+ require "json"
7
+
8
+ module TerraspaceCiCodebuild
9
+ class Error < StandardError; end
10
+ end
11
+
12
+ require "terraspace"
13
+ Terraspace::Cloud::Ci.register(
14
+ name: "codebuild",
15
+ env_key: "CODEBUILD_CI",
16
+ root: __dir__,
17
+ exe: ".cody/bin",
18
+ )
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/terraspace_ci_codebuild/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "terraspace_ci_codebuild"
7
+ spec.version = TerraspaceCiCodebuild::VERSION
8
+ spec.authors = ["Tung Nguyen"]
9
+ spec.email = ["tung@boltops.com"]
10
+
11
+ spec.summary = "Terraspace CI AWS CodeBuild support"
12
+ spec.homepage = "https://github.com/boltops-tools/terraspace_ci_codebuild"
13
+ spec.license = "MIT"
14
+ spec.required_ruby_version = ">= 2.6.0"
15
+
16
+ spec.metadata["homepage_uri"] = spec.homepage
17
+ spec.metadata["source_code_uri"] = "https://github.com/boltops-tools/terraspace_ci_codebuild"
18
+ spec.metadata["changelog_uri"] = "https://github.com/boltops-tools/terraspace_ci_codebuild/blob/master/CHANGELOG.md"
19
+
20
+ # Specify which files should be added to the gem when it is released.
21
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
+ spec.files = Dir.chdir(__dir__) do
23
+ `git ls-files -z`.split("\x0").reject do |f|
24
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
25
+ end
26
+ end
27
+ spec.bindir = "exe"
28
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ["lib"]
30
+
31
+ spec.add_dependency "zeitwerk"
32
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: terraspace_ci_codebuild
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Tung Nguyen
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-06-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: zeitwerk
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description:
28
+ email:
29
+ - tung@boltops.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".rspec"
35
+ - ".rubocop.yml"
36
+ - CHANGELOG.md
37
+ - Gemfile
38
+ - LICENSE.txt
39
+ - README.md
40
+ - Rakefile
41
+ - lib/template/.cody/bin/install
42
+ - lib/template/.cody/bin/terraspace
43
+ - lib/terraspace_ci_codebuild.rb
44
+ - lib/terraspace_ci_codebuild/autoloader.rb
45
+ - lib/terraspace_ci_codebuild/interface.rb
46
+ - lib/terraspace_ci_codebuild/vars.rb
47
+ - lib/terraspace_ci_codebuild/version.rb
48
+ - terraspace_ci_codebuild.gemspec
49
+ homepage: https://github.com/boltops-tools/terraspace_ci_codebuild
50
+ licenses:
51
+ - MIT
52
+ metadata:
53
+ homepage_uri: https://github.com/boltops-tools/terraspace_ci_codebuild
54
+ source_code_uri: https://github.com/boltops-tools/terraspace_ci_codebuild
55
+ changelog_uri: https://github.com/boltops-tools/terraspace_ci_codebuild/blob/master/CHANGELOG.md
56
+ post_install_message:
57
+ rdoc_options: []
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: 2.6.0
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ requirements: []
71
+ rubygems_version: 3.3.12
72
+ signing_key:
73
+ specification_version: 4
74
+ summary: Terraspace CI AWS CodeBuild support
75
+ test_files: []