barruun 0.1.2 → 0.1.3
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/barruun/cli.rb +2 -2
- data/lib/barruun/{logging/sink/config.rb → configurations/logging/sink.rb} +9 -3
- data/lib/barruun/{storage/bucket/config.rb → configurations/storage/bucket.rb} +3 -3
- data/lib/barruun/managers/logging/sink.rb +20 -0
- data/lib/barruun/managers/storage/bucket.rb +20 -0
- data/lib/barruun/managers/utils.rb +33 -0
- data/lib/barruun/version.rb +1 -1
- metadata +6 -6
- data/lib/barruun/logging/sink.rb +0 -18
- data/lib/barruun/storage/bucket.rb +0 -18
- data/lib/barruun/utils.rb +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b73f5132f4f102758647778bf997f63b20fc9d9ad74e457360942ea61e295f2
|
4
|
+
data.tar.gz: e19e636776ea39587f8bd3e7d9f7d7a54f6b9e0094ed24d9888bb839994a2d57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7ed19aa91be3d2ef8b234151dce95886a58363211ac4d3461ca327548cfe90ce9e2227769dd3eef874429872f07b7ea02bc2bd3f31328bd84d89b545b787707
|
7
|
+
data.tar.gz: 546fbfbaf25958d53d7d8c2023d215b05440ed898b58a0eb20c720a3b2f99f1bc38299e5db32489368d290c0610d2f7ce71b7d399ffce6c68b3f071adb1be3c9
|
data/Gemfile.lock
CHANGED
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
|
3
|
-
|
4
|
-
class
|
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
|
@@ -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
|
data/lib/barruun/version.rb
CHANGED
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.
|
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/
|
65
|
-
- lib/barruun/
|
66
|
-
- lib/barruun/storage/bucket
|
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: []
|
data/lib/barruun/logging/sink.rb
DELETED
@@ -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
|