Skip to content

Commit 8ee677d

Browse files
author
OpenShift Bot
committed
Merge pull request openshift#5343 from lnader/master
Merged by openshift-bot
2 parents 9960d73 + 1ce59d0 commit 8ee677d

File tree

5 files changed

+143
-6
lines changed

5 files changed

+143
-6
lines changed

controller/app/controllers/cartridges_controller.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ def index
5151
end
5252
else
5353
carts = carts.active.order_by(:name => 1)
54+
#filter out obsolete cartridges for versions >= 1.7
55+
carts = carts.not_in(obsolete: true) if requested_api_version >= 1.7
5456

5557
# Legacy support for cartridges/standalone|embedded
5658
feature = params[:feature].presence

controller/app/helpers/rest_model_helper.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,9 @@ def get_embedded_rest_cartridge(application, component, others, group, include_s
7777
def get_rest_cartridge(cartridge)
7878
if requested_api_version == 1.0
7979
RestCartridge10.new(cartridge)
80-
else
80+
else
8181
requires = CartridgeCache.find_requires_for(cartridge)
82+
return RestCartridge16.new(cartridge) if requested_api_version <= 1.6
8283
RestCartridge.new(cartridge)
8384
end
8485
end

controller/app/rest_models/rest_cartridge.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,14 @@
7979
# @return [Integer] Cartridge supported minimum scale
8080
# @!attribute [r] supported_scales_from
8181
# @return [Integer] Cartridge supported maximum scale
82-
# @!attribute [r] current_scale
83-
# @return [Integer] Current number of gears used to run this cartridge
8482
# @!attribute [r] scales_with
8583
# @return [Array<String>] Names of other cartridges that scale along with this cartridge and run on the same set of gears
8684
# @!attribute [r] usage_rates
8785
# @return [Array<Object>]
8886
class RestCartridge < OpenShift::Model
8987
attr_accessor :id, :type, :name, :version, :license, :license_url, :tags, :website,
9088
:help_topics, :properties, :display_name, :description, :scales_from, :scales_to,
91-
:supported_scales_to, :supported_scales_from, :current_scale, :scales_with, :usage_rates,
89+
:supported_scales_to, :supported_scales_from, :scales_with, :usage_rates,
9290
:creation_time, :automatic_updates
9391

9492
def initialize(cart)
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
##
2+
# @api REST
3+
# Describes an Cartridge
4+
# @version 1.1
5+
#
6+
# Example:
7+
# ```
8+
# <cartridge>
9+
# <name>php-5.4</name>
10+
# <status-messages nil="true"/>
11+
# <version>5.4.10</version>
12+
# <display-name>PHP 5.4</display-name>
13+
# <description>PHP is a general-purpose server-side scripting language originally designed for Web development to produce dynamic Web pages. Popular development frameworks include: CakePHP, Zend, Symfony, and Code Igniter.</description>
14+
# <license>The PHP License, version 3.0</license>
15+
# <license-url>http://www.php.net/license/3_0.txt</license-url>
16+
# <tags>
17+
# <tag>service</tag>
18+
# <tag>php</tag>
19+
# <tag>web_framework</tag>
20+
# </tags>
21+
# <website>http://www.php.net</website>
22+
# <type>standalone</type>
23+
# <usage-rates/>
24+
# <scales-from>1</scales-from>
25+
# <scales-to>1</scales-to>
26+
# <current-scale>1</current-scale>
27+
# <gear-profile>small</gear-profile>
28+
# <base-gear-storage>1</base-gear-storage>
29+
# <additional-gear-storage>0</additional-gear-storage>
30+
# <collocated-with/>
31+
# <supported-scales-from>1</supported-scales-from>
32+
# <supported-scales-to>1</supported-scales-to>
33+
# <properties>
34+
# <property>
35+
# <name>OPENSHIFT_TMP_DIR</name>
36+
# <type>environment</type>
37+
# <description>Directory to store application temporary files.</description>
38+
# </property>
39+
# ...
40+
# </properties>
41+
# <scales-with nil="true"/>
42+
# <help-topics>
43+
# <Developer-Center>https://www.openshift.com/developers</Developer-Center>
44+
# </help-topics>
45+
# <links>
46+
# ...
47+
# </links>
48+
# </cartridge>
49+
# ```
50+
#
51+
# @!attribute [r] type
52+
# @deprecated
53+
# @return [String] "standalone" or "embedded".
54+
# @!attribute [r] name
55+
# @return [String] Name of the cartridge
56+
# @!attribute [r] version
57+
# @return [String] Version of the packaged software in the cartridge
58+
# @!attribute [r] license
59+
# @return [String] License of the packaged software in the cartridge
60+
# @!attribute [r] license_url
61+
# @return [String] URI to the license file for the packaged software in the cartridge
62+
# @!attribute [r] tags
63+
# @return [Array<String>] Array of tags associated with the cartridge
64+
# @!attribute [r] website
65+
# @return [String] URI to the website for the packaged software in the cartridge
66+
# @!attribute [r] help_topics
67+
# @return [Hash] Map of topics and associated URIs that can provide help on how to use and configure this cartridge
68+
# @!attribute [r] properties
69+
# @return [Array<Property>] List of environment variables and property values that are exposed by this cartridge and usable in application code.
70+
# @!attribute [r] display_name
71+
# @return [String] Formatted name used by CLI and UIs
72+
# @!attribute [r] description
73+
# @return [String] Description of the cartridge used by CLI and UIs
74+
# @!attribute [r] scales_from
75+
# @return [Integer] User specified minimum scale for the cartridge
76+
# @!attribute [r] scales_to
77+
# @return [Integer] User specified maximum scale for the cartridge
78+
# @!attribute [r] supported_scales_from
79+
# @return [Integer] Cartridge supported minimum scale
80+
# @!attribute [r] supported_scales_from
81+
# @return [Integer] Cartridge supported maximum scale
82+
# @!attribute [r] current_scale
83+
# @return [Integer] Current number of gears used to run this cartridge
84+
# @!attribute [r] scales_with
85+
# @return [Array<String>] Names of other cartridges that scale along with this cartridge and run on the same set of gears
86+
# @!attribute [r] usage_rates
87+
# @return [Array<Object>]
88+
class RestCartridge16 < OpenShift::Model
89+
attr_accessor :id, :type, :name, :version, :license, :license_url, :tags, :website,
90+
:help_topics, :properties, :display_name, :description, :scales_from, :scales_to,
91+
:supported_scales_to, :supported_scales_from, :current_scale, :scales_with, :usage_rates,
92+
:creation_time, :automatic_updates
93+
94+
def initialize(cart)
95+
self.name = cart.name
96+
self.id = cart.id
97+
self.version = cart.version
98+
self.display_name = cart.display_name
99+
self.description = cart.description
100+
self.license = cart.license
101+
self.license_url = cart.license_url
102+
self.tags = cart.categories
103+
self.website = cart.website
104+
self.type = "standalone"
105+
self.type = "embedded" unless cart.is_web_framework?
106+
scale = cart.components.first.scaling
107+
if not scale.nil?
108+
self.supported_scales_from = scale.min
109+
self.supported_scales_to = scale.max
110+
else
111+
self.supported_scales_from = 1
112+
self.supported_scales_to = -1
113+
end
114+
self.help_topics = cart.help_topics
115+
self.usage_rates = cart.usage_rates
116+
if requires = CartridgeCache.find_requires_for(cart).presence
117+
@requires = requires
118+
end
119+
120+
@maintained_by = "redhat" if cart.cartridge_vendor == "redhat"
121+
self.automatic_updates = cart.manifest_url.blank? && !cart.categories.include?('no_updates')
122+
123+
self.creation_time = cart.created_at
124+
if cart.activated_at
125+
@activation_time = cart.activated_at.in_time_zone
126+
end
127+
128+
@obsolete = true if cart.is_obsolete?
129+
@url = cart.manifest_url if cart.manifest_url.present?
130+
end
131+
132+
def to_xml(options={})
133+
options[:tag_name] = "cartridge"
134+
super(options)
135+
end
136+
end

controller/lib/openshift/controller/api_behavior.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ module Controller
33
module ApiBehavior
44
extend ActiveSupport::Concern
55

6-
API_VERSION = 1.6
7-
SUPPORTED_API_VERSIONS = [1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6]
6+
API_VERSION = 1.7
7+
SUPPORTED_API_VERSIONS = [1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7]
88

99
included do
1010
before_filter ->{ Mongoid.identity_map_enabled = true }

0 commit comments

Comments
 (0)