Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make compatible with ruby 3 #174

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions k8s-client.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "k8s/client/version"

Gem::Specification.new do |spec|
spec.name = "k8s-client"
spec.name = "k8s-client-renewed"
spec.version = K8s::Client::VERSION
spec.authors = ["Kontena, Inc."]
spec.email = ["[email protected]"]
Expand All @@ -21,18 +21,19 @@ Gem::Specification.new do |spec|
spec.bindir = "bin"
spec.executables = []
spec.require_paths = ["lib"]
spec.required_ruby_version = '~> 2.4'
# spec.required_ruby_version = '> 2.4'

spec.add_runtime_dependency "excon", "~> 0.66"
spec.add_runtime_dependency "recursive-open-struct", "~> 1.1.0"
spec.add_runtime_dependency 'hashdiff', '~> 1.0.0'
spec.add_runtime_dependency 'jsonpath', '~> 0.9.5'
spec.add_runtime_dependency "yaml-safe_load_stream", "~> 0.1"
spec.add_runtime_dependency "excon"#, "~> 0.66"
spec.add_runtime_dependency "recursive-open-struct"#, "~> 1.1.0"
spec.add_runtime_dependency 'hashdiff'#, '~> 1.0.0'
spec.add_runtime_dependency 'jsonpath'#, '~> 0.9.5'
spec.add_runtime_dependency "yaml-safe_load_stream-renewed"#, "~> 0.1"

spec.add_development_dependency "bundler", ">= 1.17", "< 3.0"
spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency "rspec", "~> 3.7"
spec.add_development_dependency "webmock", "~> 3.6.2"
spec.add_development_dependency "rubocop", "~> 0.59"
spec.add_development_dependency 'yajl-ruby', '~> 1.4.0'
# spec.add_development_dependency "bundler"#, ">= 1.17", "< 3.0"
spec.add_development_dependency "byebug"#, "~> 10.0"
spec.add_development_dependency "rake"#, "~> 10.0"
spec.add_development_dependency "rspec"#, "~> 3.7"
spec.add_development_dependency "webmock"#, "~> 3.6.2"
spec.add_development_dependency "rubocop"#, "~> 0.59"
spec.add_development_dependency 'yajl-ruby'#, '~> 1.4.0'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which of these gemspec changes are necessary? Do you really want all dependencies listed with no version costrains?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

counter question: do you really want to drag along 3 year outdated dependencies although the checks are all green?

Copy link

@cben cben Jun 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, it's a useful experiment and good question for a gem that's not very active. (My question was more "do these belong in same PR" or whether they were debug leftovers committed by mistake.)

However, if you drop constraints entirely, you also allow even older versions! Anything at all if it lets bundler solve the app constraints.
For dev dependencies, maybe that's fine.
For runtime dependencies, IMHO it's safer to at least set >=, and preferably pin major versions to current one (EDIT: I mean each library's last released, not current in this file).

  • I never remember what exactly ~> means, love this reference 👀... OK, ~> 3.7 form means 3.y (y >=7) and is useful; ~> 3.6.2 form also constrains minor 3.6.z (z >= 2) and is probably unnecessarily strict.

Anyway, I'm not a maintainer here, just watching and pushing my nose occasionally, these are more questions to @kke @jakolehm...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't touched ruby in a long time. I believe the same applies to many of the other past contributors. If any of you want to take ownership and maintain the gem, I think we will gladly transfer/grant that, @matti ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we tried to move the development in this fork: https://github.com/k8s-ruby/k8s-ruby

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kke what about #175

end
2 changes: 1 addition & 1 deletion lib/k8s/client/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
module K8s
class Client
# Updated on releases using semver.
VERSION = "0.10.3"
VERSION = "0.10.5-1"
end
end
17 changes: 12 additions & 5 deletions lib/k8s/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,21 @@ def self.from_files(path)
end
end

def self.default_options
{
mutate_input_hash: false,
recurse_over_arrays: true,
preserve_original_keys: false
}
end

# @param hash [Hash]
# @param recurse_over_arrays [Boolean]
# @param options [Hash] see RecursiveOpenStruct#initialize
def initialize(hash, recurse_over_arrays: true, **options)
def initialize hash, options = {}
super(
hash.is_a?(Hash) ? hash : hash.to_h,
recurse_over_arrays: recurse_over_arrays,
**options
options
)
end

Expand All @@ -54,8 +61,8 @@ def <=>(other)

# @param options [Hash] see Hash#to_json
# @return [String]
def to_json(**options)
to_h.to_json(**options)
def to_json(options = {})
to_h.to_json(options)
end

# merge in fields
Expand Down