cfoundry_helper 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.textile +14 -6
- data/Gemfile.lock +1 -1
- data/README.textile +17 -14
- data/config/services.yml.example +18 -25
- data/lib/cfoundry_helper.rb +37 -45
- data/lib/cfoundry_helper/helpers/client_helper.rb +1 -1
- data/lib/cfoundry_helper/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 537df23f74bd2092dbf4e29f0c81002251763424
|
4
|
+
data.tar.gz: 0fc6be2168d5bd780a557dcfaae57d3534285e62
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8ca889bf78357bfc20032681b658f15c92f76ae961bbe86e041ffa46d0d61e9f8999f908258c3451b0d40ff07cb8fc53da5e24eccb6b2a831f146d49433acd9
|
7
|
+
data.tar.gz: eb658526e019a09b72161ea95b993170ff5061fc2e31c2e78a76076d473d520a8498136e36076f08229c5c4f81dc4792dc402389ce810674ee78e1f85163970d
|
data/CHANGELOG.textile
CHANGED
@@ -1,10 +1,18 @@
|
|
1
|
-
|
2
|
-
*
|
3
|
-
*
|
4
|
-
*
|
1
|
+
h2. v0.3.1
|
2
|
+
* removes env
|
3
|
+
* removes necessary configuration file
|
4
|
+
* adds the possibility to load configuration either from a file or from a hash
|
5
5
|
|
6
|
-
h2. v0.
|
7
|
-
*
|
6
|
+
h2. v0.3.0
|
7
|
+
* multiple target support
|
8
8
|
|
9
9
|
h2. v0.2.1
|
10
10
|
* Bugfix: Don't cache the cloud controller client since the access token expires in long running apps.
|
11
|
+
|
12
|
+
h2. v0.2.0
|
13
|
+
* add users to org script
|
14
|
+
|
15
|
+
h2. v0.1.0
|
16
|
+
* OrganizationHelper implementation
|
17
|
+
* ClientHelper implementation
|
18
|
+
* UserHelper implementation
|
data/Gemfile.lock
CHANGED
data/README.textile
CHANGED
@@ -5,12 +5,22 @@ API. It implements common use cases when administrating a Cloud Foundry installa
|
|
5
5
|
|
6
6
|
h2. Configuration
|
7
7
|
|
8
|
-
You can configure multiple targets within
|
8
|
+
a) You can configure multiple targets within a configuration file. Please execute the following code to load the file's contents into the configuration:
|
9
|
+
CFoundryHelper.load_config_from_file file_location
|
9
10
|
|
10
|
-
|
11
|
+
b) You can also configure the targets by passing in a configuration hash:
|
12
|
+
CfoundryHelper.load_config_from_hash config_hash
|
13
|
+
|
14
|
+
!!! It is important to load a configuration using one of the methods above before executing any helper functions.
|
15
|
+
|
11
16
|
|
17
|
+
h2. Target Selection
|
12
18
|
Since cfoundry_helper now supports multiple CF targets you have to set your desired target by using the
|
13
|
-
|
19
|
+
CFoundryHelper::Helpers::ClientHelper.current_target_url= method for selecting a target from your service configuration file.
|
20
|
+
You can list all configured targets using the CFoundryHelper.available_targets method.
|
21
|
+
|
22
|
+
!!! It is important to select a target before executing any helper functions, e.g:
|
23
|
+
CFoundryHelper::Helpers::ClientHelper.current_target_url = CFoundryHelper.available_targets.first
|
14
24
|
|
15
25
|
h2. Organization management
|
16
26
|
|
@@ -40,25 +50,18 @@ The CFoundryHelper::Helpers::OrganizationHelper modules' methods provide helper
|
|
40
50
|
|
41
51
|
h2. Client Helper
|
42
52
|
|
43
|
-
The CFoundryHelper::Helpers::ClientHelper is a factory for uaa and cloud controller clients. The current_target_url has to point to your desired endpoint
|
53
|
+
The CFoundryHelper::Helpers::ClientHelper is a factory for uaa and cloud controller clients. The current_target_url has to point to your desired endpoint. (see Target Selection)
|
44
54
|
|
45
55
|
|
46
56
|
h2. Scripts
|
47
57
|
|
48
58
|
* bin/add_users_to_org : adds users to an organization
|
49
|
-
** usage :
|
59
|
+
** usage : bundle exec bin/add_users_to_org <org name> <users_email_list_file_location> <services_config_file_location>
|
50
60
|
* bin/create_space_for_org : creates a space to an organization and assigns all organization members to it
|
51
|
-
** usage :
|
52
|
-
|
53
|
-
h2. Important environment variables
|
61
|
+
** usage : bundle exec bin/create_space_for_org <org name> <space name> <services_config_file_location>
|
54
62
|
|
55
|
-
* RAILS_ENV : The helper is reading the target environment on which to execute commands using the RAILS_ENV environment variable. (e.g. production, test)
|
56
|
-
|
57
|
-
* CFOUNDRY_HELPER_CONFIG This variable has to point to your services.yml file.
|
58
63
|
|
59
64
|
h2. Console Usage
|
60
65
|
|
61
66
|
Use the following command to start the console:
|
62
|
-
|
63
|
-
|
64
|
-
e.g.: RAILS_ENV=production CFOUNDRY_HELPER_CONFIG=config/services.yml rake c
|
67
|
+
bundle exec rake c
|
data/config/services.yml.example
CHANGED
@@ -1,25 +1,18 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
uaa
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
uaa
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
password: "admin_password"
|
20
|
-
|
21
|
-
development:
|
22
|
-
<<: *defaults
|
23
|
-
|
24
|
-
test:
|
25
|
-
<<: *defaults
|
1
|
+
"http://api.any9app.com":
|
2
|
+
uaa:
|
3
|
+
site: "http://uaa.any9app.com"
|
4
|
+
client_id: "user_registrator"
|
5
|
+
client_secret: "user_registrator_password"
|
6
|
+
cloud_controller:
|
7
|
+
site: "http://api.any9app.com"
|
8
|
+
username: "admin"
|
9
|
+
password: "admin_password"
|
10
|
+
"http://api.other_target.com":
|
11
|
+
uaa:
|
12
|
+
site: "http://uaa.other_target.com"
|
13
|
+
client_id: "user_registrator"
|
14
|
+
client_secret: "user_registrator_password"
|
15
|
+
cloud_controller:
|
16
|
+
site: "http://api.other_target.com"
|
17
|
+
username: "admin"
|
18
|
+
password: "admin_password"
|
data/lib/cfoundry_helper.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'bundler'
|
2
2
|
require 'cfoundry'
|
3
3
|
require 'active_support/core_ext/object/try'
|
4
|
+
require 'active_support/hash_with_indifferent_access'
|
4
5
|
|
5
6
|
Bundler.require
|
6
7
|
|
@@ -10,26 +11,26 @@ module CFoundryHelper
|
|
10
11
|
autoload :Errors, File.expand_path('../cfoundry_helper/errors', __FILE__)
|
11
12
|
|
12
13
|
@@config = nil
|
13
|
-
@@config_file_path = nil
|
14
|
-
|
15
|
-
def self.env
|
16
|
-
unless ENV['RAILS_ENV']
|
17
|
-
return :development
|
18
|
-
else
|
19
|
-
ENV['RAILS_ENV'].to_sym
|
20
|
-
end
|
21
|
-
end
|
22
14
|
|
23
|
-
|
24
|
-
|
15
|
+
# Loads the configuration from the specified hash.
|
16
|
+
def self.load_config_from_hash(hash)
|
17
|
+
config = hash
|
18
|
+
check_config! config
|
19
|
+
@@config = config
|
20
|
+
@@config
|
25
21
|
end
|
26
22
|
|
27
|
-
|
28
|
-
|
23
|
+
# Loads the configuration from the specified yaml file.
|
24
|
+
def self.load_config_from_file(file_location)
|
25
|
+
raise "There's no configuration file on #{file_location}!" unless File.exists? file_location
|
26
|
+
config = YAML.load_file(file_location)
|
27
|
+
check_config! config
|
28
|
+
@@config = config
|
29
|
+
@@config
|
29
30
|
end
|
30
|
-
|
31
|
-
def self.
|
32
|
-
|
31
|
+
|
32
|
+
def self.config
|
33
|
+
@@config
|
33
34
|
end
|
34
35
|
|
35
36
|
# Returns an array of target available target urls defined in the configuration file as strings.
|
@@ -38,38 +39,29 @@ module CFoundryHelper
|
|
38
39
|
self.config.keys
|
39
40
|
end
|
40
41
|
|
41
|
-
# Returns the config hash for the given target url as defined in the configuration
|
42
|
-
# Returns nil if the given target url is not defined within the
|
42
|
+
# Returns the config hash for the given target url as defined in the configuration.
|
43
|
+
# Returns nil if the given target url is not defined within the configuration.
|
43
44
|
def self.config_for_target(url)
|
44
45
|
self.config[url]
|
45
46
|
end
|
46
47
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
end
|
65
|
-
|
66
|
-
# sets the configuration file path from reading the CFOUNDRY_HELPER_CONFIG env variable
|
67
|
-
def self.set_config_file_path_from_env
|
68
|
-
config_file_path = ENV["CFOUNDRY_HELPER_CONFIG"]
|
69
|
-
unless config_file_path.nil?
|
70
|
-
self.config_file_path = config_file_path
|
48
|
+
private
|
49
|
+
|
50
|
+
def self.check_config!(config)
|
51
|
+
raise "No target hashes are defined within the configuration!" if config.count == 0
|
52
|
+
|
53
|
+
config.each do |target,hash|
|
54
|
+
# check uaa config
|
55
|
+
raise "No uaa section is specified within the target #{target} !" if hash["uaa"].nil?
|
56
|
+
raise "No uaa:site is specifed within the target #{target} !" if hash["uaa"]["site"].nil?
|
57
|
+
raise "No uaa:client_id is specifed within the target #{target} !" if hash["uaa"]["client_id"].nil?
|
58
|
+
raise "No uaa:client_secret is specifed within the target #{target} !" if hash["uaa"]["client_secret"].nil?
|
59
|
+
|
60
|
+
# check cc config
|
61
|
+
raise "No cloud_controller section is specified within the target #{target} !" if hash["cloud_controller"].nil?
|
62
|
+
raise "No cloud_controller:site is specifed within the target #{target} !" if hash["cloud_controller"]["site"].nil?
|
63
|
+
raise "No cloud_controller:username is specifed within the target #{target} !" if hash["cloud_controller"]["username"].nil?
|
64
|
+
raise "No cloud_controller:password is specifed within the target #{target} !" if hash["cloud_controller"]["password"].nil?
|
71
65
|
end
|
72
66
|
end
|
73
|
-
end
|
74
|
-
|
75
|
-
CFoundryHelper.config
|
67
|
+
end
|
@@ -52,7 +52,7 @@ module CFoundryHelper::Helpers
|
|
52
52
|
# and register a new user.
|
53
53
|
def self.cloud_controller_client
|
54
54
|
# just return the already initialized client if present
|
55
|
-
raise CFoundryHelper::Errors::ConfigurationError, "The ClientHelper's current target url is not defined in the configuration
|
55
|
+
raise CFoundryHelper::Errors::ConfigurationError, "The ClientHelper's current target url is not defined in the configuration!" if CFoundryHelper.config[@@current_target_url].nil?
|
56
56
|
|
57
57
|
|
58
58
|
# just return the already initialized client if it was explicit setted.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cfoundry_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julian Weber
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|