summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Keiser <jkeiser@opscode.com>2014-07-16 20:18:09 -0700
committerJohn Keiser <jkeiser@opscode.com>2014-07-23 19:21:23 -0600
commitf8658b80828262b5356f086f6c6ea69b706dde06 (patch)
tree360fae5dbdebc4fbb04a9d508069698119a4ae90
parent1e8315cf54a39f78c5b7afeff83f2cc0c1d4721b (diff)
downloadchef-zero-f8658b80828262b5356f086f6c6ea69b706dde06.tar.gz
Introduce osc_compat so multi org can still use osc_compat
-rw-r--r--lib/chef_zero/data_store/default_facade.rb10
-rw-r--r--lib/chef_zero/server.rb40
-rw-r--r--spec/run.rb2
3 files changed, 27 insertions, 25 deletions
diff --git a/lib/chef_zero/data_store/default_facade.rb b/lib/chef_zero/data_store/default_facade.rb
index 2285576..1512422 100644
--- a/lib/chef_zero/data_store/default_facade.rb
+++ b/lib/chef_zero/data_store/default_facade.rb
@@ -3,14 +3,14 @@ require 'chef_zero/data_store/interface_v2'
module ChefZero
module DataStore
class DefaultFacade < ChefZero::DataStore::InterfaceV2
- def initialize(real_store, single_org)
+ def initialize(real_store, osc_compat)
@real_store = real_store
- @single_org = single_org
+ @osc_compat = osc_compat
clear
end
attr_reader :real_store
- attr_reader :single_org
+ attr_reader :osc_compat
def default(path, name=nil)
value = @defaults
@@ -72,7 +72,7 @@ module ChefZero
'organizations' => {},
'acls' => {}
}
- if !single_org
+ if !osc_compat
@defaults['users'] = {
'pivotal' => '{}'
}
@@ -302,7 +302,7 @@ module ChefZero
'association_requests' => {},
}
- if single_org
+ if osc_compat
result['users']['admin'] = '{ "admin": "true" }'
end
diff --git a/lib/chef_zero/server.rb b/lib/chef_zero/server.rb
index c3447f8..41b4c8f 100644
--- a/lib/chef_zero/server.rb
+++ b/lib/chef_zero/server.rb
@@ -92,6 +92,9 @@ module ChefZero
def initialize(options = {})
@options = DEFAULT_OPTIONS.merge(options)
+ if @options[:single_org] && !@options.has_key?(:osc_compat)
+ @options[:osc_compat] = true
+ end
@options.freeze
ChefZero::Log.level = @options[:log_level].to_sym
@@ -139,13 +142,13 @@ module ChefZero
#
def data_store
@data_store ||= begin
- result = @options[:data_store] || DataStore::DefaultFacade.new(DataStore::MemoryStoreV2.new, options[:single_org])
+ result = @options[:data_store] || DataStore::DefaultFacade.new(DataStore::MemoryStoreV2.new, options[:osc_compat])
if options[:single_org]
if result.respond_to?(:interface_version) && result.interface_version >= 2 && result.interface_version < 3
result.create_dir([ 'organizations' ], options[:single_org])
else
result = ChefZero::DataStore::V1ToV2Adapter.new(result, options[:single_org])
- result = ChefZero::DataStore::DefaultFacade.new(result, options[:single_org])
+ result = ChefZero::DataStore::DefaultFacade.new(result, options[:osc_compat])
end
else
if !(result.respond_to?(:interface_version) && result.interface_version >= 2 && result.interface_version < 3)
@@ -405,7 +408,7 @@ module ChefZero
private
def open_source_endpoints
- result = if options[:single_org]
+ result = if options[:osc_compat]
# OSC-only
[
[ "/organizations/*/users", ActorsEndpoint.new(self) ],
@@ -426,27 +429,26 @@ module ChefZero
[ "/users/*/association_requests/*", UserAssociationRequestEndpoint.new(self) ],
[ "/users/*/organizations", UserOrganizationsEndpoint.new(self) ],
[ "/authenticate_user", AuthenticateUserEndpoint.new(self) ],
- [ "/system_recovery", SystemRecoveryEndpoint.new(self) ]
+ [ "/system_recovery", SystemRecoveryEndpoint.new(self) ],
+
+ [ "/organizations", OrganizationsEndpoint.new(self) ],
+ [ "/organizations/*", OrganizationEndpoint.new(self) ],
+ [ "/organizations/*/_validator_key", OrganizationValidatorKeyEndpoint.new(self) ],
+ [ "/organizations/*/association_requests", OrganizationAssociationRequestsEndpoint.new(self) ],
+ [ "/organizations/*/association_requests/*", OrganizationAssociationRequestEndpoint.new(self) ],
+ [ "/organizations/*/containers", ContainersEndpoint.new(self) ],
+ [ "/organizations/*/containers/*", ContainerEndpoint.new(self) ],
+ [ "/organizations/*/groups", GroupsEndpoint.new(self) ],
+ [ "/organizations/*/groups/*", GroupEndpoint.new(self) ],
+ [ "/organizations/*/organization/_acl", AclsEndpoint.new(self) ],
+ [ "/organizations/*/*/*/_acl", AclsEndpoint.new(self) ],
+ [ "/organizations/*/organization/_acl/*", AclEndpoint.new(self) ],
+ [ "/organizations/*/*/*/_acl/*", AclEndpoint.new(self) ]
]
end
result +
[
# Both
- [ "/organizations", OrganizationsEndpoint.new(self) ],
- [ "/organizations/*", OrganizationEndpoint.new(self) ],
- [ "/organizations/*/_validator_key", OrganizationValidatorKeyEndpoint.new(self) ],
- [ "/organizations/*/association_requests", OrganizationAssociationRequestsEndpoint.new(self) ],
- [ "/organizations/*/association_requests/*", OrganizationAssociationRequestEndpoint.new(self) ],
-
- [ "/organizations/*/containers", ContainersEndpoint.new(self) ],
- [ "/organizations/*/containers/*", ContainerEndpoint.new(self) ],
- [ "/organizations/*/groups", GroupsEndpoint.new(self) ],
- [ "/organizations/*/groups/*", GroupEndpoint.new(self) ],
- [ "/organizations/*/organization/_acl", AclsEndpoint.new(self) ],
- [ "/organizations/*/*/*/_acl", AclsEndpoint.new(self) ],
- [ "/organizations/*/organization/_acl/*", AclEndpoint.new(self) ],
- [ "/organizations/*/*/*/_acl/*", AclEndpoint.new(self) ],
-
[ "/organizations/*/clients", ActorsEndpoint.new(self) ],
[ "/organizations/*/clients/*", ActorEndpoint.new(self) ],
[ "/organizations/*/cookbooks", CookbooksEndpoint.new(self) ],
diff --git a/spec/run.rb b/spec/run.rb
index 0403059..a0aaf40 100644
--- a/spec/run.rb
+++ b/spec/run.rb
@@ -50,7 +50,7 @@ begin
server.start_background
else
- server = ChefZero::Server.new(:port => 8889, :single_org => false)
+ server = ChefZero::Server.new(:port => 8889, :single_org => false, :osc_compat => true)
server.data_store.create_dir([ 'organizations' ], 'pedant')
server.start_background
end