knife-push 1.0.3 → 2.0.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 7359291d95a4127626ee1ded020f4dac0b190bc3
4
- data.tar.gz: c93d14229d13dfc877620ba927e523f51df6809b
2
+ SHA256:
3
+ metadata.gz: '09682030a071d728840558d4ed755fd0980378036d74c1f9254fa42e6275120a'
4
+ data.tar.gz: eb86d0f49bf1815ff4d8ee4930c6e1c4cd5562d5936f8985ea1dd60470947c1c
5
5
  SHA512:
6
- metadata.gz: 82a129ac9723ff271536e4648915da93563fe5c0a55f85c58033dcbf95f8a2323556c26c81825d7a904966847844b01ad665e1020167be1194718a6a02d8effc
7
- data.tar.gz: ce5195d21102c7e89724c7a2b617e83733c88c11185a99cd116249cc8b0080387e2c77dd7c507d961959dabba9c7f5c3b99d82dc33acc492d645fb0dfceb3470
6
+ metadata.gz: 7840c5205db39cf5e5b9ecb8e36f93eab3a19f603e70d5fa45110f417f91e7a2020000995aed04654657c6332ffa76f2c9f40d008936dc265b7173be5dd60c94
7
+ data.tar.gz: 13a57975ebb55f4d359f71789e9accc5a8f4f1b83204143415170cfdf4beeaa9046798a43e145404438786dc53ac8bd19a7a8cba1165917d71c5ab77fdcbb342
@@ -15,6 +15,8 @@
15
15
  # under the License.
16
16
  #
17
17
 
18
+ require "addressable/uri" unless defined?(Addressable::URI)
19
+
18
20
  class Chef
19
21
  class Knife
20
22
  module JobHelpers
@@ -22,11 +24,10 @@ class Chef
22
24
  node_names = []
23
25
  if search
24
26
  q = Chef::Search::Query.new
25
- escaped_query = URI.escape(search,
26
- Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
27
+ escaped_query = Addressable::URI.encode_component(search, Addressable::URI::CharacterClasses::QUERY)
27
28
  begin
28
29
  nodes = q.search(:node, escaped_query).first
29
- rescue Net::HTTPServerException => e
30
+ rescue Net::HTTPClientException => e
30
31
  msg Chef::JSONCompat.from_json(e.response.body)["error"].first
31
32
  ui.error("knife search failed: #{msg}")
32
33
  exit 1
@@ -41,7 +42,7 @@ class Chef
41
42
  exit 1
42
43
  end
43
44
 
44
- return node_names
45
+ node_names
45
46
  end
46
47
 
47
48
  def status_string(job)
@@ -81,8 +82,8 @@ class Chef
81
82
 
82
83
  def status_code(job)
83
84
  if job["status"] == "complete" && job["nodes"].keys.all? do |key|
84
- key == "succeeded" || key == "nacked" || key == "unavailable"
85
- end
85
+ key == "succeeded" || key == "nacked" || key == "unavailable"
86
+ end
86
87
  0
87
88
  else
88
89
  1
@@ -117,7 +118,7 @@ class Chef
117
118
  exit 1
118
119
  end
119
120
  contents = ""
120
- if File.exists?(file_name)
121
+ if File.exist?(file_name)
121
122
  File.open(file_name, "rb") do |file|
122
123
  contents = file.read
123
124
  end
@@ -125,7 +126,7 @@ class Chef
125
126
  ui.error "#{file_name} not found"
126
127
  exit 1
127
128
  end
128
- return contents
129
+ contents
129
130
  end
130
131
 
131
132
  def get_env(config)
@@ -21,9 +21,9 @@ class Chef
21
21
  banner "knife job output <job id> <node> [<node> ...]"
22
22
 
23
23
  option :channel,
24
- :long => "--channel stdout|stderr",
25
- :default => "stdout",
26
- :description => "Which output channel to fetch (default stdout)."
24
+ long: "--channel stdout|stderr",
25
+ default: "stdout",
26
+ description: "Which output channel to fetch (default stdout)."
27
27
 
28
28
  def run
29
29
  job_id = name_args[0]
@@ -38,17 +38,11 @@ class Chef
38
38
  end
39
39
 
40
40
  def get_channel(channel)
41
- channel = channel || "stdout"
42
- case channel
43
- when "stdout"
44
- return channel
45
- when "stderr"
46
- return channel
47
- else
48
- raise "Invalid Format please enter stdout or stderr"
49
- end
50
- end
41
+ channel ||= "stdout"
42
+ return channel if channel == "stdout" || channel == "stderr"
51
43
 
44
+ raise "Invalid Format please enter stdout or stderr"
45
+ end
52
46
  end
53
47
  end
54
48
  end
@@ -15,7 +15,7 @@
15
15
  # under the License.
16
16
  #
17
17
 
18
- require "chef/knife/job_helpers"
18
+ require_relative "job_helpers"
19
19
 
20
20
  class Chef
21
21
  class Knife
@@ -31,58 +31,58 @@ class Chef
31
31
  banner "knife job start <command> [<node> <node> ...]"
32
32
 
33
33
  option :run_timeout,
34
- :long => "--timeout TIMEOUT",
35
- :description => "Maximum time the job will be allowed to run (in seconds)."
34
+ long: "--timeout TIMEOUT",
35
+ description: "Maximum time the job will be allowed to run (in seconds)."
36
36
 
37
37
  option :quorum,
38
- :short => "-q QUORUM",
39
- :long => "--quorum QUORUM",
40
- :default => "100%",
41
- :description => "Pushy job quorum. Percentage (-q 50%) or Count (-q 145)."
38
+ short: "-q QUORUM",
39
+ long: "--quorum QUORUM",
40
+ default: "100%",
41
+ description: "Pushy job quorum. Percentage (-q 50%) or Count (-q 145)."
42
42
 
43
43
  option :search,
44
- :short => "-s QUERY",
45
- :long => "--search QUERY",
46
- :required => false,
47
- :description => "Solr query for list of job candidates."
44
+ short: "-s QUERY",
45
+ long: "--search QUERY",
46
+ required: false,
47
+ description: "Solr query for list of job candidates."
48
48
 
49
49
  option :send_file,
50
- :long => "--file FILE",
51
- :default => nil,
52
- :description => "File to send to job."
50
+ long: "--file FILE",
51
+ default: nil,
52
+ description: "File to send to job."
53
53
 
54
54
  option :capture_output,
55
- :long => "--capture",
56
- :boolean => true,
57
- :default => false,
58
- :description => "Capture job output."
55
+ long: "--capture",
56
+ boolean: true,
57
+ default: false,
58
+ description: "Capture job output."
59
59
 
60
60
  option :with_env,
61
- :long => "--with-env ENV",
62
- :default => nil,
63
- :description => "JSON blob of environment variables to set."
61
+ long: "--with-env ENV",
62
+ default: nil,
63
+ description: "JSON blob of environment variables to set."
64
64
 
65
65
  option :as_user,
66
- :long => "--as-user USER",
67
- :default => nil,
68
- :description => "User id to run as."
66
+ long: "--as-user USER",
67
+ default: nil,
68
+ description: "User id to run as."
69
69
 
70
70
  option :in_dir,
71
- :long => "--in-dir DIR",
72
- :default => nil,
73
- :description => "Directory to execute the command in."
71
+ long: "--in-dir DIR",
72
+ default: nil,
73
+ description: "Directory to execute the command in."
74
74
 
75
75
  option :nowait,
76
- :long => "--nowait",
77
- :short => "-b",
78
- :boolean => true,
79
- :default => false,
80
- :description => "Rather than waiting for each job to complete, exit immediately after starting the job."
76
+ long: "--nowait",
77
+ short: "-b",
78
+ boolean: true,
79
+ default: false,
80
+ description: "Rather than waiting for each job to complete, exit immediately after starting the job."
81
81
 
82
82
  option :poll_interval,
83
- :long => "--poll-interval RATE",
84
- :default => 1.0,
85
- :description => "Repeat interval for job status update (in seconds)."
83
+ long: "--poll-interval RATE",
84
+ default: 1.0,
85
+ description: "Repeat interval for job status update (in seconds)."
86
86
 
87
87
  def run
88
88
  job_name = @name_args[0]
@@ -113,7 +113,7 @@ class Chef
113
113
 
114
114
  begin
115
115
  job = run_helper(config, v2_json)
116
- rescue Net::HTTPServerException => e
116
+ rescue Net::HTTPClientException => e
117
117
  raise e if e.response.code != "400"
118
118
 
119
119
  ui.warn "Falling back to Push Jobs v1 mode."
@@ -22,7 +22,7 @@ class Chef
22
22
 
23
23
  def run
24
24
  get_node_statuses(name_args).each do |node_status|
25
- puts "#{node_status['node_name']}\t#{node_status['availability']}"
25
+ puts "#{node_status["node_name"]}\t#{node_status["availability"]}"
26
26
  end
27
27
  end
28
28
 
@@ -1,7 +1,7 @@
1
1
 
2
2
  module Knife
3
3
  module Push
4
- VERSION = "1.0.3"
4
+ VERSION = "2.0.1".freeze
5
5
  MAJOR, MINOR, TINY = VERSION.split(".")
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-push
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Keiser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-01 00:00:00.000000000 Z
11
+ date: 2020-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef
@@ -16,25 +16,35 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 12.7.2
19
+ version: '15.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 12.7.2
27
- description: Knife plugin for Chef push
26
+ version: '15.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: addressable
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Knife plugin for Chef Push Jobs
28
42
  email: jkeiser@chef.io
29
43
  executables: []
30
44
  extensions: []
31
- extra_rdoc_files:
32
- - README.md
33
- - LICENSE
45
+ extra_rdoc_files: []
34
46
  files:
35
47
  - LICENSE
36
- - README.md
37
- - Rakefile
38
48
  - lib/chef/knife/job_helpers.rb
39
49
  - lib/chef/knife/job_list.rb
40
50
  - lib/chef/knife/job_output.rb
@@ -42,7 +52,7 @@ files:
42
52
  - lib/chef/knife/job_status.rb
43
53
  - lib/chef/knife/node_status.rb
44
54
  - lib/knife-push/version.rb
45
- homepage: https://www.chef.io
55
+ homepage: https://github.com/chef/knife-push/
46
56
  licenses:
47
57
  - Apache-2.0
48
58
  metadata: {}
@@ -54,16 +64,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
54
64
  requirements:
55
65
  - - ">="
56
66
  - !ruby/object:Gem::Version
57
- version: 2.2.2
67
+ version: '2.5'
58
68
  required_rubygems_version: !ruby/object:Gem::Requirement
59
69
  requirements:
60
70
  - - ">="
61
71
  - !ruby/object:Gem::Version
62
72
  version: '0'
63
73
  requirements: []
64
- rubyforge_project:
65
- rubygems_version: 2.6.11
74
+ rubygems_version: 3.0.3
66
75
  signing_key:
67
76
  specification_version: 4
68
- summary: Knife plugin for Chef push
77
+ summary: Knife plugin for Chef Push Jobs
69
78
  test_files: []
data/README.md DELETED
@@ -1,177 +0,0 @@
1
- # Knife Push
2
-
3
- [![Gem Version](https://badge.fury.io/rb/knife-push.svg)](https://badge.fury.io/rb/knife-push) [![Build Status](https://travis-ci.org/chef/knife-push.svg?branch=master)](https://travis-ci.org/chef/knife-push)
4
-
5
- The knife push plugin is used by the Chef workstation to interact with the Push API to start jobs, view job status, view job lists, and view node status.
6
-
7
- ## Requirements
8
-
9
- - Chef 12.0 higher
10
- - Ruby 2.2.2 or higher
11
-
12
- ## Installation:
13
-
14
- To build and install the plugin, run:
15
-
16
- ```shell
17
- rake install
18
- ```
19
-
20
- ## Configuration:
21
-
22
- If push server is running on the same host as the Chef Server, then no reconfiguration is required on the Chef workstation.
23
-
24
- ## Subcommands:
25
-
26
- This plugin provides the following Knife subcommands. Specific command options can be found by invoking the subcommand with a `--help` flag.
27
-
28
- ### job list
29
-
30
- The `job list` subcommand is used to view a list of Push jobs.
31
-
32
- #### Syntax $ knife job list
33
-
34
- ### job start
35
-
36
- The `job start` subcommand is used to start a Push job.
37
-
38
- #### Syntax
39
-
40
- ```shell
41
- knife job start (options) COMMAND [NODE, NODE, ...]
42
- ```
43
-
44
- #### Options
45
-
46
- This argument has the following options:
47
-
48
- `--timeout TIMEOUT`
49
-
50
- The maximum amount of time (in seconds) by which a job must complete, before it will be stopped.
51
-
52
- `-q QUORUM --quorum QUORUM`
53
-
54
- The minimum number of nodes that match the search criteria, are available, and acknowledge the job request. This can be expressed as a percentage (e.g. 50%) or as an absolute number of nodes (e.g. 145). Default value: 100%
55
-
56
- `-b --nowait`
57
-
58
- Exit immediately after starting a job instead of waiting for it to complete.
59
-
60
- `--with-env ENVIRONMENT`
61
-
62
- Accept a json blob of environment variables and use those to set the variables for the client. For example '{"test": "foo"}' will set the push client environment variable "test" to "foo". (Push 2.0 and later)
63
-
64
- `--in-dir DIR`
65
-
66
- Execute the remote command in the directory DIR. (Push 2.0 and later)
67
-
68
- `--file DATAFILE`
69
-
70
- Send the file to the client. (Push 2.0 and later)
71
-
72
- `--capture`
73
-
74
- Capture stdin and stdout for this job. (Push 2.0 and later)
75
-
76
- #### Examples
77
-
78
- For example, to search for nodes assigned the role "webapp", and where 90% of those nodes must be available, enter:
79
-
80
- ```shell
81
- knife job start -quorum 90% 'chef-client' --search 'role:webapp'
82
- ```
83
-
84
- To search for a specific set of nodes (named chico, harpo, groucho, gummo, zeppo), and where 90% of those nodes must be available, enter:
85
-
86
- ```shell
87
- knife job start --quorum 90% 'chef-client' chico harpo groucho gummo zeppo
88
- ```
89
-
90
- Use the `knife job start` subcommand to run a job with the following syntax:
91
-
92
- ```shell
93
- knife job start job_name node_name
94
- ```
95
-
96
- For example, to run a job named add-glasses against a node named "ricardosalazar", enter the following:
97
-
98
- ```shell
99
- knife job start add-glasses 'ricardosalazar'
100
- ```
101
-
102
- ### job output
103
-
104
- The `job output` command is used to view the output of Push jobs. (Push 2.0 and later). The output capture flag must have been set on job start; see the --capture option.
105
-
106
- #### Syntax
107
-
108
- ```shell
109
- knife job output JOBID
110
- ```
111
-
112
- #### Examples
113
-
114
- ```shell
115
- knife job output 26e98ba162fa7ba6fb2793125553c7ae test --channel stdout
116
- ```
117
-
118
- #### Options
119
-
120
- --channel [stderr|stdout]
121
-
122
- The output channel to capture.
123
-
124
- ### job status
125
-
126
- The `job status` command is used to view the status of Push jobs.
127
-
128
- #### Syntax
129
-
130
- ```shell
131
- knife job status JOBID
132
- ```
133
-
134
- #### Examples
135
-
136
- For example, to view the status of a job that has the identifier of "235", enter:
137
-
138
- ```shell
139
- knife job status 235
140
- ```
141
-
142
- ### node status
143
-
144
- The `node status` argument is used to identify nodes that Push may interact with.
145
-
146
- #### Syntax
147
-
148
- ```shell
149
- knife node status
150
- ```
151
-
152
- ## Contributing
153
-
154
- For information on contributing to this project see <https://github.com/chef/chef/blob/master/CONTRIBUTING.md>
155
-
156
-
157
- ## License
158
-
159
- **Author:** John Keiser([jkeiser@chef.io](mailto:jkeiser@chef.io))
160
-
161
- **Copyright:** Copyright 2008-2016, Chef Software, Inc.
162
-
163
- **License:** Apache License, Version 2.0
164
-
165
- ```text
166
- Licensed under the Apache License, Version 2.0 (the "License");
167
- you may not use this file except in compliance with the License.
168
- You may obtain a copy of the License at
169
-
170
- http://www.apache.org/licenses/LICENSE-2.0
171
-
172
- Unless required by applicable law or agreed to in writing, software
173
- distributed under the License is distributed on an "AS IS" BASIS,
174
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
175
- See the License for the specific language governing permissions and
176
- limitations under the License.
177
- ```
data/Rakefile DELETED
@@ -1,14 +0,0 @@
1
- require "bundler"
2
- require "rubygems"
3
- require "rspec/core/rake_task"
4
-
5
- Bundler::GemHelper.install_tasks
6
-
7
- task :default => :spec
8
-
9
- desc "Run specs"
10
- RSpec::Core::RakeTask.new(:spec) do |spec|
11
- spec.pattern = "spec/**/*_spec.rb"
12
- end
13
-
14
- gem_spec = eval(File.read("knife-push.gemspec"))