I am very new to using cloud foundry. Currently, I am trying to automate the task of pushing an app to a target URL using the cloud foundry java client library but I am not being able to figure out how to push the manifest file ,i.e, how do i execute the command "cf push -f " using java client library ?
I am being able to login and view the list of spaces and organizations. I just need to push into an organization in the dev space.
Thanks in advance !
For starters, you want to use the CloudFoundryOperations API. This is a higher level abstraction and mimics the behaviors of the
cf
cli. This is opposed to the CloudFoundryClient API which more closely mimics the raw underlying Cloud Foundry API.The
CloudFoundryOperations.pushManifest(..)
method should do what you want. It takes aPushApplicationManifestRequest
object.You can use the builder directly to create one, or you can use the
ApplicationManifestUtils.read(..)
method. Theread(..)
method will read from a traditional cf climanifest.yml
file and you can use the Builder's methods likeaddAllManifests(..)
ormanifests(..)
to add theApplicationManifest
object that you get from the call toread(..)
to yourPushApplicationManifestRequest
object.When you have the
PushApplicationManifestRequest
object build the way you want, you simply pass that through toCloudFoundryOperations.pushManifest(..)
.For other's reference, there is a
CloudFoundryOperations.push(..)
method, if you don't want to use a manifest that one will work too. It functions roughly the same, but doesn't have the support for manifests.