cpl 1.0.0 → 1.0.2

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.
data/lib/cpl/version.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cpl
4
- VERSION = "1.0.0"
4
+ VERSION = "1.0.2"
5
+ MIN_CPLN_VERSION = "0.0.71"
5
6
  end
data/lib/cpl.rb CHANGED
@@ -40,16 +40,57 @@ end
40
40
  module Cpl
41
41
  class Error < StandardError; end
42
42
 
43
- class Cli < Thor
43
+ class Cli < Thor # rubocop:disable Metrics/ClassLength
44
44
  package_name "cpl"
45
45
  default_task :no_command
46
46
 
47
47
  def self.start(*args)
48
+ check_cpln_version
49
+ check_cpl_version
48
50
  fix_help_option
49
51
 
50
52
  super(*args)
51
53
  end
52
54
 
55
+ def self.check_cpln_version # rubocop:disable Metrics/MethodLength
56
+ return if @checked_cpln_version
57
+
58
+ @checked_cpln_version = true
59
+
60
+ result = `cpln --version 2>/dev/null`
61
+ if $CHILD_STATUS.success?
62
+ data = JSON.parse(result)
63
+
64
+ version = data["npm"]
65
+ min_version = Cpl::MIN_CPLN_VERSION
66
+ if Gem::Version.new(version) < Gem::Version.new(min_version)
67
+ ::Shell.abort("Current 'cpln' version: #{version}. Minimum supported version: #{min_version}. " \
68
+ "Please update it with 'npm update -g @controlplane/cli'.")
69
+ end
70
+ else
71
+ ::Shell.abort("Can't find 'cpln' executable. Please install it with 'npm install -g @controlplane/cli'.")
72
+ end
73
+ end
74
+
75
+ def self.check_cpl_version # rubocop:disable Metrics/MethodLength
76
+ return if @checked_cpl_version
77
+
78
+ @checked_cpl_version = true
79
+
80
+ result = `gem search ^cpl$ --remote 2>/dev/null`
81
+ return unless $CHILD_STATUS.success?
82
+
83
+ matches = result.match(/cpl \((.+)\)/)
84
+ return unless matches
85
+
86
+ version = Cpl::VERSION
87
+ latest_version = matches[1]
88
+ return unless Gem::Version.new(version) < Gem::Version.new(latest_version)
89
+
90
+ ::Shell.warn("You are not using the latest 'cpl' version. Please update it with 'gem update cpl'.")
91
+ $stderr.puts
92
+ end
93
+
53
94
  # This is so that we're able to run `cpl COMMAND --help` to print the help
54
95
  # (it basically changes it to `cpl --help COMMAND`, which Thor recognizes)
55
96
  # Based on https://stackoverflow.com/questions/49042591/how-to-add-help-h-flag-to-thor-command
@@ -46,7 +46,7 @@ file_data =
46
46
  <<~DATA
47
47
  <!-- NOTE: This file is automatically generated by running `script/generate_commands_docs`. Do NOT edit it manually. -->
48
48
 
49
- ### Common Options
49
+ ## Common Options
50
50
 
51
51
  ```
52
52
  -a XXX, --app XXX app ref on Control Plane (GVC)
@@ -55,7 +55,7 @@ file_data =
55
55
  This `-a` option is used in most of the commands and will pick all other app configurations from the project-specific
56
56
  `.controlplane/controlplane.yml` file.
57
57
 
58
- ### Commands
58
+ ## Commands
59
59
 
60
60
  #{commands_str}
61
61
  DATA
@@ -4,23 +4,24 @@ spec:
4
4
  # https://docs.controlplane.com/reference/workload#cron-configuration
5
5
  type: cron
6
6
  job:
7
- # Run daily job at 2am, see cron docs
7
+ # Run daily job at 2am (see cron docs)
8
8
  schedule: 0 2 * * *
9
9
  # Never or OnFailure
10
10
  restartPolicy: Never
11
11
  containers:
12
12
  - name: daily-task
13
+ cpu: 50m
14
+ memory: 256Mi
13
15
  args:
14
16
  - bundle
15
17
  - exec
16
18
  - rails
17
19
  - db:prepare
18
- cpu: 50m
19
20
  inheritEnv: true
20
- image: '/org/APP_ORG/image/APP_IMAGE'
21
- memory: 256Mi
21
+ image: "/org/APP_ORG/image/APP_IMAGE"
22
22
  defaultOptions:
23
23
  autoscaling:
24
+ minScale: 1
24
25
  maxScale: 1
25
26
  capacityAI: false
26
27
  firewallConfig:
@@ -6,15 +6,16 @@ spec:
6
6
  - name: maintenance
7
7
  env:
8
8
  - name: PORT
9
- value: '3000'
9
+ value: "3000"
10
10
  - name: PAGE_URL
11
- value: ''
12
- image: 'shakacode/maintenance-mode'
11
+ value: ""
12
+ image: "shakacode/maintenance-mode"
13
13
  ports:
14
14
  - number: 3000
15
15
  protocol: http
16
16
  defaultOptions:
17
17
  autoscaling:
18
+ minScale: 1
18
19
  maxScale: 1
19
20
  capacityAI: false
20
21
  timeoutSeconds: 60
@@ -7,15 +7,16 @@ spec:
7
7
  cpu: 3m
8
8
  memory: 10Mi
9
9
  args:
10
- - '-l'
10
+ - "-l"
11
11
  - 0.0.0.0
12
- image: 'memcached:alpine'
12
+ image: "memcached:alpine"
13
13
  ports:
14
14
  - number: 11211
15
15
  protocol: tcp
16
16
  defaultOptions:
17
17
  autoscaling:
18
18
  metric: latency
19
+ minScale: 1
19
20
  maxScale: 1
20
21
  capacityAI: false
21
22
  firewallConfig:
@@ -13,17 +13,18 @@ spec:
13
13
  value: password123
14
14
  - name: POSTGRES_USER
15
15
  value: postgres
16
- image: 'postgres:13.8-alpine'
16
+ image: "postgres:13.8-alpine"
17
17
  ports:
18
18
  - number: 5432
19
19
  protocol: tcp
20
20
  volumes:
21
21
  - path: /var/lib/postgresql/data
22
22
  recoveryPolicy: retain
23
- uri: 'scratch://postgres-vol'
23
+ uri: "scratch://postgres-vol"
24
24
  defaultOptions:
25
25
  autoscaling:
26
26
  metric: latency
27
+ minScale: 1
27
28
  maxScale: 1
28
29
  capacityAI: false
29
30
  firewallConfig:
data/templates/rails.yml CHANGED
@@ -5,14 +5,15 @@ spec:
5
5
  containers:
6
6
  - name: rails
7
7
  cpu: 512m
8
- inheritEnv: true
9
- image: '/org/APP_ORG/image/APP_IMAGE'
10
8
  memory: 1Gi
9
+ inheritEnv: true
10
+ image: "/org/APP_ORG/image/APP_IMAGE"
11
11
  ports:
12
12
  - number: 3000
13
13
  protocol: http
14
14
  defaultOptions:
15
15
  autoscaling:
16
+ minScale: 1
16
17
  maxScale: 1
17
18
  capacityAI: false
18
19
  timeoutSeconds: 60
data/templates/redis.yml CHANGED
@@ -6,13 +6,14 @@ spec:
6
6
  - name: redis
7
7
  cpu: 3m
8
8
  memory: 20Mi
9
- image: 'redis:latest'
9
+ image: "redis:latest"
10
10
  ports:
11
11
  - number: 6379
12
12
  protocol: tcp
13
13
  defaultOptions:
14
14
  autoscaling:
15
15
  metric: latency
16
+ minScale: 1
16
17
  maxScale: 1
17
18
  capacityAI: false
18
19
  firewallConfig:
@@ -4,21 +4,30 @@ spec:
4
4
  type: standard
5
5
  containers:
6
6
  - name: sidekiq
7
+ cpu: 50m
8
+ memory: 256Mi
7
9
  args:
8
10
  - bundle
9
11
  - exec
10
12
  - sidekiq
11
- - '-C'
13
+ - "-C"
12
14
  - config/sidekiq.yml
13
- cpu: 50m
14
15
  inheritEnv: true
15
- image: '/org/APP_ORG/image/APP_IMAGE'
16
- memory: 256Mi
16
+ image: "/org/APP_ORG/image/APP_IMAGE"
17
17
  ports:
18
18
  - number: 7433
19
19
  protocol: http
20
+ lifecycle:
21
+ preStop:
22
+ exec:
23
+ command:
24
+ - pkill
25
+ - "-TSTP"
26
+ - "-f"
27
+ - ^sidekiq\s
20
28
  defaultOptions:
21
29
  autoscaling:
30
+ minScale: 1
22
31
  maxScale: 1
23
32
  capacityAI: false
24
33
  firewallConfig:
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cpl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Gordon
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-05-29 00:00:00.000000000 Z
12
+ date: 2023-07-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: debug
@@ -219,9 +219,14 @@ files:
219
219
  - bin/cpl
220
220
  - cpl
221
221
  - cpl.gemspec
222
+ - docs/assets/grafana-alert.png
223
+ - docs/assets/memcached.png
224
+ - docs/assets/sidekiq-pre-stop-hook.png
222
225
  - docs/commands.md
226
+ - docs/migrating.md
223
227
  - docs/postgres.md
224
228
  - docs/redis.md
229
+ - docs/tips.md
225
230
  - docs/troubleshooting.md
226
231
  - examples/circleci.yml
227
232
  - examples/controlplane.yml
@@ -251,6 +256,7 @@ files:
251
256
  - lib/command/ps_restart.rb
252
257
  - lib/command/ps_start.rb
253
258
  - lib/command/ps_stop.rb
259
+ - lib/command/ps_wait.rb
254
260
  - lib/command/run.rb
255
261
  - lib/command/run_cleanup.rb
256
262
  - lib/command/run_detached.rb