Skip to content

feat(apps): Add Generate App Manifest functionality #244

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cloudfoundry_client/networking/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ def _append_encoded_parameter(parameters: List[str], args: Tuple[str, Any]) -> L
for value in value_list:
parameters.append("%s=%s" % (parameter_name, str(value)))
elif isinstance(parameter_value, (list, tuple)):
parameters.append("q=%s" % quote("%s IN %s" % (parameter_name, ",".join(parameter_value))))
parameters.append("%s=%s" % (parameter_name, quote(",".join(parameter_value))))
else:
parameters.append("q=%s" % quote("%s:%s" % (parameter_name, str(parameter_value))))
parameters.append("%s=%s" % (parameter_name, quote(str(parameter_value))))
return parameters

if len(kwargs) > 0:
Expand Down
3 changes: 3 additions & 0 deletions cloudfoundry_client/v3/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ def get_env(self, application_guid: str) -> JsonObject:

def get_routes(self, application_guid: str) -> JsonObject:
return super(AppManager, self)._get("%s%s/%s/routes" % (self.target_endpoint, self.entity_uri, application_guid))

def get_manifest(self, application_guid: str) -> str:
return self.client.get(url="%s%s/%s/manifest" % (self.target_endpoint, self.entity_uri, application_guid)).text
28 changes: 28 additions & 0 deletions tests/fixtures/v3/apps/GET_{id}_manifest_response.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
applications:
- name: my-app
stack: cflinuxfs4
features:
ssh: true
revisions: true
service-binding-k8s: false
file-based-vcap-services: false
services:
- my-service
routes:
- route: my-app.example.com
protocol: http1
processes:
- type: web
instances: 2
memory: 512M
log-rate-limit-per-second: 1KB
disk_quota: 1024M
health-check-type: http
health-check-http-endpoint: /healthy
health-check-invocation-timeout: 10
health-check-interval: 5
readiness-health-check-type: http
readiness-health-check-http-endpoint: /ready
readiness-health-check-invocation-timeout: 20
readiness-health-check-interval: 5
28 changes: 28 additions & 0 deletions tests/v3/test_apps.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import unittest
import yaml
from http import HTTPStatus
from typing import Optional, List, Union

from abstract_test_case import AbstractTestCase
from cloudfoundry_client.common_objects import JsonObject
Expand Down Expand Up @@ -132,3 +134,29 @@ def test_list_include_space(self):
self.assertIsInstance(all_spaces[0], Entity)
self.assertEqual(all_spaces[1]["name"], "my_space")
self.assertIsInstance(all_spaces[1], Entity)

def test_get_manifest(self):
self.client.get.return_value = self.mock_response(
"/v3/apps/app_id/manifest", HTTPStatus.OK, {"Content-Type": "application/x-yaml"}, "v3", "apps",
"GET_{id}_manifest_response.yml"
)
manifest_response: str = self.client.v3.apps.get_manifest("app_id")
self.assertIsInstance(manifest_response, str)
manifest: dict = yaml.safe_load(manifest_response)
applications: Optional[list[dict]] = manifest.get("applications")
self.assertIsInstance(applications, list)
self.assertEqual(len(applications), 1)
application: dict = applications[0]
self.assertEqual(application.get("name"), "my-app")
self.assertEqual(application.get("stack"), "cflinuxfs4")
application_services: Optional[list[str]] = application.get("services")
self.assertIsInstance(application_services, list)
self.assertEqual(len(application_services), 1)
self.assertEqual(application_services[0], "my-service")
application_routes: Optional[List[Union[dict, str]]] = application.get("routes")
self.assertIsInstance(application_routes, list)
self.assertEqual(len(application_routes), 1)
application_route: dict = application_routes[0]
self.assertIsInstance(application_route, dict)
self.assertEqual(application_route.get("route"), "my-app.example.com")
self.assertEqual(application_route.get("protocol"), "http1")
Loading