dip 3.5.1 → 3.6.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: 1ddf8801ef01a76da6d71d1b32957bde546c51dd1886c25096f6ca4422d740d5
4
- data.tar.gz: 8b49bd15402dfcd852d6e1b80e9907f1f92babc0ab8fc789e4c38c5b8e44a558
3
+ metadata.gz: 3246e04b08a0a56b6e0affd8eff3d770647145546f3c47425291fd8f6f731da4
4
+ data.tar.gz: d68016e14a196cb6265dcc7a37782df46d1ba911921aab9bc42d7e62e6ed7230
5
5
  SHA512:
6
- metadata.gz: 979d79ae46e6449c74e650c544a0249b1f5d6ae423a314b5e96cc940ac9586d09b157ffbe28c06b6a623c28ff6b06a57bac7035efd9beb25be2195e96934f8a1
7
- data.tar.gz: 27cc30b7d126641d8cc1c380977288a9e541fd6dedd4b3e734bef5f572a5a753d7f346b945df845ba9e049b797792f9428f96aa4468009c8a388e808b3d9169e
6
+ metadata.gz: 9a846265e4fae5e87cd5e4e0ff75c7c7b4c6a600113fe5ffe509bec059aff169c53e45512408034fba1c22e6e23dcf9802730aee64952f05e301f9734bd9f775
7
+ data.tar.gz: bf3372c2dcae8432c1faf37a2d807b5214f1aa26f934195191a5abfcc8d37cd60c87683e9b59769ec5d4ee5028001e9410287cccc4d38b2ddb8db51041d53c94
data/README.md CHANGED
@@ -6,30 +6,57 @@
6
6
 
7
7
  Docker Interaction Process
8
8
 
9
- CLI utility for straightforward provisioning and interacting with an application configured by docker-compose.
9
+ Command line utility that gives the "native" interaction with applications configured with Docker Compose. It is for the local development only. In practice, it creates the feeling that you work without containers.
10
10
 
11
- DIP also contains commands for running support containers such as ssh-agent and DNS server.
11
+ <a href="https://evilmartians.com/?utm_source=dip">
12
+ <img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg" alt="Sponsored by Evil Martians" width="236" height="54"></a>
12
13
 
13
- ## Installation
14
+ ## Presentations and examples
15
+
16
+ - [Local development with Docker containers](https://slides.com/bibendi/dip)
17
+ - [Dockerized Ruby on Rails application](https://github.com/bibendi/dip-example-rails)
18
+ - [Dockerized Node.js application](https://github.com/bibendi/yt-graphql-react-event-booking-api)
19
+ - [Dockerized Ruby gem](https://github.com/bibendi/schked)
20
+
21
+ [![asciicast](https://asciinema.org/a/210236.svg)](https://asciinema.org/a/210236)
22
+
23
+ ## Integration with shell
24
+
25
+ Dip can be injected into current shell. For now, it supported ZSH only.
14
26
 
15
27
  ```sh
16
- gem install dip
28
+ dip console | source /dev/stdin
17
29
  ```
18
30
 
19
- ## Changelog
31
+ After that we can type commands without `dip` prefix. For example:
20
32
 
21
- https://github.com/bibendi/dip/releases
33
+ ```sh
34
+ <run-command> *any-args
35
+ compose *any-compose-arg
36
+ up <service>
37
+ down
38
+ provision
39
+ ```
40
+
41
+ When we change the current directory, all shell aliases will be automatically removed. But when we will enter back to a directory with a dip.yml file, then shell aliases will be renewed.
42
+
43
+ Also, in shell mode Dip is trying to determine passed manually environment variables. For example:
44
+
45
+ ```sh
46
+ VERSION=20180515103400 rails db:migrate:down
47
+ ```
48
+
49
+ ## Installation
22
50
 
51
+ ```sh
52
+ gem install dip
53
+ ```
23
54
 
24
55
  ## Docker installation
25
56
 
26
57
  - [Ubuntu](docs/docker-ubuntu-install.md)
27
58
  - [Mac OS](docs/docker-for-mac-install.md)
28
59
 
29
- ## Examples
30
-
31
- - [Modern Rails application with webpack](https://github.com/bibendi/dip-example-rails)
32
-
33
60
  ## Usage
34
61
 
35
62
  ```sh
@@ -39,6 +66,15 @@ dip SUBCOMMAND --help
39
66
 
40
67
  ### dip.yml
41
68
 
69
+ The configuration file `dip.yml` should be placed in a project root directory.
70
+ Also, in some cases, you may want to change the default config path by providing an environment variable `DIP_FILE`.
71
+ If nearby places `dip.override.yml` file it would be merged into the main config.
72
+
73
+ Below is an example of real config.
74
+ `dip.yml` reference will be written soon.
75
+ Also, you can check out examples in the top.
76
+
77
+
42
78
  ```yml
43
79
  version: '2'
44
80
 
@@ -53,7 +89,7 @@ compose:
53
89
  project_name: bear
54
90
 
55
91
  interaction:
56
- sh:
92
+ bash:
57
93
  service: app
58
94
  compose_run_options: [no-deps]
59
95
 
@@ -77,16 +113,16 @@ interaction:
77
113
  subcommands:
78
114
  s:
79
115
  service: web
80
- compose_method: up
116
+ compose_run_options: [service-ports]
81
117
 
82
118
  psql:
83
119
  service: app
84
120
  command: psql -h pg -U postgres
85
121
 
86
122
  provision:
123
+ - dip compose down --volumes
87
124
  - dip compose up -d pg redis
88
- - dip bundle install
89
- - dip rake db:migrate
125
+ - dip bash -c ./bin/setup
90
126
  ```
91
127
 
92
128
  ### dip run
@@ -119,32 +155,6 @@ dip compose COMMAND [OPTIONS]
119
155
  dip compose up -d redis
120
156
  ```
121
157
 
122
- ### Integration with shell
123
-
124
- Dip can be injected into current shell. For now, it supported ZSH only.
125
-
126
- ```sh
127
- dip console | source /dev/stdin
128
- ```
129
-
130
- After that we can type commands without `dip` prefix. For example:
131
-
132
- ```sh
133
- <run-command> *any-args
134
- compose *any-compose-arg
135
- up <service>
136
- down
137
- provision
138
- ```
139
-
140
- When we change the current directory, all shell aliases will be automatically removed. But when we will enter back to a directory with a dip.yml file, then shell aliases will be renewed.
141
-
142
- Also, in shell mode Dip is trying to determine passed manually environment variables. For example:
143
-
144
- ```sh
145
- VERSION=20180515103400 rails db:migrate:down
146
- ```
147
-
148
158
  ### dip ssh
149
159
 
150
160
  Runs ssh-agent container based on https://github.com/whilp/ssh-agent with your ~/.ssh/id_rsa.
@@ -237,3 +247,7 @@ dip dns up
237
247
  cd foo-project
238
248
  dip compose exec foo-web curl http://www.bar-app.docker/api/v1/baz_service
239
249
  ```
250
+
251
+ ## Changelog
252
+
253
+ https://github.com/bibendi/dip/releases
data/exe/dip CHANGED
@@ -21,7 +21,7 @@ end
21
21
 
22
22
  begin
23
23
  Dip::CLI.start(ARGV)
24
- rescue Dip::Error => err
25
- puts "ERROR: #{err.message}"
24
+ rescue Dip::Error => e
25
+ puts "ERROR: #{e.message}"
26
26
  exit 1
27
27
  end
data/lib/dip.rb CHANGED
@@ -12,7 +12,7 @@ module Dip
12
12
  end
13
13
 
14
14
  def env
15
- @env ||= Dip::Environment.new(config.exist? ? config.environment : {})
15
+ @env ||= Dip::Environment.new(Dip::Config.exist? ? config.environment : {})
16
16
  end
17
17
 
18
18
  def bin_path
@@ -55,7 +55,7 @@ module Dip
55
55
  end
56
56
 
57
57
  def execute
58
- if Dip.config.exist?
58
+ if Dip::Config.exist?
59
59
  alias_interaction if Dip.config.interaction
60
60
  alias_compose
61
61
  add_alias("provision")
data/lib/dip/config.rb CHANGED
@@ -3,16 +3,35 @@
3
3
  require "yaml"
4
4
  require "erb"
5
5
 
6
+ require "dip/ext/hash"
7
+
8
+ using ActiveSupportHashHelpers
9
+
6
10
  module Dip
7
11
  class Config
8
12
  DEFAULT_PATH = "dip.yml"
9
13
 
10
- def initialize
11
- @path = ENV["DIP_FILE"] || File.join(Dir.pwd, DEFAULT_PATH)
12
- end
14
+ class << self
15
+ def exist?
16
+ File.exist?(path)
17
+ end
18
+
19
+ def path
20
+ ENV["DIP_FILE"] || File.join(Dir.pwd, DEFAULT_PATH)
21
+ end
22
+
23
+ def override_path
24
+ path.gsub(/\.yml$/, ".override.yml")
25
+ end
13
26
 
14
- def exist?
15
- File.exist?(@path)
27
+ def load_yaml(file_path = path)
28
+ return {} unless File.exist?(file_path)
29
+
30
+ YAML.safe_load(
31
+ ERB.new(File.read(file_path)).result,
32
+ [], [], true
33
+ ).deep_symbolize_keys!
34
+ end
16
35
  end
17
36
 
18
37
  %i[environment compose interaction provision].each do |key|
@@ -28,39 +47,14 @@ module Dip
28
47
  private
29
48
 
30
49
  def config
31
- @config ||= load
32
- end
33
-
34
- def load
35
- raise ArgumentError, "Dip config not found at path '#{@path}'" unless exist?
50
+ return @config if @config
36
51
 
37
- @config = YAML.safe_load(
38
- ERB.new(File.read(@path)).result,
39
- [], [], true
40
- )
52
+ raise ArgumentError, "Dip config not found at path '#{self.class.path}'" unless self.class.exist?
41
53
 
42
- deep_symbolyze_keys!(@config)
54
+ config = self.class.load_yaml
55
+ config.deep_merge!(self.class.load_yaml(self.class.override_path))
43
56
 
44
- @config
45
- end
46
-
47
- # rubocop:disable Metrics/MethodLength
48
- def deep_symbolyze_keys!(object)
49
- case object
50
- when Hash
51
- object.keys.each do |key|
52
- value = object.delete(key)
53
- key = key.to_sym if key.is_a?(String)
54
- object[key] = deep_symbolyze_keys!(value)
55
- end
56
-
57
- object
58
- when Array
59
- object.map! { |e| deep_symbolyze_keys!(e) }
60
- else
61
- object
62
- end
57
+ @config = config
63
58
  end
64
- # rubocop:enable Metrics/MethodLength
65
59
  end
66
60
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Dip
4
4
  class Environment
5
- VAR_REGEX = /\$[\{]?(?<var_name>[a-zA-Z_][a-zA-Z0-9_]*)[\}]?/
5
+ VAR_REGEX = /\$[\{]?(?<var_name>[a-zA-Z_][a-zA-Z0-9_]*)[\}]?/.freeze
6
6
  SPECIAL_VARS = {"DIP_OS" => :find_dip_os}.freeze
7
7
 
8
8
  attr_reader :vars
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ # active_support helpers
4
+ module ActiveSupportHashHelpers
5
+ refine Hash do
6
+ def deep_symbolize_keys!
7
+ deep_transform_keys! { |key| key.respond_to?(:to_sym) ? key.to_sym : key }
8
+ end
9
+
10
+ def deep_transform_keys!(&block)
11
+ keys.each do |key|
12
+ value = delete(key)
13
+ self[yield(key)] = value.is_a?(Hash) ? value.deep_transform_keys!(&block) : value
14
+ end
15
+
16
+ self
17
+ end
18
+
19
+ def deep_merge(other_hash, &block)
20
+ dup.deep_merge!(other_hash, &block)
21
+ end
22
+
23
+ def deep_merge!(other_hash, &block)
24
+ merge!(other_hash) do |key, this_val, other_val|
25
+ if this_val.is_a?(Hash) && other_val.is_a?(Hash)
26
+ this_val.deep_merge(other_val, &block)
27
+ elsif block_given?
28
+ block.call(key, this_val, other_val)
29
+ else
30
+ other_val
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
data/lib/dip/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dip
4
- VERSION = "3.5.1"
4
+ VERSION = "3.6.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dip
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.1
4
+ version: 3.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - bibendi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-10-17 00:00:00.000000000 Z
11
+ date: 2019-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -28,14 +28,14 @@ dependencies:
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.16'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.16'
41
41
  - !ruby/object:Gem::Dependency
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '10.0'
61
+ version: '12.3'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '10.0'
68
+ version: '12.3'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -150,6 +150,7 @@ files:
150
150
  - lib/dip/commands/ssh.rb
151
151
  - lib/dip/config.rb
152
152
  - lib/dip/environment.rb
153
+ - lib/dip/ext/hash.rb
153
154
  - lib/dip/run_vars.rb
154
155
  - lib/dip/version.rb
155
156
  homepage: https://github.com/bibendi/dip