charmkit 0.4.6 → 0.4.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/charmkit/helpers/fs.rb +64 -0
- data/lib/charmkit/helpers/hookenv.rb +38 -0
- data/lib/charmkit/version.rb +1 -1
- data/lib/charmkit.rb +2 -0
- 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: e201ba0a33383d5c381aed3569be8a03e6c54339
|
4
|
+
data.tar.gz: e7b14f1633dfae5496cae7dd80e74f992601cac8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95c1513993c42c4c3886700241e3bc77bad76d3054b01233c856aefb527b2135966e0c64c0610452e22c192cc313bf8c9a0cac2b4eb15ba3bd9d30d337d9d1f7
|
7
|
+
data.tar.gz: 9697c096517fd1a8f5a4db3c3b7fe1ae1f75e6bd3b81d26a33c1438a854b29dc49c7f8983ef7f0e4ffb8f281d68d40c27cd3b94c9ad06fd9821bd7c721538e47
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module Charmkit
|
2
|
+
module Helpers
|
3
|
+
# Create a file with data
|
4
|
+
#
|
5
|
+
# @param dst String
|
6
|
+
# @param content String
|
7
|
+
# @return nil
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
# file "/etc/nginx/nginx.conf", "Some data"
|
11
|
+
def file(dst, content)
|
12
|
+
File.write(dst, content)
|
13
|
+
end
|
14
|
+
|
15
|
+
# Check if file exists
|
16
|
+
#
|
17
|
+
# @param path String
|
18
|
+
# @return Boolean
|
19
|
+
#
|
20
|
+
# @example
|
21
|
+
# is_file? "/etc/nginx/nginx.conf"
|
22
|
+
def is_file?(path)
|
23
|
+
return File.exists? path
|
24
|
+
end
|
25
|
+
|
26
|
+
def is_dir?(path)
|
27
|
+
return Dir.exists? path
|
28
|
+
end
|
29
|
+
|
30
|
+
def cat(src)
|
31
|
+
return File.read(src)
|
32
|
+
end
|
33
|
+
|
34
|
+
# Installs packages
|
35
|
+
#
|
36
|
+
# @param packages Array
|
37
|
+
# @param opts Hash
|
38
|
+
# @return Boolean
|
39
|
+
#
|
40
|
+
# @example
|
41
|
+
# package ['nginx-full'], :update_cache
|
42
|
+
def package(packages, *opts)
|
43
|
+
if opts.include?(:update_cache)
|
44
|
+
run "apt-get update"
|
45
|
+
end
|
46
|
+
run "apt-get install -qyf #{packages.join(' ')}"
|
47
|
+
end
|
48
|
+
|
49
|
+
# Checks if a package is installed
|
50
|
+
#
|
51
|
+
# @param package String
|
52
|
+
# @return Boolean
|
53
|
+
#
|
54
|
+
# @example
|
55
|
+
# is_install? "nginx-full"
|
56
|
+
def is_installed?(package)
|
57
|
+
begin
|
58
|
+
run "dpkg -s #{package}" and return true
|
59
|
+
rescue
|
60
|
+
return false
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Charmkit
|
2
|
+
module Helpers
|
3
|
+
def status(level=:maintenance, msg="")
|
4
|
+
levels = [:maintenance, :active, :blocked, :waiting]
|
5
|
+
raise unless levels.include?(level)
|
6
|
+
cmd.run "status-set #{level.to_s} '#{msg}'"
|
7
|
+
end
|
8
|
+
|
9
|
+
def config(item)
|
10
|
+
out, err = cmd.run "config-get '#{item}'"
|
11
|
+
return out.chomp
|
12
|
+
end
|
13
|
+
|
14
|
+
def resource(item)
|
15
|
+
out, err = cmd.run "resource-get '#{item}'"
|
16
|
+
return out.chomp
|
17
|
+
end
|
18
|
+
|
19
|
+
def unit(item)
|
20
|
+
out, err = cmd.run "unit-get '#{item}'"
|
21
|
+
return out.chomp
|
22
|
+
end
|
23
|
+
|
24
|
+
def action(item)
|
25
|
+
out, err = cmd.run "action-get '#{item}'"
|
26
|
+
return out.chomp
|
27
|
+
end
|
28
|
+
|
29
|
+
def action=(item)
|
30
|
+
out, err = cmd.run "action-set '#{item}'"
|
31
|
+
return out.chomp
|
32
|
+
end
|
33
|
+
|
34
|
+
def log(msg)
|
35
|
+
cmd.run "juju-log #{msg}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/charmkit/version.rb
CHANGED
data/lib/charmkit.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: charmkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Stokes
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tty-command
|
@@ -133,6 +133,8 @@ files:
|
|
133
133
|
- examples/render_inline.rb
|
134
134
|
- lib/charmkit.rb
|
135
135
|
- lib/charmkit/extend/string_tools.rb
|
136
|
+
- lib/charmkit/helpers/fs.rb
|
137
|
+
- lib/charmkit/helpers/hookenv.rb
|
136
138
|
- lib/charmkit/helpers/runner.rb
|
137
139
|
- lib/charmkit/helpers/template.rb
|
138
140
|
- lib/charmkit/plugins/nginx.rb
|