dip 8.2.5 → 8.3.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: 43ca40663a00675570ed4dcd668987e7845c6a3d9682b999889c9af37368cfea
4
- data.tar.gz: c9eb17ad1d6f9615868f04024afb434a821a758bffa48daac1516a1cd99b10e7
3
+ metadata.gz: b1251c437797a56125f593a350dde6c3709f70936a6cc274949d0b2b58dd814f
4
+ data.tar.gz: d1e4d3484bdc41ed6281d14a7ce324146cd1768989c3e3f3fa09fc412d72bf2d
5
5
  SHA512:
6
- metadata.gz: 4fc103b4c4e0f22c58d4b87e9d1b48a61f95bd948b9b00e7afbaaf453c0d11ef5720d698e11376837f032e35639058f9e47cd74716a2f7274da00c868589110a
7
- data.tar.gz: 13a8525d318c4e312287d136005b0bf6c751f11f85f984de5266c2222aa432deb44eb0173172305739022fe654770290dea07b712b1a1b029015782a2582d38d
6
+ metadata.gz: 1dafa2c574e88f414a498ed0e3cbeaab047085ee0232977fcf1900ef92637c333cab39dc9d9ae1e5eaf93843949e3bd62a9c61f23f46ba83711cd0aecf83412c
7
+ data.tar.gz: 3ce49864159703c73ac8811a5a9f8d295192f3dc0be569a7d6708a5084013a2464de89b67cb1982edd888dec7284d44761959b85fa02b62e23b95547b5ef70fc
data/README.md CHANGED
@@ -12,7 +12,7 @@ The dip is a CLI dev–tool that provides native-like interaction with a Dockeri
12
12
  ## Presentations and examples
13
13
 
14
14
  - [Local development with Docker containers](https://slides.com/bibendi/dip)
15
- - [Dockerized Ruby on Rails application](https://SberMarket-Tech/outbox-example-apps)
15
+ - [Dockerized Ruby on Rails application](https://github.com/Kuper-Tech/outbox-example-apps)
16
16
  - Dockerized Node.js application: [one](https://github.com/bibendi/twinkle.js), [two](https://github.com/bibendi/yt-graphql-react-event-booking-api)
17
17
  - [Dockerized Ruby gem](https://github.com/bibendi/schked)
18
18
  - [Dockerizing Ruby and Rails development](https://evilmartians.com/chronicles/ruby-on-whales-docker-for-ruby-rails-development)
@@ -20,6 +20,14 @@ The dip is a CLI dev–tool that provides native-like interaction with a Dockeri
20
20
 
21
21
  [![asciicast](https://asciinema.org/a/210236.svg)](https://asciinema.org/a/210236)
22
22
 
23
+ ## Quick start with AI
24
+
25
+ [dip-skill](https://github.com/kalashnikovisme/dip-skill) helps you quickly configure a `dip` environment for your project. It detects the tech stack and bootstraps `dip.yml`, compose files, and Dockerfiles.
26
+
27
+ ```sh
28
+ npx skills add kalashnikovisme/dip-skill
29
+ ```
30
+
23
31
  ## Installation
24
32
 
25
33
  ```sh
@@ -66,12 +74,12 @@ dip SUBCOMMAND --help
66
74
 
67
75
  ### dip.yml
68
76
 
69
- The configuration is loaded from `dip.yml` file. It may be located in a working directory, or it will be found in the nearest parent directory up to the file system root. If nearby places `dip.override.yml` file, it will be merged into the main config.
77
+ The configuration is loaded from `dip.yml` file. It may be located in a working directory, or it will be found in the nearest parent directory up to the file system root. If a `dip.override.yml` file exists nearby, it will be merged into the main config.
70
78
 
71
79
  Also, in some cases, you may want to change the default config path by providing an environment variable `DIP_FILE`.
72
80
 
73
81
  Below is an example of a real config.
74
- Config file reference will be written soon.
82
+ The schema is defined in `schema.json` and can be validated with `dip validate`.
75
83
  Also, you can check out examples at the top.
76
84
 
77
85
  ```yml
@@ -178,13 +186,21 @@ provision:
178
186
  - dip clean_cache
179
187
  - dip compose up -d pg redis
180
188
  - dip bash -c ./bin/setup
189
+
190
+ preflight:
191
+ - ./bin/check-credentials
192
+ - test -f .env
181
193
  ```
182
194
 
195
+ `preflight` is an array of shell commands that dip runs before any command that touches a running container or cluster: `dip compose ...` (and its aliases `dip up`, `dip build`, `dip stop`, `dip down`), `dip ktl ...`, and `dip run ...` (including the interaction shorthand `dip <name>`). If any command exits non-zero, dip aborts before the underlying operation runs. Useful for verifying credentials are present, required files exist, env vars are set, etc.
196
+
197
+ Not triggered by `dip down --all` (cross-project teardown), `dip ssh`, `dip infra`, or `dip provision`.
198
+
183
199
  ### Predefined environment variables
184
200
 
185
201
  #### $DIP_OS
186
202
 
187
- Current OS architecture (e.g. `linux`, `darwin`, `freebsd`, and so on). Sometime it may be useful to have one common `docker-compose.yml` and OS-dependent Compose configs.
203
+ Current OS name (e.g. `linux`, `darwin`, `freebsd`, and so on). Sometimes it may be useful to have one common `docker-compose.yml` and OS-dependent Compose configs.
188
204
 
189
205
  #### $DIP_WORK_DIR_REL_PATH
190
206
 
@@ -240,7 +256,7 @@ The container will run using the same user ID as your host machine.
240
256
 
241
257
  ### Modules
242
258
 
243
- Modules are defined as array in `modules` section of dip.yml, modules are stored in `.dip` subdirectory of dip.yml directory.
259
+ Modules are defined as an array in the `modules` section of dip.yml. Module files are stored in the `.dip` subdirectory next to dip.yml.
244
260
 
245
261
  The main purpose of modules is to improve maintainability for a group of projects.
246
262
  Imagine having multiple gems which are managed with dip, each of them has the same commands, so to change one command in dip you need to update all gems individualy.
@@ -328,7 +344,7 @@ Nested modules are not supported.
328
344
 
329
345
  Run commands defined within the `interaction` section of dip.yml
330
346
 
331
- A command will be executed by specified runner. Dip has three types of them:
347
+ A command will be executed by the specified runner. You can set the runner explicitly via the `runner` key (e.g. `runner: docker_compose`). Otherwise dip picks the runner automatically:
332
348
 
333
349
  - `docker compose` runner — used when the `service` option is defined.
334
350
  - `kubectl` runner — used when the `pod` option is defined.
@@ -436,7 +452,7 @@ STAGE=some dip ktl get pods
436
452
 
437
453
  Runs ssh-agent container based on https://github.com/whilp/ssh-agent with your ~/.ssh/id_rsa.
438
454
  It creates a named volume `ssh_data` with ssh socket.
439
- An application's docker-compose.yml should contains environment variable `SSH_AUTH_SOCK=/ssh/auth/sock` and connects to external volume `ssh_data`.
455
+ An application's docker-compose.yml should contain the environment variable `SSH_AUTH_SOCK=/ssh/auth/sock` and connect the external volume `ssh_data`.
440
456
 
441
457
  ```sh
442
458
  dip ssh up
@@ -492,7 +508,6 @@ If validation fails, you'll get detailed error messages indicating what needs to
492
508
  You can skip validation by setting `DIP_SKIP_VALIDATION` environment variable.
493
509
 
494
510
  Add `# yaml-language-server: $schema=https://raw.githubusercontent.com/bibendi/dip/refs/heads/master/schema.json` to the top of your dip.yml to get schema validation in VSCode. Read more about [YAML Language Server](https://github.com/redhat-developer/vscode-yaml?tab=readme-ov-file#associating-schemas).
495
-
496
511
  ## Changelog
497
512
 
498
- https://github.com/bibendi/dip/releases
513
+ See [CHANGELOG.md](CHANGELOG.md).
data/lib/dip/cli.rb CHANGED
@@ -49,7 +49,10 @@ module Dip
49
49
 
50
50
  desc "compose CMD [OPTIONS]", "Run Docker Compose commands"
51
51
  def compose(*argv)
52
+ require_relative "commands/preflight"
52
53
  require_relative "commands/compose"
54
+
55
+ Dip::Commands::Preflight.new.execute
53
56
  Dip::Commands::Compose.new(*argv).execute
54
57
  end
55
58
 
@@ -84,7 +87,10 @@ module Dip
84
87
 
85
88
  desc "ktl CMD [OPTIONS]", "Run kubectl commands"
86
89
  def ktl(*argv)
90
+ require_relative "commands/preflight"
87
91
  require_relative "commands/kubectl"
92
+
93
+ Dip::Commands::Preflight.new.execute
88
94
  Dip::Commands::Kubectl.new(*argv).execute
89
95
  end
90
96
 
@@ -96,8 +102,10 @@ module Dip
96
102
  if argv.empty? || options[:help]
97
103
  invoke :help, ["run"]
98
104
  else
105
+ require_relative "commands/preflight"
99
106
  require_relative "commands/run"
100
107
 
108
+ Dip::Commands::Preflight.new.execute
101
109
  Dip::Commands::Run.new(
102
110
  *argv,
103
111
  **options.to_h.transform_keys!(&:to_sym)
@@ -12,7 +12,7 @@ module Dip
12
12
  longest_name = tree.keys.map(&:size).max
13
13
 
14
14
  tree.each do |name, command|
15
- puts "#{name.ljust(longest_name)} ##{command[:description] ? " #{command[:description]}" : ""}"
15
+ puts "#{name.ljust(longest_name)} ##{" #{command[:description]}" if command[:description]}"
16
16
  end
17
17
  end
18
18
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../command"
4
+
5
+ module Dip
6
+ module Commands
7
+ class Preflight < Dip::Command
8
+ def execute
9
+ Dip.config.preflight.each do |command|
10
+ exec_subprocess(command)
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
data/lib/dip/config.rb CHANGED
@@ -20,10 +20,11 @@ module Dip
20
20
  kubectl: {},
21
21
  infra: {},
22
22
  interaction: {},
23
- provision: []
23
+ provision: [],
24
+ preflight: []
24
25
  }.freeze
25
26
 
26
- TOP_LEVEL_KEYS = %i[environment compose kubectl infra interaction provision].freeze
27
+ TOP_LEVEL_KEYS = %i[environment compose kubectl infra interaction provision preflight].freeze
27
28
 
28
29
  ConfigKeyMissingError = Class.new(ArgumentError)
29
30
 
data/lib/dip/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dip
4
- VERSION = "8.2.5"
4
+ VERSION = "8.3.0"
5
5
  end
data/schema.json CHANGED
@@ -175,6 +175,16 @@
175
175
  ]
176
176
  ]
177
177
  },
178
+ "preflight": {
179
+ "type": "array",
180
+ "items": {
181
+ "type": "string"
182
+ },
183
+ "description": "Shell commands to run before any `dip compose` subcommand. A non-zero exit aborts the command.",
184
+ "examples": [
185
+ ["./bin/check-credentials", "test -f .env"]
186
+ ]
187
+ },
178
188
  "environment": {
179
189
  "$ref": "#/definitions/environment_vars"
180
190
  },
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dip
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.2.5
4
+ version: 8.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - bibendi
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-11-29 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: thor
@@ -154,14 +153,14 @@ dependencies:
154
153
  requirements:
155
154
  - - "~>"
156
155
  - !ruby/object:Gem::Version
157
- version: '2.2'
156
+ version: '3.0'
158
157
  type: :development
159
158
  prerelease: false
160
159
  version_requirements: !ruby/object:Gem::Requirement
161
160
  requirements:
162
161
  - - "~>"
163
162
  - !ruby/object:Gem::Version
164
- version: '2.2'
163
+ version: '3.0'
165
164
  - !ruby/object:Gem::Dependency
166
165
  name: simplecov
167
166
  requirement: !ruby/object:Gem::Requirement
@@ -232,6 +231,7 @@ files:
232
231
  - lib/dip/commands/infra/service.rb
233
232
  - lib/dip/commands/kubectl.rb
234
233
  - lib/dip/commands/list.rb
234
+ - lib/dip/commands/preflight.rb
235
235
  - lib/dip/commands/provision.rb
236
236
  - lib/dip/commands/run.rb
237
237
  - lib/dip/commands/runners/base.rb
@@ -252,7 +252,6 @@ licenses:
252
252
  - MIT
253
253
  metadata:
254
254
  allowed_push_host: https://rubygems.org/
255
- post_install_message:
256
255
  rdoc_options: []
257
256
  require_paths:
258
257
  - lib
@@ -267,8 +266,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
267
266
  - !ruby/object:Gem::Version
268
267
  version: '0'
269
268
  requirements: []
270
- rubygems_version: 3.5.21
271
- signing_key:
269
+ rubygems_version: 3.6.9
272
270
  specification_version: 4
273
271
  summary: Ruby gem CLI tool for better interacting Docker Compose files.
274
272
  test_files: []