checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
---
2
2
SHA256:
3
- metadata.gz: 4565e0bbd3195b9c1e5848b764328c26d73eb39ba48232327efcde01299c3ac2
4
- data.tar.gz: 701f070d2538ab410ab0560e89b8c4171b0b4b893348fcfbd25d5650b6208fb0
3
+ metadata.gz: 2aee1d0a664e3a03c0ef1139816708264a40d39a324b7698cec10e5ebe303972
4
+ data.tar.gz: af415232480d26cce9582d68f9e8384dcf0e8027efb7371ad1f9341a5fbd065c
5
5
SHA512:
6
- metadata.gz: 75eaf53a4209cba8626f1f38a3729db5a3954ce4877a225dfa2c162d6763883d14be5d17a9e695561aa94feb82e3b03f1a243b3526b839d7d59ba537094f04d4
7
- data.tar.gz: 91440fc0feac380f9a8d606a145adcfb1b58a467ad217680d548f8fa893e5b675652babb2341ac43356c57d3ea9650a47e63ca0dde8d0915305ab4714b5f3575
6
+ metadata.gz: cc1cdf72aee4a83b61284f12da0c80112d7fe66e2ddeeafdaadfe55758228c410a23b3f400e0e3bdb5d2e107f370e2c3766508bc99676f135e7aaefbb30db903
7
+ data.tar.gz: b119e25b9a1557f5faffb204da95e86a20800dfbe0baec31ecdc816a9d39bd40c795b9010f7c832c1255e6c8cb8266c4cbbb662360b0b1da37a4de9e776c5e58
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
PATH
2
2
remote: .
3
3
specs:
4
- skull_island (1.2.5)
4
+ skull_island (1.2.6)
5
5
deepsort (~> 0.4)
6
6
erubi (~> 1.8)
7
7
json (~> 2.1)
data/README.md CHANGED
@@ -37,6 +37,8 @@ Commands:
37
37
skull_island help [COMMAND] # Describe available commands or one specific command
38
38
skull_island import [OPTIONS] [INPUT|-] # Import a configuration from INPUT
39
39
skull_island migrate [OPTIONS] [INPUT|-] [OUTPUT|-] # Migrate an older config from INPUT to OUTPUT
40
+ skull_island reset # Fully reset a gateway (removing all config)
41
+ skull_island version # Display the current installed version of skull_island
40
42
41
43
Options:
42
44
[--verbose], [--no-verbose]
@@ -138,6 +140,26 @@ If you don't have a previous export, you'll need to install an older version of
138
140
139
141
While it would be possible to make migration _automatic_ for the `import` command, `skull_island` intentionally doesn't do this to avoid the appearance that the config is losslessly compatible across versions. In reality, the newer config version has additional features (like tagging) that will likely be used heavily. It makes sense to this author to maintain the migration component and the normal functionality as distinct features to encourage the use of the newer capabilities in 1.1+.
140
142
143
+ ### Reset A Gateway
144
+
145
+ Skull Island can completely clear the configuration from a Kong instance using the `reset` command. **THIS COMMAND WILL COMPLETELY CLEAR YOUR CONFIGURATION!** Since this is a pretty serious command, it requires you to include `--force`, otherwise it simply exits with an error.
146
+
147
+ Fully resetting a gateway looks like this:
148
+
149
+ ```
150
+ skull_island reset --force
151
+ ```
152
+
153
+ You can, of course, include `--verbose` to see `skull_island` do its work, though the output may be slightly misleading because of the cascading nature of deletions (e.g., deleting a Service will delete all Routes associated with it automatically).
154
+
155
+ You can also restrict the reset to just resources associated with a particular project using the `--project` flag:
156
+
157
+ ```
158
+ skull_island reset --force --project foo
159
+ ```
160
+
161
+ This assumes the project is called `foo`.
162
+
141
163
### Check Installed Version
142
164
143
165
If you're wondering what version of `skull_island` is installed, use:
data/lib/skull_island/cli.rb CHANGED
@@ -102,6 +102,29 @@ module SkullIsland
102
102
end
103
103
end
104
104
105
+ desc('reset', 'Fully reset a gateway (removing all config)')
106
+ option :force, type: :boolean, desc: 'Force the reset (required)'
107
+ option :project, desc: 'Project identifier for metadata'
108
+ def reset
109
+ unless options['force']
110
+ puts '[ERR] Missing --force flag.'
111
+ exit 2
112
+ end
113
+
114
+ if options['project'] && options['verbose']
115
+ warn "[WARN] ! Resetting gateway for project '#{options['project']}'"
116
+ elsif options['verbose']
117
+ warn '[WARN] ! FULLY Resetting gateway'
118
+ end
119
+ [
120
+ Resources::Certificate,
121
+ Resources::Consumer,
122
+ Resources::Upstream,
123
+ Resources::Service,
124
+ Resources::Plugin
125
+ ].each { |clname| reset_class(clname, options['project']) }
126
+ end
127
+
105
128
desc('version', 'Display the current installed version of skull_island')
106
129
def version
107
130
puts "SkullIsland Version: #{SkullIsland::VERSION}"
@@ -131,6 +154,16 @@ module SkullIsland
131
154
)
132
155
end
133
156
157
+ def reset_class(class_name, project)
158
+ warn "[WARN] ! Resetting #{class_name.route_key}" if options['verbose']
159
+ resources = project ? class_name.all.select { |r| r.project == project } : class_name.all
160
+
161
+ resources.each do |resource|
162
+ puts "[WARN] ! Removing #{class_name.name} (#{resource.id})"
163
+ resource.destroy
164
+ end
165
+ end
166
+
134
167
# Used to pull input from either STDIN or the specified file
135
168
def acquire_input(input_file, verbose = false)
136
169
if input_file == '-'
data/lib/skull_island/version.rb CHANGED
@@ -4,6 +4,6 @@ module SkullIsland
4
4
VERSION = [
5
5
1, # Major
6
6
2, # Minor
7
- 5 # Patch
7
+ 6 # Patch
8
8
].join('.')
9
9
end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
--- !ruby/object:Gem::Specification
2
2
name: skull_island
3
3
version: !ruby/object:Gem::Version
4
- version: 1.2.5
4
+ version: 1.2.6
5
5
platform: ruby
6
6
authors:
7
7
- Jonathan Gnagy