barruun 0.1.2 → 0.1.3

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: b40d405d04ce967216dc4c25caa14508492e6ba01186498b0aa936402f500462
4
- data.tar.gz: 83f9e2dd29e7978ca8e1c70517ccb8e51e2088a456b3caa0659fba1d7180061e
3
+ metadata.gz: 7b73f5132f4f102758647778bf997f63b20fc9d9ad74e457360942ea61e295f2
4
+ data.tar.gz: e19e636776ea39587f8bd3e7d9f7d7a54f6b9e0094ed24d9888bb839994a2d57
5
5
  SHA512:
6
- metadata.gz: 25daa66e59e6952a409dd201854505366ea626d44d2c924213888f6464f368becf936c3fa616ca8d236960f8d321fe35d57ff44affbce74217bbb092c95fd591
7
- data.tar.gz: ec560ce503e8b6fcabb55dfd16672c508e28b38deb6ed75c729c73c6174f4c44fed8ac93f2fcef0e2438669de7fb9c0d7b2856bdd0df0a3e44594a04a69bfc67
6
+ metadata.gz: a7ed19aa91be3d2ef8b234151dce95886a58363211ac4d3461ca327548cfe90ce9e2227769dd3eef874429872f07b7ea02bc2bd3f31328bd84d89b545b787707
7
+ data.tar.gz: 546fbfbaf25958d53d7d8c2023d215b05440ed898b58a0eb20c720a3b2f99f1bc38299e5db32489368d290c0610d2f7ce71b7d399ffce6c68b3f071adb1be3c9
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- barruun (0.1.2)
4
+ barruun (0.1.3)
5
5
  active_hash
6
6
  thor (~> 1.1)
7
7
 
data/lib/barruun/cli.rb CHANGED
@@ -4,14 +4,14 @@ module Barruun
4
4
  class StorageCommand < Thor
5
5
  desc "bucket [FILEPATH]", "Create or update bucket"
6
6
  def bucket(file_path)
7
- Barruun::Storage::Bucket.new(file_path).call
7
+ Barruun::Managers::Storage::Bucket.new(file_path).call
8
8
  end
9
9
  end
10
10
 
11
11
  class LoggingCommand < Thor
12
12
  desc "sink [FILEPATH]", "Create or update sink"
13
13
  def sink(file_path)
14
- Barruun::Logging::Sink.new(file_path).call
14
+ Barruun::Managers::Logging::Sink.new(file_path).call
15
15
  end
16
16
  end
17
17
 
@@ -1,10 +1,16 @@
1
1
  module Barruun
2
- module Logging
3
- class Sink
4
- class Config
2
+ module Configurations
3
+ module Logging
4
+ class Sink
5
+ class ProjectIDNotProvidedError < RuntimeError; end
6
+
5
7
  def initialize(hash, project_id = ENV["PROJECT_ID"])
6
8
  @hash = hash
7
9
  @project_id = project_id
10
+
11
+ if @project_id.nil?
12
+ raise ProjectIDNotProvidedError, "Project ID not provided"
13
+ end
8
14
  end
9
15
 
10
16
  def name
@@ -1,7 +1,7 @@
1
1
  module Barruun
2
- module Storage
3
- class Bucket
4
- class Config
2
+ module Configurations
3
+ module Storage
4
+ class Bucket
5
5
  def initialize(hash)
6
6
  @hash = hash
7
7
  end
@@ -0,0 +1,20 @@
1
+ require_relative "../../configurations/logging/sink"
2
+ require_relative "../utils"
3
+
4
+ module Barruun
5
+ module Managers
6
+ module Logging
7
+ class Sink
8
+ include Barruun::Managers::Utils
9
+
10
+ def create
11
+ `gcloud logging sinks create #{@config.name} #{@config.destination} #{options_string}`
12
+ end
13
+
14
+ def exist?
15
+ `gcloud logging sinks list --filter='name: #{@config.name}'`.include?(@config.name)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ require_relative "../../configurations/storage/bucket"
2
+ require_relative "../utils"
3
+
4
+ module Barruun
5
+ module Managers
6
+ module Storage
7
+ class Bucket
8
+ include Barruun::Managers::Utils
9
+
10
+ def create
11
+ `gcloud alpha storage buckets create #{options_string} #{@config.name}`
12
+ end
13
+
14
+ def exist?
15
+ `gcloud alpha storage buckets list --filter='name: #{@config.name}'`.include?(@config.name)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,33 @@
1
+ require "yaml"
2
+
3
+ module Barruun
4
+ module Managers
5
+ module Utils
6
+ def self.included(obj)
7
+ obj.const_set('ConfigFileLoadError', Class.new(RuntimeError))
8
+ end
9
+
10
+ def initialize(file_path, config_klass = Object.const_get("#{self.class.name.gsub("Managers", "Configurations")}"))
11
+ @file_path = file_path
12
+ begin
13
+ @config = config_klass.new(YAML.load_file(file_path))
14
+ rescue
15
+ raise self.class::ConfigFileLoadError, "Error loading config file: #{file_path}"
16
+ end
17
+ end
18
+
19
+ def call
20
+ if exist?
21
+ puts "#{self.class.name} #{@config.name} already exists. Nothing to do."
22
+ else
23
+ puts "#{self.class.name} #{@config.name} not found."
24
+ create
25
+ end
26
+ end
27
+
28
+ def options_string
29
+ @config.options.map { |k, v| "--#{k}=#{v}" }.compact.join(" ")
30
+ end
31
+ end
32
+ end
33
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Barruun
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: barruun
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - cc-kawakami
@@ -60,11 +60,11 @@ files:
60
60
  - exe/barruun
61
61
  - lib/barruun.rb
62
62
  - lib/barruun/cli.rb
63
- - lib/barruun/logging/sink.rb
64
- - lib/barruun/logging/sink/config.rb
65
- - lib/barruun/storage/bucket.rb
66
- - lib/barruun/storage/bucket/config.rb
67
- - lib/barruun/utils.rb
63
+ - lib/barruun/configurations/logging/sink.rb
64
+ - lib/barruun/configurations/storage/bucket.rb
65
+ - lib/barruun/managers/logging/sink.rb
66
+ - lib/barruun/managers/storage/bucket.rb
67
+ - lib/barruun/managers/utils.rb
68
68
  - lib/barruun/version.rb
69
69
  homepage:
70
70
  licenses: []
@@ -1,18 +0,0 @@
1
- require_relative "./sink/config"
2
- require_relative "../utils"
3
-
4
- module Barruun
5
- module Logging
6
- class Sink
7
- include Barruun::Utils
8
-
9
- def create
10
- `gcloud logging sinks create #{@config.name} #{@config.destination} #{options_string}`
11
- end
12
-
13
- def exist?
14
- `gcloud logging sinks list --filter='name: #{@config.name}'`.include?(@config.name)
15
- end
16
- end
17
- end
18
- end
@@ -1,18 +0,0 @@
1
- require_relative "./bucket/config"
2
- require_relative "../utils"
3
-
4
- module Barruun
5
- module Storage
6
- class Bucket
7
- include Barruun::Utils
8
-
9
- def create
10
- system("gcloud alpha storage buckets create #{options_string} #{@config.name}")
11
- end
12
-
13
- def exist?
14
- `gcloud alpha storage buckets list --filter='name: #{@config.name}'`.include?(@config.name)
15
- end
16
- end
17
- end
18
- end
data/lib/barruun/utils.rb DELETED
@@ -1,23 +0,0 @@
1
- require "yaml"
2
-
3
- module Barruun
4
- module Utils
5
- def initialize(file_path, config_klass = self.class::Config)
6
- @file_path = file_path
7
- @config = config_klass.new(YAML.load_file(file_path))
8
- end
9
-
10
- def call
11
- if exist?
12
- puts "#{self.class.name} #{@config.name} already exists. Nothing to do."
13
- else
14
- puts "#{self.class.name} #{@config.name} not found."
15
- create
16
- end
17
- end
18
-
19
- def options_string
20
- @config.options.map { |k, v| "--#{k}=#{v}" }.compact.join(" ")
21
- end
22
- end
23
- end