Sign inSign up

dom1n1k/cf-cli-resource

By dom1n1k

•Updated about 6 years ago

Image
0

100K+

dom1n1k/cf-cli-resource repository overview

⁠cf cli Concourse Resource

CI Builds Docker Pulls

An output only resource capable of running lots of Cloud Foundry cli commands.

⁠Source Configuration

Note: you must provide either username and password or client_id and client_secret.

  • api: Required. The address of the Cloud Controller in the Cloud Foundry deployment.
  • username: Optional. The username used to authenticate.
  • password: Optional. The password used to authenticate.
  • origin: Optional. The identity provider to be used for authentication (only valid for username & password authentication)
  • client_id: Optional. The client id used to authenticate.
  • client_secret: Optional. The client secret used to authenticate.
  • skip_cert_check: Optional. Check the validity of the CF SSL cert. Defaults to false.
  • org: Optional. Sets the default organization to target (can be overridden in the params config).
  • space: Optional. Sets the default space to target (can be overridden in the params config).
  • cf_color: Optional. Set to false to not colorize cf output (can be overridden in the params config).
  • cf_dial_timeout: Optional. Max wait time to establish a connection, including name resolution, in seconds (can be overridden in the params config).
  • cf_trace: Optional. Set to true to print cf API request diagnostics to stdout (can be overridden in the params config).
resource_types:
  - name: cf-cli-resource
    type: docker-image
    source:
      repository: nulldriver/cf-cli-resource
      tag: latest

resources:
  - name: cf-env
    type: cf-cli-resource
    source:
      api: https://api.local.pcfdev.io
      username: admin
      password: admin
      skip_cert_check: true

⁠Multiple Command Syntax

This resource is capable of running single commands in separate put steps.

NOTE: A common practice is to use different logical names for each put step and reuse the same resource. In this example were we use cf-create-org and cf-create-space to describe the put steps and use the same cf-env resource for both steps.

- put: cf-create-org
  resource: cf-env
  params:
    command: create-org
    org: myorg
- put: cf-create-space
  resource: cf-env
  params:
    command: create-space
    org: myorg
    space: myspace

or they can be combined in a single put step:

- put: cf-create-org-and-space
  resource: cf-env
  params:
    commands:
      - command: create-org
        org: myorg
      - command: create-space
        org: myorg
        space: myspace

And, of course, if you have your org and space defined in the source config, it gets even simpler:

- put: cf-create-org-and-space
  resource: cf-env
  params:
    commands:
      - command: create-org
      - command: create-space

⁠CF_HOME

The standard way to authenticate the cf-cli-resource with a target Cloud Foundry environment is to either use username and password or client_id and client_secret, which will save a $CF_HOME/.cf/config.json file containing the API endpoint, and access token. For some pipeline workflows, it is necessary to authenticate using alternative methods and then supply the pre-configured config.json to the cf-cli-resource.

For example:

resources:
  - name: cf-prod
    type: cf-cli-resource

jobs:
  - name: deploy
    plan:
      - get: my-repo
      - task: authenticate
        file: my-repo/some-script-that-authenticates-and-creates-a-cf-config-json.yml
      - put: cf-prod
        params:
          cf_home: authenticate-task-output
          commands:
            - command: push
              path: my-repo/myapp
              manifest: my-repo/manifest.yml

⁠Command via file input

This resource supports file inputs. This allows the pipeline to parameterize and generate commands during pipeline execution.

  • command_file: Optional. Contains path to a YAML file that contains the same fields as params; including command or commands. If used, this resource uses only the configuration listed in this file. All other configurations specified in the params section will be ignored. The command_file field (if exists) is ignored within the content of the file itself.
- task: configure
  config:
    platform: linux
    image_resource:
      type: docker-image
      source:
        repository: ubuntu
    run:
      path: bash
      args:
        - -excl
        - |-
          cat > cf_command/params.yml <<EOF
          command: delete
          app_name: app
          delete_mapped_routes: true
          EOF
    outputs:
      - name: cf_command
- put: cf-delete
  resource: cf-env
  params:
    command: delete
    command_file: cf_command/params.yml

⁠Behavior

⁠out: Run a cf cli command.

Run cf command(s) on a Cloud Foundry installation.

⁠create-org

Create an org

  • org: Optional. The organization to create (required if not set in the source config)
- put: cf-create-org
  resource: cf-env
  params:
    command: create-org
    org: myorg
⁠delete-org

Delete an org

  • org: Optional. The organization to delete (required if not set in the source config)
- put: cf-delete-org
  resource: cf-env
  params:
    command: delete-org
    org: myorg
⁠create-space

Create a space

  • org: Optional. The organization to target (required if not set in the source config)
  • space: Optional. The space to create (required if not set in the source config)
- put: cf-create-space
  resource: cf-env
  params:
    command: create-space
    org: myorg
    space: myspace
⁠delete-space

Delete a space

  • org: Optional. The organization to target (required if not set in the source config)
  • space: Optional. The space to delete (required if not set in the source config)
- put: cf-delete-space
  resource: cf-env
  params:
    command: delete-space
    org: myorg
    space: myspace
⁠create-domain

Create a domain in an org for later use

  • org: Optional. The organization to create the domain in (required if not set in the source config)
  • domain: Optional. The domain to add to the organization
- put: cf-create-domain
  resource: cf-env
  params:
    command: create-domain
    org: myorg
    domain: example.com
⁠delete-domain

Delete a domain

  • org: Optional. The organization to target (required if not set in the source config)
  • space: Optional. The space to target (required if not set in the source config)
  • domain: Optional. The domain to delete
- put: cf-delete-domain
  resource: cf-env
  params:
    command: delete-domain
    domain: example.com
⁠create-route

Create a url route in a space for later use

  • org: Optional. The organization to target (required if not set in the source config)
  • space: Optional. The space to target (required if not set in the source config)
  • other_space: Optional. The space for the route (if not set the source or params specified space will be used)
  • domain: Required. Domain for the HTTP route
  • hostname: Optional. Hostname for the HTTP route (required for shared domains)
  • path: Optional. Path for the HTTP route
- put: cf-create-route
  resource: cf-env
  params:
    command: create-route
    domain: example.com
    hostname: myhost
    path: foo
⁠map-route

Add a url route to an app

  • org: Optional. The organization to target (required if not set in the source config)
  • space: Optional. The space to target (required if not set in the source config)
  • app_name: Required. The application to map the route to
  • domain: Required. The domain to map to the application
  • hostname: Optional. Hostname for the HTTP route (required for shared domains)
  • path: Optional. Path for the HTTP route
- put: cf-map-route
  resource: cf-env
  params:
    command: map-route
    app_name: myapp-ui
    domain: example.com
    hostname: myhost
    path: foo
⁠unmap-route

Remove a url route from an app

  • org: Optional. The organization to target (required if not set in the source config)
  • space: Optional. The space to target (required if not set in the source config)
  • app_name: Required. The application to map the route to
  • domain: Required. The domain to unmap from the application
  • hostname: Optional. Hostname used to identify the HTTP route
  • path: Optional. Path used to identify the HTTP route
- put: cf-unmap-route
  resource: cf-env
  params:
    command: unmap-route
    app_name: myapp-ui
    domain: example.com
    hostname: myhost
    path: foo
⁠delete-route

Delete a route

  • org: Optional. The organization to target (required if not set in the source config)
  • space: Optional. The space to target (required if not set in the source config)
  • domain: Required. Domain used to identify the HTTP route
  • hostname: Optional. Hostname used to identify the HTTP route
  • path: Optional. Path used to identify the HTTP route
- put: cf-delete-route
  resource: cf-env
  params:
    command: delete-route
    domain: example.com
    hostname: myhost
    path: foo
⁠create-user

Create a new user

  • username: Required. The user to create
  • password: Optional. The password (must specify either password or origin)
  • origin: Optional. The authentication origin (e.g. ldap, provider-alias) (must specify either password or origin)

Create a user with credentials:

- put: prepare-env
  resource: cf-env
  params:
    command: create-user
    username: [email protected]
    password: S3cr3t

Create an LDAP user:

- put: prepare-env
  resource: cf-env
  params:
    command: create-user
    username: [email protected]
    origin: ldap
⁠create-users-from-file

Bulk create users from a csv file

  • file: Required. The csv file containing the users
- put: prepare-env
  resource: cf-env
  params:
    command: create-users-from-file
    file: somepath/users.csv

The format of the bulk load file:

UsernamePasswordOrgSpaceOrgManagerBillingManagerOrgAuditorSpaceManagerSpaceDeveloperSpaceAuditor
user1S3cr3torg1devxxxxxx
user2org2devxxxx
user3S3cr3torg3devxx
user3S3cr3torg3testxx

Notes:

  • The file must include the header row
  • The file must be in comma separated value format
  • You can specify the user more than once to assign multiple orgs/spaces
  • If you omit the Org, no org or space roles will be assigned
  • If you omit the Space, no space roles will be assigned
⁠delete-user

Delete a user

  • username: Required. The user to delete
- put: prepare-env
  resource: cf-env
  params:
    command: delete-user
    username: [email protected]
⁠create-user-provided-service

Make a user-provided service instance available to CF apps

  • org: Optional. The organization to target (required if not set in the source config)
  • space: Optional. The space to target (required if not set in the source config)
  • service_instance: Required. The name to give the service instance
  • Options: Only specify one.
    • credentials: Credentials, provided as YAML, inline json or in a file, to be exposed in the VCAP_SERVICES environment variable for bound applications
    • syslog_drain_url: URL to which logs for bound applications will be streamed
    • route_service_url: URL to which requests for bound routes will be forwarded. Scheme for this URL must be https
- put: cf-create-user-provided-service
  resource: cf-env
  params:
    commands:
      # credentials as YAML
      - command: create-user-provided-service
        service_instance: my-db-mine
        credentials:
          username: admin
          password: pa55woRD
      # credentials as inline json
      - command: create-user-provided-service
        service_instance: my-db-mine
        credentials: '{"username":"admin","password":"pa55woRD"}'
      # credentials as json file
      - command: create-user-provided-service
        service_instance: another-db-mine
        credentials: path/to/credentials.json
      # syslog drain url
      - command: create-user-provided-service
        service_instance: my-drain-service
        syslog_drain_url: syslog://example.com
      # route service url
      - command: create-user-provided-service
        service_instance: my-route-service
        route_service_url: https://example.com
⁠create-service

Create a service instance

  • org: Optional. The organization to target (required if not set in the source config)
  • space: Optional. The space to target (required if not set in the source config)
  • service: Required. The marketplace service name to create
  • plan: Required. The service plan name to create
  • service_instance: Required. The name to give the service instance
  • broker: Optional. Create a service instance from a particular broker. Required when service name is ambiguous
  • configuration: Optional. Valid JSON object containing service-specific configuration parameters, provided either in-line or in a file. For a list of supported configuration parameters, see documentation for the particular service offering.
  • tags: Optional. User provided tags
  • timeout: Optional. Max wait time for service creation, in seconds. Defaults to 600 (10 minutes)
  • wait_for_service: Optional. Wait for the asynchronous service to start. Defaults to false.
  • update_service: Optional. Update service instance if it already exists. Defaults to false.
- put: cf-create-service
  resource: cf-env
  params:
    command: create-service
    service: p-config-server
    plan: standard
    service_instance: my-config-server
    configuration: '{"count":1}'
    tags: "list, of, tags"
    timeout: 300
    wait_for_service: true
⁠update-service

Update a service instance

  • org: Optional. The organization to target (required if not set in the source config)
  • space: Optional. The space to target (required if not set in the source config)
  • service_instance: Required. The name of the service instance
  • plan: Required. Change service plan for a service instance
  • configuration: Optional. Valid JSON object containing service-specific configuration parameters, provided either in-line or in a file. For a list of supported configuration parameters, see documentation for the particular service offering.
  • tags: Optional. User provided tags
  • timeout: Optional. Max wait time for service update, in seconds. Defaults to 600 (10 minutes)
  • wait_for_service: Optional. Wait for the asynchronous service to update. Defaults to false.
- put: cf-update-service
  resource: cf-env
  params:
    command: update-service
    service: p-config-server
    plan: pro
    service_instance: my-config-server
    configuration: '{"count":2}'
    tags: "list, of, tags"
    timeout: 300
    wait_for_service: true
⁠delete-service

Delete a service instance

  • org: Optional. The organization to target (required if not set in the source config)
  • space: Optional. The space to target (required if not set in the source config)
  • service_instance: Required. The service instance to delete
  • wait_for_service: Optional. Wait for the service to delete. Defaults to false.
- put: cf-delete-service
  resource: cf-env
  params:
    command: delete-service
    service_instance: my-config-server
    wait_for_service: true
⁠share-service

Share a service instance with another space

  • org: Optional. The organization to target (required if not set in the source config)
  • space: Optional. The space to target (required if not set in the source config)
  • service_instance: Required. The name of the service instance to share
  • other_org: Optional. Org of the other space (Default: targeted org)
  • other_space: Required. Space to share the service instance into
- put: cf-share-service
  resource: cf-env
  params:
    command: share-service
    service_instance: my-shared-service
    other_org: other-org
    other_space: other-space
⁠unshare-service

Unshare a shared service instance from a space

  • org: Optional. The organization to target (required if not set in the source config)
  • space: Optional. The space to target (required if not set in the source config)
  • service_instance: Required. The name of the service instance to unshare
  • other_org: Optional. Org of the other space (Default: targeted org)
  • other_space: Required. Space to unshare the service instance from
- put: cf-unshare-service
  resource: cf-env
  params:
    command: unshare-service
    service_instance: my-shared-service
    other_org: other-org
    other_space: other-space
⁠create-service-key

Create a service key

  • org: Optional. The organization to target (required if not set in the source config)
  • space: Optional. The space to target (required if not set in the source config)
  • service_instance: Required. The name of the service instance for which the key is to be created
  • service_key: Required. The name to give the service key
  • configuration: Optional. Valid JSON object containing service-specific configuration parameters, provided either in-line or in a file. For a list of supported configuration parameters, see documentation for the particular service offering.
- put: cf-create-service-key
  resource: cf-env
  params:
    command: create-service-key
    service_instance: my-db
    service_key: my-db-service-key
⁠delete-service-key

Delete a service key

  • org: Optional. The organization to target (required if not set in the source config)
  • space: Optional. The space to target (required if not set in the source config)
  • service_instance: Required. The service instance that has the service key
  • service_key: Required. The service key to delete
- put: cf-delete-service-key
  resource: cf-env
  params:
    command: delete-service-key
    service_instance: my-db
    service_key: my-db-service-key
⁠create-service-broker

Create/Update a service broker. If a service broker already exists, updates the existing service broker.

  • org: Optional. The organization to target (required if space_scoped: true)
  • space: Optional. The space to target (required if space_scoped: true)
  • service_broker: Required. The service broker name to create
  • username: Required. The service broker username
  • password: Required. The service broker password
  • url: Required. The service broker url
  • space_scoped: Optional. Make the broker's service plans only visible within the targeted space. Defaults to false.
- put: cf-create-service-broker
  resource: cf-env
  params:
    command: create-service-broker
    service_broker: some-service
    username: admin
    password: password
    url: http://broker.name.com
    space_scoped: true
⁠delete-service-broker

Deletes a service broker

  • org: Optional. The organization to target (required if not set in the source config)
  • space: Optional. The space to target (required if not set in the source config)
  • service_broker: Required. The service broker name to delete
- put: cf-delete-service-broker
  resource: cf-env
  params:
    command: delete-service-broker
    service_broker: some-service
⁠wait-for-service

Wait for a service instance to start

  • org: Optional. The organization to target (required if not set in the source config)
  • space: Optional. The space to target (required if not set in the source config)
  • service_instance: Required. The service instance to wait for
  • timeout: Optional. Max wait time for service creation, in seconds. Defaults to 600 (10 minutes)
- put: cf-wait-for-service
  resource: cf-env
  params:
    command: wait-for-service
    service_instance: my-config-server
    timeout: 300
⁠enable-service-access

Enable access to a service or service plan for one or all orgs

  • service: Required. The marketplace service name to enable
  • broker: Optional. Enable access to a service from a particular service broker. Required when service name is ambiguous
  • access_org: Optional. Enable access for a specified organization
  • plan: Optional. Enable access to a specified service plan
- put: cf-enable-service-access
  resource: cf-env
  params:
    command: enable-service-access
    service: some-service
    broker: some-service-broker
    access_org: myorg
    plan: simple
⁠disable-service-access

Disable access to a service or service plan for one or all orgs

  • service: Required. The marketplace service name to disable
  • access_org: Optional. Disable access for a specified organization
  • plan: Optional. Disable access to a specified service plan
- put: cf-disable-service-access
  resource: cf-env
  params:
    command: disable-service-access
    service: some-service
    access_org: myorg
    plan: simple
⁠bind-service

Bind a service instance to an app

  • org: Optional. The organization to target (required if not set in the source config)
  • space: Optional. The space to target (required if not set in the source config)
  • app_name: Required. The application to bind to the service
  • service_instance: Required. The service instance to bind to the application
  • configuration: Optional. Valid JSON object containing service-specific configuration parameters, provided either in-line or in a file. For a list of supported configuration parameters, see documentation for the particular service offering.
- put: cf-bind-service
  resource: cf-env
  params:
    command: bind-service
    app_name: myapp-ui
    service_instance: mydb
    configuration: '{"permissions":"read-only"}'
⁠unbind-service

Unbind a service instance from an app

  • org: Optional. The organization to target (required if not set in the source config)
  • space: Optional. The space to target (required if not set in the source config)
  • app_name: Required. The application to unbind from the service instance
  • service_instance: Required. The service instance to unbind from the application
- put: cf-unbind-service
  resource: cf-env
  params:
    command: unbind-service
    app_name: myapp-ui
    service_instance: mydb
⁠bind-route-service

Bind a service instance to an HTTP route

  • org: Optional. The organization to target (required if not set in the source config)
  • space: Optional. The space to target (required if not set in the source config)
  • domain: Required. The domain to bind the route to
  • service_instance: Required. The service instance to bind the route to
  • hostname: Optional. Hostname used in combination with domain to specify the route to bind
  • path: Optional. Path used in combination with hostname and domain to specify the route to bind
- put: cf-bind-route-service
  resource: cf-env
  params:
    command: bind-route-service
    domain: example.com
    service_instance: mylogger
    hostname: myhost
    path: foo
⁠enable-feature-flag

Allow use of a feature

  • feature_name: Required. Feature to enable
- put: cf-enable-feature-flag
  resource: cf-env
  params:
    command: enable-feature-flag
    feature_name: service_instance_sharing
⁠disable-feature-flag

Prevent use of a feature

  • feature_name: Required. Feature to disable
- put: cf-disable-feature-flag
  resource: cf-env
  params:
    command: disable-feature-flag
    feature_name: service_instance_sharing
⁠push

Push a new app or sync changes to an existing app

NOTE: A manifest can be used to specify values for required parameters. Any parameters specified will override manifest values.

⁠Common params
  • org: Optional. The organization to target (required if not set in the sourc

Tag summary

Content type

Image

Digest

Size

45.5 MB

Last updated

about 6 years ago

docker pull dom1n1k/cf-cli-resource