fauxpaas-client 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.codeclimate.yml +41 -0
- data/.gitignore +64 -0
- data/.rubocop.yml +150 -0
- data/.rubocop_todo.yml +23 -0
- data/.simplecov +9 -0
- data/.travis.yml +16 -0
- data/Gemfile +8 -0
- data/LICENSE.md +27 -0
- data/Rakefile +22 -0
- data/bin/fauxpaas +7 -0
- data/config/settings.yml +1 -0
- data/config/settings/development.yml +0 -0
- data/config/settings/production.yml +0 -0
- data/config/settings/test.yml +1 -0
- data/fauxpaas.gemspec +33 -0
- data/lib/fauxpaas.rb +54 -0
- data/lib/fauxpaas/cli.rb +12 -0
- data/lib/fauxpaas/cli/main.rb +90 -0
- data/lib/fauxpaas/cli/syslog.rb +51 -0
- data/lib/fauxpaas/command.rb +116 -0
- data/lib/fauxpaas/invoker.rb +26 -0
- data/lib/fauxpaas/passthrough_runner.rb +23 -0
- data/lib/fauxpaas/version.rb +5 -0
- metadata +208 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 90ee7544799c89e5dfbad17f252128a1b27234c3
|
4
|
+
data.tar.gz: d77141d7e92c32906e30549fd55a795820b18ede
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0d84909e2cb77dae4169384e72ee9851ca5d513ff9ac9dadfdcebc3d15b5a0dacec361038d46daf33845d909fe21c936d668cfd370292df8fb6f6dc252978643
|
7
|
+
data.tar.gz: bf6bc9dd4916897d0ade7c98859776c56ddf7cf9109b731a837c37b328c09141f0643c8a084f5e82012206a7ecc7e5d01811334842ba2a3ca798af5ed8b03a3f
|
data/.codeclimate.yml
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
plugins:
|
2
|
+
brakeman:
|
3
|
+
enabled: false # not a rails app
|
4
|
+
bundler-audit:
|
5
|
+
enabled: false # gems don't have Gemfile.lock
|
6
|
+
rubocop:
|
7
|
+
enabled: true
|
8
|
+
duplication:
|
9
|
+
enabled: true
|
10
|
+
config:
|
11
|
+
languages:
|
12
|
+
- ruby:
|
13
|
+
- javascript:
|
14
|
+
fixme:
|
15
|
+
enabled: true
|
16
|
+
config:
|
17
|
+
strings:
|
18
|
+
- FIXME
|
19
|
+
- TODO
|
20
|
+
|
21
|
+
ratings:
|
22
|
+
paths:
|
23
|
+
- app/**/*
|
24
|
+
- lib/**/*
|
25
|
+
|
26
|
+
exclude_paths:
|
27
|
+
- spec/
|
28
|
+
- .bundle/
|
29
|
+
- app/assets/fonts/
|
30
|
+
- app/assets/images/
|
31
|
+
- app/assets/javascripts/vendor/
|
32
|
+
- app/assets/stylesheets/vendor/
|
33
|
+
- bin/rails
|
34
|
+
- bin/rake
|
35
|
+
- db/
|
36
|
+
- doc/
|
37
|
+
- public/
|
38
|
+
- tmp/
|
39
|
+
|
40
|
+
|
41
|
+
|
data/.gitignore
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# Compiled gems
|
2
|
+
/pkg/
|
3
|
+
|
4
|
+
# bundler
|
5
|
+
/.bundle
|
6
|
+
/.bundle/ruby
|
7
|
+
/vendor/
|
8
|
+
|
9
|
+
# rspec failure tracking
|
10
|
+
.rspec_status
|
11
|
+
|
12
|
+
# default SQLite database.
|
13
|
+
/db/*.sqlite3
|
14
|
+
/db/*.sqlite3-journal
|
15
|
+
|
16
|
+
# logfiles and tempfiles.
|
17
|
+
/log/*
|
18
|
+
!/log/.keep
|
19
|
+
/tmp/
|
20
|
+
|
21
|
+
# Intellij/Rubymine
|
22
|
+
/.idea/
|
23
|
+
|
24
|
+
# rspec config
|
25
|
+
/.rspec
|
26
|
+
|
27
|
+
# test coverage
|
28
|
+
/spec/reports/
|
29
|
+
/coverage
|
30
|
+
|
31
|
+
# Emacs backup files
|
32
|
+
*~
|
33
|
+
|
34
|
+
# Folder attributes file on Macs
|
35
|
+
.DS_Store
|
36
|
+
|
37
|
+
# Generated docs
|
38
|
+
/_yardoc/
|
39
|
+
/.yardoc/
|
40
|
+
/doc/
|
41
|
+
|
42
|
+
# vim
|
43
|
+
tags
|
44
|
+
*~
|
45
|
+
*.swp
|
46
|
+
*.swo
|
47
|
+
|
48
|
+
# testbed
|
49
|
+
/sandbox
|
50
|
+
|
51
|
+
# We're a gem
|
52
|
+
Gemfile.lock
|
53
|
+
|
54
|
+
# These dirs are for users
|
55
|
+
/data
|
56
|
+
/data/instances/*
|
57
|
+
/data/stages/*
|
58
|
+
/releases/*
|
59
|
+
|
60
|
+
# Ignore local configuration files
|
61
|
+
config/settings.local.yml
|
62
|
+
config/settings/test.local.yml
|
63
|
+
config/settings/production.local.yml
|
64
|
+
config/settings/development.local.yml
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
2
|
+
|
3
|
+
AllCops:
|
4
|
+
DisplayCopNames: true
|
5
|
+
TargetRubyVersion: 2.3
|
6
|
+
Exclude:
|
7
|
+
- '*.gemspec'
|
8
|
+
|
9
|
+
Naming/FileName:
|
10
|
+
ExpectMatchingDefinition: true
|
11
|
+
Exclude:
|
12
|
+
- 'spec/**/*'
|
13
|
+
- 'lib/*/version.rb'
|
14
|
+
- 'bin/console'
|
15
|
+
- 'deploy/**/*'
|
16
|
+
- 'lib/*/components/*'
|
17
|
+
- 'lib/*/components.rb'
|
18
|
+
|
19
|
+
Style/Documentation:
|
20
|
+
Exclude:
|
21
|
+
- 'spec/**/*'
|
22
|
+
- 'lib/*/components/*'
|
23
|
+
- 'lib/*/components.rb'
|
24
|
+
|
25
|
+
# We disable this cop because we want to use Pathname#/
|
26
|
+
# and this cop is not configurable at all.
|
27
|
+
Layout/SpaceAroundOperators:
|
28
|
+
Enabled: false
|
29
|
+
|
30
|
+
Security/YAMLLoad:
|
31
|
+
Exclude:
|
32
|
+
- 'lib/fauxpaas/file_instance_repo.rb'
|
33
|
+
- 'spec/**/*'
|
34
|
+
|
35
|
+
Style/Alias:
|
36
|
+
EnforcedStyle: prefer_alias_method
|
37
|
+
|
38
|
+
Metrics/LineLength:
|
39
|
+
Max: 100
|
40
|
+
AllowHeredoc: true
|
41
|
+
AllowURI: true
|
42
|
+
URISchemes:
|
43
|
+
- http
|
44
|
+
- https
|
45
|
+
|
46
|
+
Metrics/BlockLength:
|
47
|
+
Exclude:
|
48
|
+
- 'spec/**/*_spec.rb'
|
49
|
+
|
50
|
+
Layout/ElseAlignment:
|
51
|
+
Enabled: false
|
52
|
+
|
53
|
+
Layout/FirstParameterIndentation:
|
54
|
+
EnforcedStyle: consistent
|
55
|
+
|
56
|
+
Layout/AlignParameters:
|
57
|
+
EnforcedStyle: with_fixed_indentation
|
58
|
+
|
59
|
+
Layout/CaseIndentation:
|
60
|
+
EnforcedStyle: end
|
61
|
+
|
62
|
+
Layout/ClosingParenthesisIndentation:
|
63
|
+
Enabled: false
|
64
|
+
|
65
|
+
Style/ClassAndModuleChildren:
|
66
|
+
EnforcedStyle: nested
|
67
|
+
|
68
|
+
Style/CommentAnnotation:
|
69
|
+
Enabled: false
|
70
|
+
|
71
|
+
# Does not work for multi-line copyright notices.
|
72
|
+
Style/Copyright:
|
73
|
+
Enabled: false
|
74
|
+
|
75
|
+
Layout/EmptyLineBetweenDefs:
|
76
|
+
AllowAdjacentOneLineDefs: true
|
77
|
+
|
78
|
+
# These two cops do not differentiate between the scope the file is describing
|
79
|
+
# and any namespaces it is nested under. If this is not acceptable,
|
80
|
+
# no_empty_lines produces the least offensive results.
|
81
|
+
Layout/EmptyLinesAroundClassBody:
|
82
|
+
Enabled: false
|
83
|
+
Layout/EmptyLinesAroundModuleBody:
|
84
|
+
Enabled: false
|
85
|
+
|
86
|
+
# Produces poor results.
|
87
|
+
Style/GuardClause:
|
88
|
+
Enabled: false
|
89
|
+
|
90
|
+
Style/IfUnlessModifier:
|
91
|
+
Enabled: false
|
92
|
+
|
93
|
+
Layout/IndentArray:
|
94
|
+
EnforcedStyle: consistent
|
95
|
+
|
96
|
+
Layout/IndentHash:
|
97
|
+
EnforcedStyle: consistent
|
98
|
+
|
99
|
+
Layout/AlignHash:
|
100
|
+
EnforcedColonStyle: table
|
101
|
+
EnforcedHashRocketStyle: table
|
102
|
+
EnforcedLastArgumentHashStyle: always_ignore
|
103
|
+
|
104
|
+
Layout/MultilineMethodCallIndentation:
|
105
|
+
EnforcedStyle: indented
|
106
|
+
|
107
|
+
Layout/MultilineOperationIndentation:
|
108
|
+
EnforcedStyle: indented
|
109
|
+
|
110
|
+
# Produces poor results.
|
111
|
+
Style/Next:
|
112
|
+
Enabled: false
|
113
|
+
|
114
|
+
Style/RedundantReturn:
|
115
|
+
AllowMultipleReturnValues: true
|
116
|
+
|
117
|
+
Style/RegexpLiteral:
|
118
|
+
AllowInnerSlashes: true
|
119
|
+
|
120
|
+
Style/Semicolon:
|
121
|
+
AllowAsExpressionSeparator: true
|
122
|
+
|
123
|
+
Style/StringLiterals:
|
124
|
+
EnforcedStyle: double_quotes
|
125
|
+
|
126
|
+
Style/StringLiteralsInInterpolation:
|
127
|
+
EnforcedStyle: double_quotes
|
128
|
+
|
129
|
+
Layout/SpaceInsideBlockBraces:
|
130
|
+
SpaceBeforeBlockParameters: false
|
131
|
+
|
132
|
+
Style/SymbolArray:
|
133
|
+
EnforcedStyle: brackets
|
134
|
+
|
135
|
+
Lint/BlockAlignment:
|
136
|
+
EnforcedStyleAlignWith: start_of_block
|
137
|
+
#EnforcedStyleAlignWith: start_of_line
|
138
|
+
|
139
|
+
Lint/EndAlignment:
|
140
|
+
EnforcedStyleAlignWith: start_of_line
|
141
|
+
|
142
|
+
Lint/DefEndAlignment:
|
143
|
+
EnforcedStyleAlignWith: def
|
144
|
+
|
145
|
+
Performance/RedundantMerge:
|
146
|
+
Enabled: false
|
147
|
+
|
148
|
+
Style/WordArray:
|
149
|
+
EnforcedStyle: brackets
|
150
|
+
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2017-10-27 15:26:00 -0500 using RuboCop version 0.51.0.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 1
|
10
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
11
|
+
Metrics/BlockLength:
|
12
|
+
Max: 30
|
13
|
+
|
14
|
+
# Offense count: 14
|
15
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
16
|
+
# URISchemes: http, https
|
17
|
+
Metrics/LineLength:
|
18
|
+
Max: 133
|
19
|
+
|
20
|
+
# Offense count: 1
|
21
|
+
# Configuration parameters: CountComments.
|
22
|
+
Metrics/ModuleLength:
|
23
|
+
Max: 185
|
data/.simplecov
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
Copyright (c) 2015, The Regents of the University of Michigan.
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
5
|
+
modification, are permitted provided that the following conditions are
|
6
|
+
met:
|
7
|
+
|
8
|
+
* Redistributions of source code must retain the above copyright
|
9
|
+
notice, this list of conditions and the following disclaimer.
|
10
|
+
* Redistributions in binary form must reproduce the above copyright
|
11
|
+
notice, this list of conditions and the following disclaimer in the
|
12
|
+
documentation and/or other materials provided with the distribution.
|
13
|
+
* Neither the name of the The University of Michigan nor the
|
14
|
+
names of its contributors may be used to endorse or promote products
|
15
|
+
derived from this software without specific prior written permission.
|
16
|
+
|
17
|
+
THIS SOFTWARE IS PROVIDED BY THE REGENTS OF THE UNIVERSITY OF MICHIGAN AND
|
18
|
+
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
|
19
|
+
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
20
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OF THE
|
21
|
+
UNIVERSITY OF MICHIGAN BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
22
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
23
|
+
TO,PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
24
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
25
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
26
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
27
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/Rakefile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rspec/core/rake_task"
|
5
|
+
|
6
|
+
desc "Run unit tests"
|
7
|
+
RSpec::Core::RakeTask.new("spec:unit") do |task|
|
8
|
+
task.pattern = "./spec/**/*_spec.rb"
|
9
|
+
task.rspec_opts = "--tag ~integration"
|
10
|
+
end
|
11
|
+
|
12
|
+
desc "Run integration tests"
|
13
|
+
task "spec:integration" do
|
14
|
+
puts "This seems to break rspec"
|
15
|
+
puts "Specify the filename explicitly for now:"
|
16
|
+
puts "bundle exec rspec spec/integration_spec.rb"
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "Run unit tests [default]"
|
20
|
+
task test: "spec:unit"
|
21
|
+
|
22
|
+
task default: "spec:unit"
|
data/bin/fauxpaas
ADDED
data/config/settings.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
server: deployhost
|
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
server: localhost
|
data/fauxpaas.gemspec
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path("../lib", __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require "fauxpaas/version"
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = "fauxpaas-client"
|
9
|
+
spec.version = Fauxpaas::VERSION
|
10
|
+
spec.authors = ["Bryan Hockey"]
|
11
|
+
spec.email = ["bhock@umich.edu"]
|
12
|
+
|
13
|
+
spec.summary = "fauxpaas-client"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
16
|
+
f.match(%r{^(test|spec|features)/})
|
17
|
+
end
|
18
|
+
spec.bindir = "bin"
|
19
|
+
spec.executables = spec.files.grep(%r{^bin/}) {|f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_runtime_dependency "canister"
|
23
|
+
spec.add_runtime_dependency "ettin", "~> 1.1.0"
|
24
|
+
spec.add_runtime_dependency "thor"
|
25
|
+
spec.add_runtime_dependency "thor-hollaback"
|
26
|
+
|
27
|
+
spec.add_development_dependency "bundler", "~> 1.15"
|
28
|
+
spec.add_development_dependency "pry"
|
29
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
30
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
31
|
+
spec.add_development_dependency "rubocop"
|
32
|
+
spec.add_development_dependency "simplecov"
|
33
|
+
end
|
data/lib/fauxpaas.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "fauxpaas/version"
|
4
|
+
require "fauxpaas/invoker"
|
5
|
+
require "fauxpaas/passthrough_runner"
|
6
|
+
|
7
|
+
require "pathname"
|
8
|
+
require "canister"
|
9
|
+
require "ettin"
|
10
|
+
|
11
|
+
# Fake Platform As A Service
|
12
|
+
module Fauxpaas
|
13
|
+
class << self
|
14
|
+
attr_reader :config, :env, :settings
|
15
|
+
attr_writer :config, :env
|
16
|
+
|
17
|
+
def method_missing(method, *args, &block)
|
18
|
+
if config.respond_to?(method)
|
19
|
+
config.send(method, *args, &block)
|
20
|
+
else
|
21
|
+
super(method, *args, &block)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def root
|
26
|
+
@root ||= Pathname.new(__FILE__).dirname.parent
|
27
|
+
end
|
28
|
+
|
29
|
+
def env
|
30
|
+
@env ||= ENV["FAUXPAAS_ENV"] || ENV["RAILS_ENV"] || "development"
|
31
|
+
end
|
32
|
+
|
33
|
+
def reset!
|
34
|
+
@settings = nil
|
35
|
+
@loaded = false
|
36
|
+
@config = nil
|
37
|
+
end
|
38
|
+
|
39
|
+
def load_settings!(hash = {})
|
40
|
+
@settings = Ettin.for(Ettin.settings_files(root/"config", env))
|
41
|
+
@settings.merge!(hash)
|
42
|
+
end
|
43
|
+
|
44
|
+
def initialize!
|
45
|
+
load_settings! unless @settings
|
46
|
+
@config ||= Canister.new.tap do |container|
|
47
|
+
container.register(:system_runner) { PassthroughRunner.new(STDOUT) }
|
48
|
+
container.register(:server) { settings.server }
|
49
|
+
container.register(:invoker) { Fauxpaas::Invoker.new }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
data/lib/fauxpaas/cli.rb
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "thor"
|
4
|
+
require "fauxpaas"
|
5
|
+
require "fauxpaas/cli/syslog"
|
6
|
+
require "fauxpaas/command"
|
7
|
+
|
8
|
+
module Fauxpaas
|
9
|
+
module CLI
|
10
|
+
|
11
|
+
# Main commands of the cli
|
12
|
+
class Main < Thor
|
13
|
+
|
14
|
+
def initialize(*args)
|
15
|
+
super(*args)
|
16
|
+
@opts = setup
|
17
|
+
@invoker = Fauxpaas.invoker
|
18
|
+
end
|
19
|
+
|
20
|
+
class_option :verbose,
|
21
|
+
aliases: "-v",
|
22
|
+
type: :boolean,
|
23
|
+
desc: "Show output from system commands",
|
24
|
+
default: false,
|
25
|
+
required: false
|
26
|
+
|
27
|
+
desc "deploy <instance> [<reference>]",
|
28
|
+
"Deploys the instance using the source described by the default branch. " \
|
29
|
+
"If a reference is given, that will be deployed instead. " \
|
30
|
+
"The reference be a branch, tag, or SHA."
|
31
|
+
def deploy(instance_name, reference = nil)
|
32
|
+
invoker.add_command(DeployCommand.new(opts.merge(reference: reference)))
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "default_branch <instance> [<new_branch>]",
|
36
|
+
"Display or set the default branch for the instance"
|
37
|
+
def default_branch(instance_name, new_branch = nil)
|
38
|
+
command = if new_branch
|
39
|
+
SetDefaultBranchCommand.new(opts.merge({new_branch: new_branch}))
|
40
|
+
else
|
41
|
+
ReadDefaultBranchCommand.new(opts)
|
42
|
+
end
|
43
|
+
invoker.add_command(command)
|
44
|
+
end
|
45
|
+
|
46
|
+
desc "rollback <instance> [<cache>]",
|
47
|
+
"Initiate a rollback to the specified cache if specified, or the most " \
|
48
|
+
"recent one otherwise. Use with care."
|
49
|
+
def rollback(instance_name, cache = "")
|
50
|
+
invoker.add_command(RollbackCommand.new(opts.merge({cache: cache})))
|
51
|
+
end
|
52
|
+
|
53
|
+
desc "caches <instance>",
|
54
|
+
"List cached releases for the instance"
|
55
|
+
def caches(instance_name)
|
56
|
+
invoker.add_command(CachesCommand.new(opts))
|
57
|
+
end
|
58
|
+
|
59
|
+
desc "releases <instance>",
|
60
|
+
"List release history for the instance"
|
61
|
+
def releases(instance_name)
|
62
|
+
invoker.add_command(ReleasesCommand.new(opts))
|
63
|
+
end
|
64
|
+
|
65
|
+
desc "restart <instance>",
|
66
|
+
"Restart the application for the instance"
|
67
|
+
def restart(instance_name)
|
68
|
+
invoker.add_command(RestartCommand.new(opts))
|
69
|
+
end
|
70
|
+
|
71
|
+
desc "syslog SUBCOMMAND <instance> args...",
|
72
|
+
"Interact with system log contents for the instance"
|
73
|
+
subcommand "syslog", CLI::Syslog
|
74
|
+
|
75
|
+
private
|
76
|
+
|
77
|
+
attr_reader :opts, :invoker
|
78
|
+
|
79
|
+
def setup
|
80
|
+
Fauxpaas.load_settings!(options.symbolize_keys)
|
81
|
+
Fauxpaas.initialize!
|
82
|
+
options.merge({
|
83
|
+
server: Fauxpaas.server,
|
84
|
+
instance_name: @args.first
|
85
|
+
})
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "thor"
|
4
|
+
require "fauxpaas"
|
5
|
+
require "fauxpaas/kernel_system"
|
6
|
+
require "fauxpaas/command"
|
7
|
+
|
8
|
+
module Fauxpaas
|
9
|
+
module CLI
|
10
|
+
|
11
|
+
# Main commands of the cli
|
12
|
+
class Syslog < Thor
|
13
|
+
def initialize(*args)
|
14
|
+
super(*args)
|
15
|
+
@opts = setup
|
16
|
+
@invoker = Fauxpaas.invoker
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "view <instance>",
|
20
|
+
"View the system logs for the instance"
|
21
|
+
def view(instance_name)
|
22
|
+
invoker.add_command(SyslogViewCommand.new(opts))
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "grep <instance> pattern",
|
26
|
+
"View the system logs for the instance"
|
27
|
+
def grep(instance_name, pattern = ".")
|
28
|
+
invoker.add_command(SyslogGrepCommand.new(opts.merge({pattern: pattern})))
|
29
|
+
end
|
30
|
+
|
31
|
+
desc "follow <instance>",
|
32
|
+
"Follow the system logs for the instance"
|
33
|
+
def follow(instance_name)
|
34
|
+
invoker.add_command(SyslogFollowCommand.new(opts))
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
attr_reader :opts, :invoker
|
40
|
+
|
41
|
+
def setup
|
42
|
+
Fauxpaas.load_settings!(options.symbolize_keys)
|
43
|
+
Fauxpaas.initialize!
|
44
|
+
Fauxpaas.config.register(:system_runner) { KernelSystem.new }
|
45
|
+
options.merge(instance_name: @args.first)
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Fauxpaas
|
4
|
+
|
5
|
+
# Represetns a command within Fauxpaas
|
6
|
+
class Command
|
7
|
+
|
8
|
+
def initialize(options)
|
9
|
+
@options = options
|
10
|
+
end
|
11
|
+
|
12
|
+
def bin
|
13
|
+
"help"
|
14
|
+
end
|
15
|
+
|
16
|
+
def execute
|
17
|
+
Fauxpaas.system_runner.run(ssh_command)
|
18
|
+
end
|
19
|
+
|
20
|
+
def default_keys
|
21
|
+
[:instance_name, :server]
|
22
|
+
end
|
23
|
+
|
24
|
+
def extra_keys
|
25
|
+
[]
|
26
|
+
end
|
27
|
+
|
28
|
+
def keys
|
29
|
+
default_keys | extra_keys
|
30
|
+
end
|
31
|
+
|
32
|
+
def missing
|
33
|
+
keys.select {|k| options[k].nil? }
|
34
|
+
end
|
35
|
+
|
36
|
+
def valid?
|
37
|
+
missing.empty?
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
attr_reader :options
|
43
|
+
|
44
|
+
def ssh_command
|
45
|
+
"ssh #{options[:server]} #{bin} #{options[:instance_name]} #{extra_keys.map {|k| options[k] }.join(" ")}"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
class ReadDefaultBranchCommand < Command
|
50
|
+
def bin
|
51
|
+
"default_branch"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
class CachesCommand < Command
|
55
|
+
def bin
|
56
|
+
"caches"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
class ReleasesCommand < Command
|
60
|
+
def bin
|
61
|
+
"releases"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
class RestartCommand < Command
|
65
|
+
def bin
|
66
|
+
"restart"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
class SyslogViewCommand < Command
|
70
|
+
def bin
|
71
|
+
"syslog view"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
class SyslogFollowCommand < Command
|
75
|
+
def bin
|
76
|
+
"syslog follow"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
class DeployCommand < Command
|
80
|
+
def bin
|
81
|
+
"deploy"
|
82
|
+
end
|
83
|
+
|
84
|
+
def extra_keys
|
85
|
+
[:reference]
|
86
|
+
end
|
87
|
+
end
|
88
|
+
class SetDefaultBranchCommand < Command
|
89
|
+
def bin
|
90
|
+
"default_branch"
|
91
|
+
end
|
92
|
+
|
93
|
+
def extra_keys
|
94
|
+
[:new_branch]
|
95
|
+
end
|
96
|
+
end
|
97
|
+
class RollbackCommand < Command
|
98
|
+
def bin
|
99
|
+
"rollback"
|
100
|
+
end
|
101
|
+
|
102
|
+
def extra_keys
|
103
|
+
[:cache]
|
104
|
+
end
|
105
|
+
end
|
106
|
+
class SyslogGrepCommand < Command
|
107
|
+
def bin
|
108
|
+
"syslog grep"
|
109
|
+
end
|
110
|
+
|
111
|
+
def extra_keys
|
112
|
+
[:pattern]
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Fauxpaas
|
4
|
+
class Invoker
|
5
|
+
|
6
|
+
# TODO: test this
|
7
|
+
def add_command(command)
|
8
|
+
run(command)
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def validate!(command)
|
14
|
+
unless command.valid?
|
15
|
+
raise KeyError, "Missing keys: #{command.missing.join(", ")}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# TODO: test this
|
20
|
+
def run(command)
|
21
|
+
validate!(command)
|
22
|
+
command.execute
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "open3"
|
4
|
+
|
5
|
+
module Fauxpaas
|
6
|
+
class PassthroughRunner
|
7
|
+
attr_reader :stream
|
8
|
+
|
9
|
+
def initialize(stream)
|
10
|
+
@stream = stream
|
11
|
+
end
|
12
|
+
|
13
|
+
def run(command)
|
14
|
+
Open3.popen2e(command) do |_stdin, output, thread|
|
15
|
+
while line = output.gets
|
16
|
+
stream.puts line
|
17
|
+
end
|
18
|
+
exit_status = thread.value
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,208 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fauxpaas-client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bryan Hockey
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-04-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: canister
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: ettin
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.1.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.1.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: thor
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: thor-hollaback
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.15'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.15'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '10.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '10.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '3.0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '3.0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rubocop
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: simplecov
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
description:
|
154
|
+
email:
|
155
|
+
- bhock@umich.edu
|
156
|
+
executables:
|
157
|
+
- fauxpaas
|
158
|
+
extensions: []
|
159
|
+
extra_rdoc_files: []
|
160
|
+
files:
|
161
|
+
- ".codeclimate.yml"
|
162
|
+
- ".gitignore"
|
163
|
+
- ".rspec"
|
164
|
+
- ".rubocop.yml"
|
165
|
+
- ".rubocop_todo.yml"
|
166
|
+
- ".simplecov"
|
167
|
+
- ".travis.yml"
|
168
|
+
- Gemfile
|
169
|
+
- LICENSE.md
|
170
|
+
- Rakefile
|
171
|
+
- bin/fauxpaas
|
172
|
+
- config/settings.yml
|
173
|
+
- config/settings/development.yml
|
174
|
+
- config/settings/production.yml
|
175
|
+
- config/settings/test.yml
|
176
|
+
- fauxpaas.gemspec
|
177
|
+
- lib/fauxpaas.rb
|
178
|
+
- lib/fauxpaas/cli.rb
|
179
|
+
- lib/fauxpaas/cli/main.rb
|
180
|
+
- lib/fauxpaas/cli/syslog.rb
|
181
|
+
- lib/fauxpaas/command.rb
|
182
|
+
- lib/fauxpaas/invoker.rb
|
183
|
+
- lib/fauxpaas/passthrough_runner.rb
|
184
|
+
- lib/fauxpaas/version.rb
|
185
|
+
homepage:
|
186
|
+
licenses: []
|
187
|
+
metadata: {}
|
188
|
+
post_install_message:
|
189
|
+
rdoc_options: []
|
190
|
+
require_paths:
|
191
|
+
- lib
|
192
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
193
|
+
requirements:
|
194
|
+
- - ">="
|
195
|
+
- !ruby/object:Gem::Version
|
196
|
+
version: '0'
|
197
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
requirements: []
|
203
|
+
rubyforge_project:
|
204
|
+
rubygems_version: 2.6.13
|
205
|
+
signing_key:
|
206
|
+
specification_version: 4
|
207
|
+
summary: fauxpaas-client
|
208
|
+
test_files: []
|