tcp-server 1.0.3-java → 1.0.4-java

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
2
  SHA256:
3
- metadata.gz: ee220a0690f6cfd1a8adeb7a7147f93755082ee6e947f2ee9823cea6e4ddda2b
4
- data.tar.gz: d9ef67e6d0bf3e8496d4c0b73b47bcb2cca158706d38de245cd5cbfa15db6ac1
3
+ metadata.gz: 3e13c7b958e72b6551472ad5a12389bc88687984b2d17f915f31a34dc2a420e8
4
+ data.tar.gz: 8682f4628c10fda39dcf7953ce0a31af1947af8507b5fc9ea41593ed8e4e3cba
5
5
  SHA512:
6
- metadata.gz: 56326ddbedd68dd85915bb3616ef02204a17b36643224106f72f134fabc723e29de06baae753e08821af4c85d943fbadf39f30a743d6150107d8e2756400bae5
7
- data.tar.gz: 807ba39230059812a6e6d0075ec41029dd3f5da11234e13705e46a04f66ed45f6e60b12f29f24a10fc9d03294a9be2b348e0840fe95ad6607f95a4caa267cb42
6
+ metadata.gz: 0535ec8e3b2a0c4d03f3150a1c8f551b2a32a4cf0c387d00b82b1d16f2b75e5fda2111fa8686febd3a36be2acaed68f165d08c99a6fa36a1515dbd4e129e9406
7
+ data.tar.gz: c2546356d7833043fbc7664afacba069ed21d9b8d5f460a58688f8714bd51dacaca95a60ce6319e3d19c6f54ad05faa57717af087c9e2085c5755b1d50efefe3
data/README.md CHANGED
@@ -173,6 +173,33 @@ Use the GitLab CI Linting API to validate the syntax of a CI definition file.
173
173
  jq --null-input --arg yaml "$(<.gitlab/ci/gem.gitlab-ci.yml)" '.content=$yaml' | curl --silent --location https://gitlab.com/api/v4/ci/lint --header "PRIVATE-TOKEN: ${GITLAB_COM_API_PRIVATE_TOKEN}" --header "Content-Type: application/json" --data @- | jq --raw-output '.errors[0]'
174
174
  ```
175
175
 
176
+ ## CI configuration
177
+
178
+ Generate a deploy key.
179
+
180
+ ```sh
181
+ ssh-keygen -t ed25519 -C deploy_key
182
+ ```
183
+
184
+ Use the GitLab Project-level Variables API to add the deploy key as a ssh private key variable.
185
+
186
+ ```sh
187
+ project_path="nelsnelson/$(basename $(pwd))"
188
+
189
+ project=$(curl --silent --show-error --location "https://gitlab.com/api/v4/search?scope=projects&search=${project_path}" --header "PRIVATE-TOKEN: ${GITLAB_COM_API_PRIVATE_TOKEN}" | jq --arg project_path "${project_path}" '.[] | select(.path_with_namespace == $project_path)')
190
+
191
+ project_id=$(curl --silent --show-error --location "https://gitlab.com/api/v4/search?scope=projects&search=${project_path}" --header "PRIVATE-TOKEN: ${GITLAB_COM_API_PRIVATE_TOKEN}" | jq --arg project_path "${project_path}" '.[] | select(.path_with_namespace == $project_path) | .id')
192
+
193
+ # Add the deploy_token as a CI variable:
194
+ curl --silent --show-error --location --request POST "https://gitlab.com/api/v4/projects/${project_id}/variables" --header "PRIVATE-TOKEN: ${GITLAB_COM_API_PRIVATE_TOKEN}" --form "key=SSH_PRIVATE_KEY" --form "value=$(cat ./deploy_token)" --form "protected=true" | jq
195
+ ```
196
+
197
+ Use the Deploy keys API to add a the public deploy key as a deploy key for the project.
198
+
199
+ ```sh
200
+ curl --silent --show-error --location --request POST "https://gitlab.com/api/v4/projects/${project_id}/deploy_keys" --header "PRIVATE-TOKEN: ${GITLAB_COM_API_PRIVATE_TOKEN}" --data '{"title": "deploy_key", "key": "$(cat ./deploy_token.pub)", "can_push": "true"}' | jq
201
+ ```
202
+
176
203
  [license]: https://gitlab.com/nelsnelson/tcp-server-jruby/blob/master/LICENSE
177
204
  [asdf]: https://asdf-vm.com/
178
205
  [Netty project]: https://github.com/netty/netty
@@ -27,14 +27,14 @@ module Server
27
27
  # The InstanceMethods module
28
28
  module InstanceMethods
29
29
  def configure_handlers(&block)
30
- ::Server::ChannelInitializer::DefaultHandler.add_listener(self)
30
+ add_listener(self)
31
31
  channel_initializer << block if block_given?
32
32
  end
33
33
 
34
34
  def bootstrap
35
35
  @bootstrap = ServerBootstrap.new
36
36
  @bootstrap.group(boss_group, worker_group)
37
- @bootstrap.channel(::Server::CHANNEL_TYPE)
37
+ @bootstrap.channel(Server::CHANNEL_TYPE)
38
38
  @bootstrap.option(ChannelOption::SO_BACKLOG, 100.to_java(java.lang.Integer))
39
39
  @bootstrap.handler(logging_handler) if options[:log_requests]
40
40
  @bootstrap.childHandler(channel_initializer)
@@ -89,6 +89,10 @@ module Server
89
89
  def <<(handler)
90
90
  channel_initializer << handler
91
91
  end
92
+
93
+ def add_listener(listener)
94
+ ::Server::ChannelInitializer::DefaultHandler.add_listener(listener)
95
+ end
92
96
  end
93
97
  # module ServerInstanceMethods
94
98
  end
data/lib/server/server.rb CHANGED
@@ -18,10 +18,9 @@ require_relative 'listenable'
18
18
 
19
19
  # The Server module
20
20
  module Server
21
- CHANNEL_TYPE = Java::io.netty.channel.socket.nio.NioServerSocketChannel.java_class
22
-
23
21
  # The Server class sets up the netty server.
24
22
  class Server
23
+ CHANNEL_TYPE = Java::io.netty.channel.socket.nio.NioServerSocketChannel.java_class
25
24
  include ::Server::InstanceMethods
26
25
  attr_reader :options
27
26
 
@@ -40,10 +39,6 @@ module Server
40
39
  log.debug "Sending response: #{response.inspect}"
41
40
  ctx.writeAndFlush("#{response}\n")
42
41
  end
43
-
44
- def add_listener(listener)
45
- ::Server::ChannelInitializer::DefaultHandler.add_listener(listener)
46
- end
47
42
  # rubocop: enable Metrics/AbcSize
48
43
  end
49
44
  # class Server
@@ -12,5 +12,5 @@
12
12
 
13
13
  # The Server module
14
14
  module Server
15
- VERSION = '1.0.3'.freeze
15
+ VERSION = '1.0.4'.freeze
16
16
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tcp-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: java
6
6
  authors:
7
7
  - Nels Nelson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-06-16 00:00:00.000000000 Z
11
+ date: 2022-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement