dapp 0.6.15 → 0.6.16
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 +4 -4
- data/config/en/common.yml +2 -0
- data/config/en/net_status.yml +4 -0
- data/lib/dapp.rb +2 -0
- data/lib/dapp/application.rb +13 -0
- data/lib/dapp/application/stages.rb +3 -3
- data/lib/dapp/build/stage/base.rb +1 -1
- data/lib/dapp/cli.rb +2 -1
- data/lib/dapp/cli/tag.rb +24 -0
- data/lib/dapp/config/directive/docker/base.rb +3 -1
- data/lib/dapp/docker_registry.rb +9 -9
- data/lib/dapp/image/docker.rb +9 -0
- data/lib/dapp/image/stage.rb +22 -12
- data/lib/dapp/project.rb +1 -0
- data/lib/dapp/project/command/common.rb +4 -0
- data/lib/dapp/project/command/push.rb +1 -0
- data/lib/dapp/project/command/spush.rb +1 -0
- data/lib/dapp/project/command/stages/common.rb +1 -0
- data/lib/dapp/project/command/stages/pull.rb +1 -0
- data/lib/dapp/project/command/stages/push.rb +1 -0
- data/lib/dapp/project/command/tag.rb +18 -0
- data/lib/dapp/project/logging/process.rb +1 -1
- data/lib/dapp/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 876026d4b44e0e133226070491379a862830e00e
|
4
|
+
data.tar.gz: e2b22a947be59dcef0b43f76f1d603172b51d95a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53ddd82966ead8876733adcef218708576845ee385d80e0f4aae84ee6a80822bc72317a1193b2260bdeb94133118164ee8e22d0c2f5bf83029e5598750512872
|
7
|
+
data.tar.gz: 297cf30895ee5f6e9cfaf542cc3b583f07e8f92490763b7962e2fc796f4aba2ebcf3b3257971d72c17dea797058e84cd22c251d03793850ab30bd747d3eb7aef
|
data/config/en/common.yml
CHANGED
@@ -28,6 +28,7 @@ en:
|
|
28
28
|
pulling: '[PULLING]'
|
29
29
|
building: '[BUILDING]'
|
30
30
|
default: '[RUNNING]'
|
31
|
+
tagging: '[TAGGING]'
|
31
32
|
success:
|
32
33
|
default: '[OK]'
|
33
34
|
failed:
|
@@ -40,6 +41,7 @@ en:
|
|
40
41
|
empty: '[EMPTY]'
|
41
42
|
push: '[PUSH]'
|
42
43
|
pull: '[PULL]'
|
44
|
+
tag: '[TAG]'
|
43
45
|
warning:
|
44
46
|
excess_builder_instruction: "WARNING: Excessive use of the 'builder' instruction. Builder type will be automatically determined by the first use of any builder."
|
45
47
|
excess_name_instruction: "WARNING: Excessive use of the 'name' instruction. Given name corresponds to default name."
|
data/config/en/net_status.yml
CHANGED
@@ -19,6 +19,9 @@ en:
|
|
19
19
|
from_image_not_found: 'Image `%{name}` not found!'
|
20
20
|
project:
|
21
21
|
spush_command_unexpected_apps_number: "Command 'spush' can process only one application!"
|
22
|
+
tag_command_unexpected_apps_number: "Command 'tag' can process only one application!"
|
23
|
+
tag_command_incorrect_tag: "Incorrect tag ('%{name}') given!"
|
24
|
+
repo_name_incorrect: "Incorrect repo ('%{name}') given!"
|
22
25
|
command_unexpected_apps_number: "Command can process only one application!"
|
23
26
|
no_such_app: "No such app: '%{apps_patterns}'!"
|
24
27
|
dappfile_not_found: "Dappfile not found!"
|
@@ -39,6 +42,7 @@ en:
|
|
39
42
|
stage_artifact_not_supported_associated_stage: "Artifact not supported associated stage '%{stage}'!"
|
40
43
|
git_artifact_unexpected_attribute: "'%{type}' git artifact doesn't has attribute '%{attr}'!"
|
41
44
|
docker_from_incorrect: "`docker.from` has incorrect value `%{name}`: expected format `image_name:tag`!"
|
45
|
+
docker_from_without_tag: "`docker.from` has incorrect value `%{name}`: expected format `image_name:tag`!"
|
42
46
|
app_name_incorrect: "Application has incorrect name '%{name}': doesn't match regex '%{reg}'!"
|
43
47
|
chef:
|
44
48
|
stage_path_overlap: "Cannot install '%{cookbook}' cookbook's path %{from} into %{to}: already exists"
|
data/lib/dapp.rb
CHANGED
@@ -42,6 +42,7 @@ require 'dapp/cli/base'
|
|
42
42
|
require 'dapp/cli/build'
|
43
43
|
require 'dapp/cli/push'
|
44
44
|
require 'dapp/cli/spush'
|
45
|
+
require 'dapp/cli/tag'
|
45
46
|
require 'dapp/cli/list'
|
46
47
|
require 'dapp/cli/stages'
|
47
48
|
require 'dapp/cli/stages/flush_local'
|
@@ -119,6 +120,7 @@ require 'dapp/project/command/list'
|
|
119
120
|
require 'dapp/project/command/push'
|
120
121
|
require 'dapp/project/command/run'
|
121
122
|
require 'dapp/project/command/spush'
|
123
|
+
require 'dapp/project/command/tag'
|
122
124
|
require 'dapp/project/command/stages/common'
|
123
125
|
require 'dapp/project/command/stages/cleanup_local'
|
124
126
|
require 'dapp/project/command/stages/cleanup_repo'
|
data/lib/dapp/application.rb
CHANGED
@@ -39,6 +39,19 @@ module Dapp
|
|
39
39
|
FileUtils.rm_rf(tmp_path)
|
40
40
|
end
|
41
41
|
|
42
|
+
def tag!(tag)
|
43
|
+
project.lock("#{config._basename}.images", readonly: true) do
|
44
|
+
applicaion_name = config._name
|
45
|
+
if project.dry_run?
|
46
|
+
project.log_state(applicaion_name, state: project.t(code: 'state.tag'), styles: { status: :success })
|
47
|
+
else
|
48
|
+
project.log_process(applicaion_name, process: project.t(code: 'status.process.tagging')) do
|
49
|
+
last_stage.image.tag!(tag)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
42
55
|
def export!(repo, format:)
|
43
56
|
project.lock("#{config._basename}.images", readonly: true) do
|
44
57
|
tags.each do |tag|
|
@@ -17,14 +17,14 @@ module Dapp
|
|
17
17
|
|
18
18
|
def images
|
19
19
|
(@images ||= []).tap do |images|
|
20
|
-
stages.
|
20
|
+
stages.each do |stage|
|
21
21
|
if stage.respond_to?(:images)
|
22
22
|
images.concat(stage.images)
|
23
23
|
else
|
24
24
|
images << stage.image
|
25
25
|
end
|
26
|
-
end
|
27
|
-
end
|
26
|
+
end
|
27
|
+
end.uniq!(&:name)
|
28
28
|
end
|
29
29
|
|
30
30
|
protected
|
data/lib/dapp/cli.rb
CHANGED
@@ -5,7 +5,7 @@ module Dapp
|
|
5
5
|
include Mixlib::CLI
|
6
6
|
include Helper::Trivia
|
7
7
|
|
8
|
-
SUBCOMMANDS = ['build', 'push', 'spush', 'list', 'run', 'stages', 'cleanup', 'bp', 'mrproper', 'stage image'].freeze
|
8
|
+
SUBCOMMANDS = ['build', 'push', 'spush', 'list', 'run', 'stages', 'cleanup', 'bp', 'mrproper', 'stage image', 'tag'].freeze
|
9
9
|
|
10
10
|
banner <<BANNER.freeze
|
11
11
|
Usage: dapp [options] sub-command [sub-command options]
|
@@ -16,6 +16,7 @@ dapp build [options] [APPS PATTERN ...]
|
|
16
16
|
dapp bp [options] [APPS PATTERN ...] REPO
|
17
17
|
dapp push [options] [APP PATTERN] REPO
|
18
18
|
dapp spush [options] [APPS PATTERN ...] REPO
|
19
|
+
dapp tag [options] [APP PATTERN ...] TAG
|
19
20
|
dapp list [options] [APPS PATTERN ...]
|
20
21
|
dapp run [options] [APP PATTERN] [DOCKER ARGS]
|
21
22
|
dapp cleanup [options] [APPS PATTERN ...]
|
data/lib/dapp/cli/tag.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
module Dapp
|
2
|
+
class CLI
|
3
|
+
# CLI tag subcommand
|
4
|
+
class Tag < Base
|
5
|
+
banner <<BANNER.freeze
|
6
|
+
Version: #{Dapp::VERSION}
|
7
|
+
|
8
|
+
Usage:
|
9
|
+
dapp tag [options] [APP PATTERN ...] TAG
|
10
|
+
|
11
|
+
APP PATTERN Application to process [default: *].
|
12
|
+
REPO Pushed image name.
|
13
|
+
|
14
|
+
Options:
|
15
|
+
BANNER
|
16
|
+
|
17
|
+
def run(argv = ARGV)
|
18
|
+
self.class.parse_options(self, argv)
|
19
|
+
tag = self.class.required_argument(self)
|
20
|
+
Project.new(cli_options: config, apps_patterns: cli_arguments).public_send(class_to_lowercase, tag)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -18,7 +18,9 @@ module Dapp
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def from(image, cache_version: nil)
|
21
|
-
|
21
|
+
image = image.to_s
|
22
|
+
raise(Error::Config, code: :docker_from_incorrect, data: { name: image }) unless image =~ Image::Docker.image_regex
|
23
|
+
raise(Error::Config, code: :docker_from_without_tag, data: { name: image }) unless image.include?(':')
|
22
24
|
@_from = image
|
23
25
|
@_from_cache_version = cache_version
|
24
26
|
end
|
data/lib/dapp/docker_registry.rb
CHANGED
@@ -3,8 +3,8 @@ module Dapp
|
|
3
3
|
module DockerRegistry
|
4
4
|
def self.new(repo)
|
5
5
|
repo_regex =~ repo
|
6
|
-
expected_hostname = Regexp.last_match(
|
7
|
-
expected_repo_suffix = Regexp.last_match(
|
6
|
+
expected_hostname = Regexp.last_match(:hostname)
|
7
|
+
expected_repo_suffix = Regexp.last_match(:repo_suffix)
|
8
8
|
expected_hostname_url = expected_hostname ? "http://#{expected_hostname}" : nil
|
9
9
|
|
10
10
|
if hostname_exist?(expected_hostname_url)
|
@@ -15,13 +15,13 @@ module Dapp
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.repo_regex
|
18
|
-
separator =
|
19
|
-
alpha_numeric =
|
20
|
-
component =
|
21
|
-
port_number =
|
22
|
-
hostcomponent =
|
23
|
-
hostname =
|
24
|
-
%r{^(
|
18
|
+
separator = '[_.]|__|[-]*'
|
19
|
+
alpha_numeric = '[[:alnum:]]*'
|
20
|
+
component = "#{alpha_numeric}[#{separator}#{alpha_numeric}]*"
|
21
|
+
port_number = '[[:digit:]]+'
|
22
|
+
hostcomponent = '[[:alnum:]-]*[[:alnum:]]'
|
23
|
+
hostname = "#{hostcomponent}[\.#{hostcomponent}]*(?<port>:#{port_number})?"
|
24
|
+
%r{^(?<hostname>#{hostname}/)?(?<repo_suffix>#{component}[/#{component}]*)$}
|
25
25
|
end
|
26
26
|
|
27
27
|
def self.hostname_exist?(url)
|
data/lib/dapp/image/docker.rb
CHANGED
@@ -68,6 +68,15 @@ module Dapp
|
|
68
68
|
end
|
69
69
|
|
70
70
|
class << self
|
71
|
+
def image_regex
|
72
|
+
/^[a-z0-9]+(?:[._-][a-z0-9]+)*(:[\w][\w.-]{0,127})?$/
|
73
|
+
end
|
74
|
+
|
75
|
+
def tag!(id:, tag:)
|
76
|
+
Project.shellout!("docker tag #{id} #{tag}")
|
77
|
+
cache_reset
|
78
|
+
end
|
79
|
+
|
71
80
|
def cache
|
72
81
|
@cache ||= (@cache = {}).tap { cache_reset }
|
73
82
|
end
|
data/lib/dapp/image/stage.rb
CHANGED
@@ -33,24 +33,30 @@ module Dapp
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def export!(name)
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
36
|
+
tag!(name).tap do |image|
|
37
|
+
image.push!
|
38
|
+
image.untag!
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def tag!(name)
|
43
|
+
clone!(name).tap do |image|
|
44
|
+
self.class.tag!(id: image.built_id, tag: image.name)
|
45
|
+
end
|
40
46
|
end
|
41
47
|
|
42
48
|
def import!(name)
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
49
|
+
clone!(name).tap do |image|
|
50
|
+
image.pull!
|
51
|
+
@built_id = image.built_id
|
52
|
+
save_in_cache!
|
53
|
+
image.untag!
|
54
|
+
end
|
48
55
|
end
|
49
56
|
|
50
|
-
def
|
57
|
+
def save_in_cache!
|
51
58
|
project.log_warning(desc: { code: :another_image_already_tagged }) if !(existed_id = id).nil? && built_id != existed_id
|
52
|
-
|
53
|
-
cache_reset
|
59
|
+
self.class.tag!(id: built_id, tag: name)
|
54
60
|
end
|
55
61
|
|
56
62
|
def labels
|
@@ -77,6 +83,10 @@ module Dapp
|
|
77
83
|
def commit!
|
78
84
|
project.shellout!("docker commit #{prepared_change} #{container_name}").stdout.strip
|
79
85
|
end
|
86
|
+
|
87
|
+
def clone!(name)
|
88
|
+
self.class.new(name: name, project: project, built_id: built_id)
|
89
|
+
end
|
80
90
|
end # Stage
|
81
91
|
end # Image
|
82
92
|
end # Dapp
|
data/lib/dapp/project.rb
CHANGED
@@ -63,6 +63,10 @@ module Dapp
|
|
63
63
|
basename
|
64
64
|
end
|
65
65
|
|
66
|
+
def validate_repo_name(repo)
|
67
|
+
raise(Error::Project, code: :repo_name_incorrect, data: { name: repo }) unless repo =~ DockerRegistry.repo_regex
|
68
|
+
end
|
69
|
+
|
66
70
|
def proper_cache_version?
|
67
71
|
!!cli_options[:proper_cache_version]
|
68
72
|
end
|
@@ -6,6 +6,7 @@ module Dapp
|
|
6
6
|
# Spush
|
7
7
|
module Spush
|
8
8
|
def spush(repo)
|
9
|
+
validate_repo_name(repo)
|
9
10
|
raise Error::Project, code: :spush_command_unexpected_apps_number unless build_configs.one?
|
10
11
|
Application.new(config: build_configs.first, project: self, ignore_git_fetch: true, should_be_built: true).tap do |app|
|
11
12
|
app.export!(repo, format: '%{repo}:%{tag}')
|
@@ -7,6 +7,7 @@ module Dapp
|
|
7
7
|
# Push
|
8
8
|
module Push
|
9
9
|
def stages_push(repo)
|
10
|
+
validate_repo_name(repo)
|
10
11
|
build_configs.each do |config|
|
11
12
|
log_step_with_indent(config._name) do
|
12
13
|
Application.new(config: config, project: self, ignore_git_fetch: true, should_be_built: true).tap do |app|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Dapp
|
2
|
+
# Project
|
3
|
+
class Project
|
4
|
+
# Command
|
5
|
+
module Command
|
6
|
+
# Tag
|
7
|
+
module Tag
|
8
|
+
def tag(tag)
|
9
|
+
raise Error::Project, code: :tag_command_unexpected_apps_number unless build_configs.one?
|
10
|
+
raise Error::Project, code: :tag_command_incorrect_tag, data: { name: tag } unless tag =~ Image::Docker.image_regex
|
11
|
+
Application.new(config: build_configs.first, project: self, ignore_git_fetch: true, should_be_built: true).tap do |app|
|
12
|
+
app.tag!(tag)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end # Project
|
18
|
+
end # Dapp
|
@@ -48,7 +48,7 @@ module Dapp
|
|
48
48
|
# rubocop:enable Metrics/ParameterLists
|
49
49
|
|
50
50
|
def log_secondary_process(message, **kwargs, &blk)
|
51
|
-
log_process(message, **kwargs.merge(style: { message: :secondary, success: :secondary }), &blk)
|
51
|
+
log_process(message, **kwargs.merge(style: { message: :secondary, success: :secondary }, quiet: !log_verbose?), &blk)
|
52
52
|
end
|
53
53
|
|
54
54
|
protected
|
data/lib/dapp/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dapp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Stolyarov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mixlib-shellout
|
@@ -408,6 +408,7 @@ files:
|
|
408
408
|
- lib/dapp/cli/stages/flush_repo.rb
|
409
409
|
- lib/dapp/cli/stages/pull.rb
|
410
410
|
- lib/dapp/cli/stages/push.rb
|
411
|
+
- lib/dapp/cli/tag.rb
|
411
412
|
- lib/dapp/config/application.rb
|
412
413
|
- lib/dapp/config/artifact.rb
|
413
414
|
- lib/dapp/config/directive/artifact.rb
|
@@ -473,6 +474,7 @@ files:
|
|
473
474
|
- lib/dapp/project/command/stages/flush_repo.rb
|
474
475
|
- lib/dapp/project/command/stages/pull.rb
|
475
476
|
- lib/dapp/project/command/stages/push.rb
|
477
|
+
- lib/dapp/project/command/tag.rb
|
476
478
|
- lib/dapp/project/dappfile.rb
|
477
479
|
- lib/dapp/project/deps/base.rb
|
478
480
|
- lib/dapp/project/deps/gitartifact.rb
|