terraspace_ci_bitbucket 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7975dcf44742b099697b1331e0420a517015bde5b03e44a2945881916102f35e
4
+ data.tar.gz: d749a49df01319ddaf558569606e245cd69a37ad8701dff660e898603fb20a87
5
+ SHA512:
6
+ metadata.gz: 77f5c7b4527caa83a17d55e2272c20dad14acda46b2904faafda4d0e34085cc99583573a83acafc7225e3ad0fe9ffd6194550794d0e86aba0f936c07f139a672
7
+ data.tar.gz: c5123892600b410dc4c41d2e648b54ff8f4ec36484e71d3fc5df6f2437754630bdec30c6d3c56e9770810d34a3610061eea4398e75badcb42a7452f2153ddd59
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-09
7
+
8
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,10 @@
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"
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) <%= Time.now.year %>
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,25 @@
1
+ # terraspace_ci_bitbucket
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/terraspace.png)](http://badge.fury.io/rb/terraspace)
4
+
5
+ [![BoltOps Badge](https://img.boltops.com/boltops/badges/boltops-badge.png)](https://www.boltops.com)
6
+
7
+ [![BoltOps Learn Badge](https://img.boltops.com/boltops-learn/boltops-learn.png)](https://learn.boltops.com)
8
+
9
+ Provides Terraspace CI support for Bitbucket.
10
+
11
+ ## Installation
12
+
13
+ Add gem to your Terraspace project
14
+
15
+ Gemfile
16
+
17
+ gem terraspace_ci_bitbucket
18
+
19
+ Then to install run
20
+
21
+ bundle
22
+
23
+ ## Contributing
24
+
25
+ Bug reports and pull requests are welcome on GitHub at https://github.com/boltops-tools/terraspace_ci_bitbucket/
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,37 @@
1
+ image: ruby:latest
2
+
3
+ pipelines:
4
+ branches:
5
+ main:
6
+ - step:
7
+ name: Main Pipeline
8
+ script:
9
+ - .bitbucket/bin/install
10
+ - .bitbucket/bin/terraspace up demo -y
11
+
12
+ pull-requests:
13
+ '**': # this runs as default for any branch not elsewhere defined
14
+ - step:
15
+ script:
16
+ - .bitbucket/bin/install
17
+ - .bitbucket/bin/terraspace plan demo
18
+
19
+ custom:
20
+ terraspace:
21
+ - variables:
22
+ - name: TS_ENV
23
+ default: prod
24
+ allowed-values:
25
+ - dev
26
+ - prod
27
+ - step:
28
+ name: plan
29
+ script:
30
+ - .bitbucket/bin/install
31
+ - .bitbucket/bin/terraspace plan demo
32
+ - step:
33
+ name: up
34
+ trigger: manual
35
+ script:
36
+ - .bitbucket/bin/install
37
+ - .bitbucket/bin/terraspace up demo -y
@@ -0,0 +1,23 @@
1
+ require "zeitwerk"
2
+
3
+ module TerraspaceCiBitbucket
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_BITBUCKET_AUTOLOAD_LOG"]
18
+ loader.setup
19
+ end
20
+ end
21
+ end
22
+ end
23
+
@@ -0,0 +1,13 @@
1
+ module TerraspaceCiBitbucket
2
+ class Interface
3
+ # required interface
4
+ def vars
5
+ Vars.new.data
6
+ end
7
+
8
+ # optional interface
9
+ # def comment(url)
10
+ # Pr.new.comment(url)
11
+ # end
12
+ end
13
+ end
@@ -0,0 +1,72 @@
1
+ module TerraspaceCiBitbucket
2
+ class Vars
3
+ # Hash of properties to store
4
+ def data
5
+ {
6
+ build_system: "bitbucket",
7
+ host: host,
8
+ full_repo: full_repo,
9
+ branch_name: branch_name,
10
+ # urls
11
+ pr_url: pr_url,
12
+ build_url: build_url,
13
+ # additional properties
14
+ build_type: build_type, # required IE: pull_request or push
15
+ pr_number: pr_number, # set when build_type=pull_request
16
+ sha: sha,
17
+ # additional properties
18
+ # commit_message: commit_message,
19
+ build_id: build_id,
20
+ build_number: ENV['REPLACE_ME'],
21
+ }
22
+ end
23
+
24
+ def host
25
+ ENV['BITBUCKET_HOST'] || 'https://bitbucket.org'
26
+ end
27
+
28
+ def commit_url
29
+ "#{host}/#{full_repo}/commits/#{sha}"
30
+ end
31
+
32
+ def branch_url
33
+ "#{host}/#{full_repo}/branch/#{branch_name}"
34
+ end
35
+
36
+ def pr_url
37
+ "#{host}/#{full_repo}/pull-requests/#{pr_number}" if pr_number
38
+ end
39
+
40
+ def build_url
41
+ "#{repo_url}/addon/pipelines/home#!/results/#{build_id}"
42
+ end
43
+
44
+ def pr_number
45
+ ENV['BITBUCKET_PR_ID']
46
+ end
47
+
48
+ def repo_url
49
+ ENV['BITBUCKET_GIT_HTTP_ORIGIN']
50
+ end
51
+
52
+ def branch_name
53
+ ENV['BITBUCKET_BRANCH']
54
+ end
55
+
56
+ def sha
57
+ ENV['BITBUCKET_COMMIT']
58
+ end
59
+
60
+ def full_repo
61
+ ENV['BITBUCKET_REPO_FULL_NAME']
62
+ end
63
+
64
+ def build_id
65
+ ENV['BITBUCKET_BUILD_NUMBER']
66
+ end
67
+
68
+ def build_type
69
+ 'pull_request' if ENV['BITBUCKET_PR_ID']
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TerraspaceCiBitbucket
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "terraspace_ci_bitbucket/autoloader"
4
+ TerraspaceCiBitbucket::Autoloader.setup
5
+
6
+ require "json"
7
+ require "memoist"
8
+
9
+ module TerraspaceCiBitbucket
10
+ class Error < StandardError; end
11
+ end
12
+
13
+ Terraspace::Cloud::Ci.register(
14
+ name: "bitbucket",
15
+ env_key: "BITBUCKET_COMMIT",
16
+ root: __dir__,
17
+ exe: ".bitbucket/bin",
18
+ )
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/terraspace_ci_bitbucket/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "terraspace_ci_bitbucket"
7
+ spec.version = TerraspaceCiBitbucket::VERSION
8
+ spec.authors = ["Tung Nguyen"]
9
+ spec.email = ["tung@boltops.com"]
10
+
11
+ spec.summary = "Terraspace CI Bitbucket support"
12
+ spec.homepage = "https://github.com/boltops-tools/terraspace_ci_bitbucket"
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_bitbucket"
18
+ spec.metadata["changelog_uri"] = "https://github.com/boltops-tools/terraspace_ci_bitbucket/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 "activesupport"
32
+ spec.add_dependency "rack"
33
+ spec.add_dependency "rainbow"
34
+
35
+ spec.add_dependency "memoist"
36
+ spec.add_dependency "zeitwerk"
37
+ end
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: terraspace_ci_bitbucket
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: activesupport
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
+ - !ruby/object:Gem::Dependency
28
+ name: rack
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rainbow
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: memoist
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: zeitwerk
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description:
84
+ email:
85
+ - tung@boltops.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".rspec"
91
+ - ".rubocop.yml"
92
+ - CHANGELOG.md
93
+ - Gemfile
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - lib/template/.bitbucket/bin/install
98
+ - lib/template/.bitbucket/bin/terraspace
99
+ - lib/template/bitbucket-pipelines.yml
100
+ - lib/terraspace_ci_bitbucket.rb
101
+ - lib/terraspace_ci_bitbucket/autoloader.rb
102
+ - lib/terraspace_ci_bitbucket/interface.rb
103
+ - lib/terraspace_ci_bitbucket/vars.rb
104
+ - lib/terraspace_ci_bitbucket/version.rb
105
+ - terraspace_ci_bitbucket.gemspec
106
+ homepage: https://github.com/boltops-tools/terraspace_ci_bitbucket
107
+ licenses:
108
+ - MIT
109
+ metadata:
110
+ homepage_uri: https://github.com/boltops-tools/terraspace_ci_bitbucket
111
+ source_code_uri: https://github.com/boltops-tools/terraspace_ci_bitbucket
112
+ changelog_uri: https://github.com/boltops-tools/terraspace_ci_bitbucket/blob/master/CHANGELOG.md
113
+ post_install_message:
114
+ rdoc_options: []
115
+ require_paths:
116
+ - lib
117
+ required_ruby_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: 2.6.0
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ requirements: []
128
+ rubygems_version: 3.3.12
129
+ signing_key:
130
+ specification_version: 4
131
+ summary: Terraspace CI Bitbucket support
132
+ test_files: []