fastlane-plugin-docker 0.1.0.pre.alpha.pre.3

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d70f2096fa94924d5274c2481521d9c4ff0beb86
4
+ data.tar.gz: 6dd9b5aeea62edcc34f88c89e553e822d30bb360
5
+ SHA512:
6
+ metadata.gz: cc3fc28924fb47bee47b9c85a8ef7d6bfaf167ae31912388bb9917ea266eb405a94f21f86f3d4f3c475b623cc33fc93634a7ad94de4466a746c385ee838df57f
7
+ data.tar.gz: bd5f36a15dcd6907fa7b1a29ecf348baecdfc4c98a1b4f763738892a8e98605a060bd4d2183b224d900541109dfbf7210cdf73c29c16dd902467641ac79c1bec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Manu Wallner <m.wallner@xforge.at>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # docker plugin
2
+
3
+ [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-docker)
4
+
5
+ ## Getting Started
6
+
7
+ This project is a [fastlane](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-docker`, add it to your project by running:
8
+
9
+ ```bash
10
+ fastlane add_plugin docker
11
+ ```
12
+
13
+ ## About docker
14
+
15
+ Actions to support building images, logging into Docker Hub, and pushing those images to the Hub
16
+
17
+ ## Example
18
+
19
+ Here is some sample code to get you started:
20
+
21
+ ```ruby
22
+
23
+ lane :release_docker_image do
24
+ ensure_docker_machine_available(
25
+ machine_name: "docker-build-machine"
26
+ )
27
+
28
+ docker_login
29
+
30
+ docker_build(
31
+ repository: "example-org/server",
32
+ tag: "1.2.0"
33
+ )
34
+
35
+ docker_push
36
+ end
37
+
38
+ ```
39
+
40
+ This will start using a docker machine (creating it if it doesn't exist yet), login to docker hub, build and tag a new docker image and push that image to Docker Hub.
41
+
42
+ Alternatively, check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin. Try it by cloning the repo, setting your Docker Hub username and password as environment variables by running `export DOCKER_LOGIN_USER="<your user name>"` and `export DOCKER_LOGIN_PASSWORD="<your password>"`, running `fastlane install_plugins` and `bundle exec fastlane test`.
43
+
44
+ Attention: If you don't change the example Fastfile at all, a new repository with `<your username>/test` will be pushed to Docker Hub!
45
+
46
+ ## Run tests for this plugin
47
+
48
+ To run both the tests, and code style validation, run
49
+
50
+ ```
51
+ rake
52
+ ```
53
+
54
+ To automatically fix many of the styling issues, use
55
+ ```
56
+ rubocop -a
57
+ ```
58
+
59
+ ## Issues and Feedback
60
+
61
+ For any other issues and feedback about this plugin, please submit it to this repository.
62
+
63
+ ## Troubleshooting
64
+
65
+ If you have trouble using plugins, check out the [Plugins Troubleshooting](https://github.com/fastlane/fastlane/blob/master/fastlane/docs/PluginsTroubleshooting.md) doc in the main `fastlane` repo.
66
+
67
+ ## Using `fastlane` Plugins
68
+
69
+ For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Plugins.md).
70
+
71
+ ## About `fastlane`
72
+
73
+ `fastlane` is the easiest way to automate beta deployments and releases for your iOS and Android apps. To learn more, check out [fastlane.tools](https://fastlane.tools).
@@ -0,0 +1,16 @@
1
+ require 'fastlane/plugin/docker/version'
2
+
3
+ module Fastlane
4
+ module Docker
5
+ # Return all .rb files inside the "actions" and "helper" directory
6
+ def self.all_classes
7
+ Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]
8
+ end
9
+ end
10
+ end
11
+
12
+ # By default we want to import all available actions and helpers
13
+ # A plugin can contain any number of actions and plugins
14
+ Fastlane::Docker.all_classes.each do |current|
15
+ require current
16
+ end
@@ -0,0 +1,59 @@
1
+ module Fastlane
2
+ module Actions
3
+ module SharedValues
4
+ DOCKER_BUILT_IMAGE = :DOCKER_BUILT_IMAGE
5
+ DOCKER_BUILT_REPO = :DOCKER_BUILT_REPO
6
+ DOCKER_BUILT_TAG = :DOCKER_BUILT_TAG
7
+ end
8
+
9
+ class DockerBuildAction < Action
10
+ def self.run(params)
11
+ UI.message "Building docker image..."
12
+
13
+ Actions.lane_context[SharedValues::DOCKER_BUILT_IMAGE] = DockerClient.new.build(params[:repository], params[:path], tag: params[:tag])
14
+ Actions.lane_context[SharedValues::DOCKER_BUILT_REPO] = params[:repository]
15
+ Actions.lane_context[SharedValues::DOCKER_BUILT_TAG] = params[:tag]
16
+ end
17
+
18
+ def self.description
19
+ "Build docker images in the current directory"
20
+ end
21
+
22
+ def self.available_options
23
+ [
24
+ FastlaneCore::ConfigItem.new(key: :repository,
25
+ description: "The docker repository",
26
+ env_name: "DOCKER_BUILD_REPOSITORY"),
27
+ FastlaneCore::ConfigItem.new(key: :tag,
28
+ description: "The tag for the new image",
29
+ default_value: "latest",
30
+ env_name: "DOCKER_BUILD_TAG"),
31
+ FastlaneCore::ConfigItem.new(key: :path,
32
+ description: "Path to the Dockerfile",
33
+ default_value: ".",
34
+ env_name: "DOCKER_BUILD_PATH")
35
+ ]
36
+ end
37
+
38
+ def self.output
39
+ [
40
+ ["DOCKER_BUILT_IMAGE", "The ID of the docker image that was built. Other docker actions pick this up automatically"],
41
+ ["DOCKER_BUILT_REPO", "The Repository of the docker image that was built. Other docker actions pick this up automatically"],
42
+ ["DOCKER_BUILT_TAG", "The Tag of the docker image that was built. Other docker actions pick this up automatically"]
43
+ ]
44
+ end
45
+
46
+ def self.return_value
47
+ "The ID of the created image"
48
+ end
49
+
50
+ def self.authors
51
+ ["milch"]
52
+ end
53
+
54
+ def self.is_supported?(platform)
55
+ true
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,26 @@
1
+ module Fastlane
2
+ module Actions
3
+ class DockerClient
4
+ def build(repository, path, tag: "latest")
5
+ result = Actions.sh "docker build --pull -t #{repository.shellescape}:#{tag.shellescape} #{path.shellescape}"
6
+
7
+ # Image ID is the last word of the last line
8
+ return result.lines.last.split(" ").last
9
+ end
10
+
11
+ def login(username, password, email: nil)
12
+ cmd = "docker login --username=\"#{username}\" --password=\"#{password}\""
13
+ cmd << "--email=\"#{email}\"" unless email.nil?
14
+
15
+ Actions.sh cmd
16
+ end
17
+
18
+ def push(repository, tag: nil)
19
+ cmd = "docker push #{repository}"
20
+ cmd << ":#{tag}" unless tag.nil?
21
+
22
+ Actions.sh cmd
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,36 @@
1
+ module Fastlane
2
+ module Actions
3
+ class DockerLoginAction < Action
4
+ def self.run(params)
5
+ UI.message "Logging into docker hub..."
6
+ DockerClient.new.login(params[:username], params[:password], email: params[:email])
7
+ end
8
+
9
+ def self.description
10
+ "Login to Docker Hub"
11
+ end
12
+
13
+ def self.available_options
14
+ [
15
+ FastlaneCore::ConfigItem.new(key: :username,
16
+ description: "Username for Docker Hub",
17
+ env_name: "DOCKER_LOGIN_USER"),
18
+ FastlaneCore::ConfigItem.new(key: :password,
19
+ description: "Password for Docker Hub",
20
+ env_name: "DOCKER_LOGIN_PASSWORD"),
21
+ FastlaneCore::ConfigItem.new(key: :email,
22
+ description: "Email for Docker Hub",
23
+ optional: true)
24
+ ]
25
+ end
26
+
27
+ def self.authors
28
+ ["milch"]
29
+ end
30
+
31
+ def self.is_supported?(platform)
32
+ true
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,41 @@
1
+ module Fastlane
2
+ module Actions
3
+ module SharedValues
4
+ DOCKER_ACTIVE_MACHINE = :DOCKER_ACTIVE_MACHINE
5
+ end
6
+ class DockerMachineClient
7
+ def list
8
+ script = <<SCRIPT
9
+ docker-machine ls | tail -n +2 | tr -s " " "," | cut -f 1 -d ","
10
+ SCRIPT
11
+ machines = Actions.sh script.strip
12
+ return machines.lines.map(&:strip)
13
+ end
14
+
15
+ def machine_available?(machine_name)
16
+ return list.include? machine_name
17
+ end
18
+
19
+ def is_running?(machine_name)
20
+ Actions.sh("docker-machine status #{machine_name}").strip == "Running"
21
+ end
22
+
23
+ def start(machine_name)
24
+ Actions.sh("docker-machine start #{machine_name}")
25
+ end
26
+
27
+ def create_machine(name)
28
+ Actions.sh "docker-machine create -d virtualbox #{name.shellescape} 1> /dev/null"
29
+ end
30
+
31
+ def configure_env(machine_name)
32
+ instructions = (Actions.sh "docker-machine env #{machine_name} --shell sh").lines
33
+ instructions.map!(&:strip).select! { |i| i =~ /^export/ }
34
+ instructions.each do |i|
35
+ key, value = i.split(" ").last.split("=")
36
+ ENV[key] = value.chomp("\"").reverse.chomp("\"").reverse
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,33 @@
1
+ module Fastlane
2
+ module Actions
3
+ class DockerPushAction < Action
4
+ def self.run(params)
5
+ UI.message "Pushing docker image..."
6
+ DockerClient.new.push(params[:repository], tag: params[:tag])
7
+ end
8
+
9
+ def self.description
10
+ "Push a docker image to its' repository"
11
+ end
12
+
13
+ def self.available_options
14
+ [
15
+ FastlaneCore::ConfigItem.new(key: :repository,
16
+ description: "The repository to upload",
17
+ default_value: Actions.lane_context[SharedValues::DOCKER_BUILT_REPO]),
18
+ FastlaneCore::ConfigItem.new(key: :tag,
19
+ description: "The tag to upload",
20
+ default_value: Actions.lane_context[SharedValues::DOCKER_BUILT_TAG])
21
+ ]
22
+ end
23
+
24
+ def self.authors
25
+ ["milch"]
26
+ end
27
+
28
+ def self.is_supported?(platform)
29
+ true
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,43 @@
1
+ module Fastlane
2
+ module Actions
3
+ class EnsureDockerMachineAvailableAction < Action
4
+ def self.run(params)
5
+ client = DockerMachineClient.new
6
+ machine_name = params[:machine_name]
7
+
8
+ unless client.machine_available? machine_name
9
+ UI.message "No machine of name #{machine_name} found, creating one..."
10
+ client.create_machine machine_name
11
+ end
12
+
13
+ client.start(machine_name) unless client.is_running? machine_name
14
+
15
+ client.configure_env(machine_name)
16
+
17
+ UI.message "Your machine is ready to go!"
18
+ Actions.lane_context[SharedValues::DOCKER_ACTIVE_MACHINE] = machine_name
19
+ end
20
+
21
+ def self.description
22
+ "Makes sure a docker machine is created and available for us to use"
23
+ end
24
+
25
+ def self.available_options
26
+ [
27
+ FastlaneCore::ConfigItem.new(key: :machine_name,
28
+ description: "Name of the Docker Machine",
29
+ default_value: "fastlane-docker")
30
+
31
+ ]
32
+ end
33
+
34
+ def self.authors
35
+ ["milch"]
36
+ end
37
+
38
+ def self.is_supported?(platform)
39
+ true
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,12 @@
1
+ module Fastlane
2
+ module Helper
3
+ class DockerHelper
4
+ # class methods that you define here become available in your action
5
+ # as `Helper::DockerHelper.your_method`
6
+ #
7
+ def self.show_message
8
+ UI.message("Hello from the docker plugin helper!")
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ module Fastlane
2
+ module Docker
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,139 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastlane-plugin-docker
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0.pre.alpha.pre.3
5
+ platform: ruby
6
+ authors:
7
+ - Manu Wallner
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-11-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pry
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: fastlane
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 1.107.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 1.107.0
97
+ description:
98
+ email: manu@supermil.ch
99
+ executables: []
100
+ extensions: []
101
+ extra_rdoc_files: []
102
+ files:
103
+ - LICENSE
104
+ - README.md
105
+ - lib/fastlane/plugin/docker.rb
106
+ - lib/fastlane/plugin/docker/actions/docker_build.rb
107
+ - lib/fastlane/plugin/docker/actions/docker_client.rb
108
+ - lib/fastlane/plugin/docker/actions/docker_login.rb
109
+ - lib/fastlane/plugin/docker/actions/docker_machine_client.rb
110
+ - lib/fastlane/plugin/docker/actions/docker_push.rb
111
+ - lib/fastlane/plugin/docker/actions/ensure_docker_machine_available.rb
112
+ - lib/fastlane/plugin/docker/helper/docker_helper.rb
113
+ - lib/fastlane/plugin/docker/version.rb
114
+ homepage: https://github.com/milch/fastlane-plugin-docker
115
+ licenses:
116
+ - MIT
117
+ metadata: {}
118
+ post_install_message:
119
+ rdoc_options: []
120
+ require_paths:
121
+ - lib
122
+ required_ruby_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ required_rubygems_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">"
130
+ - !ruby/object:Gem::Version
131
+ version: 1.3.1
132
+ requirements: []
133
+ rubyforge_project:
134
+ rubygems_version: 2.4.8
135
+ signing_key:
136
+ specification_version: 4
137
+ summary: fastlane Actions to support building images, logging into Docker Hub, and
138
+ pushing those images to the Hub
139
+ test_files: []