barruun 0.1.3 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7b73f5132f4f102758647778bf997f63b20fc9d9ad74e457360942ea61e295f2
4
- data.tar.gz: e19e636776ea39587f8bd3e7d9f7d7a54f6b9e0094ed24d9888bb839994a2d57
3
+ metadata.gz: 92137572d76b3bcc1570800046fc475d35a15099a146d10d3070b5ccc834ab63
4
+ data.tar.gz: 28fa491ba821e908275f010f46031f5b2dfda8ee30ed393cf5464a6769ee6f22
5
5
  SHA512:
6
- metadata.gz: a7ed19aa91be3d2ef8b234151dce95886a58363211ac4d3461ca327548cfe90ce9e2227769dd3eef874429872f07b7ea02bc2bd3f31328bd84d89b545b787707
7
- data.tar.gz: 546fbfbaf25958d53d7d8c2023d215b05440ed898b58a0eb20c720a3b2f99f1bc38299e5db32489368d290c0610d2f7ce71b7d399ffce6c68b3f071adb1be3c9
6
+ metadata.gz: d3d13217cd65b35b24fa0368f99341f263ec887bdeabc2e75c03fde42254a9faa7c193909906e1216c5b43c5d2d2d88b2b9d6e6c3a91f7c33ded86e7b7493f7c
7
+ data.tar.gz: 515c1509949cc92dce9dd7243b8a24bab5e169e8e9f36762ee57c77b24ba1555c92af7b2d15d3e4db9f2da2d69ae6924808ff677ed8035670495fdb9c856b41d
data/Gemfile.lock CHANGED
@@ -1,25 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- barruun (0.1.3)
5
- active_hash
4
+ barruun (0.1.7)
6
5
  thor (~> 1.1)
7
6
 
8
7
  GEM
9
8
  remote: https://rubygems.org/
10
9
  specs:
11
- active_hash (3.1.0)
12
- activesupport (>= 5.0.0)
13
- activesupport (7.0.1)
14
- concurrent-ruby (~> 1.0, >= 1.0.2)
15
- i18n (>= 1.6, < 2)
16
- minitest (>= 5.1)
17
- tzinfo (~> 2.0)
18
- concurrent-ruby (1.1.9)
19
10
  diff-lcs (1.5.0)
20
- i18n (1.8.11)
21
- concurrent-ruby (~> 1.0)
22
- minitest (5.15.0)
23
11
  power_assert (1.1.7)
24
12
  rake (13.0.6)
25
13
  rspec (3.10.0)
@@ -39,8 +27,6 @@ GEM
39
27
  rspec (>= 2.14)
40
28
  rspec-support (3.10.3)
41
29
  thor (1.2.1)
42
- tzinfo (2.0.4)
43
- concurrent-ruby (~> 1.0)
44
30
  webrick (1.7.0)
45
31
  yard (0.9.27)
46
32
  webrick (~> 1.7.0)
data/README.md CHANGED
@@ -62,6 +62,21 @@ bucket-level: 'on'
62
62
  location: us-central1
63
63
  ```
64
64
 
65
+ ### BigQuery
66
+
67
+ ```
68
+ Commands:
69
+ barruun bigquery dataset [FILEPATH] # Create dataset
70
+ barruun bigquery help [COMMAND] # Describe subcommands or one specific subcommand
71
+ ```
72
+
73
+ #### Dataset
74
+
75
+ ```yaml
76
+ name: foobar
77
+ location: asia-northeast1
78
+ ```
79
+
65
80
  ## Development
66
81
 
67
82
  After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
data/barruun.gemspec CHANGED
@@ -12,9 +12,9 @@ Gem::Specification.new do |spec|
12
12
  "
13
13
  spec.description = "Barruun is a simple tool for Infrastructure as Code of Google Cloud Platform using `gcloud` command.
14
14
  "
15
- spec.required_ruby_version = ">= 2.6.0"
15
+ spec.required_ruby_version = ">= 2.5.0"
16
16
 
17
- spec.metadata["source_code_uri"] = "https://github.com/colorfulcompany/barruun"
17
+ spec.metadata["source_code_uri"] = "https://github.com/cc-kawakami/barruun"
18
18
 
19
19
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
20
20
  `git ls-files -z`.split("\x0").reject do |f|
@@ -26,5 +26,4 @@ Gem::Specification.new do |spec|
26
26
  spec.require_paths = ["lib"]
27
27
 
28
28
  spec.add_runtime_dependency "thor", "~> 1.1"
29
- spec.add_runtime_dependency "active_hash"
30
29
  end
data/lib/barruun/cli.rb CHANGED
@@ -2,18 +2,25 @@ require "thor"
2
2
 
3
3
  module Barruun
4
4
  class StorageCommand < Thor
5
- desc "bucket [FILEPATH]", "Create or update bucket"
5
+ desc "bucket [FILEPATH]", "Create bucket"
6
6
  def bucket(file_path)
7
7
  Barruun::Managers::Storage::Bucket.new(file_path).call
8
8
  end
9
9
  end
10
10
 
11
11
  class LoggingCommand < Thor
12
- desc "sink [FILEPATH]", "Create or update sink"
12
+ desc "sink [FILEPATH]", "Create sink"
13
13
  def sink(file_path)
14
14
  Barruun::Managers::Logging::Sink.new(file_path).call
15
15
  end
16
16
  end
17
+
18
+ class BigqueryCommand < Thor
19
+ desc "dataset [FILEPATH]", "Create dataset"
20
+ def sink(file_path)
21
+ Barruun::Managers::Bigquery::Dataset.new(file_path).call
22
+ end
23
+ end
17
24
 
18
25
  class CLI < Thor
19
26
  def self.exit_on_failure?
@@ -22,5 +29,6 @@ module Barruun
22
29
 
23
30
  register(StorageCommand, 'storage', 'storage <command>', 'Manage Cloud Storage')
24
31
  register(LoggingCommand, 'logging', 'logging <command>', 'Manage Cloud Logging')
32
+ register(BigqueryCommand, 'bigquery', 'bigquery <command>', 'Manage BigQuery')
25
33
  end
26
34
  end
@@ -0,0 +1,19 @@
1
+ module Barruun
2
+ module Configurations
3
+ module Bigquery
4
+ class Dataset
5
+ def initialize(hash)
6
+ @hash = hash
7
+ end
8
+
9
+ def name
10
+ @hash["name"]
11
+ end
12
+
13
+ def options
14
+ @hash.reject { |k| ["name"].include?(k) }
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,20 @@
1
+ require_relative "../../configurations/bigquery/dataset"
2
+ require_relative "../utils"
3
+
4
+ module Barruun
5
+ module Managers
6
+ module Bigquery
7
+ class Dataset
8
+ include Barruun::Managers::Utils
9
+
10
+ def create
11
+ `bq #{location_string} mk --dataset #{options_string(@config.options)} #{@config.name}`
12
+ end
13
+
14
+ def exist?
15
+ `bq ls`.include?(@config.name)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -8,7 +8,7 @@ module Barruun
8
8
  include Barruun::Managers::Utils
9
9
 
10
10
  def create
11
- `gcloud logging sinks create #{@config.name} #{@config.destination} #{options_string}`
11
+ `gcloud logging sinks create #{@config.name} #{@config.destination} #{options_string(@config.options)}`
12
12
  end
13
13
 
14
14
  def exist?
@@ -8,7 +8,7 @@ module Barruun
8
8
  include Barruun::Managers::Utils
9
9
 
10
10
  def create
11
- `gcloud alpha storage buckets create #{options_string} #{@config.name}`
11
+ `gcloud alpha storage buckets create #{options_string(@config.options)} #{@config.name}`
12
12
  end
13
13
 
14
14
  def exist?
@@ -9,11 +9,10 @@ module Barruun
9
9
 
10
10
  def initialize(file_path, config_klass = Object.const_get("#{self.class.name.gsub("Managers", "Configurations")}"))
11
11
  @file_path = file_path
12
- begin
13
- @config = config_klass.new(YAML.load_file(file_path))
14
- rescue
12
+ if !File.exists?(@file_path)
15
13
  raise self.class::ConfigFileLoadError, "Error loading config file: #{file_path}"
16
14
  end
15
+ @config = config_klass.new(YAML.load_file(file_path))
17
16
  end
18
17
 
19
18
  def call
@@ -25,8 +24,8 @@ module Barruun
25
24
  end
26
25
  end
27
26
 
28
- def options_string
29
- @config.options.map { |k, v| "--#{k}=#{v}" }.compact.join(" ")
27
+ def options_string(options)
28
+ options.map { |k, v| "--#{k}=#{v}" }.compact.join(" ")
30
29
  end
31
30
  end
32
31
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Barruun
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.7"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: barruun
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - cc-kawakami
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-18 00:00:00.000000000 Z
11
+ date: 2022-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.1'
27
- - !ruby/object:Gem::Dependency
28
- name: active_hash
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
27
  description: 'Barruun is a simple tool for Infrastructure as Code of Google Cloud
42
28
  Platform using `gcloud` command.
43
29
 
@@ -60,8 +46,10 @@ files:
60
46
  - exe/barruun
61
47
  - lib/barruun.rb
62
48
  - lib/barruun/cli.rb
49
+ - lib/barruun/configurations/bigquery/dataset.rb
63
50
  - lib/barruun/configurations/logging/sink.rb
64
51
  - lib/barruun/configurations/storage/bucket.rb
52
+ - lib/barruun/managers/bigquery/dataset.rb
65
53
  - lib/barruun/managers/logging/sink.rb
66
54
  - lib/barruun/managers/storage/bucket.rb
67
55
  - lib/barruun/managers/utils.rb
@@ -69,7 +57,7 @@ files:
69
57
  homepage:
70
58
  licenses: []
71
59
  metadata:
72
- source_code_uri: https://github.com/colorfulcompany/barruun
60
+ source_code_uri: https://github.com/cc-kawakami/barruun
73
61
  post_install_message:
74
62
  rdoc_options: []
75
63
  require_paths:
@@ -78,7 +66,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
78
66
  requirements:
79
67
  - - ">="
80
68
  - !ruby/object:Gem::Version
81
- version: 2.6.0
69
+ version: 2.5.0
82
70
  required_rubygems_version: !ruby/object:Gem::Requirement
83
71
  requirements:
84
72
  - - ">="