beaker-google 0.3.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md ADDED
@@ -0,0 +1,59 @@
1
+ # Changelog
2
+
3
+ ## [0.5.0](https://github.com/voxpupuli/beaker-google/tree/0.5.0) (2022-10-04)
4
+
5
+ [Full Changelog](https://github.com/voxpupuli/beaker-google/compare/0.4.0...0.5.0)
6
+
7
+ **Implemented enhancements:**
8
+
9
+ - Also enable SSH on images from the windows-sql-cloud project [\#27](https://github.com/voxpupuli/beaker-google/pull/27) ([jaevans](https://github.com/jaevans))
10
+ - Add the OpenSSH directory to the system path [\#25](https://github.com/voxpupuli/beaker-google/pull/25) ([jaevans](https://github.com/jaevans))
11
+ - Enable windows support [\#23](https://github.com/voxpupuli/beaker-google/pull/23) ([jaevans](https://github.com/jaevans))
12
+
13
+ ## [0.4.0](https://github.com/voxpupuli/beaker-google/tree/0.4.0) (2022-09-16)
14
+
15
+ [Full Changelog](https://github.com/voxpupuli/beaker-google/compare/0.3.0...0.4.0)
16
+
17
+ **Merged pull requests:**
18
+
19
+ - Update rake requirement from ~\> 10.1 to ~\> 13.0 [\#20](https://github.com/voxpupuli/beaker-google/pull/20) ([dependabot[bot]](https://github.com/apps/dependabot))
20
+ - Transfer to Vox Pupuli Prep [\#19](https://github.com/voxpupuli/beaker-google/pull/19) ([yachub](https://github.com/yachub))
21
+ - Support updated google APIs [\#17](https://github.com/voxpupuli/beaker-google/pull/17) ([jaevans](https://github.com/jaevans))
22
+ - Update fakefs requirement from ~\> 0.6 to ~\> 1.8 [\#16](https://github.com/voxpupuli/beaker-google/pull/16) ([dependabot[bot]](https://github.com/apps/dependabot))
23
+
24
+ ## [0.3.0](https://github.com/voxpupuli/beaker-google/tree/0.3.0) (2022-09-08)
25
+
26
+ [Full Changelog](https://github.com/voxpupuli/beaker-google/compare/0.2.1...0.3.0)
27
+
28
+ **Merged pull requests:**
29
+
30
+ - \(RE-14811\) Add RE as codeowners [\#18](https://github.com/voxpupuli/beaker-google/pull/18) ([yachub](https://github.com/yachub))
31
+ - \(DIO-3133\) Scan repo with Snyk [\#13](https://github.com/voxpupuli/beaker-google/pull/13) ([suckatrash](https://github.com/suckatrash))
32
+ - Add Dependabot to keep thins up to date [\#8](https://github.com/voxpupuli/beaker-google/pull/8) ([genebean](https://github.com/genebean))
33
+
34
+ ## [0.2.1](https://github.com/voxpupuli/beaker-google/tree/0.2.1) (2020-01-29)
35
+
36
+ [Full Changelog](https://github.com/voxpupuli/beaker-google/compare/0.2.0...0.2.1)
37
+
38
+ **Merged pull requests:**
39
+
40
+ - \(MAINT\) update beaker testing version [\#7](https://github.com/voxpupuli/beaker-google/pull/7) ([kevpl](https://github.com/kevpl))
41
+ - \(MAINT\) remove markdown requirement [\#6](https://github.com/voxpupuli/beaker-google/pull/6) ([kevpl](https://github.com/kevpl))
42
+ - Update google-api-client dependency [\#5](https://github.com/voxpupuli/beaker-google/pull/5) ([cdenneen](https://github.com/cdenneen))
43
+
44
+ ## [0.2.0](https://github.com/voxpupuli/beaker-google/tree/0.2.0) (2018-09-17)
45
+
46
+ [Full Changelog](https://github.com/voxpupuli/beaker-google/compare/0.1.0...0.2.0)
47
+
48
+ **Merged pull requests:**
49
+
50
+ - \(BKR-1509\) Hypervisor usage instructions for Beaker 4..0 [\#4](https://github.com/voxpupuli/beaker-google/pull/4) ([Dakta](https://github.com/Dakta))
51
+ - \(MAINT\) Overall GCE Updates [\#3](https://github.com/voxpupuli/beaker-google/pull/3) ([trevor-vaughan](https://github.com/trevor-vaughan))
52
+
53
+ ## [0.1.0](https://github.com/voxpupuli/beaker-google/tree/0.1.0) (2017-07-19)
54
+
55
+ [Full Changelog](https://github.com/voxpupuli/beaker-google/compare/34ca3d6b58dd87455316e055214367215fdff71f...0.1.0)
56
+
57
+
58
+
59
+ \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
data/Gemfile CHANGED
@@ -1,27 +1,23 @@
1
- source ENV['GEM_SOURCE'] || "https://rubygems.org"
1
+ source ENV.fetch('GEM_SOURCE', 'https://rubygems.org')
2
2
 
3
3
  gemspec
4
4
 
5
-
6
-
7
5
  def location_for(place, fake_version = nil)
8
6
  if place =~ /^git:([^#]*)#(.*)/
9
- [fake_version, { :git => $1, :branch => $2, :require => false }].compact
10
- elsif place =~ /^file:\/\/(.*)/
11
- ['>= 0', { :path => File.expand_path($1), :require => false }]
7
+ [fake_version, { git: Regexp.last_match(1), branch: Regexp.last_match(2), require: false }].compact
8
+ elsif place =~ %r{^file://(.*)}
9
+ ['>= 0', { path: File.expand_path(Regexp.last_match(1)), require: false }]
12
10
  else
13
- [place, { :require => false }]
11
+ [place, { require: false }]
14
12
  end
15
13
  end
16
14
 
17
-
18
15
  # We don't put beaker in as a test dependency because we
19
16
  # don't want to create a transitive dependency
20
17
  group :acceptance_testing do
21
- gem "beaker", *location_for(ENV['BEAKER_VERSION'] || '~> 4.0')
18
+ gem 'beaker', *location_for(ENV.fetch('BEAKER_VERSION', '~> 4.0'))
22
19
  end
23
20
 
24
-
25
- if File.exists? "#{__FILE__}.local"
26
- eval(File.read("#{__FILE__}.local"), binding)
21
+ group :release do
22
+ gem 'github_changelog_generator', require: false
27
23
  end
data/README.md CHANGED
@@ -1,40 +1,69 @@
1
1
  # beaker-google
2
2
 
3
+ [![License](https://img.shields.io/github/license/voxpupuli/beaker-google.svg)](https://github.com/voxpupuli/beaker-google/blob/master/LICENSE)
4
+ [![Test](https://github.com/voxpupuli/beaker-google/actions/workflows/ci.yml/badge.svg)](https://github.com/voxpupuli/beaker-google/actions/workflows/ci.yml)
5
+ [![codecov](https://codecov.io/gh/voxpupuli/beaker-google/branch/main/graph/badge.svg)](https://codecov.io/gh/voxpupuli/beaker-google)
6
+ [![Release](https://github.com/voxpupuli/beaker-google/actions/workflows/release.yml/badge.svg)](https://github.com/voxpupuli/beaker-google/actions/workflows/release.yml)
7
+ [![RubyGem Version](https://img.shields.io/gem/v/beaker-google.svg)](https://rubygems.org/gems/beaker-google)
8
+ [![RubyGem Downloads](https://img.shields.io/gem/dt/beaker-google.svg)](https://rubygems.org/gems/beaker-google)
9
+ [![Donated by Puppet Inc](https://img.shields.io/badge/donated%20by-Puppet%20Inc-fb7047.svg)](#transfer-notice)
10
+
3
11
  Beaker library to use the Google hypervisor
4
12
 
5
13
  # How to use this wizardry
6
14
 
7
- This is a gem that allows you to use hosts with [google compute](google_compute_engine.md) hypervisor with [Beaker](https://github.com/puppetlabs/beaker).
8
-
9
- See the [documentation](docs/manual.md) for the full manual.
15
+ This is a gem that allows you to use hosts with [Google Compute](https://cloud.google.com/compute) hypervisor with [Beaker](https://github.com/voxpupuli/beaker).
10
16
 
11
17
  Beaker will automatically load the appropriate hypervisors for any given hosts file, so as long as your project dependencies are satisfied there's nothing else to do. No need to `require` this library in your tests.
12
18
 
13
- ## With Beaker 3.x
14
- This gem is already included as [beaker dependency](https://github.com/puppetlabs/beaker/blob/master/beaker.gemspec)
15
- for you, so you don't need to do anything special to use this gem's
16
- functionality with Beaker.
17
-
18
- This library is included as a dependency of Beaker 3.x versions, so there's nothing to do.
19
-
20
19
  ## With Beaker 4.x
21
20
 
22
21
  As of Beaker 4.0, all hypervisor and DSL extension libraries have been removed and are no longer dependencies. In order to use a specific hypervisor or DSL extension library in your project, you will need to include them alongside Beaker in your Gemfile or project.gemspec. E.g.
23
22
 
24
- ~~~ruby
23
+ ```ruby
25
24
  # Gemfile
26
25
  gem 'beaker', '~>4.0'
27
- gem 'beaker-aws'
26
+ gem 'beaker-google'
28
27
  # project.gemspec
29
28
  s.add_runtime_dependency 'beaker', '~>4.0'
30
- s.add_runtime_dependency 'beaker-aws'
31
- ~~~
29
+ s.add_runtime_dependency 'beaker-google'
30
+ ```
31
+
32
+ ## Authentication
33
+
34
+ You must be authenticated to Google Compute Engine to be able to use `beaker-google`. Authentication is attempted in two different ways, and the first that succeeds is used.
35
+
36
+ - Using the environment variable [`GOOGLE_APPLICATION_CREDENTIALS`](https://cloud.google.com/docs/authentication/production#passing_variable), which points to a file containing the credentials for a GCP service account, created by `gcloud iam service-accounts keys create` (or equivalent).
37
+ - Using [Application Default Credentials](https://cloud.google.com/docs/authentication/production).
38
+
39
+ ## Configuration
40
+
41
+ The behavior of this library can be configured using either the beaker host configuration file, or environment variables.
42
+
43
+ | configuration option | required | default | description |
44
+ | -------------------- | ---------------- | -------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
45
+ | gce_project | true | | The ID of the Google GCP project to host resources. |
46
+ | gce_zone | true | | The zone to place compute instances in. The region is calculated from the zone name. |
47
+ | gce_network | false | Default | The name of the network to attach to instances. If the project uses the default network, this and `gce_subnetwork` can be left empty. |
48
+ | gce_subnetwork | false | Default | The name of the subnetwork to attach to the instances network interface. If the Default network is not used, this must be supplied. |
49
+ | gce_ssh_private_key | false | $HOME/.ssh/google_compute_engine | The file path of the private key to use to connect to instances. If using the key created by the gcloud tool, this can be left blank. |
50
+ | gce_ssh_public_key | false | <gce_ssh_private_key>.pub | The file path of the public key to upload to the instance. If left blank, attempt to use the file at `gce_ssh_private_key` with a `.pub` extension. |
51
+ | gce_machine_type | false | e2-standard-4 | The machine type to use for the instance. If the `BEAKER_gce_machine_type` environment variable is set, it will be used for all hosts. |
52
+ | volume_size | false | Source Image disk's size | The size of the boot disk for the image. If unset, the disk will be the same size as the image's boot disk. Provided size must be equal to or larger than the image's disk size. |
53
+ | image | true or `family` | | The image to use for creating this instance. It can be either in the form `{project}/{image}` to use an image in a different project, or `{image}`, which will look for the image in `gce_project`. |
54
+ | family | true or `image` | | The image family to use for creating this instance. It can be either in the form `{project}/{family}` to use an image from a family in a different project, or `{family}`, which will look for the image family in `gce_project`. The latest non-deprecated image in the family will be used. |
55
+
56
+ All the variables in the list can be set in the Beaker host configuration file, or the ones starting with `gce_` can be overridden by environment variables in the form `BEAKER_gce_...`. i.e. To override the `gce_machine_type` setting in the environment, set `BEAKER_gce_machine_type`.
57
+
58
+ # Cleanup
59
+
60
+ In cases where the beaker process is killed before finishing, it may leave resources in GCP. These resources will need to be manually deleted.
32
61
 
33
- In Beaker's next major version, the requirement for `beaker-google` will be
34
- pulled from that repo. When that happens, then the usage pattern will change.
35
- In order to use this then, you'll need to include `beaker-google` as a dependency
36
- right next to beaker itself.
62
+ | Resource Type | Name Pattern | Count |
63
+ | ------------- | ------------------- | ------------------------------------------- |
64
+ | Firewall | `beaker-<number>-*` | 1 |
65
+ | Instance | `beaker-*` | One or more depending on test configuration |
37
66
 
38
67
  # Contributing
39
68
 
40
- Please refer to puppetlabs/beaker's [contributing](https://github.com/puppetlabs/beaker/blob/master/CONTRIBUTING.md) guide.
69
+ Please refer to voxpupuli/beaker's [contributing](https://github.com/voxpupuli/beaker/blob/master/CONTRIBUTING.md) guide.
data/Rakefile CHANGED
@@ -5,65 +5,61 @@ require 'rspec/core/rake_task'
5
5
  # Documentation Tasks
6
6
  #
7
7
  ###########################################################
8
- DOCS_DAEMON = "yard server --reload --daemon --server thin"
8
+ DOCS_DAEMON = 'yard server --reload --daemon --server thin'
9
9
  FOREGROUND_SERVER = 'bundle exec yard server --reload --verbose --server thin lib/beaker'
10
10
 
11
- def running?( cmdline )
11
+ def running?(cmdline)
12
12
  ps = `ps -ef`
13
- found = ps.lines.grep( /#{Regexp.quote( cmdline )}/ )
14
- if found.length > 1
15
- raise StandardError, "Found multiple YARD Servers. Don't know what to do."
16
- end
13
+ found = ps.lines.grep(/#{Regexp.quote(cmdline)}/)
14
+ raise StandardError, "Found multiple YARD Servers. Don't know what to do." if found.length > 1
17
15
 
18
16
  yes = found.empty? ? false : true
19
- return yes, found.first
17
+ [yes, found.first]
20
18
  end
21
19
 
22
- def pid_from( output )
20
+ def pid_from(output)
23
21
  output.squeeze(' ').strip.split(' ')[1]
24
22
  end
25
23
 
26
24
  desc 'Start the documentation server in the foreground'
27
- task :docs => 'docs:clear' do
25
+ task docs: 'docs:clear' do
28
26
  original_dir = Dir.pwd
29
- Dir.chdir( File.expand_path(File.dirname(__FILE__)) )
27
+ Dir.chdir(__dir__)
30
28
  sh FOREGROUND_SERVER
31
- Dir.chdir( original_dir )
29
+ Dir.chdir(original_dir)
32
30
  end
33
31
 
34
32
  namespace :docs do
35
-
36
33
  desc 'Clear the generated documentation cache'
37
34
  task :clear do
38
35
  original_dir = Dir.pwd
39
- Dir.chdir( File.expand_path(File.dirname(__FILE__)) )
36
+ Dir.chdir(__dir__)
40
37
  sh 'rm -rf docs'
41
- Dir.chdir( original_dir )
38
+ Dir.chdir(original_dir)
42
39
  end
43
40
 
44
41
  desc 'Generate static documentation'
45
- task :gen => 'docs:clear' do
42
+ task gen: 'docs:clear' do
46
43
  original_dir = Dir.pwd
47
- Dir.chdir( File.expand_path(File.dirname(__FILE__)) )
44
+ Dir.chdir(__dir__)
48
45
  output = `bundle exec yard doc`
49
46
  puts output
50
- if output =~ /\[warn\]|\[error\]/
51
- fail "Errors/Warnings during yard documentation generation"
52
- end
53
- Dir.chdir( original_dir )
47
+ raise 'Errors/Warnings during yard documentation generation' if output =~ /\[warn\]|\[error\]/
48
+
49
+ Dir.chdir(original_dir)
54
50
  end
55
51
 
56
52
  desc 'Run the documentation server in the background, alias `bg`'
57
- task :background => 'docs:clear' do
58
- yes, output = running?( DOCS_DAEMON )
53
+ task background: 'docs:clear' do
54
+ yes, output = running?(DOCS_DAEMON)
59
55
  if yes
60
- puts "Not starting a new YARD Server..."
61
- puts "Found one running with pid #{pid_from( output )}."
56
+ puts 'Not starting a new YARD Server...'
57
+ puts "Found one running with pid #{pid_from(output)}."
62
58
  else
63
59
  original_dir = Dir.pwd
64
- Dir.chdir( File.expand_path(File.dirname(__FILE__)) )
60
+ Dir.chdir(__dir__)
65
61
  sh "bundle exec #{DOCS_DAEMON}"
66
- Dir.chdir( original_dir )
62
+ Dir.chdir(original_dir)
67
63
  end
68
64
  end
69
65
 
@@ -71,37 +67,51 @@ namespace :docs do
71
67
 
72
68
  desc 'Check the status of the documentation server'
73
69
  task :status do
74
- yes, output = running?( DOCS_DAEMON )
70
+ yes, output = running?(DOCS_DAEMON)
75
71
  if yes
76
- pid = pid_from( output )
72
+ pid = pid_from(output)
77
73
  puts "Found a YARD Server running with pid #{pid}"
78
74
  else
79
- puts "Could not find a running YARD Server."
75
+ puts 'Could not find a running YARD Server.'
80
76
  end
81
77
  end
82
78
 
83
- desc "Stop a running YARD Server"
79
+ desc 'Stop a running YARD Server'
84
80
  task :stop do
85
- yes, output = running?( DOCS_DAEMON )
81
+ yes, output = running?(DOCS_DAEMON)
86
82
  if yes
87
- pid = pid_from( output )
83
+ pid = pid_from(output)
88
84
  puts "Found a YARD Server running with pid #{pid}"
89
85
  `kill #{pid}`
90
- puts "Stopping..."
91
- yes, output = running?( DOCS_DAEMON )
86
+ puts 'Stopping...'
87
+ yes, output = running?(DOCS_DAEMON)
92
88
  if yes
93
89
  `kill -9 #{pid}`
94
- yes, output = running?( DOCS_DAEMON )
90
+ yes, output = running?(DOCS_DAEMON)
95
91
  if yes
96
- puts "Could not Stop Server!"
92
+ puts 'Could not Stop Server!'
97
93
  else
98
- puts "Server stopped."
94
+ puts 'Server stopped.'
99
95
  end
100
96
  else
101
- puts "Server stopped."
97
+ puts 'Server stopped.'
102
98
  end
103
99
  else
104
- puts "Could not find a running YARD Server"
100
+ puts 'Could not find a running YARD Server'
105
101
  end
106
102
  end
107
103
  end
104
+
105
+ begin
106
+ require 'rubygems'
107
+ require 'github_changelog_generator/task'
108
+ rescue LoadError
109
+ else
110
+ GitHubChangelogGenerator::RakeTask.new :changelog do |config|
111
+ config.exclude_labels = %w{duplicate question invalid wontfix wont-fix skip-changelog}
112
+ config.user = 'voxpupuli'
113
+ config.project = 'beaker-google'
114
+ gem_version = Gem::Specification.load("#{config.project}.gemspec").version
115
+ config.future_release = gem_version
116
+ end
117
+ end
@@ -5,11 +5,11 @@ require 'beaker-google/version'
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "beaker-google"
7
7
  s.version = BeakerGoogle::VERSION
8
- s.authors = ["Rishi Javia, Kevin Imber, Tony Vu"]
9
- s.email = ["rishi.javia@puppet.com, kevin.imber@puppet.com, tony.vu@puppet.com"]
10
- s.homepage = "https://github.com/puppetlabs/beaker-google"
8
+ s.authors = ["Puppet", "Voxpupuli"]
9
+ s.email = ["voxpupuli@groups.io"]
10
+ s.homepage = "https://github.com/voxpupuli/beaker-google"
11
11
  s.summary = %q{Beaker DSL Extension Helpers!}
12
- s.description = %q{For use for the Beaker acceptance testing tool}
12
+ s.description = %q{Google Compute Engine support for the Beaker acceptance testing tool.}
13
13
  s.license = 'Apache2'
14
14
 
15
15
  s.files = `git ls-files`.split("\n")
@@ -17,16 +17,13 @@ Gem::Specification.new do |s|
17
17
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
18
  s.require_paths = ["lib"]
19
19
 
20
+ s.required_ruby_version = Gem::Requirement.new('>= 2.4')
21
+
20
22
  # Testing dependencies
21
23
  s.add_development_dependency 'rspec', '~> 3.0'
22
24
  s.add_development_dependency 'rspec-its'
23
- # pin fakefs for Ruby < 2.3
24
- if RUBY_VERSION < "2.3"
25
- s.add_development_dependency 'fakefs', '~> 0.6', '< 0.14'
26
- else
27
- s.add_development_dependency 'fakefs', '~> 0.6'
28
- end
29
- s.add_development_dependency 'rake', '~> 10.1'
25
+ s.add_development_dependency 'fakefs', '~> 1.8'
26
+ s.add_development_dependency 'rake', '~> 13.0'
30
27
  s.add_development_dependency 'simplecov'
31
28
  s.add_development_dependency 'pry', '~> 0.10'
32
29
 
@@ -36,7 +33,8 @@ Gem::Specification.new do |s|
36
33
 
37
34
  # Run time dependencies
38
35
  s.add_runtime_dependency 'stringify-hash', '~> 0.0.0'
39
- s.add_runtime_dependency 'google-api-client', '~> 0.8'
40
36
 
37
+ s.add_runtime_dependency 'google-apis-compute_v1', '~> 0.1'
38
+ s.add_runtime_dependency 'google-apis-oslogin_v1', '~> 0.1'
39
+ s.add_runtime_dependency 'googleauth', '~> 1.2'
41
40
  end
42
-
data/bin/beaker-google CHANGED
@@ -4,7 +4,7 @@ require 'rubygems' unless defined?(Gem)
4
4
  require 'beaker-google'
5
5
 
6
6
  VERSION_STRING =
7
- "
7
+ "
8
8
  _ .--.
9
9
  ( ` )
10
10
  beaker-google .-' `--,
@@ -25,8 +25,6 @@ VERSION_STRING =
25
25
  '=='
26
26
  "
27
27
 
28
-
29
-
30
28
  puts BeakerGoogle::VERSION
31
29
 
32
30
  exit 0