odania-static-pages 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.
Files changed (41) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -0
  3. data/.travis.yml +5 -0
  4. data/CODE_OF_CONDUCT.md +74 -0
  5. data/Gemfile +6 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +44 -0
  8. data/Rakefile +10 -0
  9. data/bin/console +14 -0
  10. data/bin/setup +8 -0
  11. data/cf-templates/s3-http.yml +50 -0
  12. data/cf-templates/s3-logging.yml +21 -0
  13. data/cf-templates/s3-state.yml +21 -0
  14. data/exe/odania-static-pages +5 -0
  15. data/lib/odania_static_pages/cli/deploy_cli.rb +17 -0
  16. data/lib/odania_static_pages/cli/generator_cli.rb +17 -0
  17. data/lib/odania_static_pages/cli.rb +30 -0
  18. data/lib/odania_static_pages/config/docker_compose.rb +24 -0
  19. data/lib/odania_static_pages/config/generator/jekyll.rb +126 -0
  20. data/lib/odania_static_pages/config/rsync.rb +24 -0
  21. data/lib/odania_static_pages/config/s3.rb +41 -0
  22. data/lib/odania_static_pages/config.rb +127 -0
  23. data/lib/odania_static_pages/deploy/docker_compose.rb +148 -0
  24. data/lib/odania_static_pages/deploy/rsync.rb +73 -0
  25. data/lib/odania_static_pages/deploy/s3.rb +165 -0
  26. data/lib/odania_static_pages/generator/jekyll.rb +112 -0
  27. data/lib/odania_static_pages/server/nginx.rb +7 -0
  28. data/lib/odania_static_pages/version.rb +3 -0
  29. data/lib/odania_static_pages.rb +28 -0
  30. data/odania-static-pages.gemspec +33 -0
  31. data/odania-static-pages.iml +15 -0
  32. data/templates/docker-compose/docker-compose.yml.erb +68 -0
  33. data/templates/jekyll/Gemfile.erb +44 -0
  34. data/templates/jekyll/example_config.yml +19 -0
  35. data/templates/nginx/default-live-vhost.conf +13 -0
  36. data/templates/nginx/default-vhost.conf +21 -0
  37. data/templates/nginx/index.html.erb +14 -0
  38. data/templates/nginx/nginx.conf +41 -0
  39. data/templates/nginx/vhost-redirects.conf.erb +14 -0
  40. data/templates/nginx/vhost.conf.erb +22 -0
  41. metadata +196 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c7daf33ae327e89440d7c6c34a5f9617b84eadc8
4
+ data.tar.gz: 79a77a816c345f184dd89b81da735a56dbdd233c
5
+ SHA512:
6
+ metadata.gz: 81d3320c164d9cada2fe2d532347252b8ff1059267391209226071c3f8985bca2da0c76a383c54f0943c9d65cc4b692418771a7c43bc5262002509d23b631f09
7
+ data.tar.gz: d2c5390105a055afb7757a2354f45c6d1a2de600831a7e7feac2d394313d03a53c4558c657859bfa48ef0a9a3428869c56f3780a54b57dbbe73d0fe13b48c8f9
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .idea
11
+ *.iml
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.3
5
+ before_install: gem install bundler -v 1.15.4
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at mike@odania-it.de. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}"}
4
+
5
+ # Specify your gem's dependencies in odania-static-pages.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Mike Petersen
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,44 @@
1
+ # Odania::Static::Pages
2
+
3
+ This is a helper for managing static pages for multiple domains.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'odania-static-pages'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install odania-static-pages
20
+
21
+ ## Usage
22
+
23
+ odania-static-pages new DIRECTORY <- Create a new project under the given directory
24
+ odania-static-pages deploy init -e live <- Initialize deploy state
25
+ odania-static-pages deploy publish -e live <- Publishes the project in the live environment
26
+ odania-static-pages generate init <- Initialize the generator
27
+
28
+ ## Development
29
+
30
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
31
+
32
+ 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).
33
+
34
+ ## Contributing
35
+
36
+ Bug reports and pull requests are welcome on GitHub at https://github.com/OdaniaIT/odania-static-pages. 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.
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
42
+ ## Code of Conduct
43
+
44
+ Everyone interacting in the Odania::Static::Pages project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/odania-static-pages/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'odania/static/pages'
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(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,50 @@
1
+ ---
2
+ AWSTemplateFormatVersion: '2010-09-09'
3
+
4
+ Description: Stack for preparing http serving bucket.
5
+ Parameters:
6
+ LoggingStackName:
7
+ Type: String
8
+ BucketNameGreen:
9
+ Type: String
10
+ BucketNameBlue:
11
+ Type: String
12
+
13
+ Resources:
14
+ HttpBucketGreen:
15
+ Type: AWS::S3::Bucket
16
+ Properties:
17
+ AccessControl: PublicRead
18
+ BucketName: !Sub "${BucketNameGreen}"
19
+ WebsiteConfiguration:
20
+ IndexDocument: index.html
21
+ ErrorDocument: 404.html
22
+ LoggingConfiguration:
23
+ DestinationBucketName: !ImportValue {"Fn::Sub": "${LoggingStackName}-LoggingBucketName"}
24
+ LogFilePrefix: logs
25
+ Tags:
26
+ - Key: Test1
27
+ Value: val-1
28
+ DeletionPolicy: Retain
29
+ HttpBucketBlue:
30
+ Type: AWS::S3::Bucket
31
+ Properties:
32
+ AccessControl: PublicRead
33
+ BucketName: !Sub "${BucketNameBlue}"
34
+ WebsiteConfiguration:
35
+ IndexDocument: index.html
36
+ ErrorDocument: 404.html
37
+ LoggingConfiguration:
38
+ DestinationBucketName: !ImportValue {"Fn::Sub": "${LoggingStackName}-LoggingBucketName"}
39
+ LogFilePrefix: logs
40
+ DeletionPolicy: Retain
41
+
42
+ Outputs:
43
+ HttpBucketGreen:
44
+ Value: !Ref HttpBucketGreen
45
+ Export:
46
+ Name: !Sub ${AWS::StackName}-HttpBucketNameGreen
47
+ HttpBucketBlue:
48
+ Value: !Ref HttpBucketBlue
49
+ Export:
50
+ Name: !Sub ${AWS::StackName}-HttpBucketNameBlue
@@ -0,0 +1,21 @@
1
+ ---
2
+ AWSTemplateFormatVersion: '2010-09-09'
3
+
4
+ Description: Stack for preparing log bucket.
5
+ Parameters:
6
+ BucketName:
7
+ Type: String
8
+
9
+ Resources:
10
+ LoggingBucket:
11
+ Type: AWS::S3::Bucket
12
+ Properties:
13
+ AccessControl: LogDeliveryWrite
14
+ BucketName: !Sub "${BucketName}"
15
+ DeletionPolicy: Retain
16
+
17
+ Outputs:
18
+ LoggingBucketName:
19
+ Value: !Ref LoggingBucket
20
+ Export:
21
+ Name: !Sub ${AWS::StackName}-LoggingBucketName
@@ -0,0 +1,21 @@
1
+ ---
2
+ AWSTemplateFormatVersion: '2010-09-09'
3
+
4
+ Description: Stack for preparing state bucket.
5
+ Parameters:
6
+ BucketName:
7
+ Type: String
8
+
9
+ Resources:
10
+ StateBucket:
11
+ Type: AWS::S3::Bucket
12
+ Properties:
13
+ AccessControl: BucketOwnerFullControl
14
+ BucketName: !Sub "${BucketName}"
15
+ DeletionPolicy: Retain
16
+
17
+ Outputs:
18
+ StateBucketName:
19
+ Value: !Ref StateBucket
20
+ Export:
21
+ Name: !Sub ${AWS::StackName}-StateBucketName
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/odania_static_pages'
4
+
5
+ OdaniaStaticPages::Cli.start(ARGV)
@@ -0,0 +1,17 @@
1
+ module OdaniaStaticPages
2
+ class DeployCli < Thor
3
+ desc 'init', 'Initialize'
4
+ def init
5
+ config = OdaniaStaticPages.config
6
+ deploy_module = "OdaniaStaticPages::Deploy::#{config.current_environment.deploy_type}".constantize.new
7
+ deploy_module.prepare
8
+ end
9
+
10
+ desc 'publish <color> <do_rebuild>', 'Publish website. Color is optional and can be used to force a publish of a specific color'
11
+ def publish(color=nil, do_rebuild=false)
12
+ config = OdaniaStaticPages.config
13
+ deploy_module = "OdaniaStaticPages::Deploy::#{config.current_environment.deploy_type}".constantize.new
14
+ deploy_module.publish(color, do_rebuild)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ module OdaniaStaticPages
2
+ class GeneratorCli < Thor
3
+ desc 'init', 'Initialize'
4
+ def init
5
+ config = OdaniaStaticPages.config
6
+ deploy_module = "OdaniaStaticPages::Generator::#{config.generator_type}".constantize.new
7
+ deploy_module.init
8
+ end
9
+
10
+ desc 'build', 'Build websites'
11
+ def build
12
+ config = OdaniaStaticPages.config
13
+ deploy_module = "OdaniaStaticPages::Generator::#{config.generator_type}".constantize.new
14
+ deploy_module.build options[:environment]
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,30 @@
1
+ require_relative 'cli/deploy_cli'
2
+ require_relative 'cli/generator_cli'
3
+
4
+ module OdaniaStaticPages
5
+ class Cli < Thor
6
+ class_option :environment, default: 'develop', aliases: '-e', desc: 'Environment'
7
+
8
+ def initialize(*args)
9
+ super
10
+
11
+ OdaniaStaticPages.config.environment = options[:environment]
12
+ end
13
+
14
+ desc 'new <path>', 'creates a new project'
15
+ def new(path='.')
16
+ path = File.absolute_path path
17
+ puts "Generating project under #{path}"
18
+
19
+ FileUtils.mkdir_p path unless File.exist? path
20
+ config = OdaniaStaticPages.config path
21
+ config.save!
22
+ end
23
+
24
+ desc 'deploy', 'Deploy subcommand'
25
+ subcommand 'deploy', OdaniaStaticPages::DeployCli
26
+
27
+ desc 'generate', 'Generate subcommand'
28
+ subcommand 'generate', OdaniaStaticPages::GeneratorCli
29
+ end
30
+ end
@@ -0,0 +1,24 @@
1
+ module OdaniaStaticPages
2
+ class Config
3
+ module Deploy
4
+ class DockerCompose
5
+ attr_reader :state_file, :compose_images, :expires, :varnish_secret
6
+
7
+ def initialize(state_file: 'docker_compose_state.yml', compose_images: [], expires: '-1', varnish_secret: nil)
8
+ @state_file = state_file
9
+ @compose_images = compose_images
10
+ @expires = expires
11
+ @varnish_secret = varnish_secret.nil? ? SecureRandom.hex : varnish_secret
12
+ end
13
+
14
+ def to_h
15
+ {
16
+ state_file: @state_file,
17
+ compose_images: @compose_images,
18
+ expires: @expires
19
+ }.stringify_keys!
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,126 @@
1
+ module OdaniaStaticPages
2
+ class Config
3
+ module Generator
4
+ class Jekyll
5
+ attr_reader :plugins, :encoding, :common_folder, :extra_options, :gem_extra
6
+
7
+ def initialize(project_dir, options)
8
+ @plugins = options['plugins'] || %w(jekyll-feed octopress-image-tag octopress-gist)
9
+ @encoding = options['encoding'] || 'utf-8'
10
+ @common_folder = options['common_folder'] || 'common'
11
+ @extra_options = options['extra_options'] || {}
12
+ @gem_extra = options['gem_extra'] || ''
13
+ @project_dir = project_dir
14
+ end
15
+
16
+ def to_h
17
+ {
18
+ plugins: @plugins,
19
+ encoding: @encoding,
20
+ common_folder: @common_folder,
21
+ extra_options: @extra_options,
22
+ gem_extra: @gem_extra
23
+ }.stringify_keys!
24
+ end
25
+
26
+ def self.from_hash(project_dir, data)
27
+ Jekyll.new project_dir, data
28
+ end
29
+
30
+ def prepare_config(cfg)
31
+ page_config = cfg.clone
32
+ page_config['plugins'] = @plugins
33
+ page_config['encoding'] = @encoding
34
+ @extra_options.merge page_config
35
+ end
36
+
37
+ def link(base_dir, page_path, page)
38
+ common_subfolders.each do |folder|
39
+ create_link_if_required page_path, folder
40
+ end
41
+
42
+ puts ' -> Linking plugins'
43
+ plugins_dir = File.join(page_path, '_plugins')
44
+ FileUtils.mkdir_p plugins_dir
45
+
46
+ Dir.glob(File.join(full_common_folder, '_plugins', '*')).each do |plugin_file|
47
+ puts " -> Linking plugin #{File.basename(plugin_file)}"
48
+ FileUtils.ln_s plugin_file, plugins_dir, force: true
49
+ end
50
+
51
+ puts ' -> Linking Gemfile*'
52
+ FileUtils.ln_s File.join(full_common_folder, 'Gemfile'), File.join(page_path, 'Gemfile'), force: true
53
+ FileUtils.ln_s File.join(full_common_folder, 'Gemfile.lock'), File.join(page_path, 'Gemfile.lock'), force: true
54
+
55
+ puts ' -> Linking common pages'
56
+ FileUtils.mkdir_p template_pages_dir
57
+ link_common_pages template_pages_dir, page_path, template_pages_dir, page['lang']
58
+ end
59
+
60
+ def full_common_folder
61
+ File.join(@project_dir, @common_folder)
62
+ end
63
+
64
+ def template_pages_dir
65
+ File.join(full_common_folder, '_pages')
66
+ end
67
+
68
+ def pages_dir
69
+ File.join(@project_dir, 'pages')
70
+ end
71
+
72
+ def page_path(page_config)
73
+ uri = URI.parse(page_config['url'])
74
+ uri.host
75
+ end
76
+
77
+ def jekyll_config_file
78
+ File.join(@project_dir, '_jekyll_config.yml')
79
+ end
80
+
81
+ def jekyll_config
82
+ return YAML.load_file jekyll_config_file if File.exist? jekyll_config_file
83
+ {}
84
+ end
85
+
86
+ private
87
+
88
+ def create_link_if_required(page_path, name)
89
+ puts " -> Linking #{name}"
90
+ file = File.join(full_common_folder, name)
91
+ FileUtils.mkdir_p file unless File.exist? file
92
+ FileUtils.ln_s file, page_path, force: true
93
+ end
94
+
95
+ def common_subfolders
96
+ %w(_affiliate _i18n _layouts _themes)
97
+ end
98
+
99
+ def link_common_pages(src_folder, target_folder, pages_dir, lang)
100
+ Dir.glob(File.join(src_folder, '*')).each do |common_page_file|
101
+ if File.directory? common_page_file
102
+ link_common_pages common_page_file, target_folder, pages_dir, lang
103
+ else
104
+ short_file = common_page_file.gsub("#{pages_dir}/", '')
105
+ target_file = File.join target_folder, short_file
106
+
107
+ basename = File.basename(short_file)
108
+ if basename.start_with? 'lang-'
109
+ cleaned_name = basename.split('-')
110
+ cleaned_name.shift
111
+ file_lang = cleaned_name.shift
112
+ next unless lang.eql? file_lang
113
+
114
+ target_file = File.join target_folder, File.dirname(short_file), cleaned_name.join('-')
115
+ end
116
+
117
+ puts " -> Linking common page #{short_file} => #{target_file.gsub(target_folder, '')}"
118
+ FileUtils.mkdir_p File.dirname target_file
119
+ FileUtils.ln_s common_page_file, target_file, force: true
120
+ end
121
+ end
122
+ end
123
+ end
124
+ end
125
+ end
126
+ end
@@ -0,0 +1,24 @@
1
+ module OdaniaStaticPages
2
+ class Config
3
+ module Deploy
4
+ class Rsync
5
+ attr_reader :targets, :rsync_options, :state_file
6
+
7
+ def initialize(targets: {green: '/tmp/rsync-deploy-test/blue', blue: '/tmp/rsync-deploy-test/blue'},
8
+ rsync_options: '-a --delete', state_file: '_current_state.yml')
9
+ @targets = targets
10
+ @rsync_options = rsync_options
11
+ @state_file = state_file
12
+ end
13
+
14
+ def to_h
15
+ {
16
+ targets: @targets,
17
+ rsync_options: @rsync_options,
18
+ state_file: @state_file
19
+ }.stringify_keys!
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,41 @@
1
+ module OdaniaStaticPages
2
+ class Config
3
+ module Deploy
4
+ class S3
5
+ attr_reader :bucket_name_green, :bucket_name_blue, :logging_bucket, :state_bucket, :region, :profile
6
+
7
+ def initialize(bucket_name_green: 'odania-http-green', bucket_name_blue: 'odania-http-blue',
8
+ logging_bucket: 'odania-logging', region: 'eu-central-1', state_bucket: 'odania-state',
9
+ profile: nil, tags: {deployed_by: 'odania-static-pages'})
10
+ @bucket_name_green = bucket_name_green
11
+ @bucket_name_blue = bucket_name_blue
12
+ @logging_bucket = logging_bucket
13
+ @state_bucket = state_bucket
14
+ @region = region
15
+ @profile = profile
16
+ @tags = tags
17
+ end
18
+
19
+ def to_h
20
+ {
21
+ bucket_name_green: @bucket_name_green,
22
+ bucket_name_blue: @bucket_name_blue,
23
+ logging_bucket: @logging_bucket,
24
+ state_bucket: @state_bucket,
25
+ region: @region,
26
+ profile: @profile,
27
+ tags: @tags.stringify_keys!
28
+ }.stringify_keys!
29
+ end
30
+
31
+ def tags
32
+ result = []
33
+ @tags.each_pair do |key, val|
34
+ result << {key: key, value: val}
35
+ end
36
+ result
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end