rubernetes 0.0.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -2
- data/lib/rubernetes/auth/kube_config.rb +30 -0
- data/lib/rubernetes/auth/service_account.rb +33 -0
- data/lib/rubernetes/auth/source.rb +41 -0
- data/lib/rubernetes/event.rb +44 -0
- data/lib/rubernetes/kube_client.rb +37 -0
- data/lib/rubernetes/logger.rb +29 -0
- data/lib/rubernetes/operator.rb +108 -0
- data/lib/rubernetes/version.rb +1 -1
- data/lib/rubernetes.rb +5 -1
- metadata +40 -18
- data/.github/workflows/main.yml +0 -45
- data/.github/workflows/release.yml +0 -28
- data/.gitignore +0 -65
- data/.rspec +0 -3
- data/.rubocop.yml +0 -67
- data/CODE_OF_CONDUCT.md +0 -88
- data/CONTRIBUTING.md +0 -25
- data/Gemfile +0 -14
- data/Gemfile.lock +0 -65
- data/LICENSE +0 -21
- data/Rakefile +0 -8
- data/SECURITY.md +0 -11
- data/rubernetes.gemspec +0 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ffa9c6204defe6efe0a4b2dcdb5e1afaf065228956462f06c9326a5cab8fa1d
|
4
|
+
data.tar.gz: 75b414dbcedb55979bc6da8c31cce0102dd6aa155b647800c5176084b2486cce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb4575fcfdcb9fe359e18697dfa79addffb4a770ef6953bda7ef4f322901c4f4f798fe9077e5777c0d2318378e0414a47fd5e66877a225baa8dc8a1154af36b3
|
7
|
+
data.tar.gz: d618b67d3095a6e8f4bcbc383bd7e5f66c26b6dd80ed4b83df8f9e31f5fa4a00c134ad2867932c6cf592d02c3b76e274791df51e0da8a3da06619e780c5e083a
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
-
#
|
2
|
-
A ruby gem to provide the base for building Kubernetes custom resources
|
1
|
+
# <span style="color:blue">Rub</span><span style="color:red">ernetes</span>
|
2
|
+
A ruby gem to provide the base for building Kubernetes custom resources operators in Ruby.
|
3
|
+
|
4
|
+
![logo](./assets/logo.gif)
|
3
5
|
|
4
6
|
## Installation
|
5
7
|
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rubernetes
|
4
|
+
module Auth
|
5
|
+
# This class is used to read and parse a KUBECONFIG file.
|
6
|
+
# It will try to read the KUBECONFIG from ENV first, otherwise it will fallback to ~/.kube/config.
|
7
|
+
# It extracts the kube API endpoint and authentication details.
|
8
|
+
class KubeConfig
|
9
|
+
KUBECONFIG_DEFAULT_PATH = "#{Dir.home}/.kube/config"
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
config_path = ENV.fetch('KUBECONFIG', KUBECONFIG_DEFAULT_PATH)
|
13
|
+
config = Kubeclient::Config.read(config_path)
|
14
|
+
@context = config.context
|
15
|
+
end
|
16
|
+
|
17
|
+
def api_endpoint
|
18
|
+
@context.api_endpoint
|
19
|
+
end
|
20
|
+
|
21
|
+
def ssl_options
|
22
|
+
@context.ssl_options
|
23
|
+
end
|
24
|
+
|
25
|
+
def auth_options
|
26
|
+
@context.auth_options
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rubernetes
|
4
|
+
module Auth
|
5
|
+
# This class is used as a serviceaccount's crt/token options wrapper.
|
6
|
+
# It assumes that the serviceaccount crt/token is mounted at
|
7
|
+
# `/var/run/secrets/kubernetes.io/serviceaccount`.
|
8
|
+
class ServiceAccount
|
9
|
+
CRT_PATH = '/var/run/secrets/kubernetes.io/serviceaccount/ca.crt'
|
10
|
+
TOKEN_PATH = '/var/run/secrets/kubernetes.io/serviceaccount/token'
|
11
|
+
|
12
|
+
def initialize; end
|
13
|
+
|
14
|
+
def api_endpoint
|
15
|
+
@api_endpoint ||= "#{ssl_options.empty? ? 'http' : 'https'}://kubernetes.default.svc"
|
16
|
+
end
|
17
|
+
|
18
|
+
def ssl_options
|
19
|
+
@ssl_options ||= if File.exist?(CRT_PATH)
|
20
|
+
{ ca_file: CRT_PATH }
|
21
|
+
else
|
22
|
+
{}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def auth_options
|
27
|
+
@auth_options ||= {
|
28
|
+
bearer_token_file: TOKEN_PATH
|
29
|
+
}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'kube_config'
|
4
|
+
require_relative 'service_account'
|
5
|
+
require 'forwardable'
|
6
|
+
|
7
|
+
module Rubernetes
|
8
|
+
module Auth
|
9
|
+
# This class is used to decide on which auth mechanism to use (service_account? vs. kube_config?).
|
10
|
+
# It helps to run Rubernetes in development/local enviornments where a serviceaccount is missing.
|
11
|
+
class Source
|
12
|
+
extend Forwardable
|
13
|
+
def_delegators :@authenticator, :api_endpoint, :ssl_options, :auth_options
|
14
|
+
attr_accessor :authenticator
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
@authenticator = if service_account?
|
18
|
+
ServiceAccount.new
|
19
|
+
elsif kube_config?
|
20
|
+
KubeConfig.new
|
21
|
+
else
|
22
|
+
raise Rubernetes::MissingAuthSource, 'Could not recognize authentication source'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def service_account?
|
29
|
+
File.exist?(ServiceAccount::TOKEN_PATH)
|
30
|
+
end
|
31
|
+
|
32
|
+
def kube_config?
|
33
|
+
File.exist?(kube_config_path)
|
34
|
+
end
|
35
|
+
|
36
|
+
def kube_config_path
|
37
|
+
ENV.fetch('KUBECONFIG', "#{Dir.home}/.kube/config")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rubernetes
|
4
|
+
class Event
|
5
|
+
attr_reader :event, :logger, :store
|
6
|
+
|
7
|
+
def initialize(event, logger, store)
|
8
|
+
@event = event
|
9
|
+
@logger = logger
|
10
|
+
@store = store
|
11
|
+
end
|
12
|
+
|
13
|
+
def handle(event_handlers)
|
14
|
+
logger.info('event received')
|
15
|
+
logger.debug("cached?: #{cached?.to_s}")
|
16
|
+
return if cached?
|
17
|
+
|
18
|
+
event_handlers[@event[:type].downcase.to_sym].call(event)
|
19
|
+
cache!
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def cached?
|
25
|
+
!store.transaction { store[cache_key] }.to_s.empty? &&
|
26
|
+
cache.to_i >= event.dig(:object, :metadata, :resourceVersion).to_i
|
27
|
+
end
|
28
|
+
|
29
|
+
def cache
|
30
|
+
store.transaction { store[cache_key] }
|
31
|
+
end
|
32
|
+
|
33
|
+
def cache!
|
34
|
+
store.transaction do
|
35
|
+
store[cache_key] = event.dig(:object, :metadata, :resourceVersion)
|
36
|
+
store.commit
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def cache_key
|
41
|
+
event.dig(:object, :metadata, :uid)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'auth/source'
|
4
|
+
require 'kubeclient'
|
5
|
+
|
6
|
+
module Rubernetes
|
7
|
+
# A wrapper class around original Kubeclient https://github.com/abonas/kubeclient.
|
8
|
+
# It will automatically create a Kubeclient from
|
9
|
+
# a detected `serviceaccount` or `KUBECONFIG`
|
10
|
+
class KubeClient
|
11
|
+
KUBE_CLIENT_CLASS = ::Kubeclient::Client
|
12
|
+
|
13
|
+
def initialize(crd_group, crd_version)
|
14
|
+
@crd_group = crd_group
|
15
|
+
@crd_version = crd_version
|
16
|
+
end
|
17
|
+
|
18
|
+
def method_missing(method, *args)
|
19
|
+
auth_source = Auth::Source.new
|
20
|
+
|
21
|
+
@client ||= KUBE_CLIENT_CLASS.new(
|
22
|
+
"#{auth_source.api_endpoint}/apis/#{@crd_group}",
|
23
|
+
@crd_version,
|
24
|
+
ssl_options: auth_source.ssl_options,
|
25
|
+
auth_options: auth_source.auth_options
|
26
|
+
)
|
27
|
+
|
28
|
+
return @client.send(method, *args) if @client.respond_to?(method)
|
29
|
+
|
30
|
+
super
|
31
|
+
end
|
32
|
+
|
33
|
+
def respond_to_missing?(_method_name, _include_private = false)
|
34
|
+
super
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'logger'
|
4
|
+
require 'forwardable'
|
5
|
+
|
6
|
+
module Rubernetes
|
7
|
+
# A wrapper class around Ruby Logger
|
8
|
+
# It will automatically attach a Rubernetes specific formatter
|
9
|
+
# which will prepend #{crd_group}/#{crd_version}/#{crd_plural}
|
10
|
+
# to all log messages
|
11
|
+
class Logger
|
12
|
+
extend Forwardable
|
13
|
+
def_delegators :@logger, :info, :debug, :error
|
14
|
+
attr_accessor :logger
|
15
|
+
|
16
|
+
def initialize(crd_group, crd_version, crd_plural, options)
|
17
|
+
original_formatter = ::Logger::Formatter.new
|
18
|
+
namespace ||= options[:namespace]
|
19
|
+
formatter = proc do |severity, datetime, progname, msg|
|
20
|
+
prefix = "#{crd_group}/#{crd_version}"
|
21
|
+
prefix += "/#{namespace}" if namespace
|
22
|
+
prefix += "/#{crd_plural}"
|
23
|
+
"#{prefix}: #{original_formatter.call(severity, datetime, progname, msg.dump)}"
|
24
|
+
end
|
25
|
+
@logger = ::Logger.new($stdout)
|
26
|
+
@logger.formatter = formatter
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'kube_client'
|
4
|
+
require_relative 'logger'
|
5
|
+
require_relative 'event'
|
6
|
+
require 'yaml'
|
7
|
+
require 'yaml/store'
|
8
|
+
|
9
|
+
module Rubernetes
|
10
|
+
# Operator Class to run the core operator functions for your crd
|
11
|
+
# @param group [string] Group from crd
|
12
|
+
# @param version [string] Api Version from crd
|
13
|
+
# @param plural [string] Name (plural) from crd
|
14
|
+
# @param options [Hash] Additional options
|
15
|
+
# @option options [Hash] sleepTimer Time to wait for retry if the watch event stops
|
16
|
+
# @option options [Hash] namespace Watch only an namespace, default watch all namespaces
|
17
|
+
# @option options [Hash] persistence_location Location for the yaml store, default is /tmp/persistence
|
18
|
+
class Operator
|
19
|
+
def initialize(crd_group, crd_version, crd_plural, options = {})
|
20
|
+
# parameters
|
21
|
+
@crd_group = crd_group
|
22
|
+
@crd_version = crd_version
|
23
|
+
@crd_plural = crd_plural
|
24
|
+
|
25
|
+
# defaults
|
26
|
+
@options = options
|
27
|
+
@options[:sleepTimer] ||= 1
|
28
|
+
@options[:namespace] ||= nil
|
29
|
+
|
30
|
+
# persistence/cache layer
|
31
|
+
@options[:persistence_location] ||= '/tmp/cache'
|
32
|
+
Dir.mkdir(@options[:persistence_location]) unless File.exist?(@options[:persistence_location])
|
33
|
+
@store = YAML::Store.new("#{@options[:persistence_location]}/#{@crd_group}_#{@crd_version}_#{@crd_plural}.yaml")
|
34
|
+
|
35
|
+
# utilities
|
36
|
+
@k8sclient = KubeClient.new(crd_group, crd_version)
|
37
|
+
@logger = Logger.new(crd_group, crd_version, crd_plural, namespace: @options[:namespace])
|
38
|
+
|
39
|
+
@logger.info('init the operator')
|
40
|
+
end
|
41
|
+
|
42
|
+
def run
|
43
|
+
@logger.info('start the operator')
|
44
|
+
|
45
|
+
loop do
|
46
|
+
begin
|
47
|
+
watcher.each do |event|
|
48
|
+
handle_event(event)
|
49
|
+
end
|
50
|
+
watcher.finish
|
51
|
+
rescue StandardError => e
|
52
|
+
@logger.error(e.inspect)
|
53
|
+
end
|
54
|
+
|
55
|
+
# do not overwhelm Kube API, relax between calls
|
56
|
+
sleep(@options[:sleepTimer])
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
protected
|
61
|
+
def added(event)
|
62
|
+
@logger.info('external handler(:added) called')
|
63
|
+
@logger.debug(event.inspect)
|
64
|
+
end
|
65
|
+
|
66
|
+
def modified(event)
|
67
|
+
@logger.info('external handler(:modified) called')
|
68
|
+
@logger.debug(event.inspect)
|
69
|
+
end
|
70
|
+
|
71
|
+
def deleted(event)
|
72
|
+
@logger.info('external handler(:deleted) called')
|
73
|
+
@logger.debug(event.inspect)
|
74
|
+
end
|
75
|
+
|
76
|
+
def set_status(event, patch)
|
77
|
+
name = event.dig(:object, :metadata, :name)
|
78
|
+
puts name
|
79
|
+
@k8sclient.patch_entity(@crd_plural, name, {status: patch}, 'merge-patch', @options[:namespace]) and return
|
80
|
+
end
|
81
|
+
|
82
|
+
def get_status(event)
|
83
|
+
resource_name = event.dig(:object, :metadata, :name)
|
84
|
+
@k8sclient.get_entity(@crd_plural, resource_name, @options[:namespace]).dig(:status)
|
85
|
+
end
|
86
|
+
|
87
|
+
private
|
88
|
+
|
89
|
+
def handle_event(ev)
|
90
|
+
event = Event.new(ev, @logger, @store)
|
91
|
+
handlers = {
|
92
|
+
added: method(:added),
|
93
|
+
modified: method(:modified),
|
94
|
+
deleted: method(:deleted)
|
95
|
+
}
|
96
|
+
|
97
|
+
event.handle(handlers)
|
98
|
+
end
|
99
|
+
|
100
|
+
def watcher
|
101
|
+
@watcher ||= if @options[:namespace]
|
102
|
+
@k8sclient.watch_entities(@crd_plural, namespace: @options[:namespace])
|
103
|
+
else
|
104
|
+
@k8sclient.watch_entities(@crd_plural)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
data/lib/rubernetes/version.rb
CHANGED
data/lib/rubernetes.rb
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require_relative 'rubernetes/version'
|
4
|
+
require_relative 'rubernetes/kube_client'
|
5
|
+
require_relative 'rubernetes/operator'
|
4
6
|
|
5
7
|
module Rubernetes
|
6
8
|
class Error < StandardError; end
|
9
|
+
|
10
|
+
class MissingAuthSource < Error; end
|
7
11
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubernetes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tarek N. Samni
|
@@ -10,8 +10,36 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
14
|
-
dependencies:
|
13
|
+
date: 2023-02-28 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: kubeclient
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - ">="
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '0'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: logger
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
36
|
+
type: :runtime
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
15
43
|
description: A ruby gem to provide the base for building Kubernetes custom resources
|
16
44
|
controllers in Ruby.
|
17
45
|
email:
|
@@ -22,30 +50,24 @@ executables: []
|
|
22
50
|
extensions: []
|
23
51
|
extra_rdoc_files: []
|
24
52
|
files:
|
25
|
-
- ".github/workflows/main.yml"
|
26
|
-
- ".github/workflows/release.yml"
|
27
|
-
- ".gitignore"
|
28
|
-
- ".rspec"
|
29
|
-
- ".rubocop.yml"
|
30
|
-
- CODE_OF_CONDUCT.md
|
31
|
-
- CONTRIBUTING.md
|
32
|
-
- Gemfile
|
33
|
-
- Gemfile.lock
|
34
|
-
- LICENSE
|
35
53
|
- README.md
|
36
|
-
- Rakefile
|
37
|
-
- SECURITY.md
|
38
54
|
- bin/console
|
39
55
|
- bin/setup
|
40
56
|
- lib/rubernetes.rb
|
57
|
+
- lib/rubernetes/auth/kube_config.rb
|
58
|
+
- lib/rubernetes/auth/service_account.rb
|
59
|
+
- lib/rubernetes/auth/source.rb
|
60
|
+
- lib/rubernetes/event.rb
|
61
|
+
- lib/rubernetes/kube_client.rb
|
62
|
+
- lib/rubernetes/logger.rb
|
63
|
+
- lib/rubernetes/operator.rb
|
41
64
|
- lib/rubernetes/version.rb
|
42
|
-
- rubernetes.gemspec
|
43
65
|
homepage: https://github.com/rubernetes/gem
|
44
66
|
licenses:
|
45
67
|
- MIT
|
46
68
|
metadata:
|
47
69
|
bug_tracker_uri: https://github.com/rubernetes/gem/issues
|
48
|
-
documentation_uri: https://rubydoc.info/github
|
70
|
+
documentation_uri: https://rubydoc.info/github/rubernetes/gem
|
49
71
|
homepage_uri: https://github.com/rubernetes/gem
|
50
72
|
source_code_uri: https://github.com/rubernetes/gem
|
51
73
|
post_install_message:
|
@@ -56,7 +78,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
56
78
|
requirements:
|
57
79
|
- - ">="
|
58
80
|
- !ruby/object:Gem::Version
|
59
|
-
version: 2.
|
81
|
+
version: 2.5.0
|
60
82
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
83
|
requirements:
|
62
84
|
- - ">="
|
data/.github/workflows/main.yml
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
name: Ruby CI
|
2
|
-
|
3
|
-
on:
|
4
|
-
push:
|
5
|
-
branches:
|
6
|
-
- main
|
7
|
-
pull_request:
|
8
|
-
|
9
|
-
jobs:
|
10
|
-
test-lint:
|
11
|
-
|
12
|
-
runs-on: ubuntu-latest
|
13
|
-
|
14
|
-
strategy:
|
15
|
-
matrix:
|
16
|
-
ruby-version: ['2.4', '2.5', '2.6', '2.7', '3.0']
|
17
|
-
|
18
|
-
steps:
|
19
|
-
- uses: actions/checkout@v2
|
20
|
-
- name: Set up Ruby
|
21
|
-
uses: ruby/setup-ruby@v1
|
22
|
-
with:
|
23
|
-
ruby-version: ${{ matrix.ruby-version }}
|
24
|
-
bundler-cache: true
|
25
|
-
|
26
|
-
- name: Build
|
27
|
-
run: |
|
28
|
-
gem install bundler -v 2.2.8
|
29
|
-
bundle install
|
30
|
-
|
31
|
-
- name: Rubocop run
|
32
|
-
run: |
|
33
|
-
bash -c "
|
34
|
-
bundle exec rubocop --require code_scanning --format CodeScanning::SarifFormatter -o ${{ matrix.ruby-version }}-rubocop.sarif
|
35
|
-
[[ $? -ne 2 ]]
|
36
|
-
"
|
37
|
-
|
38
|
-
- name: Test with Rspec
|
39
|
-
run: |
|
40
|
-
bundle exec rspec
|
41
|
-
|
42
|
-
- name: Upload Sarif output
|
43
|
-
uses: github/codeql-action/upload-sarif@v1
|
44
|
-
with:
|
45
|
-
sarif_file: ${{ matrix.ruby-version }}-rubocop.sarif
|
@@ -1,28 +0,0 @@
|
|
1
|
-
name: Release Gem
|
2
|
-
|
3
|
-
on:
|
4
|
-
release:
|
5
|
-
types: [published]
|
6
|
-
|
7
|
-
|
8
|
-
jobs:
|
9
|
-
build:
|
10
|
-
runs-on: ubuntu-latest
|
11
|
-
|
12
|
-
steps:
|
13
|
-
- uses: actions/checkout@v2
|
14
|
-
- name: Set up Ruby
|
15
|
-
uses: ruby/setup-ruby@v1
|
16
|
-
with:
|
17
|
-
ruby-version: 2.7.3
|
18
|
-
|
19
|
-
- name: Publish to RubyGems
|
20
|
-
run: |
|
21
|
-
mkdir -p $HOME/.gem
|
22
|
-
touch $HOME/.gem/credentials
|
23
|
-
chmod 0600 $HOME/.gem/credentials
|
24
|
-
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
25
|
-
gem build *.gemspec
|
26
|
-
gem push *.gem
|
27
|
-
env:
|
28
|
-
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_API_KEY}}"
|
data/.gitignore
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
*.gem
|
2
|
-
*.rbc
|
3
|
-
/.config
|
4
|
-
/coverage/
|
5
|
-
/InstalledFiles
|
6
|
-
/pkg/
|
7
|
-
/spec/reports/
|
8
|
-
/spec/examples.txt
|
9
|
-
/test/tmp/
|
10
|
-
/test/version_tmp/
|
11
|
-
/tmp/
|
12
|
-
# rspec failure tracking
|
13
|
-
.rspec_status
|
14
|
-
|
15
|
-
# rvm/ruby files
|
16
|
-
.ruby-gemset
|
17
|
-
.ruby-version
|
18
|
-
|
19
|
-
# Used by dotenv library to load environment variables.
|
20
|
-
# .env
|
21
|
-
|
22
|
-
# Ignore Byebug command history file.
|
23
|
-
.byebug_history
|
24
|
-
|
25
|
-
## Specific to RubyMotion:
|
26
|
-
.dat*
|
27
|
-
.repl_history
|
28
|
-
build/
|
29
|
-
*.bridgesupport
|
30
|
-
build-iPhoneOS/
|
31
|
-
build-iPhoneSimulator/
|
32
|
-
|
33
|
-
## Specific to RubyMotion (use of CocoaPods):
|
34
|
-
#
|
35
|
-
# We recommend against adding the Pods directory to your .gitignore. However
|
36
|
-
# you should judge for yourself, the pros and cons are mentioned at:
|
37
|
-
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
38
|
-
#
|
39
|
-
# vendor/Pods/
|
40
|
-
|
41
|
-
## Documentation cache and generated files:
|
42
|
-
/.yardoc/
|
43
|
-
/_yardoc/
|
44
|
-
/doc/
|
45
|
-
/rdoc/
|
46
|
-
|
47
|
-
## Environment normalization:
|
48
|
-
/.bundle/
|
49
|
-
/vendor/bundle
|
50
|
-
/lib/bundler/man/
|
51
|
-
|
52
|
-
# for a library or gem, you might want to ignore these files since the code is
|
53
|
-
# intended to run in multiple environments; otherwise, check them in:
|
54
|
-
# Gemfile.lock
|
55
|
-
# .ruby-version
|
56
|
-
# .ruby-gemset
|
57
|
-
|
58
|
-
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
59
|
-
.rvmrc
|
60
|
-
|
61
|
-
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
|
62
|
-
# .rubocop-https?--*
|
63
|
-
|
64
|
-
# Jetbrains
|
65
|
-
.idea/
|
data/.rspec
DELETED
data/.rubocop.yml
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
require:
|
2
|
-
- rubocop-rake
|
3
|
-
- rubocop-rspec
|
4
|
-
|
5
|
-
AllCops:
|
6
|
-
TargetRubyVersion: 2.4
|
7
|
-
|
8
|
-
Gemspec/DateAssignment:
|
9
|
-
Enabled: true
|
10
|
-
Layout/SpaceBeforeBrackets:
|
11
|
-
Enabled: true
|
12
|
-
Lint/AmbiguousAssignment:
|
13
|
-
Enabled: true
|
14
|
-
Lint/DeprecatedConstants:
|
15
|
-
Enabled: true
|
16
|
-
Lint/DuplicateBranch:
|
17
|
-
Enabled: true
|
18
|
-
Lint/DuplicateRegexpCharacterClassElement:
|
19
|
-
Enabled: true
|
20
|
-
Lint/EmptyBlock:
|
21
|
-
Enabled: true
|
22
|
-
Lint/EmptyClass:
|
23
|
-
Enabled: true
|
24
|
-
Lint/LambdaWithoutLiteralBlock:
|
25
|
-
Enabled: true
|
26
|
-
Lint/NoReturnInBeginEndBlocks:
|
27
|
-
Enabled: true
|
28
|
-
Lint/NumberedParameterAssignment:
|
29
|
-
Enabled: true
|
30
|
-
Lint/OrAssignmentToConstant:
|
31
|
-
Enabled: true
|
32
|
-
Lint/RedundantDirGlobSort:
|
33
|
-
Enabled: true
|
34
|
-
Lint/SymbolConversion:
|
35
|
-
Enabled: true
|
36
|
-
Lint/ToEnumArguments:
|
37
|
-
Enabled: true
|
38
|
-
Lint/TripleQuotes:
|
39
|
-
Enabled: true
|
40
|
-
Lint/UnexpectedBlockArity:
|
41
|
-
Enabled: true
|
42
|
-
Lint/UnmodifiedReduceAccumulator:
|
43
|
-
Enabled: true
|
44
|
-
Style/ArgumentsForwarding:
|
45
|
-
Enabled: true
|
46
|
-
Style/CollectionCompact:
|
47
|
-
Enabled: true
|
48
|
-
Style/DocumentDynamicEvalDefinition:
|
49
|
-
Enabled: true
|
50
|
-
Style/EndlessMethod:
|
51
|
-
Enabled: true
|
52
|
-
Style/HashConversion:
|
53
|
-
Enabled: true
|
54
|
-
Style/HashExcept:
|
55
|
-
Enabled: true
|
56
|
-
Style/IfWithBooleanLiteralBranches:
|
57
|
-
Enabled: true
|
58
|
-
Style/NegatedIfElseCondition:
|
59
|
-
Enabled: true
|
60
|
-
Style/NilLambda:
|
61
|
-
Enabled: true
|
62
|
-
Style/RedundantArgument:
|
63
|
-
Enabled: true
|
64
|
-
Style/StringChars:
|
65
|
-
Enabled: true
|
66
|
-
Style/SwapValues:
|
67
|
-
Enabled: true
|
data/CODE_OF_CONDUCT.md
DELETED
@@ -1,88 +0,0 @@
|
|
1
|
-
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
2
|
-
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
3
|
-
**Table of Contents**
|
4
|
-
|
5
|
-
- [Contributor Covenant Code of Conduct](#contributor-covenant-code-of-conduct)
|
6
|
-
- [Our Pledge](#our-pledge)
|
7
|
-
- [Our Standards](#our-standards)
|
8
|
-
- [Our Responsibilities](#our-responsibilities)
|
9
|
-
- [Scope](#scope)
|
10
|
-
- [Enforcement](#enforcement)
|
11
|
-
- [Attribution](#attribution)
|
12
|
-
|
13
|
-
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
14
|
-
|
15
|
-
# Contributor Covenant Code of Conduct
|
16
|
-
|
17
|
-
## Our Pledge
|
18
|
-
|
19
|
-
In the interest of fostering an open and welcoming environment, we as
|
20
|
-
contributors and maintainers pledge to making participation in our project and
|
21
|
-
our community a harassment-free experience for everyone, regardless of age, body
|
22
|
-
size, disability, ethnicity, gender identity and expression, level of experience,
|
23
|
-
nationality, personal appearance, race, religion, or sexual identity and
|
24
|
-
orientation.
|
25
|
-
|
26
|
-
## Our Standards
|
27
|
-
|
28
|
-
Examples of behavior that contributes to creating a positive environment
|
29
|
-
include:
|
30
|
-
|
31
|
-
* Using welcoming and inclusive language
|
32
|
-
* Being respectful of differing viewpoints and experiences
|
33
|
-
* Gracefully accepting constructive criticism
|
34
|
-
* Focusing on what is best for the community
|
35
|
-
* Showing empathy towards other community members
|
36
|
-
|
37
|
-
Examples of unacceptable behavior by participants include:
|
38
|
-
|
39
|
-
* The use of sexualized language or imagery and unwelcome sexual attention or
|
40
|
-
advances
|
41
|
-
* Trolling, insulting/derogatory comments, and personal or political attacks
|
42
|
-
* Public or private harassment
|
43
|
-
* Publishing others' private information, such as a physical or electronic
|
44
|
-
address, without explicit permission
|
45
|
-
* Other conduct which could reasonably be considered inappropriate in a
|
46
|
-
professional setting
|
47
|
-
|
48
|
-
## Our Responsibilities
|
49
|
-
|
50
|
-
Project maintainers are responsible for clarifying the standards of acceptable
|
51
|
-
behavior and are expected to take appropriate and fair corrective action in
|
52
|
-
response to any instances of unacceptable behavior.
|
53
|
-
|
54
|
-
Project maintainers have the right and responsibility to remove, edit, or
|
55
|
-
reject comments, commits, code, wiki edits, issues, and other contributions
|
56
|
-
that are not aligned to this Code of Conduct, or to ban temporarily or
|
57
|
-
permanently any contributor for other behaviors that they deem inappropriate,
|
58
|
-
threatening, offensive, or harmful.
|
59
|
-
|
60
|
-
## Scope
|
61
|
-
|
62
|
-
This Code of Conduct applies both within project spaces and in public spaces
|
63
|
-
when an individual is representing the project or its community. Examples of
|
64
|
-
representing a project or community include using an official project e-mail
|
65
|
-
address, posting via an official social media account, or acting as an appointed
|
66
|
-
representative at an online or offline event. Representation of a project may be
|
67
|
-
further defined and clarified by project maintainers.
|
68
|
-
|
69
|
-
## Enforcement
|
70
|
-
|
71
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
72
|
-
reported by contacting the project founder (Tarek) at tarek@shebanglabs.io. All
|
73
|
-
complaints will be reviewed and investigated and will result in a response that
|
74
|
-
is deemed necessary and appropriate to the circumstances. The project team is
|
75
|
-
obligated to maintain confidentiality with regard to the reporter of an incident.
|
76
|
-
Further details of specific enforcement policies may be posted separately.
|
77
|
-
|
78
|
-
Project maintainers who do not follow or enforce the Code of Conduct in good
|
79
|
-
faith may face temporary or permanent repercussions as determined by other
|
80
|
-
members of the project's leadership.
|
81
|
-
|
82
|
-
## Attribution
|
83
|
-
|
84
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
85
|
-
available at [https://www.contributor-covenant.org/version/2/0/code_of_conduct/][version]
|
86
|
-
|
87
|
-
[homepage]: https://www.contributor-covenant.org
|
88
|
-
[version]: https://www.contributor-covenant.org/version/2/0/code_of_conduct/
|
data/CONTRIBUTING.md
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
# Contributing to this repository <!-- omit in toc -->
|
2
|
-
|
3
|
-
## Getting started <!-- omit in toc -->
|
4
|
-
|
5
|
-
Before you begin:
|
6
|
-
- This project is a Ruby gem.
|
7
|
-
- Have you read the [code of conduct](CODE_OF_CONDUCT.md)?
|
8
|
-
- Check out the [existing issues](https://github.com/rubernetes/gem/issues) & see if we [accept contributions](#types-of-contributions-memo) for your type of issue.
|
9
|
-
|
10
|
-
### Don't see your issue? Open one
|
11
|
-
|
12
|
-
If you spot something new, open an issue using a [template](https://github.com/rubernetes/gem/issues/new/choose). We'll use the issue to have a conversation about the problem you want to fix.
|
13
|
-
|
14
|
-
### Ready to make a change?
|
15
|
-
|
16
|
-
At R8s we follow a standard Github `fork -> clone -> edit -> pull request` process. If you are not familiar with this process you can check [this detailed guidance](https://github.com/firstcontributions/first-contributions).
|
17
|
-
|
18
|
-
### Your PR is merged!
|
19
|
-
Congratulations! The whole R8s community thanks you. :sparkles:
|
20
|
-
|
21
|
-
Once your PR is merged, you will be proudly listed as a contributor in the [contributor chart](https://github.com/rubernetes/gem/graphs/contributors).
|
22
|
-
|
23
|
-
## Types of contributions :memo:
|
24
|
-
You can contribute to the R8s tools and technologies in several ways. Through Issues, Pull requests, Discussions, Reviews and suggested changes.
|
25
|
-
|
data/Gemfile
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
source 'https://rubygems.org'
|
4
|
-
|
5
|
-
# Specify your gem's dependencies in rubernetes.gemspec
|
6
|
-
gemspec
|
7
|
-
|
8
|
-
gem 'rake', '~> 12.0'
|
9
|
-
gem 'rspec', '~> 3.0'
|
10
|
-
|
11
|
-
gem 'code-scanning-rubocop', '~> 0.5.0', require: false
|
12
|
-
gem 'rubocop', '~> 1.12', require: false
|
13
|
-
gem 'rubocop-rake', '~> 0.5.1', require: false
|
14
|
-
gem 'rubocop-rspec', '~> 2.2', require: false
|
data/Gemfile.lock
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
rubernetes (0.0.0)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
ast (2.4.2)
|
10
|
-
code-scanning-rubocop (0.5.0)
|
11
|
-
rubocop (~> 1.0)
|
12
|
-
diff-lcs (1.4.4)
|
13
|
-
parallel (1.20.1)
|
14
|
-
parser (3.0.0.0)
|
15
|
-
ast (~> 2.4.1)
|
16
|
-
rainbow (3.0.0)
|
17
|
-
rake (12.3.3)
|
18
|
-
regexp_parser (2.1.1)
|
19
|
-
rexml (3.2.5)
|
20
|
-
rspec (3.10.0)
|
21
|
-
rspec-core (~> 3.10.0)
|
22
|
-
rspec-expectations (~> 3.10.0)
|
23
|
-
rspec-mocks (~> 3.10.0)
|
24
|
-
rspec-core (3.10.1)
|
25
|
-
rspec-support (~> 3.10.0)
|
26
|
-
rspec-expectations (3.10.1)
|
27
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
28
|
-
rspec-support (~> 3.10.0)
|
29
|
-
rspec-mocks (3.10.2)
|
30
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
31
|
-
rspec-support (~> 3.10.0)
|
32
|
-
rspec-support (3.10.2)
|
33
|
-
rubocop (1.12.1)
|
34
|
-
parallel (~> 1.10)
|
35
|
-
parser (>= 3.0.0.0)
|
36
|
-
rainbow (>= 2.2.2, < 4.0)
|
37
|
-
regexp_parser (>= 1.8, < 3.0)
|
38
|
-
rexml
|
39
|
-
rubocop-ast (>= 1.2.0, < 2.0)
|
40
|
-
ruby-progressbar (~> 1.7)
|
41
|
-
unicode-display_width (>= 1.4.0, < 3.0)
|
42
|
-
rubocop-ast (1.4.1)
|
43
|
-
parser (>= 2.7.1.5)
|
44
|
-
rubocop-rake (0.5.1)
|
45
|
-
rubocop
|
46
|
-
rubocop-rspec (2.2.0)
|
47
|
-
rubocop (~> 1.0)
|
48
|
-
rubocop-ast (>= 1.1.0)
|
49
|
-
ruby-progressbar (1.11.0)
|
50
|
-
unicode-display_width (2.0.0)
|
51
|
-
|
52
|
-
PLATFORMS
|
53
|
-
ruby
|
54
|
-
|
55
|
-
DEPENDENCIES
|
56
|
-
code-scanning-rubocop (~> 0.5.0)
|
57
|
-
rake (~> 12.0)
|
58
|
-
rspec (~> 3.0)
|
59
|
-
rubernetes!
|
60
|
-
rubocop (~> 1.12)
|
61
|
-
rubocop-rake (~> 0.5.1)
|
62
|
-
rubocop-rspec (~> 2.2)
|
63
|
-
|
64
|
-
BUNDLED WITH
|
65
|
-
2.2.8
|
data/LICENSE
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
MIT License
|
2
|
-
|
3
|
-
Copyright (c) 2021 rubernetes
|
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 all
|
13
|
-
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 THE
|
21
|
-
SOFTWARE.
|
data/Rakefile
DELETED
data/SECURITY.md
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
# Security Policy
|
2
|
-
|
3
|
-
## Supported Versions
|
4
|
-
|
5
|
-
| Version | Supported |
|
6
|
-
| ------- | ------------------ |
|
7
|
-
| 0.0.1 | :white_check_mark: |
|
8
|
-
|
9
|
-
## Reporting a Vulnerability
|
10
|
-
|
11
|
-
Please reach out to tarek@shebanglabs.io for reporting security vulnerabilities and following up on previous reports.
|
data/rubernetes.gemspec
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'lib/rubernetes/version'
|
4
|
-
|
5
|
-
Gem::Specification.new do |spec|
|
6
|
-
spec.name = 'rubernetes'
|
7
|
-
spec.version = Rubernetes::VERSION
|
8
|
-
spec.summary = 'Build Kubernetes custom resources controllers in Ruby.'
|
9
|
-
spec.description = 'A ruby gem to provide the base for building Kubernetes custom resources controllers in Ruby.'
|
10
|
-
|
11
|
-
spec.required_ruby_version = Gem::Requirement.new('>= 2.4.0')
|
12
|
-
|
13
|
-
spec.license = 'MIT'
|
14
|
-
|
15
|
-
spec.authors = ['Tarek N. Samni', 'Ramy Aboul Naga', 'Hesham Youssef']
|
16
|
-
spec.email = ['tarek.samni@gmail.com', 'ramy.naga@gmail.com', 'heshamyoussef79@gmail.com']
|
17
|
-
spec.homepage = 'https://github.com/rubernetes/gem'
|
18
|
-
|
19
|
-
spec.metadata = {
|
20
|
-
# "allowed_push_host" => "TODO: Set to 'http://mygemserver.com'"
|
21
|
-
'bug_tracker_uri' => "#{spec.homepage}/issues",
|
22
|
-
# "changelog_uri" => "#{spec.homepage}/releases/tag/v#{version}",
|
23
|
-
'documentation_uri' => "https://rubydoc.info/#{spec.homepage.gsub(%r{^https?://}, '')}",
|
24
|
-
'homepage_uri' => spec.homepage,
|
25
|
-
'source_code_uri' => spec.homepage.to_s # /tree/v#{version}
|
26
|
-
}
|
27
|
-
|
28
|
-
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
29
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
30
|
-
end
|
31
|
-
spec.require_paths = ['lib']
|
32
|
-
end
|