diff --git a/Guardfile b/Guardfile index c6ce780..51ddded 100644 --- a/Guardfile +++ b/Guardfile @@ -2,10 +2,10 @@ require 'asciidoctor' require 'erb' require './src/main/ruby/readme.rb' -options = {:mkdirs => true, :safe => :unsafe, :attributes => 'linkcss'} +options = {:mkdirs => true, :safe => :unsafe, :attributes => ['linkcss', 'allow-uri-read']} guard 'shell' do - watch(/^src\/[A-Za-z].*\.adoc$/) {|m| + watch(/^src\/[A-Z-a-z][^#]*\.adoc$/) {|m| SpringCloud::Build.render_file('src/main/asciidoc/README.adoc', :to_file => './README.adoc') Asciidoctor.render_file('src/main/asciidoc/spring-cloud-cli.adoc', options.merge(:to_dir => 'target/generated-docs')) } diff --git a/docs/src/main/asciidoc/install.adoc b/docs/src/main/asciidoc/install.adoc index e46b3db..51d4b85 100644 --- a/docs/src/main/asciidoc/install.adoc +++ b/docs/src/main/asciidoc/install.adoc @@ -20,8 +20,6 @@ $ mvn install $ spring install org.springframework.cloud:spring-cloud-cli:1.0.0.BUILD-SNAPSHOT ``` -=== Encryption and Decryption - IMPORTANT: **Prerequisites:** to use the encryption and decryption features you need the full-strength JCE installed in your JVM (it's not there by default). You can download the "Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files" diff --git a/docs/src/main/asciidoc/intro.adoc b/docs/src/main/asciidoc/intro.adoc index 65b7afa..63791f9 100644 --- a/docs/src/main/asciidoc/intro.adoc +++ b/docs/src/main/asciidoc/intro.adoc @@ -1,3 +1,5 @@ -Spring Boot command line features for -https://github.com/spring-cloud[Spring Cloud]. +Spring Boot CLI provides http://projects.spring.io/spring-boot[Spring Boot] command line features for +https://github.com/spring-cloud[Spring Cloud]. You can write Groovy scripts to run Spring Cloud component applications +(e.g. `@EnableEurekaServer`). You can also easily do things like encryption and decryption to support Spring Cloud +Config clients with secret configuration values. diff --git a/docs/src/main/asciidoc/spring-cloud-cli.adoc b/docs/src/main/asciidoc/spring-cloud-cli.adoc index aa71fc8..c1880e8 100644 --- a/docs/src/main/asciidoc/spring-cloud-cli.adoc +++ b/docs/src/main/asciidoc/spring-cloud-cli.adoc @@ -1,7 +1,71 @@ = Spring Boot Cloud CLI +:github: https://github.com/spring-cloud/spring-cloud-cli +:githubmaster: {github}/tree/master +:docslink: {githubmaster}/docs/src/main/asciidoc include::intro.adoc[] +include::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/docs/src/main/asciidoc/contributing-docs.adoc[] + == Installation include::install.adoc[] + +== Writing Groovy Scripts and Running Applications + +Spring Cloud CLI has support for most of the Spring Cloud declarative +features, such as the `@Enable*` class of annotations. For example, +here is a fully functional Eureka server + +.app.groovy +[source,groovy,indent=0] +---- +@EnableEurekaServer +class Eureka {} +---- + +which you can run from the command line like this + +---- +$ spring run app.groovy +---- + +To include additional dependencies, often it suffices just to add the +appropriate feature-enabling annotation, e.g. `@EnableConfigServer`, +`@EnableOAuth2Sso` or `@EnableEurekaClient`. To manually include a +dependency you can use a `@Grab` with the special "Spring Boot" short +style artifact co-ordinates, i.e. with just the artifact ID (no need +for group or version information), e.g. to set up a client app to +listen on AMQP for management events from the Spring CLoud Bus: + +.app.groovy +[source,groovy,indent=0] +---- +@Grab('spring-cloud-starter-bus-amqp') +@RestController +class Service { + @RequestMapping('/') + def home() { [message: 'Hello'] } +} +---- + +== Encryption and Decryption + +The Spring Cloud CLI comes with an "encrypt" and a "decrypt" +command. Both accept arguments in the same form with a key specified +as a mandatory "--key", e.g. + +---- +$ spring encrypt mysecret --key foo +682bc583f4641835fa2db009355293665d2647dade3375c0ee201de2a49f7bda +$ spring decrypt --key foo 682bc583f4641835fa2db009355293665d2647dade3375c0ee201de2a49f7bda +mysecret +---- + +To use a key in a file (e.g. an RSA public key for encyption) prepend +the key value with "@" and provide the file path, e.g. + +---- +$ spring encrypt mysecret --key @${HOME}/.ssh/id_rsa.pub +AQAjPgt3eFZQXwt8tsHAVv/QHiY5sI2dRcR+... +----