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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 218d1a66fbd76b313afcd2f05e88b8b4f61ead91
4
- data.tar.gz: 931e5e55933aab445a5c8d520017cbc20bdc6cdb
3
+ metadata.gz: e201ba0a33383d5c381aed3569be8a03e6c54339
4
+ data.tar.gz: e7b14f1633dfae5496cae7dd80e74f992601cac8
5
5
  SHA512:
6
- metadata.gz: b61176657cbe29df6ff210645c60ecb84d173fbab3d87961f5512f25e212fa83be43cea15815594c172a3306d744308bffe952317c2f6816b11f8f6e30cc2092
7
- data.tar.gz: 8473aa756f9810655ec0de1c84d8dcc6b3a10dfe5b0fd6b6d4ab4f02ef2e64def6efd48db0e9f0c758f33ced708473e1a6a0c044db4c25db7416fd3cbe973b31
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
@@ -6,7 +6,7 @@ module Charmkit
6
6
  module VERSION
7
7
  MAJOR = 0
8
8
  MINOR = 4
9
- PATCH = 6
9
+ PATCH = 7
10
10
  PRE = nil
11
11
 
12
12
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.')
data/lib/charmkit.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  require "charmkit/version"
2
2
  require "charmkit/helpers/template"
3
3
  require "charmkit/helpers/runner"
4
+ require "charmkit/helpers/hookenv"
5
+ require "charmkit/helpers/fs"
4
6
 
5
7
  module Charmkit; end
6
8
  extend Charmkit::Helpers
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.6
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-07 00:00:00.000000000 Z
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