Comments (10)
@motymichaely I'm good with a Readme change.
I think the best we can do is to consistently advocate the usage of the generic Kubeclient::resource class post #185 throughout the Readme as well as all the tests.
There are just too many ways being used in our example code now and that is confusing as well as the problem described in this issue.
In your example:
client.create_namespace(Kubeclient::Resource.new(YAML.load(namespace_str)))
@abonas @simon3z agree/disagree?
from kubeclient.
would prefer telling the user what they do wrong instead of doing work behind their back
-> call .to_h on what they give in and check if first key is a symbol, otherwise ArgumentError
from kubeclient.
cc @moolitayer
from kubeclient.
RecursiveOpenStruct symbolizes keys for us:
"Also, by default it will turn all hash keys into symbols internally:"
pod = {
'metadata' =>
...
client.create_pod(pod) # will not work
client.create_pod(Kubeclient::Pod.new(pod)) # will not work
client.create_pod(Kubeclient::Pod.new(POD)) # will work
We should not re implement rails' deep_symbolize_keys
from kubeclient.
@moolitayer Great. So I would suggest adding some info on this to the documentation.
For example:
namespace_str = <<-EOF
apiVersion: v1
kind: Namespace
metadata:
name: "my-namespace"
labels:
name: "my-namespace"
EOF
client.create_namespace(YAML.load(namespace_yaml_str))
Produces this error:
NoMethodError: undefined method `[]' for nil:NilClass
from /Users/moty/.rbenv/versions/2.0.0-p481/lib/ruby/gems/2.0.0/gems/kubeclient-1.2.0/lib/kubeclient/common.rb:229:in `create_entity'
from /Users/moty/.rbenv/versions/2.0.0-p481/lib/ruby/gems/2.0.0/gems/kubeclient-1.2.0/lib/kubeclient/common.rb:116:in `block (2 levels) in define_entity_methods'
Based on your suggestion, this works:
client.create_namespace(Kubeclient::Namespace.new(YAML.load(namespace_str)))
from kubeclient.
from kubeclient.
@motymichaely interested in submitting a pr as per the above comment ?
from kubeclient.
FYI Decided to go with .deep_symbolize_keys
(rails) in our project... easier to debug and no more ObjectStruct bugs/overhead ...
from kubeclient.
Now that we have as: :parsed_symbolized
and as: :parsed
(#306), kubeclient get_foo
may give you data that isn't a Kubeclient::Resource
, and in the latter case that you can't write back with create_foo
/update_foo
.
Also, now that we use a single Kubeclient::Resource
class everywhere, there's less value in forcing users to wrap everything in it...
=> I don't have bandwidth to work on this but would welcome a PR. @moolitayer are you still against?
from kubeclient.
hmm, good idea.
from kubeclient.
Related Issues (20)
- v4.11.0 was released but isn't noted in the CHANGELOG
- Informer.watch is not guaranteed to receive all changes during restart
- CVE-2022-44571 (High) detected in rack-2.2.3.gem - autoclosed HOT 1
- CVE-2022-44570 (High) detected in rack-2.2.3.gem - autoclosed HOT 1
- CVE-2023-22796 (High) detected in activesupport-7.0.2.3.gem - autoclosed HOT 1
- CVE-2022-44572 (High) detected in rack-2.2.3.gem - autoclosed HOT 1
- Word breaking fails for kind `APIService` HOT 1
- CVE-2023-27530 (High) detected in rack-3.0.4.1.gem - autoclosed HOT 1
- CVE-2023-27539 (Medium) detected in rack-3.0.4.1.gem - autoclosed HOT 1
- 6 tests fail KubeclientConfigTest#test_explicit_secure Expected false to be truthy. HOT 3
- Dependency Dashboard
- Is it possible to fetch ingress information? HOT 2
- getting large resources on slow connection is slow
- v5 first request is ~10x slower than v4
- CVE-2023-38037 (Medium) detected in activesupport-7.0.4.3.gem - autoclosed HOT 1
- CVE-2023-51774 (High) detected in json-jwt-1.15.3.gem - autoclosed HOT 1
- CVE-2024-25126 (Medium) detected in rack-3.0.7.gem - autoclosed HOT 1
- CVE-2024-26146 (Medium) detected in rack-3.0.7.gem - autoclosed HOT 1
- CVE-2024-26141 (Medium) detected in rack-3.0.7.gem - autoclosed HOT 1
- documentation doesn't match current Ruby gem exposed version(s) 4.11.0 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kubeclient.