Skip to content
Browse files

Marketplace Updates

 - Update acls to provide wildcards and users via config file
 - Customize service name / provider
 - Only advertise whitelisted marketplace offerings to CC

Change-Id: I14ae3ef12fb771bad2387cace541c946e0fa0874
  • Loading branch information...
1 parent 773d3a2 commit 549d48a1b4cdd98c725e18e8c9825eb4455b5992 Harshawardhan Gadgil committed Sep 5, 2012
View
6 marketplace/config/appdirect.yml
@@ -10,3 +10,9 @@ appdirect:
key: "k"
secret: "s"
+offering_whitelist: [ "mongolab" ]
+
+offering_mapping:
+ mongolab:
+ name: mongodb
+ provider: mongolab
View
8 marketplace/config/marketplace_gateway.yml
@@ -14,10 +14,10 @@ pid: /var/vcap/sys/run/marketplace.pid
marketplace: appdirect
-acls: [ "*@example.com" ]
+acls:
+ wildcards:
+ - "*@example.com"
+ users: []
external_uri: "http://appdirect-mpgw.vcap.me"
refresh_interval: 300
-
-# Used for testing purposes only
-disabled_service_ids: []
View
8 marketplace/lib/marketplaces/appdirect/appdirect_helper.rb
@@ -29,7 +29,7 @@ def initialize(opts, logger)
raise ArgumentError, "Missing options: #{missing_opts.join(', ')}" unless missing_opts.empty?
@appdirect_endpoint = appdirect_config[:endpoint]
- @disabled_service_ids = opts[:disabled_service_ids] || []
+ @whitelist = opts[:offering_whitelist]
@consumer = OAuth::Consumer.new(appdirect_config[:key], appdirect_config[:secret])
@access_token = OAuth::AccessToken.new(@consumer)
@@ -46,10 +46,10 @@ def get_catalog
data.each do |service|
# Add checks for specific categories which determine whether the addon should be listed on cc
@logger.debug("Got service '#{service["id"]}' from AppDirect")
- if (@disabled_service_ids.include?(service["id"]))
- @logger.warn("Service Offering: #{service["id"]} disabled via config")
- else
+ if (@whitelist.include?(service["id"]))
catalog["#{service["id"]}-#{service["version"]}"] = service
+ else
+ @logger.warn("Ignoring service Offering: #{service["id"]} since it is not whitelisted")
end
end
@logger.info("Got #{catalog.keys.count} services from AppDirect")
View
19 marketplace/lib/marketplaces/appdirect/appdirect_marketplace.rb
@@ -21,8 +21,8 @@ def initialize(opts)
@external_uri = opts[:external_uri]
@node_timeout = opts[:node_timeout]
@acls = opts[:acls]
- @users = opts[:users] || []
@helper = AppdirectHelper.new(opts, @logger)
+ @mapping = opts[:offering_mapping]
end
def name
@@ -34,24 +34,33 @@ def get_catalog
end
def generate_cc_advertise_request(name, bsvc, active = true)
+ raise "Service: #{name} was whitelisted but no mapping was defined" unless @mapping.keys.include?(name.to_sym)
+
+ service_mapping = @mapping[name.to_sym]
+ name = service_mapping[:name]
+ provider = service_mapping[:provider]
+
req = {}
req[:label] = "#{name}-#{bsvc["version"]}"
req[:active] = active && bsvc["active"]
req[:description] = bsvc["description"]
+ req[:provider] = provider
+
req[:supported_versions] = [ bsvc["version"] ]
req[:version_aliases] = { "current" => bsvc["version"] }
req[:acls] = {}
- req[:acls][:wildcards] = @acls
+ req[:acls][:wildcards] = @acls[:wildcards]
- users_acl = @users.dup
+ users = []
+ users.concat(@acls[:users].dup) if @acls[:users]
if bsvc["developers"] and bsvc["developers"].count > 0
bsvc["developers"].each do |dev|
- users_acl << dev["email"]
+ users << dev["email"]
end
end
- req[:acls][:users] = users_acl
+ req[:acls][:users] = users unless users.empty?
req[:url] = @external_uri

0 comments on commit 549d48a

Please sign in to comment.
Something went wrong with that request. Please try again.