This commit is contained in:
Dave Syer
2015-05-21 14:44:15 +01:00
parent 1a55cc1c71
commit 1c862dab2b
15 changed files with 127 additions and 159 deletions

View File

@@ -0,0 +1,5 @@
include::intro.adoc[]
> NOTE: if you are looking for a way to bind to services then this is the wrong library. Check out the [Spring Cloud Connectors](https://github.com/spring-cloud/spring-cloud-connectors) instead.

View File

@@ -0,0 +1,46 @@
#!/bin/bash -x
git remote set-url --push origin `git config remote.origin.url | sed -e 's/^git:/https:/'`
if ! (git remote set-branches --add origin gh-pages && git fetch -q); then
echo "No gh-pages, so not syncing"
exit 0
fi
if ! [ -d target/generated-docs ]; then
echo "No gh-pages sources in target/generated-docs, so not syncing"
exit 0
fi
# Stash any outstanding changes
###################################################################
git diff-index --quiet HEAD
dirty=$?
if [ "$dirty" != "0" ]; then git stash; fi
# Switch to gh-pages branch to sync it with master
###################################################################
git checkout gh-pages
for f in target/generated-docs/*; do
file=${f#target/generated-docs/*}
if ! git ls-files -i -o --exclude-standard --directory | grep -q ^$file$; then
# Not ignored...
cp -rf $f .
git add -A $file
fi
done
git commit -a -m "Sync docs from master to gh-pages"
# Uncomment the following push if you want to auto push to
# the gh-pages branch whenever you commit to master locally.
# This is a little extreme. Use with care!
###################################################################
git push origin gh-pages
# Finally, switch back to the master branch and exit block
git checkout master
if [ "$dirty" != "0" ]; then git stash pop; fi
exit 0

View File

@@ -0,0 +1,12 @@
Spring Cloud for Cloudfoundry makes it easy to run
https://github.com/spring-cloud[Spring Cloud] apps in
https://github.com/cloudfoundry[Cloud Foundry] (the Platform as a
Service). Cloud Foundry has the notion of a "service", which is
middlware that you "bind" to an app, essentially providing it with an
environment variable containing credentials (e.g. the location and
username to use for the service).
This project provides an implementation of Spring Cloud Commons `DiscoveryClient` so you can `@EnableDiscoveryClient`
and provide your credentials as `spring.cloud.cloudfoundry.discovery.[email,password]` and then you can use the
`DiscoveryClient` directly or via a `LoadBalancerClient` (also `*.url` if you are not connecting to [Pivotal Web
Services](https://run.pivotal.io)).

View File

@@ -0,0 +1,30 @@
Here's a Spring Cloud app with Cloud Foundry discovery:
.app.groovy
[source,java]
----
@Grab('org.springframework.cloud:spring-cloud-cloudfoundry')
@RestController
@EnableDiscoveryClient
class Application {
@Autowired
DiscoveryClient client
@RequestMapping('/')
String home() {
'Hello from ' + client.getLocalServiceInstance()
}
}
----
If you run it without any service bindings:
----
$ spring jar app.jar app.groovy
$ cf push -p app.jar
----
it will show it's app name in the home page.

View File

@@ -0,0 +1,11 @@
= Spring Cloud for Cloud Foundry
include::intro.adoc[]
The first time you use it the discovery client might be slow owing to
the fact that it has to get an access token from Cloud Foundry.
== Quickstart
include::quickstart.adoc[]

View File

@@ -0,0 +1,30 @@
#!/usr/bin/env ruby
base_dir = File.join(File.dirname(__FILE__),'../../..')
src_dir = File.join(base_dir, "/src/main/asciidoc")
require 'asciidoctor'
require 'optparse'
options = {}
file = "#{src_dir}/README.adoc"
OptionParser.new do |o|
o.on('-o OUTPUT_FILE', 'Output file (default is stdout)') { |file| options[:to_file] = file unless file=='-' }
o.on('-h', '--help') { puts o; exit }
o.parse!
end
file = ARGV[0] if ARGV.length>0
srcDir = File.dirname(file)
out = "// Do not edit this file (e.g. go instead to docs/src/main/asciidoc)\n\n"
doc = Asciidoctor.load_file file, safe: :safe, parse: false
out << doc.reader.read
unless options[:to_file]
puts out
else
File.open(options[:to_file],'w+') do |file|
file.write(out)
end
end