pfab 0.38.0 → 0.39.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4f97f4b3507d44fbd80c2e918993f9ef147977ccf00ff136d17b682ed8b1d25c
4
- data.tar.gz: 664d287826bb2b8fa896b4741621b0eaa10ad9d3cd3753447db7770e4a4e103e
3
+ metadata.gz: f561887ca5e83e755c6841adc9bd5f7bb665c7fc983f694fae7a0721a6f31803
4
+ data.tar.gz: ec200b656730a992810235c3ef54fc586f7cfbd55af8779eb43bb71a65da30e7
5
5
  SHA512:
6
- metadata.gz: 40a58495cae3d2f458391962a402200ed486f3e00234dd1e54111d6b3d430bbc72b2059b5d920329b07c59afa7c6c6188ba2b28a0c76b308a6a68369912fe5d5
7
- data.tar.gz: 3c9595f4ac5d3b11cd389dea2439a6b6c131414ee1e2e2f2beaf720367c9121e72de5560a87d3f7f6d81397895a4fc3727522de665b8eca0bf4327d5b3fd611c
6
+ metadata.gz: aa72a372ca6dbd79130a87a6aeac08211b79f8d97500ed9e854e1affdb219d495e9cf58338de835a9bebd23a7c56099c5871e16e9b2daa2887f66c92785bc98a
7
+ data.tar.gz: a6f890f67571a0bbc93c1160f1ff7adebb566f3554f945eb4a6a28b9a8db016eab4f5ef2bf84a2650bea6cd0404ea6ef85e33e5a39ad3fbbc358a8b0274b5c39
data/Gemfile.lock CHANGED
@@ -53,7 +53,8 @@ GEM
53
53
  faraday-net_http_persistent (1.2.0)
54
54
  faraday-patron (1.0.0)
55
55
  faraday-rack (1.0.0)
56
- git (1.11.0)
56
+ git (1.18.0)
57
+ addressable (~> 2.8)
57
58
  rchardet (~> 1.8)
58
59
  github_api (0.19.0)
59
60
  addressable (~> 2.4)
data/README.markdown CHANGED
@@ -124,5 +124,5 @@ Releasing
124
124
  Copyright
125
125
  ---------
126
126
 
127
- Copyright (c) 2018 Jeff Dwyer. See
127
+ Copyright (c) 2023 Prefab Inc. See
128
128
  LICENSE.txt for further details.
data/lib/pfab/cli.rb CHANGED
@@ -88,7 +88,7 @@ module Pfab
88
88
 
89
89
  first_pod = get_first_pod(app_name)
90
90
 
91
- puts_and_system("kubectl logs -f #{first_pod}")
91
+ kubectl("logs -f #{first_pod}")
92
92
  end
93
93
  end
94
94
 
@@ -100,7 +100,7 @@ module Pfab
100
100
  set_kube_context
101
101
  app_name = get_app_name
102
102
 
103
- puts_and_system "kubectl rollout restart deployment.apps/#{app_name}"
103
+ kubectl "rollout restart deployment.apps/#{app_name}"
104
104
  end
105
105
  end
106
106
 
@@ -117,7 +117,7 @@ module Pfab
117
117
  set_kube_context
118
118
  app_name = get_app_name
119
119
  first_pod = get_first_pod app_name
120
- puts_and_system "kubectl exec -it #{first_pod} -- #{options.command || '/bin/sh'}"
120
+ kubectl "exec -it #{first_pod} -- #{options.command || '/bin/sh'}"
121
121
  end
122
122
  end
123
123
 
@@ -142,11 +142,11 @@ module Pfab
142
142
  selector = "application=#{@application_yaml['name']}"
143
143
 
144
144
  if options.watch
145
- puts_and_system "kubectl get pods -l #{selector} -w"
145
+ kubectl "get pods -l #{selector} -w"
146
146
  elsif $verbose
147
- puts_and_system "kubectl describe pods -l #{selector}"
147
+ kubectl "describe pods -l #{selector}"
148
148
  else
149
- puts_and_system "kubectl get ingresses,jobs,services,cronjobs,deployments,pods -l #{selector}"
149
+ kubectl "get ingresses,jobs,services,cronjobs,deployments,pods -l #{selector}"
150
150
  end
151
151
  end
152
152
  end
@@ -185,9 +185,9 @@ module Pfab
185
185
  puts "THIS APPLIES TO THE ENTIRE NAMESPACE"
186
186
  types = %w(Failed Pending Succeeded)
187
187
  types.each do |type|
188
- system("kubectl get pods --field-selector status.phase=#{type}")
188
+ kubectl("get pods --field-selector status.phase=#{type}")
189
189
  if agree("Delete those?")
190
- `kubectl delete pods --field-selector status.phase=#{type}`
190
+ kubectl("delete pods --field-selector status.phase=#{type}")
191
191
  puts "Deleted"
192
192
  end
193
193
  end
@@ -206,9 +206,9 @@ module Pfab
206
206
  app = deployables[app_name]
207
207
  if app[:deployable_type] == "cron"
208
208
  deployed_name = deployed_name(app)
209
- puts_and_system("kubectl delete cronjob -l deployed-name=#{deployed_name}")
209
+ kubectl("delete cronjob -l deployed-name=#{deployed_name}")
210
210
  end
211
- puts_and_system("kubectl apply -f .application-k8s-#{$env}-#{app_name}.yaml")
211
+ kubectl("apply -f .application-k8s-#{$env}-#{app_name}.yaml")
212
212
  puts_and_system("git tag release-#{$env}-#{app_name}-#{Time.now.strftime("%Y-%m-%d-%H-%M-%S")} HEAD")
213
213
  puts_and_system("git push origin --tags")
214
214
  end
@@ -324,6 +324,10 @@ module Pfab
324
324
  @_config ||= YAML.load(File.read(File.join(Dir.home, ".pfab.yaml")))
325
325
  end
326
326
 
327
+ def kubectl cmd
328
+ puts_and_system "kubectl #{cmd} --namespace=#{yy.namespace}"
329
+ end
330
+
327
331
  def puts_and_system cmd
328
332
  puts cmd
329
333
  if $dryrun
@@ -369,8 +373,7 @@ module Pfab
369
373
  end
370
374
 
371
375
  def get_pods(app)
372
- get_pods_str = "kubectl get pods -o json -l deployed-name=#{app}"
373
- puts get_pods_str
376
+ kubectl "get pods -o json -l deployed-name=#{app}"
374
377
  pods_str = `#{get_pods_str}`
375
378
  JSON.parse(pods_str)
376
379
  end
@@ -17,12 +17,16 @@ module Pfab
17
17
  app_vars.dig(@data["env"], key) || app_vars[key]
18
18
  end
19
19
 
20
- def get_top_level(key)
21
- @data["application_yaml"].dig(@data["env"], key) || @data["application_yaml"][key]
20
+ def get_namespace
21
+ @data['namespace']
22
22
  end
23
23
 
24
- def get_namespace()
25
- get("namespace") || get_top_level("namespace") || @data['env']
24
+ def get_command()
25
+ cmd = get("command")
26
+ if cmd.kind_of?(Array)
27
+ return cmd
28
+ end
29
+ return cmd.split(" ")
26
30
  end
27
31
 
28
32
  def cpu(req_type)
@@ -58,7 +58,7 @@ module Pfab
58
58
  {
59
59
  image: image_name,
60
60
  name: @data['deployed_name'],
61
- command: app_vars["command"].split(" "),
61
+ command: get_command,
62
62
  env: env_vars,
63
63
  resources: resources,
64
64
  },
@@ -54,7 +54,7 @@ module Pfab
54
54
  {
55
55
  image: image_name,
56
56
  name: @data['deployed_name'],
57
- command: get("command").split(" "),
57
+ command: get_command,
58
58
  env: env_vars,
59
59
  resources: resources,
60
60
  }
@@ -49,7 +49,7 @@ module Pfab
49
49
  {
50
50
  image: image_name,
51
51
  name: @data['deployed_name'],
52
- command: app_vars["command"].split(" "),
52
+ command: get_command,
53
53
  env: env_vars,
54
54
  resources: resources,
55
55
  },
@@ -236,7 +236,7 @@ module Pfab
236
236
  {
237
237
  image: image_name,
238
238
  name: @data['deployed_name'],
239
- command: get("command").split(" "),
239
+ command: get_command,
240
240
  env: env_vars,
241
241
  resources: resources,
242
242
  ports: [
data/lib/pfab/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module Pfab
2
2
  module Version
3
3
  MAJOR = 0
4
- MINOR = 38
4
+ MINOR = 39
5
5
  PATCH = 0
6
6
  BUILD = nil
7
7
 
data/lib/pfab/yamls.rb CHANGED
@@ -4,6 +4,8 @@ module Pfab
4
4
 
5
5
  def initialize(apps:, application_yaml:, image_name:, env:, sha:, config:)
6
6
  @apps = apps
7
+ namespace = application_yaml.dig(env.to_s, "namespace") || application_yaml["namespace"]
8
+ raise "No namespace founds" unless namespace
7
9
  @base_data = {
8
10
  "env" => env.to_s,
9
11
  'image_name' => image_name,
@@ -11,7 +13,8 @@ module Pfab
11
13
  'container_repository' => config["container.repository"],
12
14
  'config' => config,
13
15
  'application' => application_yaml["name"],
14
- 'application_yaml' => application_yaml
16
+ 'application_yaml' => application_yaml,
17
+ 'namespace' => namespace,
15
18
  }
16
19
  end
17
20
 
@@ -27,8 +30,11 @@ module Pfab
27
30
  data
28
31
  end
29
32
 
30
- def generate(keys)
33
+ def namespace
34
+ @base_data['namespace']
35
+ end
31
36
 
37
+ def generate(keys)
32
38
  keys.each do |key|
33
39
  props = @apps[key]
34
40
  data = data_for(key, props)
@@ -48,9 +54,6 @@ module Pfab
48
54
  end
49
55
  filename
50
56
  end
51
-
52
57
  end
53
-
54
-
55
58
  end
56
59
  end
data/pfab.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: pfab 0.38.0 ruby lib
5
+ # stub: pfab 0.39.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "pfab".freeze
9
- s.version = "0.38.0"
9
+ s.version = "0.39.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["Jeff Dwyer".freeze]
14
- s.date = "2023-03-27"
14
+ s.date = "2023-04-14"
15
15
  s.description = "k8s helper".freeze
16
16
  s.email = "jdwyer@prefab.cloud".freeze
17
17
  s.executables = ["pfab".freeze]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pfab
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.38.0
4
+ version: 0.39.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Dwyer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-27 00:00:00.000000000 Z
11
+ date: 2023-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander