cloudfoundry / multiapps-cli-plugin

A CLI plugin for Multi-Target Application (MTA) operations in Cloud Foundry
Apache License 2.0
81 stars 41 forks source link

Multiapps controller URL should be calculated based on the shared domains #184

Open danail-branekov opened 1 year ago

danail-branekov commented 1 year ago

Description

README/Configuration says:

MULTIAPPS_CONTROLLER_URL=<URL> - By default, the plugin attempts to deduce the multiapps-controller URL based on the available shared domains.

However, this is not true. The deploy-service-url-calculator would strip the first segment on the API URL and prepend it with deploy-service. Instead, it should really check shared domains.

Here is a sample setup:

❯ cf api
API endpoint:   https://cfapi.172.17.0.1.nip.io
API version:    3.117.0+cf-k8s

❯ cf domains
Getting domains in org trinity as danail.branekov@sap.com...

name                     availability   internal   protocols
apps.172.17.0.1.nip.io   shared                    http

With this setup the calculator would calculate deploy-service.172.17.0.1.nip.io which is incorrect, it should be deploy-service.apps.172.17.0.1.nip.io

Even better, I think the plugin could get the route to the deploy service app instead of calculating it:

❯ cf apps
Getting apps in org trinity / space deploy-service as danail.branekov@sap.com...

name             requested state   processes                       routes
deploy-service   started           web:1/1, task:0/0, tomcat:0/0   deploy-service.apps.172.17.0.1.nip.io

Your environment

Steps to reproduce

theghost5800 commented 1 year ago

Hi @danail-branekov , you are right that documentation about MULTIAPPS_CONTROLLER_URL env is not right. Calculation of deploy service url calculator is changed since release of version 3.0.0. It will get cf api url and replace/add "deploy-service" as a hostname to the domain.

Before release of version 3.0.0 the plugin will make http call to v2/shared_domains call, add "deploy-service" as host to every domain and it will make http request on every domain until some of them respond with status code 200. This change was made because of initial plans to remove v2 cf api at all and resolve issues with cloudfoundry landscapes where shared(public) domains doesn't exists.

In the current situation, it will be necessary to specify url to deploy-service application in MULTIAPPS_CONTROLLER_URL env.