clusterfsck 0.1.5.0 → 0.1.5.2
Sign up to get free protection for your applications and to get access to all the features.
data/README.md
CHANGED
@@ -112,7 +112,11 @@ reader = ClusterFsck::Reader.new(:stripe)
|
|
112
112
|
reader.read[:api_key] # loads config_bucket/cluster_fsck_env/stripe and returns the api_key from the hash
|
113
113
|
```
|
114
114
|
|
115
|
-
The ClusterFsck::Reader instance will load the configuration for the environment stored in the CLUSTER_FSCK_ENV.
|
115
|
+
The ClusterFsck::Reader instance will load the configuration for the environment stored in the first defined CLUSTER_FSCK_ENV lookup location as described above.
|
116
|
+
|
117
|
+
ClusterFsck is currently Ruby only, but any links or pull requests for other language implementations of the Reader module are welcome, and should be able to cooperate happily with the Ruby version.
|
118
|
+
|
119
|
+
This code is MIT licensed, see LICENSE.txt file.
|
116
120
|
|
117
121
|
1. Fork it
|
118
122
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
data/lib/clusterfsck.rb
CHANGED
@@ -9,10 +9,11 @@ require 'commander'
|
|
9
9
|
module ClusterFsck
|
10
10
|
CLUSTER_FSCK_PATHS = ['./.clusterfsck','/usr/clusterfsck','~/.clusterfsck']
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
CONFIG_PATH = CLUSTER_FSCK_PATHS.detect do |path_string|
|
13
|
+
File.exists?(File.expand_path(path_string))
|
14
|
+
end
|
15
|
+
|
16
|
+
CLUSTER_FSCK_CONFIG = YAML.load(File.expand_path(CONFIG_PATH))
|
16
17
|
|
17
18
|
def self.logger=(logger)
|
18
19
|
@logger = logger
|
@@ -24,11 +25,11 @@ module ClusterFsck
|
|
24
25
|
|
25
26
|
def self.cluster_fsck_env
|
26
27
|
raise "Configuration failure, check ~/.clusterfsck or other config values" unless config_bucket
|
27
|
-
@env ||= ENV['CLUSTER_FSCK_ENV'] ||
|
28
|
+
@env ||= ENV['CLUSTER_FSCK_ENV'] || self.config_hash['cluster_fsck_env'] || default_env
|
28
29
|
end
|
29
30
|
|
30
31
|
def self.config_bucket
|
31
|
-
@config_bucket ||= ENV['CLUSTER_FSCK_BUCKET'] ||
|
32
|
+
@config_bucket ||= ENV['CLUSTER_FSCK_BUCKET'] || self.config_hash['cluster_fsck_bucket'] || Setup.config
|
32
33
|
end
|
33
34
|
|
34
35
|
def self.default_env
|
@@ -36,7 +37,7 @@ module ClusterFsck
|
|
36
37
|
end
|
37
38
|
|
38
39
|
def self.config_hash
|
39
|
-
CLUSTER_FSCK_CONFIG
|
40
|
+
CLUSTER_FSCK_CONFIG || {}
|
40
41
|
end
|
41
42
|
|
42
43
|
end
|
@@ -34,11 +34,11 @@ module ClusterFsck
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def from_cluster_fsck_config
|
37
|
-
if ClusterFsck
|
38
|
-
ClusterFsck
|
37
|
+
if ClusterFsck.config_hash['aws_access_key_id'] &&
|
38
|
+
ClusterFsck.config_hash['aws_secret_access_key']
|
39
39
|
{
|
40
|
-
access_key_id: ClusterFsck
|
41
|
-
secret_access_key: ClusterFsck
|
40
|
+
access_key_id: ClusterFsck.config_hash['aws_access_key_id'],
|
41
|
+
secret_access_key: ClusterFsck.config_hash['aws_secret_access_key'],
|
42
42
|
}
|
43
43
|
end
|
44
44
|
end
|
data/lib/clusterfsck/setup.rb
CHANGED
@@ -10,20 +10,20 @@ module ClusterFsck
|
|
10
10
|
variables, so you can set the environment to override the files. The bucket is read from CLUSTER_FSCK_BUCKET
|
11
11
|
and the environment (production, staging, development, etc) is read from CLUSTER_FSCK_ENV.
|
12
12
|
UI
|
13
|
-
unless ClusterFsck
|
13
|
+
unless ClusterFsck.config_hash['cluster_fsck_bucket']
|
14
14
|
set_bucket_name
|
15
15
|
end
|
16
16
|
unless ClusterFsck::CredentialGrabber.find
|
17
17
|
set_aws_keys
|
18
18
|
end
|
19
|
-
unless ClusterFsck::S3Methods.s3.buckets[ClusterFsck
|
19
|
+
unless ClusterFsck::S3Methods.s3.buckets[ClusterFsck.config_hash['cluster_fsck_bucket']].exists?
|
20
20
|
warn_create_bucket
|
21
21
|
end
|
22
|
-
ClusterFsck
|
22
|
+
ClusterFsck.config_hash['cluster_fsck_env'] ||= ClusterFsck.default_env
|
23
23
|
File.open(File.expand_path(ClusterFsck::CLUSTER_FSCK_PATHS[2]), 'w') do |f|
|
24
24
|
f.write(YAML.dump(ClusterFsck.config_hash))
|
25
25
|
end
|
26
|
-
ClusterFsck
|
26
|
+
ClusterFsck.config_hash['cluster_fsck_bucket']
|
27
27
|
end
|
28
28
|
|
29
29
|
def self.set_bucket_name
|
@@ -33,12 +33,12 @@ module ClusterFsck
|
|
33
33
|
#{random_name}
|
34
34
|
UI
|
35
35
|
input_name = ask("bucket name: ")
|
36
|
-
|
36
|
+
ClusterFsck.config_hash['cluster_fsck_bucket'] = input_name.empty? ? random_name : input_name
|
37
37
|
end
|
38
38
|
|
39
39
|
def self.set_aws_keys
|
40
|
-
|
41
|
-
|
40
|
+
ClusterFsck.config_hash['aws_access_key_id'] = ask("Enter your AWS access key: ")
|
41
|
+
ClusterFsck.config_hash['aws_secret_access_key'] = ask("Enter your AWS secret access key: ")
|
42
42
|
end
|
43
43
|
|
44
44
|
def self.warn_create_bucket
|
data/lib/clusterfsck/version.rb
CHANGED
@@ -57,9 +57,9 @@ module ClusterFsck
|
|
57
57
|
describe "when there is a ~/.clusterfsck config and with or without a ~/.fog file" do
|
58
58
|
before do
|
59
59
|
credential_grabber.stub(:exists?).with(true)
|
60
|
-
ClusterFsck
|
60
|
+
ClusterFsck.config_hash.should_receive(:[]).at_least(:once)
|
61
61
|
.with('aws_access_key_id').and_return(cf_credentials[:access_key_id])
|
62
|
-
ClusterFsck
|
62
|
+
ClusterFsck.config_hash.should_receive(:[]).at_least(:once)
|
63
63
|
.with('aws_secret_access_key').and_return(cf_credentials[:secret_access_key])
|
64
64
|
end
|
65
65
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clusterfsck
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.5.
|
4
|
+
version: 0.1.5.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-02-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-sdk
|