kube-dsl
kube-dsl copied to clipboard
Add Namespace Validator object
NOT FINAL PR
I need help me out how are the "attributes" are set in the DSL.
For example we have KubeDSL::DSL::V1::Namespace
- How to set valid
object
intometadata
? - How to set invalid
object
intometadata
?
Please add a comment in the PR and point me to the JSON you showed in the call :)
Any feedback is appreciated 🙏
Hey @deny7ko, looks like a good start. You can set attributes by calling methods with the same name as the attributes, for example:
KubeDSL.namespace do
metadata do
name 'foobar'
end
end
This is equivalent to:
KubeDSL::DSL::V1::Namespace.new do
metadata do
name 'foobar'
end
end
If you already have an instance of Namespace
ns = KubeDSL::DSL::V1::Namespace.new
ns.instance_eval do
metadata do
name 'foobar'
end
end
Does that help?
@camertron hey, yes, but I also want to understand when the value is invalid? I remember you showed me some *.json
file which contains the type:
So we have a definition:
module KubeDSL::DSL::V1
class Namespace < ::KubeDSL::DSLObject
object_field(:metadata) { KubeDSL::DSL::Meta::V1::ObjectMeta.new }
Questions:
-
What makes
metadata
field invalid? How should I identify that? -
Maybe you want me to start with testing this file - https://github.com/getkuby/kube-dsl/blob/master/lib/kube-dsl/dsl/v1/namespace_spec.rb#L3 ?
-
Please provide me with
json
file you showed me in the call -
Please give me the link to your example app so I could play around to understand how all of these gems work together
@deny7ko ah ok I understand now :)
- Here's a link to the schema for
Namespace
. - I think
ObjectMeta
is probably the right place to start.ObjectMeta
is used by almost all other objects, includingNamespace
,Service
,Deployment
, etc. Here's a link to the schema. You can see thatname
is one of the fields, and has typestring
. Thename
field would be invalid if it contained a number, for example, instead of a string. - See above
- Ah yes, sorry for the delay. The app can be found here. Follow the README to get everything set up (all the gems are included as submodules).