vidar 1.1.0 → 1.1.5

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: 965a91b756cc7f653ce73b1e178629df468805ddf402471a8ad5fc900cd9047c
4
- data.tar.gz: a696f2e3f931eea7a88a24139a9cba019c4754bc0a8a362c9fa1a58820beae0a
3
+ metadata.gz: ed660da4b231ed9dfd128c739f85bbcd5635007a907016e8d5f5b981ffa98372
4
+ data.tar.gz: 926998278a721071e8232acbaafd3daf742693d219a26e8db59551072770dc3e
5
5
  SHA512:
6
- metadata.gz: 691608831009084e56395db3dde528504ab9c81f7f431fcfbe5b3a0f0be6a2c7ebfaf3e9d589cf7849fa6543082d0d7df9e8629c3d11b1469b65f27e5d9fc0be
7
- data.tar.gz: f7694a9183fb89621187bf5033e90214a4e41a97ed7001bec60f3ccdd5eb9ae5d06e151ced35d8e3efd6bcd932619f9349c7cb67c712640311a3d2f4ce38517a
6
+ metadata.gz: a17be0f3854b58d0f9a040ca7314bc877a4cc697e9ae92b7f60291795a833259318cb5f59b99c324f8b88d70de27a0e55f6ef6480d32eb5e46f316337718a538
7
+ data.tar.gz: '083c14b658ab0eff7425086b6736461198b84af6de2be568a9767e8c0b6aa2db09fa5ecc245162610bc3808d96d6a2b08056e2dc9c1455d4d33cf9010272bad3'
@@ -9,10 +9,3 @@ update_configs:
9
9
  allowed_updates:
10
10
  - match:
11
11
  update_type: "all"
12
- automerged_updates:
13
- - match:
14
- dependency_type: "development"
15
- update_type: "all"
16
- - match:
17
- dependency_type: "production"
18
- update_type: "all"
@@ -0,0 +1,33 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to track an issue that has been identified
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Describe the bug**
11
+ A clear and concise description of what the bug is.
12
+
13
+ **To Reproduce**
14
+ Steps to reproduce the behavior:
15
+ 1. Go to '...'
16
+ 2. Click on '....'
17
+ 3. Scroll down to '....'
18
+ 4. See error
19
+
20
+ **Expected behavior**
21
+ A clear and concise description of what you expected to happen.
22
+
23
+ **Mutation/Query**
24
+
25
+ **URL and HTTP method (for non-GQL):**
26
+
27
+ **Sentry or Logs URL:**
28
+
29
+ **User/authentication details**
30
+ Impacted user name or service account
31
+
32
+ **Additional context**
33
+ Add any other context about the problem here.
@@ -0,0 +1 @@
1
+ blank_issues_enabled: false
@@ -0,0 +1,22 @@
1
+ ---
2
+ name: New story
3
+ about: Add a new story for implementation
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Describe the solution**
11
+ A clear and concise description of what you want to happen.
12
+ When will this feature be done?
13
+
14
+ **Describe the users**
15
+ Who are we building this feature for?
16
+
17
+ **Additional context**
18
+ Add any other context or screenshots about the feature request here.
19
+ Link to any applicable documents describing the feature.
20
+
21
+ **Designs**
22
+ Link to any applicable designs on Invision.
@@ -0,0 +1,18 @@
1
+ ## Description
2
+ <!--- Describe your changes in detail -->
3
+
4
+ ## Related issue(s)
5
+ <!--- GH issue number -->
6
+
7
+ ## Motivation and Context
8
+ <!--- Why is this change required? What problem does it solve? -->
9
+ <!--- If it fixes an open issue, please link to the issue here. -->
10
+
11
+ ## How Has This Been Tested?
12
+ <!--- Please describe in detail how you tested your changes. -->
13
+
14
+ ## Screenshots (if appropriate):
15
+ <!--- Please add any screenshots of the feature. -->
16
+
17
+ ## Related PRs
18
+ <!--- Please add links to any related PRs (backend, component packages, etc). -->
@@ -0,0 +1,16 @@
1
+ # automatically approve PRs submitted by Dependabot
2
+ # this will allow Dependabot to automatically merge dependency update PRs where CI passes
3
+ # from: https://github.com/hmarr/auto-approve-action
4
+ name: Auto approve Dependabot PRs
5
+
6
+ on:
7
+ pull_request
8
+
9
+ jobs:
10
+ auto-approve:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: hmarr/auto-approve-action@v2.0.0
14
+ if: github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]'
15
+ with:
16
+ github-token: "${{ secrets.GITHUB_TOKEN }}"
@@ -3,8 +3,9 @@ sudo: false
3
3
  language: ruby
4
4
  cache: bundler
5
5
  rvm:
6
- - 2.6.5
6
+ - 2.6
7
+ - 2.7
7
8
  before_install: gem install bundler
8
9
  script:
9
- - bundle exec rspec
10
- - bundle exec rubocop
10
+ - bundle exec rake spec
11
+ - bundle exec rake rubocop
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- vidar (1.1.0)
4
+ vidar (1.1.5)
5
5
  colorize
6
6
  faraday
7
7
  thor (~> 1.0)
@@ -9,49 +9,56 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- ast (2.4.0)
12
+ ast (2.4.1)
13
13
  awesome_print (1.8.0)
14
- coderay (1.1.2)
14
+ coderay (1.1.3)
15
15
  colorize (0.8.1)
16
- diff-lcs (1.3)
17
- faraday (1.0.0)
16
+ diff-lcs (1.4.4)
17
+ faraday (1.0.1)
18
18
  multipart-post (>= 1.2, < 3)
19
- jaro_winkler (1.5.4)
20
- method_source (0.9.2)
19
+ method_source (1.0.0)
21
20
  multipart-post (2.1.1)
22
- parallel (1.19.1)
23
- parser (2.7.0.2)
24
- ast (~> 2.4.0)
25
- pry (0.12.2)
26
- coderay (~> 1.1.0)
27
- method_source (~> 0.9.0)
21
+ parallel (1.19.2)
22
+ parser (2.7.1.4)
23
+ ast (~> 2.4.1)
24
+ pry (0.13.1)
25
+ coderay (~> 1.1)
26
+ method_source (~> 1.0)
28
27
  rainbow (3.0.0)
29
28
  rake (13.0.1)
29
+ regexp_parser (1.7.1)
30
+ rexml (3.2.4)
30
31
  rspec (3.9.0)
31
32
  rspec-core (~> 3.9.0)
32
33
  rspec-expectations (~> 3.9.0)
33
34
  rspec-mocks (~> 3.9.0)
34
- rspec-core (3.9.1)
35
- rspec-support (~> 3.9.1)
36
- rspec-expectations (3.9.0)
35
+ rspec-core (3.9.2)
36
+ rspec-support (~> 3.9.3)
37
+ rspec-expectations (3.9.2)
37
38
  diff-lcs (>= 1.2.0, < 2.0)
38
39
  rspec-support (~> 3.9.0)
39
40
  rspec-mocks (3.9.1)
40
41
  diff-lcs (>= 1.2.0, < 2.0)
41
42
  rspec-support (~> 3.9.0)
42
- rspec-support (3.9.2)
43
- rubocop (0.79.0)
44
- jaro_winkler (~> 1.5.1)
43
+ rspec-support (3.9.3)
44
+ rubocop (0.90.0)
45
45
  parallel (~> 1.10)
46
- parser (>= 2.7.0.1)
46
+ parser (>= 2.7.1.1)
47
47
  rainbow (>= 2.2.2, < 4.0)
48
+ regexp_parser (>= 1.7)
49
+ rexml
50
+ rubocop-ast (>= 0.3.0, < 1.0)
48
51
  ruby-progressbar (~> 1.7)
49
- unicode-display_width (>= 1.4.0, < 1.7)
50
- rubocop-performance (1.5.2)
51
- rubocop (>= 0.71.0)
52
+ unicode-display_width (>= 1.4.0, < 2.0)
53
+ rubocop-ast (0.3.0)
54
+ parser (>= 2.7.1.4)
55
+ rubocop-performance (1.7.1)
56
+ rubocop (>= 0.82.0)
57
+ rubocop-rspec (1.43.2)
58
+ rubocop (~> 0.87)
52
59
  ruby-progressbar (1.10.1)
53
60
  thor (1.0.1)
54
- unicode-display_width (1.6.1)
61
+ unicode-display_width (1.7.0)
55
62
 
56
63
  PLATFORMS
57
64
  ruby
@@ -64,6 +71,7 @@ DEPENDENCIES
64
71
  rspec
65
72
  rubocop
66
73
  rubocop-performance
74
+ rubocop-rspec
67
75
  vidar!
68
76
 
69
77
  BUNDLED WITH
data/README.md CHANGED
@@ -1,9 +1,9 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/vidar.svg)](https://rubygems.org/gems/vidar)
2
2
  [![Build Status](https://travis-ci.org/RenoFi/vidar.svg?branch=master)](https://travis-ci.org/RenoFi/vidar)
3
3
 
4
- # Vidar
4
+ # vidar
5
5
 
6
- Vidar is a set of docker & k8s deployment tools based on thor gem
6
+ `vidar` is a set of docker & k8s deployment tools based on thor gem
7
7
 
8
8
  ## Installation
9
9
 
@@ -25,12 +25,48 @@ Or install it yourself as:
25
25
  #### Requirements :
26
26
 
27
27
  * multistage `Dockerfile`, with at least 2 stages defined: `base`, `release`.
28
- * `docker-compose.ci.yml` file with defined services for all mentioned stages
28
+ * `docker-compose.ci.yml` file with defined services for all mentioned stages, e.g.
29
+
30
+ ```yml
31
+ version: '3.7'
32
+
33
+ services:
34
+ base:
35
+ image: gcr.io/[GCP-PROJECT-ID]/[APP-NAME]:base-${CURRENT_BRANCH:?err}
36
+ build:
37
+ dockerfile: Dockerfile
38
+ context: .
39
+ target: base
40
+ cache_from:
41
+ - gcr.io/[GCP-PROJECT-ID]/[APP-NAME]:base-master
42
+ - gcr.io/[GCP-PROJECT-ID]/[APP-NAME]:base
43
+ - gcr.io/[GCP-PROJECT-ID]/[APP-NAME]:release
44
+ - gcr.io/[GCP-PROJECT-ID]/[APP-NAME]:$REVISION
45
+ env_file:
46
+ - .env
47
+ environment:
48
+ - RACK_ENV=test
49
+
50
+ release:
51
+ image: gcr.io/[GCP-PROJECT-ID]/[APP-NAME]:release
52
+ build:
53
+ dockerfile: Dockerfile
54
+ context: .
55
+ target: release
56
+ args:
57
+ - REVISION=${REVISION:?err}
58
+ cache_from:
59
+ - gcr.io/[GCP-PROJECT-ID]/[APP-NAME]:base-${CURRENT_BRANCH:?err}
60
+ - gcr.io/[GCP-PROJECT-ID]/[APP-NAME]:base-master
61
+ - gcr.io/[GCP-PROJECT-ID]/[APP-NAME]:base
62
+ - gcr.io/[GCP-PROJECT-ID]/[APP-NAME]:$REVISION
63
+ ```
64
+
29
65
  * `vidar.yml` file to the project root directory, which following content:
30
66
 
31
67
  ```yml
32
68
  # docker image name, required
33
- image: gcr.io/renofiinfrastructure/vidar
69
+ image: gcr.io/[GCP-PROJECT-ID]/[APP-NAME]
34
70
  # k8s namespace, required
35
71
  namespace: borrower
36
72
  # github name used to build deployment notification content
data/Rakefile CHANGED
@@ -5,4 +5,4 @@ require 'rubocop/rake_task'
5
5
  RSpec::Core::RakeTask.new(:spec)
6
6
  RuboCop::RakeTask.new
7
7
 
8
- task default: %i[rubocop spec]
8
+ task default: %i[rubocop:auto_correct spec]
@@ -1,6 +1,7 @@
1
1
  require 'json'
2
2
  require 'open3'
3
3
  require 'ostruct'
4
+ require 'uri'
4
5
  require 'yaml'
5
6
 
6
7
  require 'colorized_string'
@@ -42,10 +42,10 @@ module Vidar
42
42
 
43
43
  desc "publish", "Publish docker images on docker registry"
44
44
  def publish
45
- base_image_tag = "#{Config.get!(:image)}:#{Config.get!(:base_stage_name)}"
45
+ base_image_tag = "#{Config.get!(:image)}:#{Config.get!(:base_stage_name)}"
46
46
  revision_image_tag = "#{Config.get!(:image)}:#{Config.get!(:revision)}"
47
- release_image_tag = "#{Config.get!(:image)}:#{Config.get!(:release_stage_name)}"
48
- latest_image_tag = "#{Config.get!(:image)}:latest"
47
+ release_image_tag = "#{Config.get!(:image)}:#{Config.get!(:release_stage_name)}"
48
+ latest_image_tag = "#{Config.get!(:image)}:latest"
49
49
 
50
50
  Log.info "Publishing #{revision_image_tag}"
51
51
  Run.docker "tag #{release_image_tag} #{revision_image_tag}"
@@ -60,7 +60,7 @@ module Vidar
60
60
  def deploy_config
61
61
  deployments = get(:deployments)
62
62
  deployments = {} unless deployments.is_a?(Hash)
63
- deployment = deployments[get!(:kubectl_context)]
63
+ deployment = deployments[get!(:kubectl_context)]
64
64
 
65
65
  if deployment.nil?
66
66
  Log.error "ERROR: could not find deployment config for #{get!(:kubectl_context)} context"
@@ -3,18 +3,22 @@ module Vidar
3
3
  class Container
4
4
  JOB_KIND = "Job".freeze
5
5
 
6
- attr_reader :data, :state, :namespace, :kind, :pod_name
6
+ attr_reader :data, :state, :namespace,
7
+ :kind, :pod_name,
8
+ :reason, :message
7
9
 
8
10
  def initialize(data)
9
- @data = data
10
- @state = data["state"]
11
+ @data = data
12
+ @state = data["state"] || {}
11
13
  @namespace = data["namespace"]
12
- @kind = data["kind"]
13
- @pod_name = data["pod_name"]
14
+ @kind = data["kind"]
15
+ @pod_name = data["pod_name"]
16
+ @reason = data["reason"]
17
+ @message = data["message"]
14
18
  end
15
19
 
16
20
  def name
17
- data["name"]
21
+ data["name"] || pod_name
18
22
  end
19
23
 
20
24
  def deployed?
@@ -40,13 +44,15 @@ module Vidar
40
44
  def to_text
41
45
  parts = []
42
46
  parts << namespace.to_s.ljust(20, " ")
43
- parts << name.to_s.ljust(25, " ")
44
- parts += text_statuses.map { |s| s.ljust(40, " ") }
47
+ parts << name.to_s.ljust(35, " ")
48
+ parts += text_statuses.map { |s| s.ljust(45, " ") }
45
49
  "| #{parts.join(' | ')} |"
46
50
  end
47
51
 
48
52
  def text_statuses
49
- if running?
53
+ if unschedulable?
54
+ [ColorizedString["Unschedulable"].light_red, ColorizedString[message].light_red]
55
+ elsif running?
50
56
  if job?
51
57
  [ColorizedString["Running"].light_yellow, "Started at: #{running_started_at}"]
52
58
  elsif ready?
@@ -97,6 +103,10 @@ module Vidar
97
103
  state.dig("terminated", "reason") == "Error" || state.dig("terminated", "exitCode")
98
104
  end
99
105
 
106
+ def unschedulable?
107
+ reason == "Unschedulable"
108
+ end
109
+
100
110
  def job?
101
111
  kind == JOB_KIND
102
112
  end
@@ -63,13 +63,13 @@ module Vidar
63
63
  def containers_data
64
64
  items.map do |i|
65
65
  owner_references = i.dig("metadata", "ownerReferences") || []
66
- kind = (owner_references[0] || {})["kind"]
67
- namespace = i.dig("metadata", "namespace")
68
- statuses = i.dig("status", "containerStatuses") || []
66
+ kind = (owner_references[0] || {})["kind"]
67
+ namespace = i.dig("metadata", "namespace")
68
+ statuses = i.dig("status", "containerStatuses") || i.dig("status", "conditions") || []
69
69
  statuses.each do |s|
70
70
  s["namespace"] = namespace
71
- s["kind"] = kind
72
- s["pod_name"] = i.dig("metadata", "name")
71
+ s["kind"] = kind
72
+ s["pod_name"] = i.dig("metadata", "name")
73
73
  end
74
74
  statuses
75
75
  end.flatten
@@ -2,7 +2,7 @@ module Vidar
2
2
  class Log
3
3
  class << self
4
4
  def line
5
- puts "|" + "-" * 122 + "|"
5
+ puts "|#{'-' * 142}|"
6
6
  end
7
7
 
8
8
  def info(text, fill_with = "#")
@@ -1,18 +1,18 @@
1
1
  module Vidar
2
2
  class SlackNotification
3
3
  def initialize(github:, revision:, revision_name:, deploy_config:, build_url: nil)
4
- @github = github
5
- @revision = revision
6
- @revision_name = revision_name
7
- @build_url = build_url
8
- @build_hostname = URI(build_url || '').hostname
9
- @deploy_name = deploy_config.name
10
- @deploy_url = deploy_config.url
11
- @default_color = deploy_config.default_color
12
- @success_color = deploy_config.success_color
13
- @failure_color = deploy_config.failure_color
14
- @webhook_url = deploy_config.slack_webhook_url
15
- @connection = Faraday.new
4
+ @github = github
5
+ @revision = revision
6
+ @revision_name = revision_name
7
+ @build_url = build_url
8
+ @build_hostname = ::URI.parse(build_url || '').hostname
9
+ @deploy_name = deploy_config.name
10
+ @deploy_url = deploy_config.url
11
+ @default_color = deploy_config.default_color
12
+ @success_color = deploy_config.success_color
13
+ @failure_color = deploy_config.failure_color
14
+ @webhook_url = deploy_config.slack_webhook_url
15
+ @connection = Faraday.new
16
16
  end
17
17
 
18
18
  def configured?
@@ -1,3 +1,3 @@
1
1
  module Vidar
2
- VERSION = '1.1.0'.freeze
2
+ VERSION = '1.1.5'.freeze
3
3
  end
@@ -3,14 +3,14 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
  require 'vidar/version'
4
4
 
5
5
  Gem::Specification.new do |spec|
6
- spec.name = 'vidar'
7
- spec.version = Vidar::VERSION
8
- spec.authors = ['Krzysztof Knapik', 'RenoFi Engineering Team']
9
- spec.email = ['knapo@knapo.net', 'engineering@renofi.com']
6
+ spec.name = 'vidar'
7
+ spec.version = Vidar::VERSION
8
+ spec.authors = ['Krzysztof Knapik', 'RenoFi Engineering Team']
9
+ spec.email = ['knapo@knapo.net', 'engineering@renofi.com']
10
10
 
11
- spec.summary = 'K8s deployment tools based on thor'
11
+ spec.summary = 'K8s deployment tools based on thor'
12
12
  spec.homepage = 'https://github.com/RenoFi/vidar'
13
- spec.license = 'MIT'
13
+ spec.license = 'MIT'
14
14
 
15
15
  spec.metadata['homepage_uri'] = 'https://github.com/RenoFi/vidar'
16
16
  spec.metadata['source_code_uri'] = 'https://github.com/RenoFi/vidar'
@@ -18,8 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.files = Dir.chdir(__dir__) do
19
19
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(bin/|spec/|\.rub)}) }
20
20
  end
21
- spec.bindir = 'exe'
22
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.bindir = 'exe'
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
23
  spec.require_paths = ['lib']
24
24
 
25
25
  spec.required_ruby_version = '>= 2.6'
@@ -35,4 +35,5 @@ Gem::Specification.new do |spec|
35
35
  spec.add_development_dependency 'rspec'
36
36
  spec.add_development_dependency 'rubocop'
37
37
  spec.add_development_dependency 'rubocop-performance'
38
+ spec.add_development_dependency 'rubocop-rspec'
38
39
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vidar
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Krzysztof Knapik
8
8
  - RenoFi Engineering Team
9
- autorequire:
9
+ autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2020-02-12 00:00:00.000000000 Z
12
+ date: 2020-09-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: colorize
@@ -151,7 +151,21 @@ dependencies:
151
151
  - - ">="
152
152
  - !ruby/object:Gem::Version
153
153
  version: '0'
154
- description:
154
+ - !ruby/object:Gem::Dependency
155
+ name: rubocop-rspec
156
+ requirement: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ type: :development
162
+ prerelease: false
163
+ version_requirements: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - ">="
166
+ - !ruby/object:Gem::Version
167
+ version: '0'
168
+ description:
155
169
  email:
156
170
  - knapo@knapo.net
157
171
  - engineering@renofi.com
@@ -161,6 +175,11 @@ extensions: []
161
175
  extra_rdoc_files: []
162
176
  files:
163
177
  - ".dependabot/config.yml"
178
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
179
+ - ".github/ISSUE_TEMPLATE/config.yml"
180
+ - ".github/ISSUE_TEMPLATE/story.md"
181
+ - ".github/PULL_REQUEST_TEMPLATE.md"
182
+ - ".github/workflows/auto-approve.yml"
164
183
  - ".gitignore"
165
184
  - ".rspec"
166
185
  - ".travis.yml"
@@ -190,7 +209,7 @@ licenses:
190
209
  metadata:
191
210
  homepage_uri: https://github.com/RenoFi/vidar
192
211
  source_code_uri: https://github.com/RenoFi/vidar
193
- post_install_message:
212
+ post_install_message:
194
213
  rdoc_options: []
195
214
  require_paths:
196
215
  - lib
@@ -205,8 +224,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
205
224
  - !ruby/object:Gem::Version
206
225
  version: '0'
207
226
  requirements: []
208
- rubygems_version: 3.0.6
209
- signing_key:
227
+ rubygems_version: 3.1.2
228
+ signing_key:
210
229
  specification_version: 4
211
230
  summary: K8s deployment tools based on thor
212
231
  test_files: []