consul-fs 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2113b5a28d7f5250e4f85479ba646e4aa46bdd45
4
+ data.tar.gz: 950efd79ce569f75b43671cf17b8b9c8ba2d47d8
5
+ SHA512:
6
+ metadata.gz: 95a9a28fe595e2f9a70db4d0a34dab19fe0e9f88a2a1315358671acc3b1af413c54b8e39d6ec3c444efce23f7280b171fae3268991144806f96d0bdc75088fe2
7
+ data.tar.gz: ab0a5832485961a49b42b59094eb9ad6793d1c454c30879f0ec330dbfdfb6e6bf016964462e1ade9d6f25ffef173087f7d6f8fe42e01998fa5be8c59d0e935af
@@ -0,0 +1,32 @@
1
+ Consul FS
2
+ =========
3
+
4
+ Proof-of-concept fuse adapter for Consul KV store. Allows you to browse the
5
+ store as a filesystem.
6
+
7
+ Only works on linux.
8
+
9
+ apt-get install libfuse-dev
10
+
11
+ gem install consul-fs
12
+ mkdir consul-kv
13
+
14
+ consul-fs consul-kv
15
+
16
+ That mounts a fuse system in the `consul-kv` directory.
17
+
18
+ > curl -X PUT --data "hello" localhost:8500/v1/kv/one
19
+ > curl -X PUT --data "world" localhost:8500/v1/kv/two
20
+ > curl -X PUT --data "!!!" localhost:8500/v1/kv/sub/three
21
+ > ls consul-kv
22
+ sub/ one two
23
+ > ls consul-kv/sub
24
+ three
25
+ > cat consul-kv/one && echo
26
+ hello
27
+
28
+
29
+ Development
30
+ -----------
31
+
32
+ A `Vagrantfile` is provided, so just `vagrant up` and you are on your way.
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
4
+
5
+ require 'consul/fs'
6
+ require 'rfusefs'
7
+
8
+ Consul::FS.start
@@ -0,0 +1,29 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.authors = ["Xavier Shay"]
5
+ gem.email = ["contact@xaviershay.com"]
6
+ gem.description =
7
+ %q{Mount the Consul KV store as a filesystem}
8
+ gem.summary = %q{
9
+ Fuse adapter for Consul KV store.
10
+ }
11
+ gem.homepage = "http://github.com/xaviershay/consul-fs"
12
+
13
+ gem.executables = []
14
+ gem.required_ruby_version = '>= 2.1.2'
15
+ gem.files = Dir.glob("{spec,lib}/**/*.rb") + %w(
16
+ README.md
17
+ consul-fs.gemspec
18
+ )
19
+ gem.test_files = Dir.glob("spec/**/*.rb")
20
+ gem.name = "consul-fs"
21
+ gem.require_paths = ["lib"]
22
+ gem.bindir = "bin"
23
+ gem.executables << "consul-fs"
24
+ gem.license = "Apache 2.0"
25
+ gem.version = '0.1.0'
26
+ gem.has_rdoc = false
27
+ gem.add_dependency 'rfusefs'
28
+ gem.add_dependency 'consul-client'
29
+ end
@@ -0,0 +1,46 @@
1
+ require 'rfusefs'
2
+ require 'consul/client'
3
+ require 'base64'
4
+
5
+ module Consul
6
+ module FS
7
+ class Dir
8
+ attr_reader :consul
9
+
10
+ def initialize
11
+ @consul = Consul::Client.v1.http
12
+ end
13
+
14
+ def contents(path)
15
+ path += "/" unless path.end_with?("/")
16
+ consul.get("/kv#{path}?recurse&separator=/&keys")
17
+ .map {|x| x[path.length-1..-1] }
18
+ end
19
+
20
+ def file?(path)
21
+ consul.get("/kv#{path}?keys")
22
+ true
23
+ rescue Consul::Client::ResponseException
24
+ false
25
+ end
26
+
27
+ def directory?(path)
28
+ consul.get("/kv#{path}?keys").any? {|x| x.include?("#{path[1..-1]}/") }
29
+ rescue Consul::Client::ResponseException
30
+ false
31
+ end
32
+
33
+ def read_file(path)
34
+ Base64.decode64(consul.get("/kv#{path}")[0]["Value"])
35
+ rescue Consul::Client::ResponseException
36
+ ""
37
+ end
38
+ end
39
+
40
+ def self.start
41
+ FuseFS.main do |options|
42
+ Dir.new
43
+ end
44
+ end
45
+ end
46
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: consul-fs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Xavier Shay
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rfusefs
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
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: consul-client
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Mount the Consul KV store as a filesystem
42
+ email:
43
+ - contact@xaviershay.com
44
+ executables:
45
+ - consul-fs
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - README.md
50
+ - bin/consul-fs
51
+ - consul-fs.gemspec
52
+ - lib/consul/fs.rb
53
+ homepage: http://github.com/xaviershay/consul-fs
54
+ licenses:
55
+ - Apache 2.0
56
+ metadata: {}
57
+ post_install_message:
58
+ rdoc_options: []
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: 2.1.2
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ requirements: []
72
+ rubyforge_project:
73
+ rubygems_version: 2.2.2
74
+ signing_key:
75
+ specification_version: 4
76
+ summary: Fuse adapter for Consul KV store.
77
+ test_files: []
78
+ has_rdoc: false