popito 0.0.1.alpha → 0.0.4.alpha

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: 3e56e16a84c3bf667dab3e304d6d83581bebfcdeceeae420efb78d27af8f08f9
4
- data.tar.gz: 1312c4cc5388d955f3c871cbedf267c6ff07d554ebe9e21555ded7957ca4334b
3
+ metadata.gz: 54bafeba7b6374adfb205c90127fd7f242fdb44e773071d3a98640dc2eea8d67
4
+ data.tar.gz: 36153ff1ade6486382c933c983acd8df5f6ef12ceeb175610070cb650fea134b
5
5
  SHA512:
6
- metadata.gz: f87b027418d1663b04f489cf6dcd20aa6894901c3f14d366fcc9657f5b8e6276eb8ae9fd8f648d7554a6533d1da11e7166e624117f802f4a759236c043837bf5
7
- data.tar.gz: 51a241c5d4ac3f04572d20df75e593dcf80b5b6760769297e97e1a208854072594dd7038f720cd148a725da730b84599a69c63ca9b983512f539b6ee8fb708c3
6
+ metadata.gz: c926366fbae27378623274a9d6f28a8c769c9dbeddc2fe11fce9ff095f0cb0bc2236aced45ef597cbfde7a9b6209161d25cd5dd8f126bd2708531651d79d62f6
7
+ data.tar.gz: 1ef977a728676570910a8fcd6cf48c93bba4fe025f74e40da863a12958bdbe42ba3543fcdf477a6da2aaf2d1b3a63f7a69f6c39123330e98b50d53d870f16e45
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- popito (0.0.1.alpha)
4
+ popito (0.0.3.alpha)
5
5
  deep_merge (~> 1.2)
6
6
  erb (~> 2.2)
7
7
  json (~> 2.5)
@@ -24,7 +24,7 @@ GEM
24
24
  json (2.5.1)
25
25
  mime-types (3.3.1)
26
26
  mime-types-data (~> 3.2015)
27
- mime-types-data (3.2021.0704)
27
+ mime-types-data (3.2021.0901)
28
28
  minitar (0.9)
29
29
  netrc (0.11.0)
30
30
  rake (13.0.3)
@@ -35,10 +35,11 @@ GEM
35
35
  netrc (~> 0.8)
36
36
  unf (0.1.4)
37
37
  unf_ext
38
- unf_ext (0.0.7.7)
38
+ unf_ext (0.0.8)
39
39
  yaml (0.1.1)
40
40
 
41
41
  PLATFORMS
42
+ ruby
42
43
  x86_64-darwin-20
43
44
 
44
45
  DEPENDENCIES
data/exe/popito CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
-
3
+ # require 'byebug'
4
4
  require 'optparse'
5
5
  require_relative '../lib/popito/deployer/deployer'
6
6
 
@@ -15,10 +15,11 @@ OptionParser.new do |opts|
15
15
  opts.on('--env ENVIRONMENT', 'It define environment used to build images and deploy files.')
16
16
  opts.on('--endpoint https://popito.mydomain.com', 'It defines popito endpoint.')
17
17
  opts.on('--token POPITO_TOKEN', 'This popito token used to auth this client in a specific project.')
18
+ opts.on('--build-config-json JSON_STRING', 'You can set any build config at execution time.')
18
19
  opts.on('--path ./project_path', 'Root folder of the app.')
19
20
  end.parse!(into: params)
20
21
 
21
- raise ArgumentError, 'You can choose --deploy and --check together.' if params[:check] && params[:deploy]
22
+ raise ArgumentError, 'You can\'t use --deploy and --check together.' if params[:check] && params[:deploy]
22
23
 
23
24
  stages = []
24
25
  stages.push('build') if params[:build]
@@ -26,15 +27,20 @@ stages.push('release') if params[:release]
26
27
  stages.push('check') if params[:check]
27
28
  stages.push('deploy') if params[:deploy]
28
29
 
30
+ build_config = JSON.parse(params[:"build-config-json"] || "{}").merge(
31
+ {
32
+ IMAGE_TAG: params[:tag],
33
+ IMAGE_TAG_ALT: params[:"tag-alt"],
34
+ ENVIRONMENT: params[:env]
35
+ }
36
+ )
37
+
29
38
  config_payload = Popito::ConfigPayload.new(
30
39
  project_path: params[:path],
31
40
  stages: stages,
32
41
  project_token: params[:token],
33
- build_config: {
34
- IMAGE_TAG: params[:tag],
35
- IMAGE_TAG_ALT: params[:tag_alt],
36
- ENVIRONMENT: params[:env]
37
- }
42
+ api_endpoint: params[:endpoint],
43
+ build_config: build_config
38
44
  )
39
45
 
40
46
  if params[:build] || params[:release]
@@ -15,29 +15,25 @@ module Popito
15
15
 
16
16
  def build
17
17
  yaml_config["build"].each do |build|
18
- build["tags"].each do |tag|
19
- builder = Popito::BuildExecutor::Builders::Docker.new(
20
- root_path: config_payload.project_path,
21
- dockerfile: "#{config_payload.build_path}/#{build['dockerfile']}",
22
- image: build["image"],
23
- tag: tag
24
- )
25
- builder.build
26
- end
18
+ builder = Popito::BuildExecutor::Builders::Docker.new(
19
+ root_path: config_payload.project_path,
20
+ dockerfile: "#{config_payload.build_path}/#{build['dockerfile']}",
21
+ image: build["image"],
22
+ tags: build["tags"]
23
+ )
24
+ builder.build
27
25
  end
28
26
  end
29
27
 
30
28
  def release
31
29
  yaml_config["build"].each do |build|
32
- build["tags"].each do |tag|
33
- builder = Popito::BuildExecutor::Builders::Docker.new(
34
- root_path: config_payload.project_path,
35
- dockerfile: "#{config_payload.build_path}/#{build['dockerfile']}",
36
- image: build["image"],
37
- tag: tag
38
- )
39
- builder.push
40
- end
30
+ builder = Popito::BuildExecutor::Builders::Docker.new(
31
+ root_path: config_payload.project_path,
32
+ dockerfile: "#{config_payload.build_path}/#{build['dockerfile']}",
33
+ image: build["image"],
34
+ tags: build["tags"]
35
+ )
36
+ builder.push
41
37
  end
42
38
  end
43
39
 
@@ -3,12 +3,12 @@ module Popito
3
3
  class BuildExecutor
4
4
  module Builders
5
5
  class Docker
6
- attr_accessor :dockerfile, :image, :tag, :root_path
6
+ attr_accessor :dockerfile, :image, :tags, :root_path
7
7
 
8
- def initialize(root_path:, dockerfile:, image:, tag:)
8
+ def initialize(root_path:, dockerfile:, image:, tags:)
9
9
  self.dockerfile = dockerfile
10
10
  self.image = image
11
- self.tag = tag
11
+ self.tags = tags
12
12
  self.root_path = root_path
13
13
  end
14
14
 
@@ -16,7 +16,7 @@ module Popito
16
16
  puts "Building ..."
17
17
  puts "Dockerfile: #{dockerfile}"
18
18
  puts "Image: #{image}"
19
- puts "Tag: #{tag}"
19
+ puts "Tags: #{tags}"
20
20
  Dir.chdir(root_path)
21
21
  docker_build
22
22
  end
@@ -25,24 +25,27 @@ module Popito
25
25
  puts "Pushing ..."
26
26
  puts "Dockerfile: #{dockerfile}"
27
27
  puts "Image: #{image}"
28
- puts "Tag: #{tag}"
28
+ puts "Tags: #{tags}"
29
29
  docker_push
30
30
  end
31
31
 
32
32
  private
33
33
 
34
34
  def docker_push
35
- puts "#{self.class.name}: docker push #{image_full_name}"
36
- system "docker push #{image_full_name}", exception: true
35
+ tags.each do |tag|
36
+ puts "#{self.class.name}: docker push #{image}:#{tag}"
37
+ system "docker push #{image}:#{tag}, exception: true"
38
+ end
37
39
  end
38
40
 
39
41
  def docker_build
40
- puts "#{self.class.name}: docker build #{image_full_name}"
41
- system "docker build -f #{dockerfile} --tag #{image_full_name} .", exception: true
42
- end
43
-
44
- def image_full_name
45
- "#{image}:#{tag}"
42
+ command = "docker build -f #{dockerfile}"
43
+ tags.each do |tag|
44
+ command << " --tag #{image}:#{tag}"
45
+ end
46
+ command << " ."
47
+ puts "#{self.class.name}: #{command}"
48
+ system command, exception: true
46
49
  end
47
50
  end
48
51
  end
@@ -6,7 +6,7 @@ module Popito
6
6
  def download_and_extract(stage:)
7
7
  payload = { stage: stage, build_config: config_payload.build_config,
8
8
  included_files: config_payload.included_files_payload }
9
- response = RestClient.post("#{API_HOST}/api/v1/archive", payload, headers = default_headers)
9
+ response = RestClient.post("#{config_payload.api_endpoint}/api/v1/archive", payload, headers = default_headers)
10
10
  extract_tgz(response.body)
11
11
  rescue RestClient::UnprocessableEntity => e
12
12
  raise parse_error(e)
@@ -4,7 +4,7 @@ require 'minitar'
4
4
  module Popito
5
5
  class IncludedFiles < Popito::ClientBase
6
6
  def included_files_list
7
- response = RestClient.get("#{API_HOST}/api/v1/included-files", headers = default_headers)
7
+ response = RestClient.get("#{config_payload.api_endpoint}/api/v1/included-files", headers = default_headers)
8
8
  JSON.parse(response.body)
9
9
  rescue RestClient::UnprocessableEntity => e
10
10
  raise parse_error(e)
@@ -1,9 +1,9 @@
1
1
  require 'base64'
2
2
  module Popito
3
3
  class ConfigPayload
4
- attr_accessor :project_path, :build_path, :deploy_path, :stages, :build_config, :project_token, :included_files
4
+ attr_accessor :project_path, :build_path, :deploy_path, :stages, :build_config, :project_token, :included_files, :api_endpoint
5
5
 
6
- def initialize(project_path:, project_token:, stages: [], build_config: {}, included_files: [])
6
+ def initialize(project_path:, project_token:, stages: [], build_config: {}, included_files: [], api_endpoint: 'http://localhost:3000')
7
7
  self.project_path = File.expand_path(project_path)
8
8
  self.build_path = File.expand_path("#{project_path}/#{Popito::BUILD_DIR_NAME}")
9
9
  self.deploy_path = File.expand_path("#{project_path}/#{Popito::DEPLOY_DIR_NAME}")
@@ -11,6 +11,7 @@ module Popito
11
11
  self.project_token = project_token
12
12
  self.build_config = build_config
13
13
  self.included_files = included_files
14
+ self.api_endpoint = api_endpoint
14
15
  end
15
16
 
16
17
  def included_files_payload
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Popito
4
- VERSION = "0.0.1.alpha"
4
+ VERSION = "0.0.4.alpha"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: popito
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.alpha
4
+ version: 0.0.4.alpha
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wagner Caixeta
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-06 00:00:00.000000000 Z
11
+ date: 2022-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deep_merge
@@ -102,7 +102,6 @@ executables:
102
102
  extensions: []
103
103
  extra_rdoc_files: []
104
104
  files:
105
- - ".byebug_history"
106
105
  - ".gitignore"
107
106
  - ".gitlab-ci.yml"
108
107
  - ".rubocop.yml"
@@ -130,7 +129,7 @@ metadata:
130
129
  homepage_uri: http://github.com/platbr/popito
131
130
  source_code_uri: http://github.com/platbr/popito
132
131
  changelog_uri: http://github.com/platbr/popito/blob/master/CHANGELOG.md
133
- post_install_message:
132
+ post_install_message:
134
133
  rdoc_options: []
135
134
  require_paths:
136
135
  - lib
@@ -145,8 +144,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
144
  - !ruby/object:Gem::Version
146
145
  version: 1.3.1
147
146
  requirements: []
148
- rubygems_version: 3.1.4
149
- signing_key:
147
+ rubygems_version: 3.0.3.1
148
+ signing_key:
150
149
  specification_version: 4
151
150
  summary: 'WIP: Build docker images for Rails Projects and deploy it on K8S using a
152
151
  Popito Server.'
data/.byebug_history DELETED
@@ -1,247 +0,0 @@
1
- q
2
- params
3
- q
4
- params
5
- q
6
- params
7
- q
8
- params
9
- q
10
- params[:token]
11
- params
12
- q
13
- params
14
- c
15
- JSON.parse(err.response.body)["message"]
16
- err
17
- q
18
- err
19
- q
20
- n
21
- y
22
- q
23
- err.response.body
24
- err
25
- q
26
- puts caller()
27
- caller()
28
- call()
29
- call
30
- err
31
- err.class
32
- err
33
- err.response
34
- JSON.parse(err.response.body)
35
- JSON.parse(err.response.body)["message"]
36
- err
37
- c
38
- JSON.parse(response.body).class
39
- JSON.parse(response.body)
40
- response.body
41
- n
42
- q
43
- default_headers
44
- q
45
- headers
46
- q
47
- config_payload
48
- continue
49
- x["build"][0]["dockerfile"]
50
- x["build"][0]["targets"]
51
- x["build"][0]
52
- x["build"]
53
- x=YAML.load(File.read("#{config_payload.build_path}/build.yaml"))
54
- x["build"]
55
- x=YAML.load(File.read("#{config_payload.build_path}/build.yaml")).class
56
- x
57
- x["build"]
58
- x=YAML.load(File.read("#{config_payload.build_path}/build.yaml")).class
59
- x[0]
60
- x=YAML.load(File.read("#{config_payload.build_path}/build.yaml")).class
61
- YAML.load(File.read("#{config_payload.build_path}/build.yaml")).class
62
- YAML.load(File.read("#{config_payload.build_path}/build.yaml"))
63
- q
64
- YAML.load(File.read("#{config_payload.project_path}/build.yaml"))
65
- c
66
- continue
67
- z.read
68
- x.read
69
- z = Zlib::GzipReader.new(StringIO.new(body))
70
- body
71
- z = Zlib::GzipReader.new(body)
72
- z = Zlib::GzipReader.new(body)
73
- unzipped = StringIO.new(z.read)
74
- body
75
- c
76
- q
77
- body
78
- c
79
- q
80
- body.size
81
- body
82
- c
83
- q
84
- JSON.parse(err.response.body)["code"]
85
- JSON.parse(err.response.body)
86
- JSON.parse(err.response.body)["codigo"]
87
- JSON.parse(err.response.body)["codigo"] + ""
88
- JSON.parse(err.response.body)["code"] + ""
89
- JSON.parse(err.response.body)["message"]
90
- TypeError.kind_of?(RuntimeError)
91
- JSON.parse('{}')
92
- JSON.parse({})
93
- JSON.parse("")
94
- JSON.parse(nil)
95
- JSON.parse(err.response.body)["message"]
96
- JSON.parse(err.response.body)
97
- ::JSON.parse(err.response.body)
98
- require 'json'
99
- ::JSON.parse(err.response.body)
100
- JSON.parse(err.response.body)
101
- JSON(err.response.body)
102
- err.response.body
103
- err.response
104
- c
105
- q
106
- response
107
- c
108
- q
109
- ARGV[0]
110
- ARGV[1]
111
- continue
112
- y
113
- q
114
- config_payload.project_path
115
- File.expand_path(config_payload.project_path)
116
- q
117
- config_payload.project_path
118
- config_payload
119
- q
120
- c
121
- q
122
- current_scope&.config.nil?
123
- context
124
- current_scope
125
- q
126
- default
127
- context.config
128
- context
129
- current_scope
130
- c
131
- q
132
- config_payload.get_value(key: 'RAILS_RUN_MIGRATES', default: 'false')
133
- q
134
- config_payload.get_value(key: 'ENVIRONMENT')
135
- config_payload.get_value(key: :ENVIRONMENT)
136
- config_payload.get_value(:ENVIRONMENTconfig_payload.get_value(key: :ENVIRONMENT))
137
- config_payload.get_value(:ENVIRONMENT)
138
- q
139
- container[:env]
140
- c
141
- container[:env]
142
- c
143
- container[:env]
144
- c
145
- container[:env]
146
- c
147
- container[:env]
148
- c
149
- container[:env]
150
- c
151
- container[:env]
152
- c
153
- container[:env]
154
- q
155
- continue
156
- q
157
- container[:env]
158
- c
159
- container[:env]
160
- byebug
161
- q
162
- container[:env]
163
- c
164
- container[:env]
165
- c
166
- container[:env]
167
- c
168
- container[:env]
169
- q
170
- continue
171
- config_payload.context.config.ENV
172
- config_payload.context.config.env
173
- config_payload.context.config
174
- container[:env][0]config_payload.context.config
175
- container[:env]
176
- c
177
- container[:env]
178
- c
179
- container[:env]
180
- c
181
- container[:env]
182
- container[:name]
183
- container
184
- config_payload.current_scope.config
185
- q
186
- config_payload.current_scope.config
187
- config_payload.current_scope.name
188
- config_payload.current_scope
189
- c
190
- config_payload.current_scope.config
191
- c
192
- config_payload.current_scope.config
193
- c
194
- config_payload.current_scope.config
195
- c
196
- config_payload.current_scope.config
197
- c
198
- config_payload.current_scope.config
199
- c
200
- config_payload.current_scope.config
201
- c
202
- config_payload.current_scope.config
203
- c
204
- config_payload.current_scope.config
205
- c
206
- config_payload.current_scope.config
207
- q
208
- config_payload.current_scope.config
209
- current_context
210
- current_scope
211
- config_payload
212
- container
213
- container["type"]
214
- container[:type]
215
- c
216
- container[:type]
217
- container["config"]
218
- c
219
- container["config"]
220
- c
221
- container["config"]
222
- c
223
- container["config"]
224
- c
225
- container["config"]
226
- c
227
- container["config"]
228
- q
229
- container["config"]
230
- c
231
- container["config"]
232
- c
233
- container["config"]
234
- c
235
- container["config"]
236
- container.config
237
- container
238
- c
239
- container
240
- container.config
241
- c
242
- container.config
243
- c
244
- container.config
245
- c
246
- container.config
247
- container