vidar 1.6.0 → 1.7.0

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: 24308079faca44676b4766b065eea95db5bbb05634f4a26f289e140ce9fdd3ab
4
- data.tar.gz: 33450f66da00a4eee7ee189ced7e6f17db5833ac8a1ae67d1e8e32f0f2a5a25f
3
+ metadata.gz: eb2df292256761c82b4c0faab70db10cb3fcf9f6b28a3777ba5843cb9949deea
4
+ data.tar.gz: eed9221ba5e8418ecc518b7c2168a469235bc383949c32d09e23f0ff3086a5b1
5
5
  SHA512:
6
- metadata.gz: 6c581da30ad838b41f2279cb67b7fe5067e072a4819ac4c411337e424b37c2d4780fab3eb347539841c4c49206e8842b9348bf72135e6ca507db670da628d83a
7
- data.tar.gz: 1b5890bce77fad3dc35ef4832e485971f7341884a1268589ab02af4361cf9acda87ec8c36bcb4b90d3e3d9034f206c158bf6a1eb37d16058c6824bec73c66798
6
+ metadata.gz: 6d949b5d18bafd71eed2722831c68b5bae941cf1e7fb62f8f5cb8c7b3a2e8c99ed54893a2982eecaf61857b984f772f5b40a1682504d538f1d97dafa9ac06b47
7
+ data.tar.gz: 1ed526fadb5d7780c1fdeaf6847793a7265329d1a29944a7a430245a0adcbd32efc33e15ef24f6f336fa8eec7cb1106bdea9d5e2e827a756788a3a7e2c518981
data/.bundler-version CHANGED
@@ -1 +1 @@
1
- 2.3.26
1
+ 2.4.4
@@ -14,3 +14,6 @@ update_configs:
14
14
  - match:
15
15
  dependency_type: "all"
16
16
  update_type: "security:patch"
17
+ labels:
18
+ - "automerge"
19
+ - "dependencies"
@@ -0,0 +1,24 @@
1
+ name: automerge-dependencies
2
+ on:
3
+ pull_request_review:
4
+ types:
5
+ - submitted
6
+ check_suite:
7
+ types:
8
+ - completed
9
+ label:
10
+ types:
11
+ - created
12
+ status: {}
13
+ jobs:
14
+ automerge:
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - name: automerge-dependencies
18
+ uses: pascalgn/automerge-action@v0.14.3
19
+ env:
20
+ GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
21
+ MERGE_METHOD: squash
22
+ MERGE_DELETE_BRANCH: true
23
+ MERGE_LABELS: dependencies
24
+ MERGE_REMOVE_LABELS: ""
@@ -6,13 +6,16 @@ on:
6
6
  check_suite:
7
7
  types:
8
8
  - completed
9
+ label:
10
+ types:
11
+ - created
9
12
  status: {}
10
13
  jobs:
11
14
  automerge:
12
15
  runs-on: ubuntu-latest
13
16
  steps:
14
17
  - name: automerge
15
- uses: "pascalgn/automerge-action@v0.12.0"
18
+ uses: pascalgn/automerge-action@v0.14.3
16
19
  env:
17
20
  GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
18
21
  MERGE_METHOD: squash
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.7.0 - 2023-01-23
4
+
5
+ Add support for publishing Honeycomb markers on deployment.
6
+
7
+ ## 1.6.0 - 2022-12-07
8
+
9
+ Allow more complex deployments. By passing extra options to the deployment command, we allow deployments where there are multiple containers per pod or where there is more than just deployments/cronjobs (like deamonsets or something similar).
10
+
3
11
  ## 1.5.3 - 2022-09-20
4
12
 
5
13
  - fix determining deploy hook status (issue introduced in 1.5.2)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- vidar (1.6.0)
4
+ vidar (1.7.0)
5
5
  colorize
6
6
  faraday
7
7
  thor (~> 1.0)
@@ -18,7 +18,7 @@ GEM
18
18
  crack (0.4.5)
19
19
  rexml
20
20
  diff-lcs (1.5.0)
21
- faraday (2.7.1)
21
+ faraday (2.7.4)
22
22
  faraday-net_http (>= 2.0, < 3.1)
23
23
  ruby2_keywords (>= 0.0.4)
24
24
  faraday-net_http (3.0.2)
@@ -26,12 +26,12 @@ GEM
26
26
  json (2.6.3)
27
27
  method_source (1.0.0)
28
28
  parallel (1.22.1)
29
- parser (3.1.3.0)
29
+ parser (3.2.0.0)
30
30
  ast (~> 2.4.1)
31
- pry (0.14.1)
31
+ pry (0.14.2)
32
32
  coderay (~> 1.1)
33
33
  method_source (~> 1.0)
34
- public_suffix (5.0.0)
34
+ public_suffix (5.0.1)
35
35
  rainbow (3.1.1)
36
36
  rake (13.0.6)
37
37
  regexp_parser (2.6.1)
@@ -42,33 +42,36 @@ GEM
42
42
  rspec-mocks (~> 3.12.0)
43
43
  rspec-core (3.12.0)
44
44
  rspec-support (~> 3.12.0)
45
- rspec-expectations (3.12.0)
45
+ rspec-expectations (3.12.2)
46
46
  diff-lcs (>= 1.2.0, < 2.0)
47
47
  rspec-support (~> 3.12.0)
48
- rspec-mocks (3.12.0)
48
+ rspec-mocks (3.12.3)
49
49
  diff-lcs (>= 1.2.0, < 2.0)
50
50
  rspec-support (~> 3.12.0)
51
51
  rspec-support (3.12.0)
52
- rubocop (1.39.0)
52
+ rubocop (1.43.0)
53
53
  json (~> 2.3)
54
54
  parallel (~> 1.10)
55
- parser (>= 3.1.2.1)
55
+ parser (>= 3.2.0.0)
56
56
  rainbow (>= 2.2.2, < 4.0)
57
57
  regexp_parser (>= 1.8, < 3.0)
58
58
  rexml (>= 3.2.5, < 4.0)
59
- rubocop-ast (>= 1.23.0, < 2.0)
59
+ rubocop-ast (>= 1.24.1, < 2.0)
60
60
  ruby-progressbar (~> 1.7)
61
- unicode-display_width (>= 1.4.0, < 3.0)
62
- rubocop-ast (1.24.0)
61
+ unicode-display_width (>= 2.4.0, < 3.0)
62
+ rubocop-ast (1.24.1)
63
63
  parser (>= 3.1.1.0)
64
+ rubocop-capybara (2.17.0)
65
+ rubocop (~> 1.41)
64
66
  rubocop-rake (0.6.0)
65
67
  rubocop (~> 1.0)
66
- rubocop-rspec (2.15.0)
68
+ rubocop-rspec (2.18.0)
67
69
  rubocop (~> 1.33)
70
+ rubocop-capybara
68
71
  ruby-progressbar (1.11.0)
69
72
  ruby2_keywords (0.0.5)
70
73
  thor (1.2.1)
71
- unicode-display_width (2.3.0)
74
+ unicode-display_width (2.4.2)
72
75
  webmock (3.18.1)
73
76
  addressable (>= 2.8.0)
74
77
  crack (>= 0.3.2)
data/README.md CHANGED
@@ -71,6 +71,8 @@ image: gcr.io/[GCP-PROJECT-ID]/[APP-NAME]
71
71
  namespace: borrower
72
72
  # github name used to build deployment notification content
73
73
  github: RenoFi/vidar
74
+ # The key to use for creating honeycomb markers, defaults to HONEYCOMB_API_KEY env var
75
+ honeycomb_api_key: secret
74
76
  # deployments config per kubectl context, required for `monitor_deploy_status` command
75
77
  deployments:
76
78
  gke_project_us-east4_staging:
@@ -88,6 +90,8 @@ deployments:
88
90
  sentry_webhook_url: https://sentry.io/api/hooks/release/builtin/123/asdf/
89
91
  # Slack webhook url used to send deploy notifications, optional
90
92
  slack_webhook_url: https://hooks.slack.com/services/ASCKNZ0vug2R3Ydo/ASCKNZ0vug2R3Ydo/ASCKNZ0vug2R3Ydo
93
+ # Name of the Honeycomb dataset to create a deployment marker in
94
+ honeycomb_dataset: staging
91
95
  # docker-compose file, optional, default value: docker-compose.ci.yml
92
96
  compose_file: docker-compose.ci.yml
93
97
  # default_branch, optional, default value: main or master (auto-detected from local branches)
data/lib/vidar/cli.rb CHANGED
@@ -78,6 +78,7 @@ module Vidar
78
78
  template_name, error, status = Open3.capture3 "kubectl get cronjob deploy-hook-template -n #{Config.get!(:namespace)} -o name --ignore-not-found=true"
79
79
 
80
80
  slack_notification = SlackNotification.get
81
+ honeycomb_notification = HoneycombNotification.get
81
82
 
82
83
  if status.success?
83
84
  if template_name.to_s.empty?
@@ -96,12 +97,14 @@ module Vidar
96
97
  Run.kubectl "describe job deploy-hook"
97
98
  Log.error "Error running deploy hook template"
98
99
  slack_notification.failure if slack_notification.configured?
100
+ honeycomb_notification.failure
99
101
  exit(1)
100
102
  end
101
103
  end
102
104
  else
103
105
  Log.info "Error getting deploy hook template: #{error}"
104
106
  slack_notification.failure if slack_notification.configured?
107
+ honeycomb_notification.failure
105
108
  exit(1)
106
109
  end
107
110
 
@@ -127,6 +130,7 @@ module Vidar
127
130
  Log.info "Checking if all containers in #{Config.get!(:namespace)} namespace(s) are ready..."
128
131
 
129
132
  slack_notification = SlackNotification.get
133
+ honeycomb_notification = HoneycombNotification.get
130
134
 
131
135
  deploy_status = Vidar::DeployStatus.new(namespace: Config.get!(:namespace))
132
136
 
@@ -135,10 +139,12 @@ module Vidar
135
139
  if deploy_status.success?
136
140
  Log.info "OK: All containers are ready"
137
141
  slack_notification.success if slack_notification.configured?
142
+ honeycomb_notification.success
138
143
  invoke :notify_sentry
139
144
  else
140
145
  Log.error "ERROR: Some of containers are errored or not ready"
141
146
  slack_notification.failure if slack_notification.configured?
147
+ honeycomb_notification.failure
142
148
  exit(1)
143
149
  end
144
150
  end
@@ -195,6 +201,11 @@ module Vidar
195
201
  sentry_notification.call if sentry_notification.configured?
196
202
  end
197
203
 
204
+ desc "notify_honeycomb", "Send test honeycomb notification"
205
+ def notify_honeycomb
206
+ HoneycombNotification.get.success
207
+ end
208
+
198
209
  method_option :message, required: true
199
210
  desc "notify_slack", "Send custom slack notification"
200
211
  def notify_slack
data/lib/vidar/config.rb CHANGED
@@ -14,6 +14,7 @@ module Vidar
14
14
  console_command: -> { "bin/console" },
15
15
  base_stage_name: -> { "base" },
16
16
  release_stage_name: -> { "release" },
17
+ honeycomb_api_key: -> { ENV['HONEYCOMB_API_KEY'] },
17
18
  }.freeze
18
19
 
19
20
  class << self
@@ -6,7 +6,7 @@ module Vidar
6
6
 
7
7
  attr_reader :name, :url,
8
8
  :default_color, :success_color, :failure_color,
9
- :slack_webhook_url, :sentry_webhook_url
9
+ :slack_webhook_url, :sentry_webhook_url, :honeycomb_dataset
10
10
 
11
11
  def initialize(options)
12
12
  @name = options.fetch(:name)
@@ -18,6 +18,7 @@ module Vidar
18
18
 
19
19
  @slack_webhook_url = options[:slack_webhook_url]
20
20
  @sentry_webhook_url = options[:sentry_webhook_url]
21
+ @honeycomb_dataset = options[:honeycomb_dataset]
21
22
  end
22
23
  end
23
24
  end
@@ -0,0 +1,87 @@
1
+ module Vidar
2
+ class HoneycombNotification
3
+ def self.get
4
+ new(
5
+ github: Config.get!(:github),
6
+ revision: Config.get!(:revision),
7
+ revision_name: Config.get!(:revision_name),
8
+ build_url: Config.build_url,
9
+ deploy_config: Config.deploy_config,
10
+ api_key: Config.get(:honeycomb_api_key),
11
+ )
12
+ end
13
+
14
+ def initialize(github:, revision:, revision_name:, deploy_config:, build_url: nil, api_key: nil, connection: Faraday.new)
15
+ @github = github
16
+ @revision = revision
17
+ @revision_name = revision_name
18
+ @build_url = build_url
19
+ @api_key = api_key
20
+ @dataset = deploy_config.honeycomb_dataset
21
+ @connection = connection
22
+ @start_time = Time.now.utc
23
+ @end_time = nil
24
+ @success = false
25
+ end
26
+
27
+ def configured?
28
+ !dataset.nil? && !api_key.nil?
29
+ end
30
+
31
+ def success
32
+ @end_time = Time.now.utc
33
+ @success = true
34
+
35
+ call
36
+ end
37
+
38
+ def failure
39
+ @end_time = Time.now.utc
40
+ @success = false
41
+
42
+ call
43
+ end
44
+
45
+ private
46
+
47
+ attr_reader :connection,
48
+ :github,
49
+ :revision,
50
+ :revision_name,
51
+ :dataset,
52
+ :build_url,
53
+ :api_key,
54
+ :start_time,
55
+ :end_time
56
+
57
+ def success?
58
+ @success
59
+ end
60
+
61
+ def call
62
+ return false unless configured?
63
+
64
+ response = connection.post do |req|
65
+ req.url "https://api.honeycomb.io/1/markers/#{dataset}"
66
+ req.headers['Content-Type'] = 'application/json'
67
+ req.headers['X-Honeycomb-Team'] = api_key.to_s
68
+ req.body = data.to_json
69
+ end
70
+
71
+ return true if response.status == 201
72
+
73
+ warn "Honeycomb marker not created: status: #{response.status} response: #{response.body}"
74
+ false
75
+ end
76
+
77
+ def data
78
+ {
79
+ message: "#{success? ? 'Successful' : 'Failed'} deploy of #{github} revision #{revision} - #{revision_name}",
80
+ type: success? ? "deploy" : "failed_deploy",
81
+ start_time: start_time.to_i,
82
+ end_time: end_time.to_i,
83
+ url: build_url,
84
+ }
85
+ end
86
+ end
87
+ end
data/lib/vidar/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Vidar
2
- VERSION = '1.6.0'.freeze
2
+ VERSION = '1.7.0'.freeze
3
3
  end
data/lib/vidar.rb CHANGED
@@ -10,6 +10,7 @@ require 'thor'
10
10
 
11
11
  require 'vidar/version'
12
12
  require 'vidar/config'
13
+ require 'vidar/honeycomb_notification'
13
14
  require 'vidar/interpolation'
14
15
  require 'vidar/log'
15
16
  require 'vidar/run'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vidar
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Krzysztof Knapik
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2022-12-07 00:00:00.000000000 Z
12
+ date: 2023-01-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: colorize
@@ -195,6 +195,7 @@ files:
195
195
  - ".github/ISSUE_TEMPLATE/story.md"
196
196
  - ".github/PULL_REQUEST_TEMPLATE.md"
197
197
  - ".github/workflows/auto-approve.yml"
198
+ - ".github/workflows/auto-merge-dependencies.yml"
198
199
  - ".github/workflows/auto-merge.yml"
199
200
  - ".github/workflows/ci.yml"
200
201
  - ".gitignore"
@@ -211,6 +212,7 @@ files:
211
212
  - lib/vidar/config.rb
212
213
  - lib/vidar/deploy_config.rb
213
214
  - lib/vidar/deploy_status.rb
215
+ - lib/vidar/honeycomb_notification.rb
214
216
  - lib/vidar/interpolation.rb
215
217
  - lib/vidar/k8s/container.rb
216
218
  - lib/vidar/k8s/pod_set.rb
@@ -243,7 +245,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
243
245
  - !ruby/object:Gem::Version
244
246
  version: '0'
245
247
  requirements: []
246
- rubygems_version: 3.3.26
248
+ rubygems_version: 3.4.4
247
249
  signing_key:
248
250
  specification_version: 4
249
251
  summary: K8s deployment tools based on thor