minke-generator-swift 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +14 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +76 -0
- data/Rakefile +7 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/generators/swift.rb +31 -0
- data/lib/generators/swift/commands.rb +25 -0
- data/lib/generators/swift/scaffold/.DS_Store +0 -0
- data/lib/generators/swift/scaffold/.gitignore +0 -0
- data/lib/generators/swift/scaffold/_build/.gitignore +0 -0
- data/lib/generators/swift/scaffold/_build/.ruby-gemset.erb +1 -0
- data/lib/generators/swift/scaffold/_build/.ruby-version +1 -0
- data/lib/generators/swift/scaffold/_build/Gemfile +8 -0
- data/lib/generators/swift/scaffold/_build/Rakefile +4 -0
- data/lib/generators/swift/scaffold/_build/config.yml.erb +47 -0
- data/lib/generators/swift/scaffold/_build/consul_keys.yml.erb +7 -0
- data/lib/generators/swift/scaffold/_build/dockercompose/<%= application_name %>/docker-compose.yml.erb +30 -0
- data/lib/generators/swift/scaffold/_build/dockercompose/<%= application_name %>/docker-no-server.yml.erb +20 -0
- data/lib/generators/swift/scaffold/_build/dockerfile/.DS_Store +0 -0
- data/lib/generators/swift/scaffold/_build/dockerfile/<%= application_name %>/.DS_Store +0 -0
- data/lib/generators/swift/scaffold/_build/dockerfile/<%= application_name %>/Dockerfile.erb +36 -0
- data/lib/generators/swift/scaffold/_build/dockerfile/<%= application_name %>/config.ctmpl.erb +7 -0
- data/lib/generators/swift/scaffold/_build/dockerfile/<%= application_name %>/libCHttpParser.so +0 -0
- data/lib/generators/swift/scaffold/_build/dockerfile/<%= application_name %>/s6-etc/.s6-svscan/crash +1 -0
- data/lib/generators/swift/scaffold/_build/dockerfile/<%= application_name %>/s6-etc/.s6-svscan/finish +1 -0
- data/lib/generators/swift/scaffold/_build/dockerfile/<%= application_name %>/s6-etc/app/finish +1 -0
- data/lib/generators/swift/scaffold/_build/dockerfile/<%= application_name %>/s6-etc/app/run.erb +3 -0
- data/lib/generators/swift/scaffold/_build/dockerfile/<%= application_name %>/s6-etc/consul-template/finish +1 -0
- data/lib/generators/swift/scaffold/_build/dockerfile/<%= application_name %>/s6-etc/consul-template/run.erb +3 -0
- data/lib/generators/swift/scaffold/_build/features/health.feature +10 -0
- data/lib/generators/swift/scaffold/_build/features/steps/cucumer_rest_monkey_patch.rb +44 -0
- data/lib/generators/swift/scaffold/_build/features/support/env.rb.erb +15 -0
- data/lib/generators/swift/scaffold/_build/swagger_spec/swagger.yml.erb +34 -0
- data/lib/generators/swift/scaffold/src/<%= application_name %>/Config.swift +11 -0
- data/lib/generators/swift/scaffold/src/<%= application_name %>/handlers/HealthHandler.swift +17 -0
- data/lib/generators/swift/scaffold/src/<%= application_name %>/models/.DS_Store +0 -0
- data/lib/generators/swift/scaffold/src/<%= application_name %>/models/HealthHandlerResponse.swift +14 -0
- data/lib/generators/swift/scaffold/src/<%= application_name %>/models/JSONDictionary.swift +5 -0
- data/lib/generators/swift/scaffold/src/<%= application_name %>App/Metrics.swift +23 -0
- data/lib/generators/swift/scaffold/src/<%= application_name %>App/Routing.swift.erb +53 -0
- data/lib/generators/swift/scaffold/src/<%= application_name %>App/config.json +15 -0
- data/lib/generators/swift/scaffold/src/<%= application_name %>App/main.swift.erb +51 -0
- data/lib/generators/swift/scaffold/src/Makefile.erb +25 -0
- data/lib/generators/swift/scaffold/src/Package.swift.erb +21 -0
- data/lib/generators/swift/scaffold/src/Tests/<%= application_name %>/HealthHandlerTests.swift.erb +38 -0
- data/lib/generators/swift/scaffold/src/Tests/<%= application_name %>/models/HealthHandlerResponseTests.swift.erb +23 -0
- data/lib/generators/swift/scaffold/src/Tests/LinuxMain.swift.erb +10 -0
- data/lib/generators/swift/version.rb +7 -0
- data/minke-generator-swift.gemspec +28 -0
- metadata +143 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: a60fc06b6b6f94efc25a743b8707601e37594457
|
|
4
|
+
data.tar.gz: 5d6cbd2d67fa251f0e7d0f2c4cbf554ec328de5e
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: eb9ae97f3dd5435d15051c8f13112478f26c28ab6fc9f4d6c2bc2c182b16004a11582f81d0e946a7d576320e0130142f9f39d90e5d5184d23e3dbc84554cc3a0
|
|
7
|
+
data.tar.gz: 18ba97a21a073463cbe7d738c4d723f982af51a69dc570094fe16c49c46edd40af4d289993b7ccc90c4437157f676d856da0a05207d3b8b0b9d4112a7a968ce1
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-gemset
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
minke-generator-swift
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.3.1
|
data/.travis.yml
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
language: ruby
|
|
2
|
+
rvm:
|
|
3
|
+
- 2.3.1
|
|
4
|
+
install: bundle
|
|
5
|
+
script:
|
|
6
|
+
- rake test
|
|
7
|
+
- rake build
|
|
8
|
+
deploy:
|
|
9
|
+
provider: rubygems
|
|
10
|
+
gem: minke-generator-swift
|
|
11
|
+
on:
|
|
12
|
+
repo: nicholasjackson/minke-generator-swift
|
|
13
|
+
api_key:
|
|
14
|
+
secure: Z4YTNo9euqypew0HJhqMKn+Qt6QpccFseNY9dj5gc1WfjkH6LBu2cd0kMB4exdSpzNdQbPUoylSOxo3Sn1BsDsVHYyJ9PRAffmqbMVtmXz/OL9tDIAUfzFA2C981BSJbMBNkFC+AjHnYuaPFJqnnyvYCPCItQILluoZlyfquM4KqzydnO7FCT1J7fl2Bt6aLPk7QQ9hwlxE7h66pX6fEGgZPUFHEwno23+lr4x8bkUrRoGgxz5sEDyvQm9WgzvjaJA5ahxJIT5o4a+I9POQQu8b6MTkLBfrBHwG/GaOQwdciSBkclOoBdwDbZMKBNKC+Hm3gBb+7vaexNNGkcB5tyFVOlo9b/VhHn/BtKRrBZkaHUA3YC1nHAYBEnnC1BmqPR13mK7o5Am/s0h6uIpnxnk6PMf3lfD515LmiLSLsZ0LESfciTjwBy1MtU1ZuN2Nf2bAv5Zl1fsjPFZqBu1NpgTHK5DSarbsuP5ZsFIAYc0VDma09zFMmLfVEcsPiqt2biMpCaM7BBupybT5imSNwssrlrOMwsDv4uW9iMmhcleF9dEbn5T89pCFNfMXSsTI2IYMLkq3j5NKTLQmkqWiN7vTSIA9w1vRj0t0N7qC8PXlHbsZ25DG0QB4H072KCOSaCVgBFTkMve2hEi/RTZYHkXGaotwNoISPU49M5pn3KDo=
|
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Contributor Code of Conduct
|
|
2
|
+
|
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
|
7
|
+
|
|
8
|
+
We are committed to making participation in this project a harassment-free
|
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
|
12
|
+
|
|
13
|
+
Examples of unacceptable behavior by participants include:
|
|
14
|
+
|
|
15
|
+
* The use of sexualized language or imagery
|
|
16
|
+
* Personal attacks
|
|
17
|
+
* Trolling or insulting/derogatory comments
|
|
18
|
+
* Public or private harassment
|
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
|
20
|
+
addresses, without explicit permission
|
|
21
|
+
* Other unethical or unprofessional conduct
|
|
22
|
+
|
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
27
|
+
threatening, offensive, or harmful.
|
|
28
|
+
|
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
|
32
|
+
Conduct may be permanently removed from the project team.
|
|
33
|
+
|
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
|
35
|
+
when an individual is representing the project or its community.
|
|
36
|
+
|
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
38
|
+
reported by contacting a project maintainer at TODO: Write your email address. All
|
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
|
42
|
+
incident.
|
|
43
|
+
|
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
45
|
+
version 1.3.0, available at
|
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
|
47
|
+
|
|
48
|
+
[homepage]: http://contributor-covenant.org
|
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 TODO: Write your name
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Minke::Generators::Swift
|
|
2
|
+
|
|
3
|
+
[](https://travis-ci.org/nicholasjackson/minke-generator-swift)
|
|
4
|
+
|
|
5
|
+
This generator creates a REST API Microservice in Swift 3.0 using the IBM Kitura framework for the Minke build and test system.
|
|
6
|
+
|
|
7
|
+
For information on Minke please see the documentation [http://nicholasjackson.github.io/minke/](http://nicholasjackson.github.io/minke/).
|
|
8
|
+
|
|
9
|
+
## Available variables for templates (erb style)
|
|
10
|
+
| Variable | Description |
|
|
11
|
+
| ----------------------- | |
|
|
12
|
+
| <%= application_name %> | The name of the application executable |
|
|
13
|
+
| <%= namespace %> | Namespace of the application |
|
|
14
|
+
| <%= src_root %> | Source root of the application |
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
Add this line to your application's Gemfile:
|
|
19
|
+
|
|
20
|
+
```ruby
|
|
21
|
+
gem 'minke'
|
|
22
|
+
gem 'minke-generator-swift'
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
And then execute:
|
|
26
|
+
```
|
|
27
|
+
$ bundle
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Or install it yourself:
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
$ gem install minke
|
|
34
|
+
$ gem install minke-generator-swift
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Usage
|
|
38
|
+
To scaffold a new service run:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
$ minke -g minke-generator-swift -o ~/nicholasjackson/helloworld
|
|
42
|
+
-a helloworld -n HelloWorld
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
You can now open the project in [VisualStudio Code](http://code.visualstudio.com) and run your first build.
|
|
46
|
+
|
|
47
|
+
## Build and test with Docker
|
|
48
|
+
To run a build with a Docker container, to execute the functional and unit tests you can use the following commands. Please see the main Minke documentation for more information [http://nicholasjackson.github.io/minke/](http://nicholasjackson.github.io/minke/).
|
|
49
|
+
|
|
50
|
+
### Build Application Code and Execute Unit tests
|
|
51
|
+
```bash
|
|
52
|
+
$ cd _build
|
|
53
|
+
$ bundle
|
|
54
|
+
$ rake app:test
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Build a Docker image and execute functional tests with Cucumber
|
|
58
|
+
```bash
|
|
59
|
+
$ rake app:build_image
|
|
60
|
+
$ rake app:cucumber
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Development
|
|
64
|
+
|
|
65
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
66
|
+
|
|
67
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
68
|
+
|
|
69
|
+
## Contributing
|
|
70
|
+
|
|
71
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/nicholasjackson/minke-generator-netmvc. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
## License
|
|
75
|
+
|
|
76
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "minke/generator/template"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require "generators/swift/version"
|
|
2
|
+
|
|
3
|
+
require 'minke/generators/register'
|
|
4
|
+
require 'minke/generators/config'
|
|
5
|
+
|
|
6
|
+
module Minke
|
|
7
|
+
module Generators
|
|
8
|
+
module Swift
|
|
9
|
+
# Register the template with minke
|
|
10
|
+
config = Minke::Generators::Config.new
|
|
11
|
+
config.name = 'minke-generator-swift'
|
|
12
|
+
config.template_location = File.expand_path(File.dirname(__FILE__)) + '/swift/scaffold'
|
|
13
|
+
|
|
14
|
+
config.build_settings = Minke::Generators::BuildSettings.new
|
|
15
|
+
|
|
16
|
+
config.build_settings.build_commands = Minke::Generators::BuildCommands.new.tap do |bc|
|
|
17
|
+
bc.fetch = [['/bin/bash', '-c', 'swift build --fetch'], ['/bin/bash', '-c', 'find Packages/ -type d -name Tests | xargs rm -rf']]
|
|
18
|
+
bc.build = [['/bin/bash', '-c', 'swift build -Xcc -fblocks']]
|
|
19
|
+
bc.test = [['/bin/bash', '-c', 'swift test']]
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
config.build_settings.docker_settings = Minke::Generators::DockerSettings.new.tap do |bs|
|
|
23
|
+
bs.image = 'ibmcom/kitura-ubuntu'
|
|
24
|
+
bs.binds = ["<%= src_root %>/src:/src"]
|
|
25
|
+
bs.working_directory = '/src'
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
Minke::Generators.register config
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module Minke
|
|
2
|
+
module Commands
|
|
3
|
+
def self.commands config
|
|
4
|
+
{
|
|
5
|
+
:build => {
|
|
6
|
+
:get => [['go','get','-t','-v','-d','./...']],
|
|
7
|
+
:build => [['go','build','-a','-installsuffix','cgo','-ldflags','\'-s\'','-o', "#{config['application_name']}"]],
|
|
8
|
+
:test => [['go','test','./...']]
|
|
9
|
+
},
|
|
10
|
+
:docker => {
|
|
11
|
+
:image => 'golang:latest',
|
|
12
|
+
:env => ['CGO_ENABLED=0'],
|
|
13
|
+
:binds => ["#{ENV['GOPATH']}/src:/go/src"],
|
|
14
|
+
:working_directory => "#{working_directory}"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.working_directory
|
|
20
|
+
dir = File.expand_path('../.')
|
|
21
|
+
gopath = "#{ENV['GOPATH']}"
|
|
22
|
+
new_dir = "/go" + dir.gsub(gopath,'')
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%= application_name %>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.3.1
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
|
+
|
|
3
|
+
gem "rake"
|
|
4
|
+
gem "cucumber", "~> 1.3.10"
|
|
5
|
+
gem "cucumber-rest-api", "= 0.3"
|
|
6
|
+
gem 'minke'
|
|
7
|
+
gem 'minke-generator-swift' # Update this to the name of your gem
|
|
8
|
+
#gem 'minke-generator-swift', :path => '/Users/nicj/Developer/gems/minke-generator-swift' # Update this to the name of your gem
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
application_name: '<%= application_name %>'
|
|
3
|
+
namespace: '<%= namespace %>'
|
|
4
|
+
generator_name: 'minke-generator-swift'
|
|
5
|
+
docker_registry:
|
|
6
|
+
url: <%= ENV['DOCKER_REGISTRY_URL'] %>
|
|
7
|
+
user: <%= ENV['DOCKER_REGISTRY_USER'] %>
|
|
8
|
+
password: <%= ENV['DOCKER_REGISTRY_PASS'] %>
|
|
9
|
+
email: <%= ENV['DOCKER_REGISTRY_EMAIL'] %>
|
|
10
|
+
namespace: <%= ENV['DOCKER_NAMESPACE'] %>
|
|
11
|
+
docker:
|
|
12
|
+
application_docker_file: './dockerfile/<%= application_name %>/'
|
|
13
|
+
application_compose_file: './dockercompose/<%= application_name %>/docker-compose.yml'
|
|
14
|
+
fetch:
|
|
15
|
+
enabled: true
|
|
16
|
+
test:
|
|
17
|
+
enabled: true
|
|
18
|
+
build:
|
|
19
|
+
post:
|
|
20
|
+
copy:
|
|
21
|
+
-
|
|
22
|
+
from: '../src/.build/debug/<%= application_name %>App'
|
|
23
|
+
to: './dockerfile/<%= application_name %>'
|
|
24
|
+
-
|
|
25
|
+
from: './swagger_spec/swagger.yml'
|
|
26
|
+
to: './dockerfile/<%= application_name %>/swagger_spec'
|
|
27
|
+
run:
|
|
28
|
+
pre:
|
|
29
|
+
consul_loader:
|
|
30
|
+
config_file: './consul_keys.yml'
|
|
31
|
+
url:
|
|
32
|
+
address: consul
|
|
33
|
+
port: 8500
|
|
34
|
+
type: private
|
|
35
|
+
cucumber:
|
|
36
|
+
pre:
|
|
37
|
+
consul_loader:
|
|
38
|
+
config_file: './consul_keys.yml'
|
|
39
|
+
url:
|
|
40
|
+
address: consul
|
|
41
|
+
port: 8500
|
|
42
|
+
type: private
|
|
43
|
+
health_check:
|
|
44
|
+
address: <%= application_name %>
|
|
45
|
+
port: 8090
|
|
46
|
+
path: /v1/health
|
|
47
|
+
type: private
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<%= application_name %>:
|
|
2
|
+
image: <%= application_name %>
|
|
3
|
+
ports:
|
|
4
|
+
- "::8090"
|
|
5
|
+
environment:
|
|
6
|
+
- "CONSUL_URI=consul:8500"
|
|
7
|
+
links:
|
|
8
|
+
- consul:consul
|
|
9
|
+
- statsd:statsd
|
|
10
|
+
consul:
|
|
11
|
+
image: progrium/consul
|
|
12
|
+
ports:
|
|
13
|
+
- "::8400"
|
|
14
|
+
- "::8500"
|
|
15
|
+
- "::53/udp"
|
|
16
|
+
hostname: node1
|
|
17
|
+
command: "-server -bootstrap -ui-dir /ui"
|
|
18
|
+
statsd:
|
|
19
|
+
image: 'hopsoft/graphite-statsd:latest'
|
|
20
|
+
ports:
|
|
21
|
+
- "::80"
|
|
22
|
+
expose:
|
|
23
|
+
- "8125/udp"
|
|
24
|
+
registrator:
|
|
25
|
+
image: 'gliderlabs/registrator:latest'
|
|
26
|
+
links:
|
|
27
|
+
- consul:consul
|
|
28
|
+
command: '-internal -tags=dev consul://consul:8500'
|
|
29
|
+
volumes:
|
|
30
|
+
- '/var/run/docker.sock:/tmp/docker.sock'
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
consul:
|
|
2
|
+
image: progrium/consul
|
|
3
|
+
ports:
|
|
4
|
+
- "9400:8400"
|
|
5
|
+
- "9500:8500"
|
|
6
|
+
- "9600:53/udp"
|
|
7
|
+
hostname: node1
|
|
8
|
+
command: "-server -bootstrap -ui-dir /ui"
|
|
9
|
+
statsd:
|
|
10
|
+
image: 'hopsoft/graphite-statsd:latest'
|
|
11
|
+
ports:
|
|
12
|
+
- "8180:80"
|
|
13
|
+
- "8125:8125/udp"
|
|
14
|
+
registrator:
|
|
15
|
+
image: 'gliderlabs/registrator:latest'
|
|
16
|
+
links:
|
|
17
|
+
- consul:consul
|
|
18
|
+
command: '-internal -tags=dev consul://consul:8500'
|
|
19
|
+
volumes:
|
|
20
|
+
- '/var/run/docker.sock:/tmp/docker.sock'
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
FROM ibmcom/kitura-ubuntu:latest
|
|
2
|
+
|
|
3
|
+
EXPOSE 8090
|
|
4
|
+
|
|
5
|
+
# Create directory for server files
|
|
6
|
+
RUN mkdir /<%= application_name %>
|
|
7
|
+
|
|
8
|
+
# Create logs folder
|
|
9
|
+
RUN mkdir /var/log/<%= application_name %>
|
|
10
|
+
|
|
11
|
+
# Install s6 and consul-template
|
|
12
|
+
RUN apt-get update
|
|
13
|
+
RUN yes | apt-get install wget tar unzip
|
|
14
|
+
|
|
15
|
+
# s6 overlay
|
|
16
|
+
ADD https://github.com/just-containers/s6-overlay/releases/download/v1.17.1.1/s6-overlay-amd64.tar.gz /tmp/s6-overlay.tar.gz
|
|
17
|
+
RUN tar xvfz /tmp/s6-overlay.tar.gz -C /; \
|
|
18
|
+
rm -rf /etc/s6
|
|
19
|
+
|
|
20
|
+
RUN wget https://releases.hashicorp.com/consul-template/0.15.0/consul-template_0.15.0_linux_386.zip; \
|
|
21
|
+
unzip consul-template_0.15.0_linux_386.zip; \
|
|
22
|
+
mv consul-template /bin/consul-template
|
|
23
|
+
|
|
24
|
+
# Configure consul-template supervisor and S6 config
|
|
25
|
+
COPY config.ctmpl /<%= application_name %>/config.ctmpl
|
|
26
|
+
|
|
27
|
+
COPY s6-etc /etc/s6
|
|
28
|
+
RUN chmod -R 755 /etc/s6
|
|
29
|
+
|
|
30
|
+
# Copy binary
|
|
31
|
+
COPY <%= application_name %>App /<%= application_name %>/<%= application_name %>App
|
|
32
|
+
COPY libCHttpParser.so /usr/local/lib/libCHttpParser.so
|
|
33
|
+
ENV LD_LIBRARY_PATH /usr/local/lib:${LD_LIBRARY_PATH}
|
|
34
|
+
|
|
35
|
+
ENTRYPOINT ["/bin/s6-svscan","/etc/s6"]
|
|
36
|
+
CMD []
|
data/lib/generators/swift/scaffold/_build/dockerfile/<%= application_name %>/libCHttpParser.so
ADDED
|
Binary file
|
data/lib/generators/swift/scaffold/_build/dockerfile/<%= application_name %>/s6-etc/.s6-svscan/crash
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/bin/bash
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/bin/bash
|
data/lib/generators/swift/scaffold/_build/dockerfile/<%= application_name %>/s6-etc/app/finish
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/bin/bash
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/bin/bash
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
@healthcheck
|
|
2
|
+
Feature: Health check
|
|
3
|
+
In order to ensure quality
|
|
4
|
+
As a user
|
|
5
|
+
I want to be able to test functionality of my API
|
|
6
|
+
|
|
7
|
+
Scenario: Health check returns ok
|
|
8
|
+
Given I send a GET request to "/v1/health"
|
|
9
|
+
Then the response status should be "200"
|
|
10
|
+
And the JSON response should have "$..status_message" with the text "OK"
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
class Object
|
|
2
|
+
def request path,request_opts
|
|
3
|
+
req = "#{$SERVER_PATH}" + path
|
|
4
|
+
uri = URI.parse(req)
|
|
5
|
+
|
|
6
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
7
|
+
|
|
8
|
+
if request_opts[:method] == :post
|
|
9
|
+
request, body = send_post_request(uri, request_opts)
|
|
10
|
+
elsif request_opts[:method] == :put
|
|
11
|
+
request, body = perform_put_request(uri, request_opts)
|
|
12
|
+
elsif request_opts[:method] == :get
|
|
13
|
+
request = send_get_request(uri, request_opts)
|
|
14
|
+
elsif request_opts[:method] == :delete
|
|
15
|
+
request, body = perform_delete_request(uri, request_opts)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
#do we have any headers to add?
|
|
19
|
+
if @headers != nil
|
|
20
|
+
@headers.each { |k,v| request.add_field(k, v) }
|
|
21
|
+
@headers = nil
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
if req.include? "https"
|
|
25
|
+
http.use_ssl = true
|
|
26
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
|
27
|
+
@response = http.request(request,body)
|
|
28
|
+
else
|
|
29
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
30
|
+
@response = http.request(request,body)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def perform_delete_request uri,request_opts
|
|
35
|
+
request = Net::HTTP::Delete.new(uri.request_uri)
|
|
36
|
+
body = nil
|
|
37
|
+
if request_opts[:params]
|
|
38
|
+
body = request_opts[:params].to_json
|
|
39
|
+
else
|
|
40
|
+
body = request_opts[:input]
|
|
41
|
+
end
|
|
42
|
+
return request, body
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require 'cucumber/rest_api'
|
|
2
|
+
require 'rest-client'
|
|
3
|
+
|
|
4
|
+
require 'minke'
|
|
5
|
+
|
|
6
|
+
discovery = Minke::Docker::ServiceDiscovery.new 'config.yml'
|
|
7
|
+
$SERVER_PATH = "http://#{discovery.public_address_for '<%= application_name %>', '8090', :cucumber}"
|
|
8
|
+
|
|
9
|
+
Before do |scenario|
|
|
10
|
+
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
After do |scenario|
|
|
14
|
+
|
|
15
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
swagger: '2.0'
|
|
2
|
+
info:
|
|
3
|
+
title: <%= application_name %>
|
|
4
|
+
description: <%= application_name %> Description
|
|
5
|
+
version: 1.0.0
|
|
6
|
+
host: api.test.com
|
|
7
|
+
schemes:
|
|
8
|
+
- http
|
|
9
|
+
basePath: /v1
|
|
10
|
+
produces:
|
|
11
|
+
- application/json
|
|
12
|
+
paths:
|
|
13
|
+
/health:
|
|
14
|
+
get:
|
|
15
|
+
summary: Health Check
|
|
16
|
+
description: |
|
|
17
|
+
The Health Check endpoint is used to determine the current status for the health of the api.
|
|
18
|
+
This endpoint will be used by other systems such as Consul and other service discovery systems.
|
|
19
|
+
tags:
|
|
20
|
+
- Health
|
|
21
|
+
responses:
|
|
22
|
+
'200':
|
|
23
|
+
description: Status message from server describing current health
|
|
24
|
+
schema:
|
|
25
|
+
type: array
|
|
26
|
+
items:
|
|
27
|
+
$ref: '#/definitions/HealthResponse'
|
|
28
|
+
definitions:
|
|
29
|
+
HealthResponse:
|
|
30
|
+
type: object
|
|
31
|
+
properties:
|
|
32
|
+
status_message:
|
|
33
|
+
type: string
|
|
34
|
+
description: 'Plain text readable response corresponding to current health status'
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
public enum Buckets: String {
|
|
4
|
+
case Application = "stockservice"
|
|
5
|
+
case HealthHandler = "health"
|
|
6
|
+
case Get = "get", Post = "post", Put = "put", Delete = "delete"
|
|
7
|
+
case Timing = "timing", Connection = "connection", Called = "called"
|
|
8
|
+
case Success = "success", Failed = "failed", NotFound = "notfound" , BadRequest = "badrequest",
|
|
9
|
+
NotAuthorised = "notauthorised", Started = "started", Error = "error"
|
|
10
|
+
case Created = "created", Disconnected = "disconnected", Retrieved = "retrieved"
|
|
11
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
import KituraNet
|
|
4
|
+
import SwiftyJSON
|
|
5
|
+
|
|
6
|
+
import StatsD
|
|
7
|
+
|
|
8
|
+
public class HealthHandler {
|
|
9
|
+
|
|
10
|
+
public static func handle(statsD: StatsDProtocol, complete: (status: HTTPStatusCode, data: JSON?) -> Void) -> Void {
|
|
11
|
+
statsD.timer(bucket: "\(Buckets.Application.rawValue).\(Buckets.HealthHandler.rawValue).\(Buckets.Get.rawValue).\(Buckets.Timing.rawValue)") {
|
|
12
|
+
let result = HealthHandlerResponse(statusMessage: "OK")
|
|
13
|
+
complete(status: HTTPStatusCode.OK, data: JSON(result.serialize()))
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
}
|
data/lib/generators/swift/scaffold/src/<%= application_name %>/models/HealthHandlerResponse.swift
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import SwiftyJSON
|
|
3
|
+
|
|
4
|
+
struct HealthHandlerResponse {
|
|
5
|
+
let statusMessage:String
|
|
6
|
+
|
|
7
|
+
init(statusMessage:String) {
|
|
8
|
+
self.statusMessage = statusMessage
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
func serialize() -> JSONDictionary {
|
|
12
|
+
return ["status_message": statusMessage]
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import StatsD
|
|
3
|
+
import LoggerAPI
|
|
4
|
+
|
|
5
|
+
class Metrics {
|
|
6
|
+
|
|
7
|
+
func setupStatsD() -> StatsD {
|
|
8
|
+
return StatsD(
|
|
9
|
+
host: config!["statsd"]["host"].stringValue,
|
|
10
|
+
port: config!["statsd"]["port"].intValue,
|
|
11
|
+
socket: UDPSocket(),
|
|
12
|
+
interval: 1.0,
|
|
13
|
+
sendCallback: { (success: Bool, error: SocketError?) in
|
|
14
|
+
if success {
|
|
15
|
+
Log.info("Sent data to StatsD")
|
|
16
|
+
} else {
|
|
17
|
+
Log.error("Failed to send data to StatsD \(error)")
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import Kitura
|
|
2
|
+
import KituraNet
|
|
3
|
+
|
|
4
|
+
import StatsD
|
|
5
|
+
import LoggerAPI
|
|
6
|
+
import SwiftyJSON
|
|
7
|
+
import <%= application_name %>
|
|
8
|
+
|
|
9
|
+
class Routing {
|
|
10
|
+
|
|
11
|
+
let statsD: StatsDProtocol
|
|
12
|
+
let config: JSON
|
|
13
|
+
|
|
14
|
+
init(statsD: StatsDProtocol, config: JSON) {
|
|
15
|
+
self.statsD = statsD
|
|
16
|
+
self.config = config
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
func setupRouter() -> Router {
|
|
20
|
+
let router = Router()
|
|
21
|
+
|
|
22
|
+
setupHealthRoutes(router: router, path: "/v1/health")
|
|
23
|
+
|
|
24
|
+
return router
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// setup the router with our handlers
|
|
28
|
+
private func setupHealthRoutes(router: Router, path: String) {
|
|
29
|
+
router.get(path) {
|
|
30
|
+
request, response, next in
|
|
31
|
+
|
|
32
|
+
HealthHandler.handle(statsD: self.statsD) {
|
|
33
|
+
(status: HTTPStatusCode, data: JSON?) in
|
|
34
|
+
|
|
35
|
+
self.sendResponse(response: response, status: status, data: data)
|
|
36
|
+
}
|
|
37
|
+
// execute next middleware in sequence
|
|
38
|
+
next()
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
private func sendResponse(response: RouterResponse, status: HTTPStatusCode, data: JSON?) {
|
|
43
|
+
response.status(status)
|
|
44
|
+
|
|
45
|
+
if data != nil {
|
|
46
|
+
do {
|
|
47
|
+
try response.send(json: data!).end()
|
|
48
|
+
} catch {
|
|
49
|
+
Log.error("Error sending response")
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"environment": "dev",
|
|
3
|
+
"api_key": "abc123456",
|
|
4
|
+
"database": {
|
|
5
|
+
"user": "root",
|
|
6
|
+
"password": "my-secret-pw",
|
|
7
|
+
"dbname": "StockService",
|
|
8
|
+
"host": "127.0.0.1",
|
|
9
|
+
"port": 3406
|
|
10
|
+
},
|
|
11
|
+
"statsd": {
|
|
12
|
+
"host" : "127.0.0.1",
|
|
13
|
+
"port" : 8125
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
import Kitura
|
|
4
|
+
import KituraSys
|
|
5
|
+
import KituraNet
|
|
6
|
+
import HeliumLogger
|
|
7
|
+
import LoggerAPI
|
|
8
|
+
import SwiftyJSON
|
|
9
|
+
|
|
10
|
+
import StatsD
|
|
11
|
+
import <%= application_name %>
|
|
12
|
+
|
|
13
|
+
var config: JSON? = nil
|
|
14
|
+
var statsD: StatsD? = nil
|
|
15
|
+
var router: Router? = nil
|
|
16
|
+
|
|
17
|
+
private func setupLogger() {
|
|
18
|
+
Log.logger = HeliumLogger()
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Load the config from the json file
|
|
22
|
+
private func loadConfig() -> JSON? {
|
|
23
|
+
if Process.arguments.count < 2 {
|
|
24
|
+
Log.error("Please specify config file")
|
|
25
|
+
|
|
26
|
+
return nil
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if let jsonData = NSData(contentsOfFile: Process.arguments[1])
|
|
30
|
+
{
|
|
31
|
+
let config = JSON(data: jsonData)
|
|
32
|
+
Log.info("Loaded config: \(config)")
|
|
33
|
+
|
|
34
|
+
return config
|
|
35
|
+
} else {
|
|
36
|
+
Log.error("Unable to load config")
|
|
37
|
+
|
|
38
|
+
return nil
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
setupLogger()
|
|
43
|
+
config = loadConfig()
|
|
44
|
+
statsD = Metrics().setupStatsD()
|
|
45
|
+
router = Routing(statsD: statsD!, config: config!).setupRouter()
|
|
46
|
+
|
|
47
|
+
Log.info("Starting Server on port 8090:")
|
|
48
|
+
statsD!.increment(bucket: "\(Buckets.Application.rawValue).\(Buckets.Started.rawValue)")
|
|
49
|
+
|
|
50
|
+
let server = HTTPServer.listen(port: 8090, delegate: router!)
|
|
51
|
+
Server.run()
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
ifeq "$(PLATFORM)" ""
|
|
2
|
+
PLATFORM := $(shell uname)
|
|
3
|
+
endif
|
|
4
|
+
|
|
5
|
+
ifeq "$(PLATFORM)" "Darwin"
|
|
6
|
+
BUILDCOMMAND := "swift build -Xcc -fblocks -Xswiftc -I/usr/local/include -Xlinker -L/usr/local/lib"
|
|
7
|
+
else
|
|
8
|
+
BUILDCOMMAND := "swift build -Xcc -fblocks -Xlinker -rpath -Xlinker .build/debug"
|
|
9
|
+
endif
|
|
10
|
+
|
|
11
|
+
fetch:
|
|
12
|
+
swift build --fetch
|
|
13
|
+
find Packages/ -type d -name Tests | xargs rm -rf
|
|
14
|
+
clean:
|
|
15
|
+
@echo --- Invoking swift build --clean
|
|
16
|
+
swift build --clean
|
|
17
|
+
build: clean fetch
|
|
18
|
+
@echo --- Building package
|
|
19
|
+
"$(BUILDCOMMAND)"
|
|
20
|
+
test: build
|
|
21
|
+
@echo --- Running tests
|
|
22
|
+
swift test
|
|
23
|
+
run: build
|
|
24
|
+
@echo --- Starting server
|
|
25
|
+
.build/debug/StockServiceApp ./Sources/<%= application_name %>App/config.json
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import PackageDescription
|
|
2
|
+
|
|
3
|
+
let package = Package(
|
|
4
|
+
name: "<%= application_name %>",
|
|
5
|
+
targets: [
|
|
6
|
+
Target(
|
|
7
|
+
name: "<%= application_name %>App",
|
|
8
|
+
dependencies: [.Target(name: "<%= application_name %>")]),
|
|
9
|
+
Target(
|
|
10
|
+
name: "<%= application_name %>")
|
|
11
|
+
],
|
|
12
|
+
dependencies: [
|
|
13
|
+
.Package(url: "https://github.com/IBM-Swift/Kitura.git", majorVersion: 0, minor: 16),
|
|
14
|
+
.Package(url: "https://github.com/IBM-Swift/HeliumLogger", majorVersion: 0, minor: 9),
|
|
15
|
+
.Package(url: "https://github.com/notonthehighstreet/swift-statsd", majorVersion: 0, minor: 3)
|
|
16
|
+
])
|
|
17
|
+
|
|
18
|
+
/*
|
|
19
|
+
.Package(url: "https://github.com/notonthehighstreet/swift-mysql", majorVersion: 0, minor: 11),
|
|
20
|
+
.Package(url: "https://github.com/notonthehighstreet/swift-statsd", majorVersion: 0, minor: 3)
|
|
21
|
+
*/
|
data/lib/generators/swift/scaffold/src/Tests/<%= application_name %>/HealthHandlerTests.swift.erb
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import XCTest
|
|
3
|
+
import SwiftyJSON
|
|
4
|
+
import KituraNet
|
|
5
|
+
|
|
6
|
+
@testable import <%= application_name %>
|
|
7
|
+
@testable import StatsD
|
|
8
|
+
|
|
9
|
+
public class HealthHandlerTests: XCTestCase {
|
|
10
|
+
var mockStatsD: MockStatsD?
|
|
11
|
+
|
|
12
|
+
public override func setUp() {
|
|
13
|
+
mockStatsD = MockStatsD()
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public func testReturnsHTTPStatusOK() {
|
|
17
|
+
HealthHandler.handle(statsD: mockStatsD!) {
|
|
18
|
+
(status: HTTPStatusCode, data: JSON?) in
|
|
19
|
+
XCTAssertEqual(HTTPStatusCode.OK, status)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public func testReturnsValidResponse() {
|
|
24
|
+
HealthHandler.handle(statsD: mockStatsD!) {
|
|
25
|
+
(status: HTTPStatusCode, data: JSON?) in
|
|
26
|
+
XCTAssertEqual("OK", data!["status_message"])
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
extension HealthHandlerTests {
|
|
32
|
+
static var allTests: [(String, HealthHandlerTests -> () throws -> Void)] {
|
|
33
|
+
return [
|
|
34
|
+
("testReturnsHTTPStatusOK", testReturnsHTTPStatusOK),
|
|
35
|
+
("testReturnsValidResponse", testReturnsValidResponse)
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import XCTest
|
|
3
|
+
|
|
4
|
+
import SwiftyJSON
|
|
5
|
+
|
|
6
|
+
@testable import <%= application_name %>
|
|
7
|
+
|
|
8
|
+
public class HealthHandlerResponseTests: XCTestCase {
|
|
9
|
+
public func testSerializesObject() {
|
|
10
|
+
let h = HealthHandlerResponse(statusMessage: "MyMessage")
|
|
11
|
+
let json = h.serialize()
|
|
12
|
+
|
|
13
|
+
XCTAssertEqual("MyMessage", json["status_message"] as? String)
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
extension HealthHandlerResponseTests {
|
|
18
|
+
static var allTests: [(String, HealthHandlerResponseTests -> () throws -> Void)] {
|
|
19
|
+
return [
|
|
20
|
+
("testSerializesObject", testSerializesObject)
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'generators/swift/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "minke-generator-swift"
|
|
8
|
+
spec.version = Minke::Generators::Swift::VERSION
|
|
9
|
+
spec.authors = ["Nic Jackson"]
|
|
10
|
+
spec.email = ["jackson.nic@gmail.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{Swift Kitura framework generator for Minke}
|
|
13
|
+
spec.description = %q{Swift Kitura framework with MySQL generator for Minke}
|
|
14
|
+
spec.homepage = "https://github.com/nicholasjackson/minkie-generator-swift"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
|
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
18
|
+
spec.bindir = "exe"
|
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
20
|
+
spec.require_paths = ["lib"]
|
|
21
|
+
|
|
22
|
+
# required so minke knows to load the gem which then registers itself
|
|
23
|
+
spec.metadata = { 'entrypoint' => 'generators/swift' }
|
|
24
|
+
|
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
27
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
28
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: minke-generator-swift
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Nic Jackson
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2016-06-14 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.11'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.11'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.0'
|
|
55
|
+
description: Swift Kitura framework with MySQL generator for Minke
|
|
56
|
+
email:
|
|
57
|
+
- jackson.nic@gmail.com
|
|
58
|
+
executables: []
|
|
59
|
+
extensions: []
|
|
60
|
+
extra_rdoc_files: []
|
|
61
|
+
files:
|
|
62
|
+
- ".gitignore"
|
|
63
|
+
- ".rspec"
|
|
64
|
+
- ".ruby-gemset"
|
|
65
|
+
- ".ruby-version"
|
|
66
|
+
- ".travis.yml"
|
|
67
|
+
- CODE_OF_CONDUCT.md
|
|
68
|
+
- Gemfile
|
|
69
|
+
- LICENSE.txt
|
|
70
|
+
- README.md
|
|
71
|
+
- Rakefile
|
|
72
|
+
- bin/console
|
|
73
|
+
- bin/setup
|
|
74
|
+
- lib/generators/swift.rb
|
|
75
|
+
- lib/generators/swift/commands.rb
|
|
76
|
+
- lib/generators/swift/scaffold/.DS_Store
|
|
77
|
+
- lib/generators/swift/scaffold/.gitignore
|
|
78
|
+
- lib/generators/swift/scaffold/_build/.gitignore
|
|
79
|
+
- lib/generators/swift/scaffold/_build/.ruby-gemset.erb
|
|
80
|
+
- lib/generators/swift/scaffold/_build/.ruby-version
|
|
81
|
+
- lib/generators/swift/scaffold/_build/Gemfile
|
|
82
|
+
- lib/generators/swift/scaffold/_build/Rakefile
|
|
83
|
+
- lib/generators/swift/scaffold/_build/config.yml.erb
|
|
84
|
+
- lib/generators/swift/scaffold/_build/consul_keys.yml.erb
|
|
85
|
+
- lib/generators/swift/scaffold/_build/dockercompose/<%= application_name %>/docker-compose.yml.erb
|
|
86
|
+
- lib/generators/swift/scaffold/_build/dockercompose/<%= application_name %>/docker-no-server.yml.erb
|
|
87
|
+
- lib/generators/swift/scaffold/_build/dockerfile/.DS_Store
|
|
88
|
+
- lib/generators/swift/scaffold/_build/dockerfile/<%= application_name %>/.DS_Store
|
|
89
|
+
- lib/generators/swift/scaffold/_build/dockerfile/<%= application_name %>/Dockerfile.erb
|
|
90
|
+
- lib/generators/swift/scaffold/_build/dockerfile/<%= application_name %>/config.ctmpl.erb
|
|
91
|
+
- lib/generators/swift/scaffold/_build/dockerfile/<%= application_name %>/libCHttpParser.so
|
|
92
|
+
- lib/generators/swift/scaffold/_build/dockerfile/<%= application_name %>/s6-etc/.s6-svscan/crash
|
|
93
|
+
- lib/generators/swift/scaffold/_build/dockerfile/<%= application_name %>/s6-etc/.s6-svscan/finish
|
|
94
|
+
- lib/generators/swift/scaffold/_build/dockerfile/<%= application_name %>/s6-etc/app/finish
|
|
95
|
+
- lib/generators/swift/scaffold/_build/dockerfile/<%= application_name %>/s6-etc/app/run.erb
|
|
96
|
+
- lib/generators/swift/scaffold/_build/dockerfile/<%= application_name %>/s6-etc/consul-template/finish
|
|
97
|
+
- lib/generators/swift/scaffold/_build/dockerfile/<%= application_name %>/s6-etc/consul-template/run.erb
|
|
98
|
+
- lib/generators/swift/scaffold/_build/features/health.feature
|
|
99
|
+
- lib/generators/swift/scaffold/_build/features/steps/cucumer_rest_monkey_patch.rb
|
|
100
|
+
- lib/generators/swift/scaffold/_build/features/support/env.rb.erb
|
|
101
|
+
- lib/generators/swift/scaffold/_build/swagger_spec/swagger.yml.erb
|
|
102
|
+
- lib/generators/swift/scaffold/src/<%= application_name %>/Config.swift
|
|
103
|
+
- lib/generators/swift/scaffold/src/<%= application_name %>/handlers/HealthHandler.swift
|
|
104
|
+
- lib/generators/swift/scaffold/src/<%= application_name %>/models/.DS_Store
|
|
105
|
+
- lib/generators/swift/scaffold/src/<%= application_name %>/models/HealthHandlerResponse.swift
|
|
106
|
+
- lib/generators/swift/scaffold/src/<%= application_name %>/models/JSONDictionary.swift
|
|
107
|
+
- lib/generators/swift/scaffold/src/<%= application_name %>App/Metrics.swift
|
|
108
|
+
- lib/generators/swift/scaffold/src/<%= application_name %>App/Routing.swift.erb
|
|
109
|
+
- lib/generators/swift/scaffold/src/<%= application_name %>App/config.json
|
|
110
|
+
- lib/generators/swift/scaffold/src/<%= application_name %>App/main.swift.erb
|
|
111
|
+
- lib/generators/swift/scaffold/src/Makefile.erb
|
|
112
|
+
- lib/generators/swift/scaffold/src/Package.swift.erb
|
|
113
|
+
- lib/generators/swift/scaffold/src/Tests/<%= application_name %>/HealthHandlerTests.swift.erb
|
|
114
|
+
- lib/generators/swift/scaffold/src/Tests/<%= application_name %>/models/HealthHandlerResponseTests.swift.erb
|
|
115
|
+
- lib/generators/swift/scaffold/src/Tests/LinuxMain.swift.erb
|
|
116
|
+
- lib/generators/swift/version.rb
|
|
117
|
+
- minke-generator-swift.gemspec
|
|
118
|
+
homepage: https://github.com/nicholasjackson/minkie-generator-swift
|
|
119
|
+
licenses:
|
|
120
|
+
- MIT
|
|
121
|
+
metadata:
|
|
122
|
+
entrypoint: generators/swift
|
|
123
|
+
post_install_message:
|
|
124
|
+
rdoc_options: []
|
|
125
|
+
require_paths:
|
|
126
|
+
- lib
|
|
127
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - ">="
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: '0'
|
|
132
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
|
+
requirements:
|
|
134
|
+
- - ">="
|
|
135
|
+
- !ruby/object:Gem::Version
|
|
136
|
+
version: '0'
|
|
137
|
+
requirements: []
|
|
138
|
+
rubyforge_project:
|
|
139
|
+
rubygems_version: 2.6.4
|
|
140
|
+
signing_key:
|
|
141
|
+
specification_version: 4
|
|
142
|
+
summary: Swift Kitura framework generator for Minke
|
|
143
|
+
test_files: []
|