Skip to content
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

Add support for cf curl #79

Closed
BartoszKaszewczuk opened this issue Jun 5, 2020 · 3 comments
Closed

Add support for cf curl #79

BartoszKaszewczuk opened this issue Jun 5, 2020 · 3 comments

Comments

@BartoszKaszewczuk
Copy link
Contributor

Some of the CF functionalities are exposed only via CF REST endpoints.
To configure them one can use CF CLI's cf curl ... eg:

cf curl /v2/route_mappings -X POST -d '{"app_guid": "someUUID", "route_guid": "someOtherUUID", "app_port": 9000}'

This is to add support for cf curl to cf-cli-resource.

@patrickcrocker
Copy link
Member

I'm curious as to how you would use this in a pipeline. Do you have an example pipeline.yml that might show how you would use cf curl? (the example you gave would certainly list out the route mappings, but I'm not seeing how that would be useful in a CI/CD pipeline. Thanks!

@BartoszKaszewczuk
Copy link
Contributor Author

BartoszKaszewczuk commented Jun 8, 2020

Sure @patrickcrocker

Use case:

Using cf-cli-resource to configure cloud environments/deployments.
CF by default binds to container port 8080. If container doesnt expose 8080 or exposes more ports then CF will bind to a port of choice which may not be a desired one. This can be overridden via CF REST API accessible via cf curl.

I came up with 4 possible options ordered by ~complexity (minus most basic usage) and personally actually made me think that option 4. would open flexibility to additionally cover many more exotic cluster/deployment manipulation needs.

Sample usage:

pipeline:
  - put: apply-config-file
    resource: cf-env
    params:
      cf_home: cf-deployer-development
      space: ((cf-space-development))
      commands:
        - command: curl
          requests: >
            # Options:
            # 1. One request per line
            /v2/route_mappings -X POST -d '{"app_guid": "someUUID", "route_guid": "someOtherUUID", "app_port": 9000}'
            /v2/route_mappings -X POST -d '{"app_guid": "someUUID", "route_guid": "someOtherUUID", "app_port": 9000}'

            # 2. Using pipe operator to allow command chaining
            /v2/route_mappings -X POST -d '{"app_guid": "someUUID", "route_guid": "someOtherUUID", "app_port": 9000}' &&
            /v2/route_mappings -X POST -d '{"app_guid": "someUUID", "route_guid": "someOtherUUID", "app_port": 9000}'

            # 3. Allow for shell execution with cf-cli in path to able to execute more complex commands
            #     Note: since this pattern allows for even more flexibility, the command name should be different eg shell
            cf curl /v2/route_mappings -X POST -d '{"app_guid": "$(cf app service-discovery-dev --guid)", "route_guid": "someOtherUUID", "app_port": 9000}' |
            cf curl /v2/route_mappings -X POST -d '{"app_guid": "someUUID", "route_guid": "someOtherUUID", "app_port": 9000}'

            # 4. Allow for raw shell script execution with cf-cli in path to able to execute even more complex manipulations against CF
          script_file: ((program-source-master))/ci/post-configure-deployment.sh

Thoughts?

@patrickcrocker
Copy link
Member

Thanks for the use case!

Rather than introduce something generic like the curl command, I'd like to explore how we could implement this functionality directly into the resource instead. Maybe something like:

command: set-app-ports
app_name: my-multi-port-app
ports:
- 7777
- 8888

I've opened #83 to track this feature request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants