cloudfoundry / bosh-deployment-resource

Apache License 2.0
12 stars 26 forks source link

deployment_name as a parameter for "put" #50

Closed cwlbraa closed 6 years ago

cwlbraa commented 6 years ago

Following our discussion this morning surrounding https://github.com/cloudfoundry/bosh-deployment-resource/issues/11 and dynamic gets, we mostly decided that dynamically configured gets for concourse resources are generally not tenable, at least without some external state provider.

In light of that, we did a bit of sketching as to what might be missing from the bosh-deployment-resource to make interop with a pool-resource and bbl-state-resource simple.

What we realized is that the only deployment-specific field on "source" for bosh-deployment-resource is "deployment_name", so if a user could set it in put and have that override source configuration, we could support both of the following configuration shapes with minimal friction.

plan:
- put: bbl-state-resource
   params:
      command: up
      name: fresh-director
- put: dynamically-configured-bosh-deployment-resource
   params:
     source_file: bbl-state/bdr_source_file
     deployment_name: cf
     manifest: $CF_DEPLOYMENT/manifest.yml
plan:
- get: concourse-pool-of-bosh-directors
   passed: step-where-we-acquired
- put: dynamically-configured-bosh-deployment-resource
   params:
     source_file: concourse-pool-of-bosh-directors/metadata
     deployment_name: cf
     manifest: $CF_DEPLOYMENT/manifest.yml

Would this be difficult? We'd be happy to have a run at PR'ing it. @evanfarrar @rowanjacobs

drich10 commented 6 years ago

I definitely see the value in allowing the user to more easily use these two resources together (especially for more than one bosh deployment). I worry about adding an additional method to reconfiguring the deployment on put. The workaround to adding this feature could look something like this

- task: update-source-file
  config:
    platform: linux
    image_resource:
      type: docker-image
      source:
        repository: ubuntu
        tag: "14.04"
    run:
      path: /bin/sh
      args:
      - -c
      - |
        set -e
        cp bbl-state/bdr_source_file source-with-deployment-name
        echo "deployment: best-deployment-name" >> source-with-deployment-name/bdr_source_file
      dir: ""
    outputs:
    - name: source-with-deployment-name
      path: ""
- put: dynamically-configured-bosh-deployment-resource
   params:
     source_file: source-with-deployment-name/bdr_source_file
     manifest: $CF_DEPLOYMENT/manifest.yml

Happy to hear what others think about these two options 👍

drich10 commented 6 years ago

Follow up here after talking with @simonjjones about this some more. An alternative to the two paths above would be to use define a bosh-deployment-resource per deployment you would like to interact with. In this case you could do something like:

resources:
- type: bosh-deployment-resource
  name: cf
  source:
    deployment: cf
- type: bosh-deployment-resource
  name: concourse
  source:
    deployment: concourse
- type: bbl-state-resource
  name: bbl-state
  source:
    ...
- type: pool-resource
  name: concourse-pool-of-bosh-directors
  source:
    ...
jobs:
- name: deploy-cf
  plan:
  - put: bbl-state
    params:
      command: up
      name: fresh-director
  - put: cf
    params:
      source_file: bbl-state/bdr_source_file
      manifest: cf/manifest.yml
....
- name: deploy-concourse
  plan:
  - get: concourse-pool-of-bosh-directors
    passed: step-where-we-acquired
  - put: concourse
    params:
      source_file: concourse-pool-of-bosh-directors/metadata
      manifest: concourse/manifest.yml

@cwlbraa and friends wdyt?

cwlbraa commented 6 years ago

I'd be happy if the second one is already supported.

drich10 commented 6 years ago

Should work as described! Closing the issue, but feel free to reopen it if something you discover along the way makes this less desirable 😄