k8sflow 0.11.12 → 0.12.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 +4 -4
- data/lib/k8sflow/command/docker/docker_topic.rb +1 -1
- data/lib/k8sflow/command/docker/run.rb +14 -8
- data/lib/k8sflow/utils/varager.rb +38 -0
- data/lib/k8sflow/version.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe138974923c31af7ba91c03df92e17cc81177be
|
4
|
+
data.tar.gz: 038750df85f202b69a429b791b5c4df0a236c725
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73003a7f4c67b31ac43839211e8c43b01cea661b1dbefca53d7519a71bfb022ca64768b990c48ecf7c4e0ad451ccc38e226f3d454040c7a6dce5a514b6dd82d7
|
7
|
+
data.tar.gz: d05d5e563948faeb5b0f8070b54636c1fd6247348ed5e15f161e9e4852e7f496608998da32f05c498e9be25a046da09f040e8167784f01518bb05874865302e3
|
@@ -5,7 +5,7 @@ module K8sflow
|
|
5
5
|
description: 'Mange docker image and run'
|
6
6
|
|
7
7
|
option :registry, '-r', '--registry DOCKER_REPO', 'Docker registry to pull/fetch images'
|
8
|
-
option :docker_api, "-H", "--host", "docker api endpoint", default: "unix://"
|
8
|
+
option :docker_api, "-H", "--host host", "docker api endpoint", default: "unix://"
|
9
9
|
option :tag, '-t', '--tag TAG', "Image tag", default: 'latest'
|
10
10
|
|
11
11
|
end
|
@@ -1,7 +1,8 @@
|
|
1
1
|
require 'optparse'
|
2
2
|
require 'optparse/time'
|
3
3
|
require 'docker'
|
4
|
-
require 'k8sflow/utils/
|
4
|
+
require 'k8sflow/utils/varager'
|
5
|
+
|
5
6
|
require_relative 'docker_image_base'
|
6
7
|
|
7
8
|
module K8sflow
|
@@ -23,10 +24,11 @@ $ k8sflow run -t 2.10 -p 3000:3000 'run server -p 3000'
|
|
23
24
|
option :port, "-p", "--port ctn_port:host_port", Array, "Publish a container's port(s) to the host"
|
24
25
|
option :port_all, "-P", "--port-all", Array, "Publish all exposed ports to random ports"
|
25
26
|
option :detach, "-d", "--detach", "daemonize container", default: false
|
26
|
-
option :app, "-A", "--app APPNAME", "application name"
|
27
27
|
option :envs, "-e", "--env VAR=VALUE,VAR2=VALUE2", Array, "envvars list"
|
28
|
-
option :
|
29
|
-
option :
|
28
|
+
option :app, "-A", "--app APP", "app name"
|
29
|
+
option :varager_api, "--varager-api API", "varager api endpoint with token, include http(s)://"
|
30
|
+
option :varager_token, "--varager-token API-TOKEN", "varager api auth token"
|
31
|
+
option :varager_db, "--heroku-db", "get DB envs only from heroku"
|
30
32
|
option :tty, "--[no-]tty", "Use tty"
|
31
33
|
option :aliases, "--aliases a=x,b=y", "commands aliases, usefull in the default file"
|
32
34
|
|
@@ -62,15 +64,19 @@ $ k8sflow run -t 2.10 -p 3000:3000 'run server -p 3000'
|
|
62
64
|
envs[key] = value
|
63
65
|
end
|
64
66
|
end
|
65
|
-
|
66
|
-
|
67
|
+
|
68
|
+
if options.has_key?(:varager_api) && options[:varager_api] != nil
|
69
|
+
uri = options[:varager_api]
|
70
|
+
token = options[:varager_token]
|
71
|
+
client = K8sflow::Utils::Varager.new(token, uri)
|
72
|
+
envs.merge!(client.envs(options[:app], false))
|
67
73
|
end
|
68
74
|
pp envs
|
69
75
|
return envs
|
70
76
|
end
|
71
77
|
|
72
78
|
def docker_run(cmd, envs, options)
|
73
|
-
Docker.url = options[:docker_api]
|
79
|
+
::Docker.url = options[:docker_api]
|
74
80
|
container_info = {
|
75
81
|
'Cmd' => cmd.split(" "),
|
76
82
|
'Image' => "#{options[:registry]}:#{options[:tag]}",
|
@@ -90,7 +96,7 @@ $ k8sflow run -t 2.10 -p 3000:3000 'run server -p 3000'
|
|
90
96
|
container_info["PublishAllPorts"] = true
|
91
97
|
end
|
92
98
|
pp container_info
|
93
|
-
container = Docker::Container.create(container_info)
|
99
|
+
container = ::Docker::Container.create(container_info)
|
94
100
|
container.start
|
95
101
|
puts "container created with id: #{container.id}"
|
96
102
|
if !options[:detach]
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'pp'
|
2
|
+
require 'varager'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module K8sflow
|
6
|
+
module Utils
|
7
|
+
class Varager
|
8
|
+
attr_reader :client
|
9
|
+
|
10
|
+
def initialize(token, endpoint)
|
11
|
+
::Varager.logger.level = 1
|
12
|
+
@client = ::Varager::Client.new
|
13
|
+
puts "TOKEN"
|
14
|
+
puts token
|
15
|
+
@client.auth_token.update(:token => token)
|
16
|
+
puts @client.auth_token.options
|
17
|
+
@client.site = endpoint
|
18
|
+
end
|
19
|
+
|
20
|
+
def envs(app, db_only=true)
|
21
|
+
envs = @client.get_env(params: {id: app}).vars
|
22
|
+
#pp "overrided vars: #{@options.envvars}"
|
23
|
+
db_vars = ["DATABASE_URL",
|
24
|
+
"MEMCACHIER_PASSWORD",
|
25
|
+
"MEMCACHIER_SERVERS",
|
26
|
+
"MEMCACHIER_USERNAME",
|
27
|
+
"REDISTOGO_URL",
|
28
|
+
"REDIS_PROVIDER"]
|
29
|
+
if db_only == true
|
30
|
+
envs.select!{|k,v| db_vars.index(k) != nil}
|
31
|
+
end
|
32
|
+
pp envs
|
33
|
+
return envs
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/k8sflow/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: k8sflow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Antoine Legrand
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cli-topic
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: varager
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: netrc
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -97,6 +111,7 @@ files:
|
|
97
111
|
- lib/k8sflow/command/pg/psql.rb
|
98
112
|
- lib/k8sflow/command/pg/restore.rb
|
99
113
|
- lib/k8sflow/utils/heroku.rb
|
114
|
+
- lib/k8sflow/utils/varager.rb
|
100
115
|
- lib/k8sflow/version.rb
|
101
116
|
- spec/spec_helper.rb
|
102
117
|
homepage: http://gitlab.com/ant31
|