rops 1.0.7 → 1.0.8
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/bin/rops +5 -2
- data/lib/buildable.rb +17 -0
- data/lib/deployer.rb +8 -9
- data/lib/image.rb +7 -10
- data/lib/site.rb +14 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4aaa2c9386c4426ae0e64d6c9136e208683d396af5175436e29105bd53be14f9
|
4
|
+
data.tar.gz: 2ca5c4ff6f0ff34ccdadc1a09113a3d5e4ea61d9022bc8476bb37190ccab92ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4764f72f23aaa3c3a7694328cabfcea48b509fa109ae9af4487dc8b965b6c4060bb7a59d501a31eee9377983a6837da118c7fb75d1a1b497008a16678d72f17d
|
7
|
+
data.tar.gz: c3249a2060872d2606b4118c8a21b173a5aeec58d19d81d2d38f2d21ce3995280f59e3cf0d23100e470b3facb57a416c343d84cca9f09271a1b768d208ab7828
|
data/Gemfile.lock
CHANGED
data/bin/rops
CHANGED
@@ -28,10 +28,11 @@ module Record360
|
|
28
28
|
super()
|
29
29
|
end
|
30
30
|
|
31
|
-
def call(
|
31
|
+
def call(branch: nil, context: nil, root: nil, specs: nil, **)
|
32
32
|
@root = root if root
|
33
33
|
@deployer ||= Deployer.new(@root)
|
34
34
|
deployer.branch = branch if branch
|
35
|
+
deployer.spec_dir = specs if specs
|
35
36
|
@context = context || deployer.default_context
|
36
37
|
end
|
37
38
|
|
@@ -141,6 +142,7 @@ module Record360
|
|
141
142
|
class CurrentStatus < Dry::CLI::Command
|
142
143
|
desc "Display status of all running specs"
|
143
144
|
argument :context, desc: "Kubernetes context"
|
145
|
+
option :specs, desc: "Kubernetes specification directory"
|
144
146
|
include Common
|
145
147
|
|
146
148
|
def call(**)
|
@@ -193,9 +195,10 @@ module Record360
|
|
193
195
|
desc "Deploy the docker image to the cluster"
|
194
196
|
argument :branch, desc: "Branch (or commit) to build"
|
195
197
|
argument :context, desc: "Kubernetes context"
|
198
|
+
option :specs, desc: "Kubernetes specification directory"
|
196
199
|
include Common
|
197
200
|
|
198
|
-
def call(**)
|
201
|
+
def call(specs: nil, **)
|
199
202
|
super
|
200
203
|
if context == production_context
|
201
204
|
if branch.blank?
|
data/lib/buildable.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
class Buildable
|
2
|
+
attr_reader :name, :repository, :commit
|
3
|
+
attr_writer :commit
|
4
|
+
|
5
|
+
def initialize(name:, repository:, commit:)
|
6
|
+
@name = name.downcase
|
7
|
+
@repository = repository
|
8
|
+
@commit = commit
|
9
|
+
end
|
10
|
+
|
11
|
+
def checkout # :yields: source directory
|
12
|
+
Dir.mktmpdir("#{name}-build") do |dir|
|
13
|
+
system("git -C #{repository} archive #{commit} | tar -x -C #{dir}") or raise "Git error"
|
14
|
+
yield dir
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/deployer.rb
CHANGED
@@ -18,6 +18,7 @@ class Deployer
|
|
18
18
|
attr_reader :root, :repository, :registry, :ssh_host, :images
|
19
19
|
attr_reader :default_branch, :default_context, :production_context
|
20
20
|
attr_reader :branch, :commit, :image_tag
|
21
|
+
attr_accessor :spec_dir
|
21
22
|
|
22
23
|
def self.docker
|
23
24
|
@docker_path ||= File.which('docker') || File.which('podman')
|
@@ -54,8 +55,7 @@ class Deployer
|
|
54
55
|
end
|
55
56
|
|
56
57
|
def specs_running(context = nil)
|
57
|
-
context
|
58
|
-
context = context.to_s
|
58
|
+
context = (context || default_context).to_s
|
59
59
|
specs = deploy_specs(context)
|
60
60
|
|
61
61
|
cmd = String.new "--output=json"
|
@@ -93,8 +93,7 @@ class Deployer
|
|
93
93
|
end
|
94
94
|
|
95
95
|
def deploy!(context)
|
96
|
-
context
|
97
|
-
context = context.to_s
|
96
|
+
context = (context || default_context).to_s
|
98
97
|
specs = deploy_specs(context).presence or raise "No kubernetes specs to deploy"
|
99
98
|
stdout, stderr, _success = kubectl(context, 'apply -f -', YAML.dump_stream(*specs))
|
100
99
|
puts stdout if stdout.present?
|
@@ -122,11 +121,11 @@ class Deployer
|
|
122
121
|
end
|
123
122
|
|
124
123
|
def specs(context = nil)
|
125
|
-
context
|
126
|
-
|
127
|
-
|
128
|
-
paths = git.ls_tree(commit,
|
129
|
-
raise "No specs found
|
124
|
+
spec_dir = self.spec_dir.presence || (context || default_context).to_s
|
125
|
+
@specs[spec_dir] ||= begin
|
126
|
+
spec_dir = "platform/#{spec_dir}/"
|
127
|
+
paths = git.ls_tree(commit, spec_dir)['blob'].keys
|
128
|
+
raise "No specs found in #{spec_dir}" unless paths.present?
|
130
129
|
paths.map { |path| YAML.load_stream( git.show(commit, path) ) }.flatten.compact
|
131
130
|
end
|
132
131
|
end
|
data/lib/image.rb
CHANGED
@@ -1,16 +1,15 @@
|
|
1
|
-
|
1
|
+
require 'buildable'
|
2
|
+
|
3
|
+
class Image < Buildable
|
2
4
|
def self.build_cores
|
3
5
|
@build_cores ||= ENV.fetch('R360_BUILD_CORES', [ 1, Concurrent::Utility::ProcessorCounter.new.processor_count - 1 ].max).to_i
|
4
6
|
end
|
5
7
|
|
6
|
-
attr_reader :
|
7
|
-
attr_writer :commit
|
8
|
+
attr_reader :dockerfile, :tag, :registry
|
8
9
|
|
9
|
-
def initialize(name:, repository:,
|
10
|
-
|
11
|
-
@repository = repository
|
10
|
+
def initialize(name:, repository:, commit:, dockerfile:, tag:, registry:)
|
11
|
+
super(name: name, repository: repository, commit: commit)
|
12
12
|
@dockerfile = dockerfile
|
13
|
-
@commit = commit
|
14
13
|
@tag = tag
|
15
14
|
@registry = registry
|
16
15
|
end
|
@@ -22,9 +21,7 @@ class Image
|
|
22
21
|
|
23
22
|
def build!
|
24
23
|
return if local_exists?
|
25
|
-
|
26
|
-
Dir.mktmpdir("#{name}-build") do |dir|
|
27
|
-
system("git -C #{repository} archive #{commit} | tar -x -C #{dir}") and
|
24
|
+
checkout do |dir|
|
28
25
|
system("#{Deployer.docker} build -f #{dockerfile} -t #{local_image} --build-arg JOBS=#{Image.build_cores} --build-arg GIT_VERSION=#{commit} #{dir}")
|
29
26
|
end
|
30
27
|
end
|
data/lib/site.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'buildable'
|
2
|
+
|
3
|
+
class Site < Buildable
|
4
|
+
attr_reader :script # NPM build script
|
5
|
+
attr_reader :bucket # S3 bucket
|
6
|
+
attr_reader :distribution # CloudFront distribution
|
7
|
+
|
8
|
+
def initialize(name:, repository:, commit:, script:, bucket:, distribution:)
|
9
|
+
super(name: name, repository: repository, commit: commit)
|
10
|
+
@script = script
|
11
|
+
@bucket = bucket
|
12
|
+
@distribution = distribution
|
13
|
+
end
|
14
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rops
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Sloan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-cli
|
@@ -107,10 +107,12 @@ files:
|
|
107
107
|
- LICENSE
|
108
108
|
- README.md
|
109
109
|
- bin/rops
|
110
|
+
- lib/buildable.rb
|
110
111
|
- lib/core_ext.rb
|
111
112
|
- lib/deployer.rb
|
112
113
|
- lib/git_ext.rb
|
113
114
|
- lib/image.rb
|
115
|
+
- lib/site.rb
|
114
116
|
homepage: https://github.com/Record360/rops
|
115
117
|
licenses:
|
116
118
|
- MIT
|